| | |
| | | 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 ? 0L : 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); |
| | | } |
| | | 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 ? 0L : userlogin.getBelongId(); |
| | | ArticleEntity articleEntity = new ArticleEntity(); |
| | | articleEntity.setBelongId(belongId); |
| | | String title = adminAddArticleDto.getTitle(); |
| | | if(StrUtil.isEmpty(title)){ |
| | | return Result.fail("请输入文章标题"); |
| | |
| | | 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("更新成功"); |
| | | } |