| | |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminUpdateArticleDto; |
| | | import com.xcong.farmer.cms.modules.system.entity.ArticleEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.ColumnEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.UserEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.UserRoleEntity; |
| | | import com.xcong.farmer.cms.modules.system.mapper.ArticleMapper; |
| | | import com.xcong.farmer.cms.modules.system.mapper.ColumnMapper; |
| | | import com.xcong.farmer.cms.modules.system.service.IArticleService; |
| | | import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; |
| | | import com.xcong.farmer.cms.modules.system.vo.AdminArticleVo; |
| | | import com.xcong.farmer.cms.modules.system.vo.AdminSeeArticleInfoVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | @Override |
| | | public Result getArticleInPage(AdminArticleDto adminArticleDto) { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | Page<AdminArticleVo> page = new Page<>(adminArticleDto.getPageNum(), adminArticleDto.getPageSize()); |
| | | ArticleEntity articleEntity = new ArticleEntity(); |
| | | Long columnId = adminArticleDto.getColumnId() == null ? 0L : adminArticleDto.getColumnId(); |
| | |
| | | if(StrUtil.isNotEmpty(title)){ |
| | | articleEntity.setTitle(title); |
| | | } |
| | | if(UserEntity.USER_BELONG_TOP != belongId){ |
| | | articleEntity.setBelongId(belongId); |
| | | } |
| | | IPage<AdminArticleVo> list = this.baseMapper.selectAdminArticleInPage(page,articleEntity); |
| | | return Result.ok(list); |
| | | } |
| | |
| | | @Override |
| | | @Transactional |
| | | public Result addArticle(AdminAddArticleDto adminAddArticleDto) { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | ArticleEntity articleEntity = new ArticleEntity(); |
| | | articleEntity.setBelongId(belongId); |
| | | String title = adminAddArticleDto.getTitle(); |
| | | if(StrUtil.isEmpty(title)){ |
| | | return Result.fail("请输入文章标题"); |
| | |
| | | String author = adminAddArticleDto.getAuthor(); |
| | | if(StrUtil.isNotEmpty(author)){ |
| | | articleEntity.setAuthor(author); |
| | | } |
| | | String authorBelong = adminAddArticleDto.getAuthorBelong(); |
| | | if(StrUtil.isNotEmpty(authorBelong)){ |
| | | articleEntity.setAuthorBelong(authorBelong); |
| | | } |
| | | String remark = adminAddArticleDto.getRemark(); |
| | | if(StrUtil.isNotEmpty(remark)){ |
| | |
| | | } |
| | | articleEntity.setTitle(title); |
| | | String childTitle = adminUpdateArticleDto.getChildTitle(); |
| | | if(StrUtil.isNotEmpty(childTitle)){ |
| | | articleEntity.setChildTitle(childTitle); |
| | | } |
| | | articleEntity.setChildTitle(childTitle); |
| | | String author = adminUpdateArticleDto.getAuthor(); |
| | | if(StrUtil.isNotEmpty(author)){ |
| | | articleEntity.setAuthor(author); |
| | | } |
| | | articleEntity.setAuthor(author); |
| | | |
| | | String remark = adminUpdateArticleDto.getRemark(); |
| | | if(StrUtil.isNotEmpty(remark)){ |
| | | articleEntity.setRemark(remark); |
| | | } |
| | | articleEntity.setRemark(remark); |
| | | long columnId = adminUpdateArticleDto.getColumnId() == null ? 0L : adminUpdateArticleDto.getColumnId(); |
| | | if(columnId == 0L){ |
| | | return Result.fail("请选择文章栏目"); |
| | |
| | | Integer visits = adminUpdateArticleDto.getVisits() == null ? 0 : adminUpdateArticleDto.getVisits(); |
| | | articleEntity.setVisits(visits); |
| | | String mainDiagram = adminUpdateArticleDto.getMainDiagram(); |
| | | if(StrUtil.isNotEmpty(mainDiagram)){ |
| | | articleEntity.setMainDiagram(mainDiagram); |
| | | } |
| | | articleEntity.setMainDiagram(mainDiagram); |
| | | String atlas = adminUpdateArticleDto.getAtlas(); |
| | | if(StrUtil.isNotEmpty(atlas)){ |
| | | articleEntity.setAtlas(atlas); |
| | | } |
| | | articleEntity.setAtlas(atlas); |
| | | Date releaseTime = adminUpdateArticleDto.getReleaseTime(); |
| | | if(ObjectUtil.isNotEmpty(releaseTime)){ |
| | | articleEntity.setReleaseTime(releaseTime); |
| | |
| | | } |
| | | articleEntity.setReleaseStatus(releaseStatus); |
| | | String articleDetails = adminUpdateArticleDto.getArticleDetails(); |
| | | if(StrUtil.isNotEmpty(articleDetails)){ |
| | | articleEntity.setArticleDetails(articleDetails); |
| | | } |
| | | articleEntity.setArticleDetails(articleDetails); |
| | | this.baseMapper.updateById(articleEntity); |
| | | return Result.ok("更新成功"); |
| | | } |