Commit 823404f3 by 梅存智

资讯增加分类

parent 975aecc7
package com.yizhi.site.application.vo.domain; package com.yizhi.site.application.vo.domain;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
...@@ -27,15 +28,51 @@ public class InformationClassify extends Model<InformationClassify> { ...@@ -27,15 +28,51 @@ public class InformationClassify extends Model<InformationClassify> {
@ApiModelProperty(value = "文章父类型") @ApiModelProperty(value = "文章父类型")
@TableField("type_one") @TableField("type_one")
private Long typeOne; private Long typeOne;
@ApiModelProperty(value = "文章父类型名称")
@TableField(exist = false)
private String typeOneName;
@ApiModelProperty(value = "文章子类型(二级)") @ApiModelProperty(value = "文章子类型(二级)")
@TableField("type_two") @TableField("type_two")
private Long typeTwo; private Long typeTwo;
@ApiModelProperty(value = "文章子类型(二级)名称")
@TableField(exist = false)
private String typeTwoName;
@ApiModelProperty(value = "文章子类型(三级)") @ApiModelProperty(value = "文章子类型(三级)")
@TableField("type_three") @TableField("type_three")
private Long typeThree; private Long typeThree;
@ApiModelProperty(value = "文章子类型(三级)名称")
@TableField(exist = false)
private String typeThreeName;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
return this.id; return this.id;
......
package com.yizhi.site.application.vo.domain; package com.yizhi.site.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/** /**
* <p> * <p>
* *
...@@ -96,6 +96,12 @@ public class InformationVo{ ...@@ -96,6 +96,12 @@ public class InformationVo{
@ApiModelProperty(value = "文章第三层类型") @ApiModelProperty(value = "文章第三层类型")
private Long typeThree; private Long typeThree;
@ApiModelProperty(value = "副标题")
private String titleSub;
@ApiModelProperty(value = "图片来源")
private String imgSource;
@ApiModelProperty(value = "资讯分类") @ApiModelProperty(value = "资讯分类")
private List<InformationClassify> informationClassify; private List<InformationClassify> informationClassify;
......
...@@ -6,9 +6,10 @@ import java.util.Date; ...@@ -6,9 +6,10 @@ import java.util.Date;
import java.util.List; import java.util.List;
import com.yizhi.site.application.domain.Information; import com.yizhi.site.application.domain.Information;
import com.yizhi.site.application.mapper.InformationClassifyMapper;
import com.yizhi.site.application.constant.SiteConstant; import com.yizhi.site.application.constant.SiteConstant;
import com.yizhi.site.application.service.PortalBannerService; import com.yizhi.site.application.service.PortalBannerService;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.comment.application.feign.PdfPagesClient; import com.yizhi.comment.application.feign.PdfPagesClient;
import com.yizhi.comment.application.vo.PdfVO; import com.yizhi.comment.application.vo.PdfVO;
import com.yizhi.core.application.event.EventWrapper; import com.yizhi.core.application.event.EventWrapper;
...@@ -28,8 +29,10 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -28,8 +29,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.site.application.service.InformationService; import com.yizhi.site.application.service.InformationService;
import com.yizhi.site.application.vo.domain.InformationClassify;
import com.yizhi.site.application.vo.site.IdOneVO; import com.yizhi.site.application.vo.site.IdOneVO;
import com.yizhi.site.application.vo.site.InfomationParamVO; import com.yizhi.site.application.vo.site.InfomationParamVO;
import com.yizhi.site.application.vo.site.ParamVO; import com.yizhi.site.application.vo.site.ParamVO;
...@@ -60,6 +63,12 @@ public class InformationManageController { ...@@ -60,6 +63,12 @@ public class InformationManageController {
@Autowired @Autowired
private PdfPagesClient pdfPagesClient; private PdfPagesClient pdfPagesClient;
@Autowired
private InformationClassifyMapper informationClassifyMapper;
@Autowired
private IdGenerator idGenerator;
private static final Logger LOGGER = LoggerFactory.getLogger(InformationManageController.class); private static final Logger LOGGER = LoggerFactory.getLogger(InformationManageController.class);
@PostMapping("/list") @PostMapping("/list")
...@@ -108,6 +117,58 @@ public class InformationManageController { ...@@ -108,6 +117,58 @@ public class InformationManageController {
information.setState(SiteConstant.TWO); information.setState(SiteConstant.TWO);
informationService.updateById(information); informationService.updateById(information);
} }
//保存资讯分类
if (!CollectionUtils.isEmpty(information.getInformationClassify())) {
for(InformationClassify item : information.getInformationClassify()){
if(item.getId() == null || item.getId() == 0){
item.setId(idGenerator.generate());
item.setInformationId(information.getId());
item.setCreateById(information.getCreateById());
item.setCreateByName(information.getCreateByName());
item.setCreateTime(information.getCreateTime());
item.setUpdateById(information.getUpdateById());
item.setUpdateByName(information.getUpdateByName());
item.setUpdateTime(information.getUpdateTime());
informationClassifyMapper.insert(item);
}
}
//删除不存在的资讯分类
//获取已有的资讯
InformationClassify classify = new InformationClassify();
classify.setInformationId(information.getId());
EntityWrapper<InformationClassify> wrapper = new EntityWrapper<InformationClassify>(classify);
List<InformationClassify> informationClassify = informationClassifyMapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(informationClassify)) {
boolean isDel = true;
for(InformationClassify old : informationClassify){
isDel = true;
for(InformationClassify item : information.getInformationClassify()){
if(old.getId().equals(item.getId())){
isDel = false;
break;
}
}
if(isDel){
informationClassifyMapper.deleteById(old.getId());
}
}
}
} else {
//删除所有资讯分类
InformationClassify classify = new InformationClassify();
classify.setInformationId(information.getId());
EntityWrapper<InformationClassify> wrapper = new EntityWrapper<InformationClassify>(classify);
List<InformationClassify> informationClassify = informationClassifyMapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(informationClassify)) {
for(InformationClassify old : informationClassify){
informationClassifyMapper.deleteById(old.getId());
}
}
}
if (!StringUtils.isEmpty(information.getPdfOssUrl()) && !StringUtils.isEmpty(information.getPdfFileName())) { if (!StringUtils.isEmpty(information.getPdfOssUrl()) && !StringUtils.isEmpty(information.getPdfFileName())) {
List<PdfVO> pdfVOs = new ArrayList<PdfVO>(); List<PdfVO> pdfVOs = new ArrayList<PdfVO>();
PdfVO pdfVO = new PdfVO(); PdfVO pdfVO = new PdfVO();
......
...@@ -121,6 +121,18 @@ public class Information extends Model<Information> { ...@@ -121,6 +121,18 @@ public class Information extends Model<Information> {
@TableField("type_three") @TableField("type_three")
private Long typeThree; private Long typeThree;
@ApiModelProperty(value = "文章子类型(三级)名称")
@TableField(exist = false)
private String typeThreeName;
@ApiModelProperty(value = "副标题")
@TableField("title_sub")
private String titleSub;
@ApiModelProperty(value = "图片来源")
@TableField("img_source")
private String imgSource;
@ApiModelProperty(value = "资讯分类") @ApiModelProperty(value = "资讯分类")
@TableField(exist = false) @TableField(exist = false)
private List<InformationClassify> informationClassify; private List<InformationClassify> informationClassify;
......
...@@ -923,10 +923,10 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor ...@@ -923,10 +923,10 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
if (list.size() > 0 && list != null) { if (list.size() > 0 && list != null) {
for (Information info : list) { for (Information info : list) {
if (info.getTypeOne() != null || info.getTypeOne() != 0) { if (info.getTypeOne() != null && info.getTypeOne() != 0) {
info.setTypeOneName(findNameById(info.getTypeOne())); info.setTypeOneName(findNameById(info.getTypeOne()));
} }
if (info.getTypeTwo() != null || info.getTypeTwo() != 0) { if (info.getTypeTwo() != null && info.getTypeTwo() != 0) {
info.setTypeTwoName(findNameById(info.getTypeTwo())); info.setTypeTwoName(findNameById(info.getTypeTwo()));
} }
} }
...@@ -980,10 +980,10 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor ...@@ -980,10 +980,10 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
} }
if (list.size() > 0 && list != null) { if (list.size() > 0 && list != null) {
for (Information info : list) { for (Information info : list) {
if (info.getTypeOne() != null || info.getTypeOne() != 0) { if (info.getTypeOne() != null && info.getTypeOne() != 0) {
info.setTypeOneName(findNameById(info.getTypeOne())); info.setTypeOneName(findNameById(info.getTypeOne()));
} }
if (info.getTypeTwo() != null || info.getTypeTwo() != 0) { if (info.getTypeTwo() != null && info.getTypeTwo() != 0) {
info.setTypeTwoName(findNameById(info.getTypeTwo())); info.setTypeTwoName(findNameById(info.getTypeTwo()));
} }
} }
...@@ -998,18 +998,34 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor ...@@ -998,18 +998,34 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
if (info == null) { if (info == null) {
return null; return null;
} }
if (info.getTypeOne() != null || info.getTypeOne() != 0) { if (info.getTypeOne() != null && info.getTypeOne() != 0) {
info.setTypeOneName(findNameById(info.getTypeOne())); info.setTypeOneName(findNameById(info.getTypeOne()));
} }
if (info.getTypeTwo() != null || info.getTypeTwo() != 0) { if (info.getTypeTwo() != null && info.getTypeTwo() != 0) {
info.setTypeTwoName(findNameById(info.getTypeTwo())); info.setTypeTwoName(findNameById(info.getTypeTwo()));
} }
if (info.getTypeThree() != null && info.getTypeThree() != 0) {
info.setTypeThreeName(findNameById(info.getTypeThree()));
}
//设置资讯分类 //设置资讯分类
InformationClassify classify = new InformationClassify(); InformationClassify classify = new InformationClassify();
classify.setInformationId(id); classify.setInformationId(id);
EntityWrapper<InformationClassify> wrapper = new EntityWrapper<InformationClassify>(classify); EntityWrapper<InformationClassify> wrapper = new EntityWrapper<InformationClassify>(classify);
List<InformationClassify> informationClassify = informationClassifyMapper.selectList(wrapper); List<InformationClassify> informationClassify = informationClassifyMapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(informationClassify)) {
for(InformationClassify item : informationClassify){
if (item.getTypeOne() != null && item.getTypeOne() != 0) {
item.setTypeOneName(findNameById(item.getTypeOne()));
}
if (item.getTypeTwo() != null && item.getTypeTwo() != 0) {
item.setTypeTwoName(findNameById(item.getTypeTwo()));
}
if (item.getTypeThree() != null && item.getTypeThree() != 0) {
item.setTypeThreeName(findNameById(item.getTypeThree()));
}
}
}
info.setInformationClassify(informationClassify); info.setInformationClassify(informationClassify);
return info; return info;
...@@ -1043,6 +1059,23 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor ...@@ -1043,6 +1059,23 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
this.insert(information); this.insert(information);
} }
//保存资讯分类
if (!CollectionUtils.isEmpty(information.getInformationClassify())) {
for(InformationClassify item : information.getInformationClassify()){
item.setId(idGenerator.generate());
item.setInformationId(information.getId());
item.setCreateById(information.getCreateById());
item.setCreateByName(information.getCreateByName());
item.setCreateTime(information.getCreateTime());
item.setUpdateById(information.getUpdateById());
item.setUpdateByName(information.getUpdateByName());
item.setUpdateTime(information.getUpdateTime());
informationClassifyMapper.insert(item);
}
}
if (!StringUtils.isEmpty(information.getPdfOssUrl()) && !StringUtils.isEmpty(information.getPdfFileName())) { if (!StringUtils.isEmpty(information.getPdfOssUrl()) && !StringUtils.isEmpty(information.getPdfFileName())) {
List<PdfVO> pdfVOs = new ArrayList<PdfVO>(); List<PdfVO> pdfVOs = new ArrayList<PdfVO>();
PdfVO pdfVO = new PdfVO(); PdfVO pdfVO = new PdfVO();
......
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