| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.AreasMapper; |
| | | import com.doumee.dao.business.KnowledgeMapper; |
| | | import com.doumee.dao.business.model.Areas; |
| | | import com.doumee.dao.business.model.Knowledge; |
| | | import com.doumee.service.business.KnowledgeService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private KnowledgeMapper knowledgeMapper; |
| | | |
| | | @Autowired |
| | | private AreasMapper areasMapper; |
| | | |
| | | @Override |
| | | public Integer create(Knowledge knowledge) { |
| | | LoginUserInfo user= (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(Objects.isNull(knowledge) |
| | | || StringUtils.isBlank(knowledge.getTitle()) |
| | | || StringUtils.isBlank(knowledge.getLink()) |
| | | // || StringUtils.isBlank(knowledge.getCityName()) |
| | | // || Objects.isNull(knowledge.getCityId()) |
| | | || StringUtils.isBlank(knowledge.getProvinceName()) |
| | | || Objects.isNull(knowledge.getProvinceId()) |
| | | || StringUtils.isBlank(knowledge.getYearInfo()) |
| | | || StringUtils.isBlank(knowledge.getTitle()) |
| | |
| | | } |
| | | if(knowledge.getLabels().split(",").length>10){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"标签数最多添加十个"); |
| | | } |
| | | Areas province = areasMapper.selectById(knowledge.getProvinceId()); |
| | | if(Objects.isNull(province)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"省份信息错误"); |
| | | } |
| | | knowledge.setProvinceName(province.getName()); |
| | | if(Objects.nonNull(knowledge.getCityId())){ |
| | | Areas city = areasMapper.selectById(knowledge.getCityId()); |
| | | if(Objects.isNull(city)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"市区信息错误"); |
| | | } |
| | | knowledge.setCityName(city.getName()); |
| | | } |
| | | knowledge.setIsdeleted(Constants.ZERO); |
| | | knowledge.setCreateDate(new Date()); |
| | |
| | | || Objects.isNull(knowledge.getId()) |
| | | || StringUtils.isBlank(knowledge.getTitle()) |
| | | || StringUtils.isBlank(knowledge.getLink()) |
| | | || StringUtils.isBlank(knowledge.getProvinceName()) |
| | | // || StringUtils.isBlank(knowledge.getCityName()) |
| | | // || Objects.isNull(knowledge.getCityId()) |
| | | || Objects.isNull(knowledge.getCityId()) |
| | | || Objects.isNull(knowledge.getProvinceId()) |
| | | || StringUtils.isBlank(knowledge.getYearInfo()) |
| | | || StringUtils.isBlank(knowledge.getTitle()) |
| | |
| | | if(knowledge.getLabels().split(",").length>10){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"标签数最多添加十个"); |
| | | } |
| | | Areas province = areasMapper.selectById(knowledge.getProvinceId()); |
| | | if(Objects.isNull(province)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"省份信息错误"); |
| | | } |
| | | knowledge.setProvinceName(province.getName()); |
| | | if(Objects.nonNull(knowledge.getCityId())){ |
| | | Areas city = areasMapper.selectById(knowledge.getCityId()); |
| | | if(Objects.isNull(city)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"市区信息错误"); |
| | | } |
| | | knowledge.setCityName(city.getName()); |
| | | } |
| | | knowledge.setEditDate(new Date()); |
| | | knowledge.setEditor(user.getId()); |
| | | knowledgeMapper.updateById(knowledge); |