Commit 823404f3 by 梅存智

资讯增加分类

parent 975aecc7
package com.yizhi.site.application.vo.domain;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
......@@ -28,14 +29,50 @@ public class InformationClassify extends Model<InformationClassify> {
@TableField("type_one")
private Long typeOne;
@ApiModelProperty(value = "文章父类型名称")
@TableField(exist = false)
private String typeOneName;
@ApiModelProperty(value = "文章子类型(二级)")
@TableField("type_two")
private Long typeTwo;
@ApiModelProperty(value = "文章子类型(二级)名称")
@TableField(exist = false)
private String typeTwoName;
@ApiModelProperty(value = "文章子类型(三级)")
@TableField("type_three")
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
protected Serializable pkVal() {
return this.id;
......
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.util.Date;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
*
......@@ -97,6 +97,12 @@ public class InformationVo{
@ApiModelProperty(value = "文章第三层类型")
private Long typeThree;
@ApiModelProperty(value = "副标题")
private String titleSub;
@ApiModelProperty(value = "图片来源")
private String imgSource;
@ApiModelProperty(value = "资讯分类")
private List<InformationClassify> informationClassify;
......
......@@ -6,9 +6,10 @@ import java.util.Date;
import java.util.List;
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.service.PortalBannerService;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.comment.application.feign.PdfPagesClient;
import com.yizhi.comment.application.vo.PdfVO;
import com.yizhi.core.application.event.EventWrapper;
......@@ -28,8 +29,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
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.InfomationParamVO;
import com.yizhi.site.application.vo.site.ParamVO;
......@@ -60,6 +63,12 @@ public class InformationManageController {
@Autowired
private PdfPagesClient pdfPagesClient;
@Autowired
private InformationClassifyMapper informationClassifyMapper;
@Autowired
private IdGenerator idGenerator;
private static final Logger LOGGER = LoggerFactory.getLogger(InformationManageController.class);
@PostMapping("/list")
......@@ -108,6 +117,58 @@ public class InformationManageController {
information.setState(SiteConstant.TWO);
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())) {
List<PdfVO> pdfVOs = new ArrayList<PdfVO>();
PdfVO pdfVO = new PdfVO();
......
......@@ -121,6 +121,18 @@ public class Information extends Model<Information> {
@TableField("type_three")
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 = "资讯分类")
@TableField(exist = false)
private List<InformationClassify> informationClassify;
......
......@@ -923,10 +923,10 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
if (list.size() > 0 && list != null) {
for (Information info : list) {
if (info.getTypeOne() != null || info.getTypeOne() != 0) {
if (info.getTypeOne() != null && info.getTypeOne() != 0) {
info.setTypeOneName(findNameById(info.getTypeOne()));
}
if (info.getTypeTwo() != null || info.getTypeTwo() != 0) {
if (info.getTypeTwo() != null && info.getTypeTwo() != 0) {
info.setTypeTwoName(findNameById(info.getTypeTwo()));
}
}
......@@ -980,10 +980,10 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
}
if (list.size() > 0 && list != null) {
for (Information info : list) {
if (info.getTypeOne() != null || info.getTypeOne() != 0) {
if (info.getTypeOne() != null && info.getTypeOne() != 0) {
info.setTypeOneName(findNameById(info.getTypeOne()));
}
if (info.getTypeTwo() != null || info.getTypeTwo() != 0) {
if (info.getTypeTwo() != null && info.getTypeTwo() != 0) {
info.setTypeTwoName(findNameById(info.getTypeTwo()));
}
}
......@@ -998,18 +998,34 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
if (info == null) {
return null;
}
if (info.getTypeOne() != null || info.getTypeOne() != 0) {
if (info.getTypeOne() != null && info.getTypeOne() != 0) {
info.setTypeOneName(findNameById(info.getTypeOne()));
}
if (info.getTypeTwo() != null || info.getTypeTwo() != 0) {
if (info.getTypeTwo() != null && info.getTypeTwo() != 0) {
info.setTypeTwoName(findNameById(info.getTypeTwo()));
}
if (info.getTypeThree() != null && info.getTypeThree() != 0) {
info.setTypeThreeName(findNameById(info.getTypeThree()));
}
//设置资讯分类
InformationClassify classify = new InformationClassify();
classify.setInformationId(id);
EntityWrapper<InformationClassify> wrapper = new EntityWrapper<InformationClassify>(classify);
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);
return info;
......@@ -1043,6 +1059,23 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
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())) {
List<PdfVO> pdfVOs = new ArrayList<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