Commit 7b115172 authored by 廖旭伟's avatar 廖旭伟

新闻公告增加关联公司

parent dec578af
...@@ -137,3 +137,5 @@ CREATE TABLE mortals_xhx_resource_image( ...@@ -137,3 +137,5 @@ CREATE TABLE mortals_xhx_resource_image(
`updateTime` datetime COMMENT '更新时间', `updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='图片资源'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='图片资源';
ALTER TABLE `mortals_xhx_news` ADD COLUMN `relatedCompany` varchar(255) COMMENT '关联公司';
\ No newline at end of file
...@@ -8,6 +8,7 @@ import java.util.List; ...@@ -8,6 +8,7 @@ import java.util.List;
import com.mortals.xhx.module.company.model.CompanyLabelsEntity; import com.mortals.xhx.module.company.model.CompanyLabelsEntity;
import com.mortals.xhx.module.company.model.CompanyPatentEntity; import com.mortals.xhx.module.company.model.CompanyPatentEntity;
import com.mortals.xhx.module.news.model.NewsEntity;
import lombok.Data; import lombok.Data;
import com.mortals.framework.annotation.Excel; import com.mortals.framework.annotation.Excel;
...@@ -41,4 +42,6 @@ public class CompanyVo extends BaseEntityLong { ...@@ -41,4 +42,6 @@ public class CompanyVo extends BaseEntityLong {
*/ */
private Integer sendBusinessCardTimes; private Integer sendBusinessCardTimes;
private List<NewsEntity> newsList;
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
...@@ -13,6 +14,9 @@ import com.mortals.xhx.module.company.service.CompanyLabelsService; ...@@ -13,6 +14,9 @@ import com.mortals.xhx.module.company.service.CompanyLabelsService;
import com.mortals.xhx.module.company.service.CompanyPatentService; import com.mortals.xhx.module.company.service.CompanyPatentService;
import com.mortals.xhx.module.labels.model.LabelsQuery; import com.mortals.xhx.module.labels.model.LabelsQuery;
import com.mortals.xhx.module.labels.service.LabelsService; import com.mortals.xhx.module.labels.service.LabelsService;
import com.mortals.xhx.module.news.model.NewsEntity;
import com.mortals.xhx.module.news.model.NewsQuery;
import com.mortals.xhx.module.news.service.NewsService;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.JsonbHttpMessageConverter; import org.springframework.http.converter.json.JsonbHttpMessageConverter;
...@@ -29,15 +33,11 @@ import com.mortals.xhx.module.company.service.CompanyService; ...@@ -29,15 +33,11 @@ import com.mortals.xhx.module.company.service.CompanyService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -62,6 +62,8 @@ public class CompanyController extends BaseCRUDJsonBodyMappingController<Company ...@@ -62,6 +62,8 @@ public class CompanyController extends BaseCRUDJsonBodyMappingController<Company
private CompanyPatentService companyPatentService; private CompanyPatentService companyPatentService;
@Autowired @Autowired
private CompanyLabelsService companyLabelsService; private CompanyLabelsService companyLabelsService;
@Autowired
private NewsService newsService;
...@@ -103,7 +105,17 @@ public class CompanyController extends BaseCRUDJsonBodyMappingController<Company ...@@ -103,7 +105,17 @@ public class CompanyController extends BaseCRUDJsonBodyMappingController<Company
List<CompanyLabelsEntity> companyLabelsEntities = companyLabelsService.find(new CompanyLabelsQuery().companyId(entity.getId())); List<CompanyLabelsEntity> companyLabelsEntities = companyLabelsService.find(new CompanyLabelsQuery().companyId(entity.getId()));
entity.setCompanyLabelsList(companyLabelsEntities); entity.setCompanyLabelsList(companyLabelsEntities);
entity.setCompanyPatentsList(companyPatentEntities); entity.setCompanyPatentsList(companyPatentEntities);
List<NewsEntity> allNews = newsService.find(new NewsQuery(),new PageInfo(-1),context).getList();
List<NewsEntity> newsList = new ArrayList<>();
for(NewsEntity newsEntity:allNews){
if(StringUtils.isNotEmpty(newsEntity.getRelatedCompany())){
List<String> companyIds = Arrays.asList(newsEntity.getRelatedCompany().split(","));
if(companyIds.contains(String.valueOf(id))){
newsList.add(newsEntity);
}
}
}
entity.setNewsList(newsList);
return super.viewAfter(id, model, entity, context); return super.viewAfter(id, model, entity, context);
} }
......
...@@ -14,7 +14,7 @@ import lombok.Data; ...@@ -14,7 +14,7 @@ import lombok.Data;
* 新闻实体对象 * 新闻实体对象
* *
* @author zxfei * @author zxfei
* @date 2023-09-28 * @date 2025-01-08
*/ */
@Data @Data
public class NewsEntity extends NewsVo { public class NewsEntity extends NewsVo {
...@@ -52,6 +52,10 @@ public class NewsEntity extends NewsVo { ...@@ -52,6 +52,10 @@ public class NewsEntity extends NewsVo {
* 发布时间 * 发布时间
*/ */
private Date publishTime; private Date publishTime;
/**
* 点赞次数
*/
private Integer upNums;
/** /**
* 责任编辑 * 责任编辑
*/ */
...@@ -81,9 +85,9 @@ public class NewsEntity extends NewsVo { ...@@ -81,9 +85,9 @@ public class NewsEntity extends NewsVo {
*/ */
private String remark; private String remark;
/** /**
* 点赞次数 * 关联公司
*/ */
private Integer upNums; private String relatedCompany;
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
...@@ -109,6 +113,7 @@ public class NewsEntity extends NewsVo { ...@@ -109,6 +113,7 @@ public class NewsEntity extends NewsVo {
this.top = 0; this.top = 0;
this.viewNums = 0; this.viewNums = 0;
this.publishTime = new Date(); this.publishTime = new Date();
this.upNums = 0;
this.editor = ""; this.editor = "";
this.shareNums = 0; this.shareNums = 0;
this.deptId = null; this.deptId = null;
...@@ -116,6 +121,6 @@ public class NewsEntity extends NewsVo { ...@@ -116,6 +121,6 @@ public class NewsEntity extends NewsVo {
this.statement = ""; this.statement = "";
this.source = ""; this.source = "";
this.remark = ""; this.remark = "";
this.upNums = 0; this.relatedCompany = "";
} }
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.news.model.NewsEntity; ...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.news.model.NewsEntity;
* 新闻查询对象 * 新闻查询对象
* *
* @author zxfei * @author zxfei
* @date 2024-12-04 * @date 2025-01-08
*/ */
public class NewsQuery extends NewsEntity { public class NewsQuery extends NewsEntity {
/** 开始 主键ID,主键,自增长 */ /** 开始 主键ID,主键,自增长 */
...@@ -208,6 +208,11 @@ public class NewsQuery extends NewsEntity { ...@@ -208,6 +208,11 @@ public class NewsQuery extends NewsEntity {
/** 备注排除列表 */ /** 备注排除列表 */
private List <String> remarkNotList; private List <String> remarkNotList;
/** 关联公司 */
private List<String> relatedCompanyList;
/** 关联公司排除列表 */
private List <String> relatedCompanyNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */ /** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<NewsQuery> orConditionList; private List<NewsQuery> orConditionList;
...@@ -1329,6 +1334,38 @@ public class NewsQuery extends NewsEntity { ...@@ -1329,6 +1334,38 @@ public class NewsQuery extends NewsEntity {
this.remarkNotList = remarkNotList; this.remarkNotList = remarkNotList;
} }
/**
* 获取 关联公司
* @return relatedCompanyList
*/
public List<String> getRelatedCompanyList(){
return this.relatedCompanyList;
}
/**
* 设置 关联公司
* @param relatedCompanyList
*/
public void setRelatedCompanyList(List<String> relatedCompanyList){
this.relatedCompanyList = relatedCompanyList;
}
/**
* 获取 关联公司
* @return relatedCompanyNotList
*/
public List<String> getRelatedCompanyNotList(){
return this.relatedCompanyNotList;
}
/**
* 设置 关联公司
* @param relatedCompanyNotList
*/
public void setRelatedCompanyNotList(List<String> relatedCompanyNotList){
this.relatedCompanyNotList = relatedCompanyNotList;
}
/** /**
* 设置 主键ID,主键,自增长 * 设置 主键ID,主键,自增长
* @param id * @param id
...@@ -1989,6 +2026,25 @@ public class NewsQuery extends NewsEntity { ...@@ -1989,6 +2026,25 @@ public class NewsQuery extends NewsEntity {
return this; return this;
} }
/**
* 设置 关联公司
* @param relatedCompany
*/
public NewsQuery relatedCompany(String relatedCompany){
setRelatedCompany(relatedCompany);
return this;
}
/**
* 设置 关联公司
* @param relatedCompanyList
*/
public NewsQuery relatedCompanyList(List<String> relatedCompanyList){
this.relatedCompanyList = relatedCompanyList;
return this;
}
/** /**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) * 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList * @return orConditionList
......
...@@ -33,4 +33,6 @@ public class NewsVo extends BaseEntityLong { ...@@ -33,4 +33,6 @@ public class NewsVo extends BaseEntityLong {
* 头像地址 * 头像地址
*/ */
private String photoPath; private String photoPath;
private String relatedCompanyName;
} }
\ No newline at end of file
...@@ -4,6 +4,8 @@ import com.mortals.framework.util.StringUtils; ...@@ -4,6 +4,8 @@ import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.module.company.model.CompanyEntity;
import com.mortals.xhx.module.company.service.CompanyService;
import com.mortals.xhx.module.favorites.model.FavoritesNewsEntity; import com.mortals.xhx.module.favorites.model.FavoritesNewsEntity;
import com.mortals.xhx.module.favorites.model.FavoritesNewsQuery; import com.mortals.xhx.module.favorites.model.FavoritesNewsQuery;
import com.mortals.xhx.module.favorites.service.FavoritesNewsService; import com.mortals.xhx.module.favorites.service.FavoritesNewsService;
...@@ -49,6 +51,8 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity ...@@ -49,6 +51,8 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
private UserService userService; private UserService userService;
@Autowired @Autowired
private FavoritesNewsService favoritesNewsService; private FavoritesNewsService favoritesNewsService;
@Autowired
private CompanyService companyService;
@Value("${domain.name:https://oa.xinhx.co}") @Value("${domain.name:https://oa.xinhx.co}")
private String domain; private String domain;
...@@ -97,12 +101,34 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity ...@@ -97,12 +101,34 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
if(StringUtils.isNotEmpty(item.getContent())) { if(StringUtils.isNotEmpty(item.getContent())) {
item.setContent(item.getContent().replaceAll(regex, replacement)); item.setContent(item.getContent().replaceAll(regex, replacement));
} }
if(StringUtils.isNotEmpty(item.getRelatedCompany())){
StringBuilder sb = new StringBuilder();
for(String id:item.getCategoryName().split(",")){
CompanyEntity companyEntity = companyService.get(Long.valueOf(id));
if(companyEntity!=null){
sb.append(companyEntity.getCompanyName());
sb.append(",");
}
}
item.setRelatedCompanyName(sb.toString());
}
} }
}else { }else {
for(NewsEntity item:list){ for(NewsEntity item:list){
if(StringUtils.isNotEmpty(item.getContent())) { if(StringUtils.isNotEmpty(item.getContent())) {
item.setContent(item.getContent().replaceAll(regex, replacement)); item.setContent(item.getContent().replaceAll(regex, replacement));
} }
if(StringUtils.isNotEmpty(item.getRelatedCompany())){
StringBuilder sb = new StringBuilder();
for(String id:item.getRelatedCompany().split(",")){
CompanyEntity companyEntity = companyService.get(Long.valueOf(id));
if(companyEntity!=null){
sb.append(companyEntity.getCompanyName());
sb.append(",");
}
}
item.setRelatedCompanyName(sb.toString());
}
} }
} }
} }
...@@ -122,6 +148,17 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity ...@@ -122,6 +148,17 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
if(StringUtils.isNotEmpty(entity.getContent())) { if(StringUtils.isNotEmpty(entity.getContent())) {
entity.setContent(entity.getContent().replaceAll(regex, replacement)); entity.setContent(entity.getContent().replaceAll(regex, replacement));
} }
if(StringUtils.isNotEmpty(entity.getRelatedCompany())){
StringBuilder sb = new StringBuilder();
for(String id:entity.getRelatedCompany().split(",")){
CompanyEntity companyEntity = companyService.get(Long.valueOf(id));
if(companyEntity!=null){
sb.append(companyEntity.getCompanyName());
sb.append(",");
}
}
entity.setRelatedCompanyName(sb.toString());
}
if(context!=null && context.getUser()!=null){ if(context!=null && context.getUser()!=null){
UserEntity userEntity = userService.get(context.getUser().getId()); UserEntity userEntity = userService.get(context.getUser().getId());
if(userEntity!=null){ if(userEntity!=null){
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<result property="statement" column="statement" /> <result property="statement" column="statement" />
<result property="source" column="source" /> <result property="source" column="source" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="relatedCompany" column="relatedCompany" />
</resultMap> </resultMap>
<!-- 表所有列 --> <!-- 表所有列 -->
...@@ -94,23 +95,26 @@ ...@@ -94,23 +95,26 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('remark') or colPickMode == 1 and data.containsKey('remark')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('remark') or colPickMode == 1 and data.containsKey('remark')))">
a.remark, a.remark,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('relatedCompany') or colPickMode == 1 and data.containsKey('relatedCompany')))">
a.relatedCompany,
</if>
</trim> </trim>
</sql> </sql>
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="NewsEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="NewsEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_news insert into mortals_xhx_news
(categoryId,categoryName,title,titleLogoPath,content,top,viewNums,publishTime,createUserId,createTime,updateUserId,updateTime,upNums,editor,shareNums,deptId,deptName,statement,source,remark) (categoryId,categoryName,title,titleLogoPath,content,top,viewNums,publishTime,createUserId,createTime,updateUserId,updateTime,upNums,editor,shareNums,deptId,deptName,statement,source,remark,relatedCompany)
VALUES VALUES
(#{categoryId},#{categoryName},#{title},#{titleLogoPath},#{content},#{top},#{viewNums},#{publishTime},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{upNums},#{editor},#{shareNums},#{deptId},#{deptName},#{statement},#{source},#{remark}) (#{categoryId},#{categoryName},#{title},#{titleLogoPath},#{content},#{top},#{viewNums},#{publishTime},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{upNums},#{editor},#{shareNums},#{deptId},#{deptName},#{statement},#{source},#{remark},#{relatedCompany})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_news insert into mortals_xhx_news
(categoryId,categoryName,title,titleLogoPath,content,top,viewNums,publishTime,createUserId,createTime,updateUserId,updateTime,upNums,editor,shareNums,deptId,deptName,statement,source,remark) (categoryId,categoryName,title,titleLogoPath,content,top,viewNums,publishTime,createUserId,createTime,updateUserId,updateTime,upNums,editor,shareNums,deptId,deptName,statement,source,remark,relatedCompany)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.categoryId},#{item.categoryName},#{item.title},#{item.titleLogoPath},#{item.content},#{item.top},#{item.viewNums},#{item.publishTime},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.upNums},#{item.editor},#{item.shareNums},#{item.deptId},#{item.deptName},#{item.statement},#{item.source},#{item.remark}) (#{item.categoryId},#{item.categoryName},#{item.title},#{item.titleLogoPath},#{item.content},#{item.top},#{item.viewNums},#{item.publishTime},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.upNums},#{item.editor},#{item.shareNums},#{item.deptId},#{item.deptName},#{item.statement},#{item.source},#{item.remark},#{item.relatedCompany})
</foreach> </foreach>
</insert> </insert>
...@@ -204,6 +208,9 @@ ...@@ -204,6 +208,9 @@
<if test="(colPickMode==0 and data.containsKey('remark')) or (colPickMode==1 and !data.containsKey('remark'))"> <if test="(colPickMode==0 and data.containsKey('remark')) or (colPickMode==1 and !data.containsKey('remark'))">
a.remark=#{data.remark}, a.remark=#{data.remark},
</if> </if>
<if test="(colPickMode==0 and data.containsKey('relatedCompany')) or (colPickMode==1 and !data.containsKey('relatedCompany'))">
a.relatedCompany=#{data.relatedCompany},
</if>
</trim> </trim>
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
...@@ -396,6 +403,13 @@ ...@@ -396,6 +403,13 @@
</if> </if>
</foreach> </foreach>
</trim> </trim>
<trim prefix="relatedCompany=(case" suffix="ELSE relatedCompany end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('relatedCompany')) or (colPickMode==1 and !item.containsKey('relatedCompany'))">
when a.id=#{item.id} then #{item.relatedCompany}
</if>
</foreach>
</trim>
</trim> </trim>
where id in where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")"> <foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
...@@ -993,6 +1007,27 @@ ...@@ -993,6 +1007,27 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="conditionParamRef.containsKey('relatedCompany')">
<if test="conditionParamRef.relatedCompany != null and conditionParamRef.relatedCompany != ''">
${_conditionType_} a.relatedCompany like #{${_conditionParam_}.relatedCompany}
</if>
<if test="conditionParamRef.relatedCompany == null">
${_conditionType_} a.relatedCompany is null
</if>
</if>
<if test="conditionParamRef.containsKey('relatedCompanyList') and conditionParamRef.relatedCompanyList.size() > 0">
${_conditionType_} a.relatedCompany in
<foreach collection="conditionParamRef.relatedCompanyList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('relatedCompanyNotList') and conditionParamRef.relatedCompanyNotList.size() > 0">
${_conditionType_} a.relatedCompany not in
<foreach collection="conditionParamRef.relatedCompanyNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</sql> </sql>
<sql id="_orderCols_"> <sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()"> <if test="orderColList != null and !orderColList.isEmpty()">
...@@ -1237,6 +1272,11 @@ ...@@ -1237,6 +1272,11 @@
<if test='orderCol.remark != null and "DESC".equalsIgnoreCase(orderCol.remark)'>DESC</if> <if test='orderCol.remark != null and "DESC".equalsIgnoreCase(orderCol.remark)'>DESC</if>
, ,
</if> </if>
<if test="orderCol.containsKey('relatedCompany')">
a.relatedCompany
<if test='orderCol.relatedCompany != null and "DESC".equalsIgnoreCase(orderCol.relatedCompany)'>DESC</if>
,
</if>
</trim> </trim>
</if> </if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment