| | |
| | | package com.xcong.farmer.cms.modules.system.service.Impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | 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.contants.AppContants; |
| | | 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.*; |
| | |
| | | import com.xcong.farmer.cms.modules.system.mapper.ColumnMapper; |
| | | import com.xcong.farmer.cms.modules.system.mapper.CompanyMapper; |
| | | import com.xcong.farmer.cms.modules.system.service.IArticleService; |
| | | import com.xcong.farmer.cms.modules.system.service.IReleaseService; |
| | | 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 org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Date; |
| | | |
| | |
| | | private CompanyMapper companyMapper; |
| | | |
| | | @Autowired |
| | | private ICmsCoreService cmsCoreService; |
| | | private IReleaseService releaseService; |
| | | |
| | | @Override |
| | | public Result getArticleInPage(AdminArticleDto adminArticleDto) { |
| | |
| | | long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); |
| | | Page<AdminArticleVo> page = new Page<>(adminArticleDto.getPageNum(), adminArticleDto.getPageSize()); |
| | | ArticleEntity articleEntity = new ArticleEntity(); |
| | | Long columnId = adminArticleDto.getColumnId() == null ? 0L : adminArticleDto.getColumnId(); |
| | | if(columnId != 0L){ |
| | | articleEntity.setColumnId(columnId); |
| | | String columnIdStrs = adminArticleDto.getColumnIdStr(); |
| | | if(StrUtil.isNotEmpty(columnIdStrs)){ |
| | | String[] columnIdStr = columnIdStrs.split(StringPool.COMMA); |
| | | List<Long> columnList = new ArrayList<>(); |
| | | for(String columnIdString : columnIdStr){ |
| | | columnList.add(Long.valueOf(columnIdString)); |
| | | } |
| | | articleEntity.setColumnList(columnList); |
| | | } |
| | | String title = adminArticleDto.getTitle(); |
| | | if(StrUtil.isNotEmpty(title)){ |
| | |
| | | |
| | | @Override |
| | | public Result webArticleInPage(HttpServletRequest request, WebArticleInPageDto webArticleInPageDto) { |
| | | 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); |
| | | |
| | | Page<WebArticleVo> page = new Page<>(webArticleInPageDto.getPageNum(), webArticleInPageDto.getPageSize()); |
| | | ArticleEntity articleEntity = new ArticleEntity(); |
| | |
| | | if(UserEntity.USER_BELONG_TOP != companyId){ |
| | | articleEntity.setCompanyId(companyId); |
| | | } |
| | | String timeType = webArticleInPageDto.getTimeType(); |
| | | if(StrUtil.isNotEmpty(timeType)){ |
| | | articleEntity.setTimeType(timeType); |
| | | } |
| | | IPage<WebArticleVo> list = this.baseMapper.selectWebArticleInPage(page,articleEntity); |
| | | return Result.ok(list); |
| | | } |
| | |
| | | articleEntity.setReleaseStatus(ArticleEntity.RELEASE_STATUS_YES); |
| | | articleEntity.setReleaseTime(new Date()); |
| | | this.baseMapper.updateById(articleEntity); |
| | | |
| | | releaseService.releaseArticle(articleEntity.getId()); |
| | | 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; |
| | | } |
| | | } |