yangdamao 4 달 전
부모
커밋
41d6291de8

+ 84 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/activity/ConsultationController.java

@@ -0,0 +1,84 @@
+package com.zhongzheng.controller.activity;
+
+
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.modules.activity.bo.ConsultationAddBo;
+import com.zhongzheng.modules.activity.bo.ConsultationDelBo;
+import com.zhongzheng.modules.activity.bo.ConsultationQueryBo;
+import com.zhongzheng.modules.activity.bo.ConsultationUpdateBo;
+import com.zhongzheng.modules.activity.service.IConsultationService;
+import com.zhongzheng.modules.activity.vo.ConsultationVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 新聞公告Controller
+ *
+ * @author hjl
+ * @date 2022-04-13
+ */
+@Api(value = "新聞公告控制器", tags = {"新聞公告管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/consultation")
+public class ConsultationController extends BaseController {
+
+    private final IConsultationService consultationService;
+
+    /**
+     * 新增新聞公告
+     */
+    @ApiOperation("新增新聞公告")
+    @PostMapping("/save")
+    public AjaxResult<Void> add(@RequestBody ConsultationAddBo bo) {
+        return toAjax(consultationService.insertByAddBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 刪除新聞公告
+     */
+    @ApiOperation("刪除新聞公告")
+    @PostMapping("/batch/del")
+    public AjaxResult<Void> batchDel(@RequestBody ConsultationDelBo bo) {
+        return toAjax(consultationService.batchDel(bo) ? 1 : 0);
+    }
+
+    /**
+     * 查看新聞列表
+     */
+    @ApiOperation("查看新聞列表")
+    @GetMapping("/list")
+    public TableDataInfo<ConsultationVo> list(ConsultationQueryBo bo) {
+        startPage();
+        List<ConsultationVo> list = consultationService.getConsultationlist(bo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查看新聞詳情
+     */
+    @ApiOperation("查看新聞列表")
+    @GetMapping("/details/{id}")
+    public AjaxResult<ConsultationVo> details(@PathVariable("id") Long id) {
+        ConsultationVo vo = consultationService.getDetails(id);
+        return AjaxResult.success(vo);
+    }
+
+    /**
+     * 修改新聞公告
+     */
+    @ApiOperation("修改新聞公告")
+    @PostMapping("/update")
+    public AjaxResult<Void> updateByBo(@RequestBody ConsultationUpdateBo bo) {
+        return toAjax(consultationService.updateByBo(bo) ? 1 : 0);
+    }
+
+
+}

+ 57 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/collect/ConsultationController.java

@@ -0,0 +1,57 @@
+package com.zhongzheng.controller.collect;
+
+
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.modules.activity.bo.ConsultationQueryBo;
+import com.zhongzheng.modules.activity.service.IConsultationService;
+import com.zhongzheng.modules.activity.vo.ConsultationVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 新聞公告Controller
+ *
+ * @author hjl
+ * @date 2022-04-13
+ */
+@Api(value = "新聞公告控制器", tags = {"新聞公告管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/app/consultation")
+public class ConsultationController extends BaseController {
+
+    private final IConsultationService consultationService;
+
+    /**
+     * 查看新聞列表
+     */
+    @ApiOperation("查看新聞列表")
+    @GetMapping("/list")
+    public TableDataInfo<ConsultationVo> list(ConsultationQueryBo bo) {
+        startPage();
+        List<ConsultationVo> list = consultationService.getConsultationlist(bo);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 查看新聞詳情
+     */
+    @ApiOperation("查看新聞列表")
+    @GetMapping("/details/{id}")
+    public AjaxResult<ConsultationVo> details(@PathVariable("id") Long id) {
+        ConsultationVo vo = consultationService.getDetails(id);
+        return AjaxResult.success(vo);
+    }
+
+}

+ 1 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java

@@ -130,6 +130,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 ).permitAll()
                 .antMatchers("/app/common/**").anonymous() //小程序非验证接口
                 .antMatchers("/sys/common/**").anonymous()
+                .antMatchers("/app/consultation/**").anonymous()
                 .antMatchers("/refreshToken/**").anonymous()
                 .antMatchers("/v1/test/**").anonymous()
                 .antMatchers("/profile/**").anonymous()

+ 32 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/bo/ConsultationAddBo.java

@@ -0,0 +1,32 @@
+package com.zhongzheng.modules.activity.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 【活动商品价格】对象 top_certificate
+ *
+ * @author ruoyi
+ * @date 2023-03-15
+ */
+@Data
+public class ConsultationAddBo implements Serializable {
+
+    /** 新闻标题 */
+    private String title;
+    /** 新闻内容 */
+    private String titleContent;
+    /** 类型: 1 新闻 2公告 */
+    private Integer type;
+    /** 排序字段 */
+    private Integer sort;
+    /**  状态 1正常 0关闭 */
+    private Integer status;
+    /** 创建时间 */
+    private Long createTime;
+    /** 更新时间 */
+    private Long updateTime;
+    private Long tenantId;
+
+}

+ 22 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/bo/ConsultationDelBo.java

@@ -0,0 +1,22 @@
+package com.zhongzheng.modules.activity.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ *
+ * @author ruoyi
+ * @date 2023-03-15
+ */
+@Data
+public class ConsultationDelBo implements Serializable {
+
+    /** 新闻标题IDs */
+    private List<Long> ids;
+
+    private Integer status;
+
+}

+ 37 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/bo/ConsultationQueryBo.java

@@ -0,0 +1,37 @@
+package com.zhongzheng.modules.activity.bo;
+
+
+import com.zhongzheng.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 【活动商品价格】对象 top_certificate
+ *
+ * @author ruoyi
+ * @date 2023-03-15
+ */
+@Data
+public class ConsultationQueryBo extends BaseEntity {
+    /** 分页大小 */
+    @ApiModelProperty("分页大小")
+    private Integer pageSize;
+    /** 当前页数 */
+    @ApiModelProperty("当前页数")
+    private Integer pageNum;
+    /** 排序列 */
+    @ApiModelProperty("排序列")
+    private String orderByColumn;
+    /** 排序的方向desc或者asc */
+    @ApiModelProperty(value = "排序的方向", example = "asc,desc")
+    private String isAsc;
+
+    /** 新闻标题 */
+    private String title;
+    /** 类型: 1 新闻 2公告 */
+    private Integer type;
+    /**  状态 1正常 0关闭 */
+    private Integer status;
+
+
+}

+ 32 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/bo/ConsultationUpdateBo.java

@@ -0,0 +1,32 @@
+package com.zhongzheng.modules.activity.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 【活动商品价格】对象 top_certificate
+ *
+ * @author ruoyi
+ * @date 2023-03-15
+ */
+@Data
+public class ConsultationUpdateBo implements Serializable {
+
+    private Long id;
+    /** 新闻标题 */
+    private String title;
+    /** 新闻内容 */
+    private String titleContent;
+    /** 类型: 1 新闻 2公告 */
+    private Integer type;
+    /** 排序字段 */
+    private Integer sort;
+    /**  状态 1正常 0关闭 */
+    private Integer status;
+    /** 创建时间 */
+    private Long createTime;
+    /** 更新时间 */
+    private Long updateTime;
+
+}

+ 44 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/domain/Consultation.java

@@ -0,0 +1,44 @@
+package com.zhongzheng.modules.activity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 【活动商品价格】对象 top_certificate
+ *
+ * @author ruoyi
+ * @date 2023-03-15
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("consultation")
+public class Consultation implements Serializable {
+
+private static final long serialVersionUID=1L;
+
+    /** $column.columnComment */
+    @TableId(value = "id")
+    private Long id;
+    /** 新闻标题 */
+    private String title;
+    /** 新闻内容 */
+    private String titleContent;
+    /** 类型: 1 新闻 2公告 */
+    private Integer type;
+    /** 排序字段 */
+    private Integer sort;
+    /**  状态 1正常 0关闭 */
+    private Integer status;
+    /** 创建时间 */
+    private Long createTime;
+    /** 更新时间 */
+    private Long updateTime;
+    private Long tenantId;
+
+}

+ 14 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/mapper/ConsultationMapper.java

@@ -0,0 +1,14 @@
+package com.zhongzheng.modules.activity.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.activity.domain.Consultation;
+
+
+/**
+ * 商品推荐Mapper接口
+ *
+ * @author hjl
+ * @date 2022-04-13
+ */
+public interface ConsultationMapper extends BaseMapper<Consultation> {
+}

+ 31 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/IConsultationService.java

@@ -0,0 +1,31 @@
+package com.zhongzheng.modules.activity.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.activity.bo.ConsultationAddBo;
+import com.zhongzheng.modules.activity.bo.ConsultationDelBo;
+import com.zhongzheng.modules.activity.bo.ConsultationQueryBo;
+import com.zhongzheng.modules.activity.bo.ConsultationUpdateBo;
+import com.zhongzheng.modules.activity.domain.Consultation;
+import com.zhongzheng.modules.activity.vo.ConsultationVo;
+
+
+import java.util.List;
+
+/**
+ * 商品推荐Service接口
+ *
+ * @author hjl
+ * @date 2022-04-13
+ */
+public interface IConsultationService extends IService<Consultation> {
+
+    boolean insertByAddBo(ConsultationAddBo bo);
+
+    boolean batchDel(ConsultationDelBo bo);
+
+    List<ConsultationVo> getConsultationlist(ConsultationQueryBo bo);
+
+    ConsultationVo getDetails(Long id);
+
+    boolean updateByBo(ConsultationUpdateBo bo);
+}

+ 97 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/impl/ConsultationServiceImpl.java

@@ -0,0 +1,97 @@
+package com.zhongzheng.modules.activity.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
+import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.activity.bo.ConsultationAddBo;
+import com.zhongzheng.modules.activity.bo.ConsultationDelBo;
+import com.zhongzheng.modules.activity.bo.ConsultationQueryBo;
+import com.zhongzheng.modules.activity.bo.ConsultationUpdateBo;
+import com.zhongzheng.modules.activity.domain.Consultation;
+import com.zhongzheng.modules.activity.mapper.ConsultationMapper;
+import com.zhongzheng.modules.activity.service.IConsultationService;
+import com.zhongzheng.modules.activity.vo.ConsultationVo;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 商品推荐Service业务层处理
+ *
+ * @author hjl
+ * @date 2022-04-13
+ */
+@Service
+public class ConsultationServiceImpl extends ServiceImpl<ConsultationMapper, Consultation> implements IConsultationService {
+
+
+    @Override
+    public boolean insertByAddBo(ConsultationAddBo bo) {
+        bo.setCreateTime(DateUtils.getNowTime());
+        bo.setUpdateTime(DateUtils.getNowTime());
+        bo.setStatus(1);
+        Consultation bean = BeanUtil.toBean(bo, Consultation.class);
+        return save(bean);
+    }
+
+    @Override
+    public boolean batchDel(ConsultationDelBo bo) {
+        if (CollectionUtils.isEmpty(bo.getIds())){
+            throw new ClassCastException("清線勾選選擇");
+        }
+        List<Consultation> consultations = listByIds(bo.getIds());
+        consultations.forEach(item -> item.setStatus(bo.getStatus()));
+        return updateBatchById(consultations);
+    }
+
+    @Override
+    public List<ConsultationVo> getConsultationlist(ConsultationQueryBo bo) {
+        List<Consultation> list = list(new LambdaQueryWrapper<Consultation>()
+                .in(ObjectUtils.isNull(bo.getStatus()),Consultation::getStatus, Arrays.asList(0,1))
+                .eq(ObjectUtils.isNotNull(bo.getStatus()), Consultation::getStatus, bo.getStatus())
+                .eq(ObjectUtils.isNotNull(bo.getType()), Consultation::getType, bo.getType())
+                .like(StringUtils.isNotBlank(bo.getTitle()), Consultation::getTitle, bo.getTitle())
+                .orderByDesc(Consultation::getSort,Consultation::getCreateTime));
+        return entity2Vo(list);
+    }
+
+    @Override
+    public ConsultationVo getDetails(Long id) {
+        Consultation consultation = getById(id);
+        return BeanUtil.toBean(consultation,ConsultationVo.class);
+    }
+
+    @Override
+    public boolean updateByBo(ConsultationUpdateBo bo) {
+        Consultation consultation = BeanUtil.toBean(bo, Consultation.class);
+        return updateById(consultation);
+    }
+
+    /**
+     * 实体类转化成视图对象
+     *
+     * @param collection 实体类集合
+     * @return
+     */
+    private List<ConsultationVo> entity2Vo(Collection<Consultation> collection) {
+        List<ConsultationVo> voList = collection.stream()
+                .map(any -> BeanUtil.toBean(any, ConsultationVo.class))
+                .collect(Collectors.toList());
+        if (collection instanceof Page) {
+            Page<Consultation> page = (Page<Consultation>)collection;
+            Page<ConsultationVo> pageVo = new Page<>();
+            BeanUtil.copyProperties(page,pageVo);
+            pageVo.addAll(voList);
+            voList = pageVo;
+        }
+        return voList;
+    }
+}

+ 31 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/vo/ConsultationVo.java

@@ -0,0 +1,31 @@
+package com.zhongzheng.modules.activity.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 【活动商品价格】对象 top_certificate
+ *
+ * @author ruoyi
+ * @date 2023-03-15
+ */
+@Data
+public class ConsultationVo implements Serializable {
+
+    private Long id;
+    /** 新闻标题 */
+    private String title;
+    /** 新闻内容 */
+    private String titleContent;
+    /** 类型: 1 新闻 2公告 */
+    private Integer type;
+    /** 排序字段 */
+    private Integer sort;
+    /**  状态 1正常 0关闭 */
+    private Integer status;
+    /** 创建时间 */
+    private Long createTime;
+    /** 更新时间 */
+    private Long updateTime;
+}