| | |
| | | package com.xcong.farmer.cms.modules.system.service.Impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.response.Result; |
| | | import com.xcong.farmer.cms.modules.core.service.ICmsCoreService; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminAddArticleDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminArticleDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; |
| | |
| | | import com.xcong.farmer.cms.modules.system.vo.AdminArticleVo; |
| | | import com.xcong.farmer.cms.modules.system.vo.AdminSeeArticleInfoVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | @Resource |
| | | private ColumnMapper columnMapper; |
| | | |
| | | @Autowired |
| | | private ICmsCoreService cmsCoreService; |
| | | |
| | | @Override |
| | | public Result getArticleInPage(AdminArticleDto adminArticleDto) { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | |
| | | String title = adminArticleDto.getTitle(); |
| | | if(StrUtil.isNotEmpty(title)){ |
| | | articleEntity.setTitle(title); |
| | | } |
| | | Integer contentType = adminArticleDto.getContentType() == null ? 0 : adminArticleDto.getContentType(); |
| | | if(contentType != 0){ |
| | | QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("content_type",contentType); |
| | | List<ColumnEntity> columnEntities = columnMapper.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(columnEntities)){ |
| | | List<Long> columIds = new ArrayList<>(); |
| | | for(ColumnEntity columnEntity : columnEntities){ |
| | | Long id = columnEntity.getId(); |
| | | columIds.add(id); |
| | | } |
| | | articleEntity.setColumnIds(columIds); |
| | | } |
| | | } |
| | | if(UserEntity.USER_BELONG_TOP != companyId){ |
| | | articleEntity.setCompanyId(companyId); |
| | |
| | | articleEntity.setAtlas(atlas); |
| | | Date releaseTime = adminAddArticleDto.getReleaseTime(); |
| | | articleEntity.setReleaseTime(releaseTime); |
| | | Integer isTop = adminAddArticleDto.getIsTop(); |
| | | articleEntity.setIsTop(isTop); |
| | | Integer releaseStatus = adminAddArticleDto.getReleaseStatus(); |
| | | articleEntity.setReleaseStatus(releaseStatus); |
| | | String articleDetails = adminAddArticleDto.getArticleDetails(); |
| | | articleEntity.setArticleDetails(articleDetails); |
| | | String uploadFile = adminAddArticleDto.getUploadFile(); |
| | | articleEntity.setUploadFile(uploadFile); |
| | | |
| | | articleEntity.setArticleUrl(adminAddArticleDto.getArticleUrl()); |
| | | articleEntity.setType(adminAddArticleDto.getType()); |
| | | articleEntity.setContentType(adminAddArticleDto.getContentType()); |
| | | this.baseMapper.insert(articleEntity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | |
| | | if(ObjectUtil.isEmpty(articleEntity)){ |
| | | return Result.fail("文章不存在"); |
| | | } |
| | | Integer isTop = adminUpdateArticleDto.getIsTop(); |
| | | articleEntity.setIsTop(isTop); |
| | | Integer releaseStatus = adminUpdateArticleDto.getReleaseStatus(); |
| | | articleEntity.setReleaseStatus(releaseStatus); |
| | | String title = adminUpdateArticleDto.getTitle(); |
| | |
| | | articleEntity.setArticleDetails(articleDetails); |
| | | String uploadFile = adminUpdateArticleDto.getUploadFile(); |
| | | articleEntity.setUploadFile(uploadFile); |
| | | |
| | | articleEntity.setArticleUrl(adminUpdateArticleDto.getArticleUrl()); |
| | | articleEntity.setType(adminUpdateArticleDto.getType()); |
| | | articleEntity.setContentType(adminUpdateArticleDto.getContentType()); |
| | | this.baseMapper.updateById(articleEntity); |
| | | return Result.ok("更新成功"); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result updateIstop(Long id) { |
| | | ArticleEntity articleEntity = this.baseMapper.selectById(id); |
| | | if(ObjectUtil.isEmpty(articleEntity)){ |
| | | return Result.fail("文章不存在"); |
| | | } |
| | | articleEntity.setIsTop(ArticleEntity.ISTOP_YES); |
| | | this.baseMapper.updateById(articleEntity); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result updateIstopOff(Long id) { |
| | | ArticleEntity articleEntity = this.baseMapper.selectById(id); |
| | | if(ObjectUtil.isEmpty(articleEntity)){ |
| | | return Result.fail("文章不存在"); |
| | | } |
| | | articleEntity.setIsTop(ArticleEntity.ISTOP_NO); |
| | | this.baseMapper.updateById(articleEntity); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result updateStatusOn(Long id) { |
| | | ArticleEntity articleEntity = this.baseMapper.selectById(id); |
| | | if(ObjectUtil.isEmpty(articleEntity)){ |