| | |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xcong.farmer.cms.common.contants.AppContants; |
| | | import com.xcong.farmer.cms.common.response.Result; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminAddMessageDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; |
| | |
| | | |
| | | @Override |
| | | public Result addMessage(HttpServletRequest request, AdminAddMessageDto adminAddMessageDto) { |
| | | StringBuffer requestURL = request.getRequestURL(); |
| | | List<CompanyEntity> companyEntities = companyMapper.selectList(new QueryWrapper<>()); |
| | | Long companyId = 0L; |
| | | if(CollUtil.isNotEmpty(companyEntities)){ |
| | | for(CompanyEntity companyEntity : companyEntities){ |
| | | boolean contains = StrUtil.contains(requestURL, companyEntity.getWebAddress()); |
| | | if(contains){ |
| | | companyId = companyEntity.getId(); |
| | | } |
| | | } |
| | | } |
| | | String website = request.getHeader(AppContants.WEBSITE_HEADER); |
| | | Long companyId = getCompanyIdFromWebsite(website); |
| | | |
| | | String title = adminAddMessageDto.getTitle(); |
| | | String remark = adminAddMessageDto.getRemark(); |
| | | if(StrUtil.isEmpty(title) && StrUtil.isEmpty(remark)){ |
| | |
| | | this.baseMapper.insert(messageBoardEntity); |
| | | return Result.ok("留言成功"); |
| | | } |
| | | |
| | | private Long getCompanyIdFromWebsite(String website){ |
| | | List<CompanyEntity> companyEntities = companyMapper.selectList(new QueryWrapper<>()); |
| | | Long companyId = 0L; |
| | | if(CollUtil.isNotEmpty(companyEntities)){ |
| | | for(CompanyEntity companyEntity : companyEntities){ |
| | | boolean contains = StrUtil.contains(companyEntity.getWebAddress(), website); |
| | | if(contains){ |
| | | companyId = companyEntity.getId(); |
| | | } |
| | | } |
| | | } |
| | | return companyId; |
| | | } |
| | | } |