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

新闻公告增加关联公司

parent dec578af
......@@ -137,3 +137,5 @@ CREATE TABLE mortals_xhx_resource_image(
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) 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;
import com.mortals.xhx.module.company.model.CompanyLabelsEntity;
import com.mortals.xhx.module.company.model.CompanyPatentEntity;
import com.mortals.xhx.module.news.model.NewsEntity;
import lombok.Data;
import com.mortals.framework.annotation.Excel;
......@@ -41,4 +42,6 @@ public class CompanyVo extends BaseEntityLong {
*/
private Integer sendBusinessCardTimes;
private List<NewsEntity> newsList;
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.YesNoEnum;
......@@ -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.labels.model.LabelsQuery;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.JsonbHttpMessageConverter;
......@@ -29,15 +33,11 @@ import com.mortals.xhx.module.company.service.CompanyService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -62,6 +62,8 @@ public class CompanyController extends BaseCRUDJsonBodyMappingController<Company
private CompanyPatentService companyPatentService;
@Autowired
private CompanyLabelsService companyLabelsService;
@Autowired
private NewsService newsService;
......@@ -103,7 +105,17 @@ public class CompanyController extends BaseCRUDJsonBodyMappingController<Company
List<CompanyLabelsEntity> companyLabelsEntities = companyLabelsService.find(new CompanyLabelsQuery().companyId(entity.getId()));
entity.setCompanyLabelsList(companyLabelsEntities);
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);
}
......
......@@ -14,7 +14,7 @@ import lombok.Data;
* 新闻实体对象
*
* @author zxfei
* @date 2023-09-28
* @date 2025-01-08
*/
@Data
public class NewsEntity extends NewsVo {
......@@ -52,6 +52,10 @@ public class NewsEntity extends NewsVo {
* 发布时间
*/
private Date publishTime;
/**
* 点赞次数
*/
private Integer upNums;
/**
* 责任编辑
*/
......@@ -81,9 +85,9 @@ public class NewsEntity extends NewsVo {
*/
private String remark;
/**
* 点赞次数
* 关联公司
*/
private Integer upNums;
private String relatedCompany;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -109,6 +113,7 @@ public class NewsEntity extends NewsVo {
this.top = 0;
this.viewNums = 0;
this.publishTime = new Date();
this.upNums = 0;
this.editor = "";
this.shareNums = 0;
this.deptId = null;
......@@ -116,6 +121,6 @@ public class NewsEntity extends NewsVo {
this.statement = "";
this.source = "";
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;
* 新闻查询对象
*
* @author zxfei
* @date 2024-12-04
* @date 2025-01-08
*/
public class NewsQuery extends NewsEntity {
/** 开始 主键ID,主键,自增长 */
......@@ -208,6 +208,11 @@ public class NewsQuery extends NewsEntity {
/** 备注排除列表 */
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) */
private List<NewsQuery> orConditionList;
......@@ -1329,6 +1334,38 @@ public class NewsQuery extends NewsEntity {
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,主键,自增长
* @param id
......@@ -1989,6 +2026,25 @@ public class NewsQuery extends NewsEntity {
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)
* @return orConditionList
......
......@@ -33,4 +33,6 @@ public class NewsVo extends BaseEntityLong {
* 头像地址
*/
private String photoPath;
private String relatedCompanyName;
}
\ No newline at end of file
......@@ -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.UserQuery;
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.FavoritesNewsQuery;
import com.mortals.xhx.module.favorites.service.FavoritesNewsService;
......@@ -49,6 +51,8 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
private UserService userService;
@Autowired
private FavoritesNewsService favoritesNewsService;
@Autowired
private CompanyService companyService;
@Value("${domain.name:https://oa.xinhx.co}")
private String domain;
......@@ -97,12 +101,34 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
if(StringUtils.isNotEmpty(item.getContent())) {
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 {
for(NewsEntity item:list){
if(StringUtils.isNotEmpty(item.getContent())) {
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
if(StringUtils.isNotEmpty(entity.getContent())) {
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){
UserEntity userEntity = userService.get(context.getUser().getId());
if(userEntity!=null){
......
......@@ -26,6 +26,7 @@
<result property="statement" column="statement" />
<result property="source" column="source" />
<result property="remark" column="remark" />
<result property="relatedCompany" column="relatedCompany" />
</resultMap>
<!-- 表所有列 -->
......@@ -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')))">
a.remark,
</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>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="NewsEntity" useGeneratedKeys="true" keyProperty="id">
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
(#{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 id="insertBatch" parameterType="paramDto">
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
<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>
</insert>
......@@ -204,6 +208,9 @@
<if test="(colPickMode==0 and data.containsKey('remark')) or (colPickMode==1 and !data.containsKey('remark'))">
a.remark=#{data.remark},
</if>
<if test="(colPickMode==0 and data.containsKey('relatedCompany')) or (colPickMode==1 and !data.containsKey('relatedCompany'))">
a.relatedCompany=#{data.relatedCompany},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
......@@ -396,6 +403,13 @@
</if>
</foreach>
</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>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
......@@ -993,6 +1007,27 @@
#{item}
</foreach>
</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 id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
......@@ -1237,6 +1272,11 @@
<if test='orderCol.remark != null and "DESC".equalsIgnoreCase(orderCol.remark)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('relatedCompany')">
a.relatedCompany
<if test='orderCol.relatedCompany != null and "DESC".equalsIgnoreCase(orderCol.relatedCompany)'>DESC</if>
,
</if>
</trim>
</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