From bb5a5bdc383f40d3338aa50cc921a74d79d0023b Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 21 Jul 2021 16:39:56 +0800
Subject: [PATCH] Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop
---
gc-sys/src/main/java/com/xzx/gc/system/dto/AddSysNewsDto.java | 30 +++
gc-sys/src/main/java/com/xzx/gc/system/dto/UpdateSysNewsDto.java | 22 ++
gc-sys/src/main/java/com/xzx/gc/system/vo/SysNewsListVo.java | 39 ++++
gc-core/src/main/java/com/xzx/gc/entity/SysNews.java | 32 ++++
gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysNewsDto.java | 10 +
gc-shop/src/main/resources/sql | 12 +
gc-sys/src/main/resources/mapper/system/SysNewsMapper.xml | 38 ++++
gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysNewsDto.java | 8 +
gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysNewsVo.java | 24 +++
gc-sys/src/main/java/com/xzx/gc/system/controller/AdminSysNewsController.java | 120 +++++++++++++++
gc-sys/src/main/java/com/xzx/gc/system/service/SysNewsService.java | 77 +++++++++
gc-sys/src/main/java/com/xzx/gc/system/dto/SysNewsListDto.java | 15 +
gc-sys/src/main/java/com/xzx/gc/system/mapper/SysNewsMapper.java | 24 +++
gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysNewsDto.java | 15 +
14 files changed, 466 insertions(+), 0 deletions(-)
diff --git a/gc-core/src/main/java/com/xzx/gc/entity/SysNews.java b/gc-core/src/main/java/com/xzx/gc/entity/SysNews.java
new file mode 100644
index 0000000..de0eff3
--- /dev/null
+++ b/gc-core/src/main/java/com/xzx/gc/entity/SysNews.java
@@ -0,0 +1,32 @@
+package com.xzx.gc.entity;
+
+import lombok.Data;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Table(name="xzx_sys_news")
+public class SysNews {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private long newsId;
+
+ private String title;
+ private String content;
+ private String createTime;
+ private String createUserId;
+ private String picture;
+ //删除0:未删除,1:删除
+ private Integer delFlag;
+ //排序
+ private Integer sort;
+ //状态 1:未发布 2:已发布
+ private Integer status;
+
+
+
+}
diff --git a/gc-shop/src/main/resources/sql b/gc-shop/src/main/resources/sql
index ac4c2ad..c6a337a 100644
--- a/gc-shop/src/main/resources/sql
+++ b/gc-shop/src/main/resources/sql
@@ -63,6 +63,18 @@
ALTER TABLE `xzx_score_order`
ADD COLUMN `is_finish` int(11) NULL DEFAULT 2 COMMENT '后台确认提货 1:是 2:否' AFTER `remark`;
+ALTER TABLE `xzx_sys_news`
+DROP COLUMN `del_flag`,
+ADD COLUMN `del_flag` int(1) NULL DEFAULT 0 COMMENT '删除0:未删除,1:删除' AFTER `picture`;
+
+ALTER TABLE `xzx_sys_news`
+ADD COLUMN `sort` int(5) NULL DEFAULT 10 COMMENT '排序' AFTER `del_flag`;
+
+ALTER TABLE `xzx_sys_news`
+ADD COLUMN `status` int(1) NULL DEFAULT 1 COMMENT '状态 1:未发布 2:已发布' AFTER `sort`;
+
+
+
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/controller/AdminSysNewsController.java b/gc-sys/src/main/java/com/xzx/gc/system/controller/AdminSysNewsController.java
new file mode 100644
index 0000000..2bdceef
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/controller/AdminSysNewsController.java
@@ -0,0 +1,120 @@
+package com.xzx.gc.system.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.xzx.gc.common.constant.CommonEnum;
+import com.xzx.gc.common.constant.Constants;
+import com.xzx.gc.common.dto.log.OperationAppLog;
+import com.xzx.gc.common.request.BaseController;
+import com.xzx.gc.entity.JhyInfo;
+import com.xzx.gc.entity.SysNews;
+import com.xzx.gc.model.JsonResult;
+import com.xzx.gc.system.dto.*;
+import com.xzx.gc.system.mapper.SysNewsMapper;
+import com.xzx.gc.system.service.SysNewsService;
+import com.xzx.gc.system.vo.SysNewsListVo;
+import com.xzx.gc.system.vo.ViewSysNewsVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.Map;
+
+@RestController
+@Api(tags = {"广播通知"})
+@Slf4j
+public class AdminSysNewsController extends BaseController {
+
+ @Autowired
+ private SysNewsService sysNewsService;
+
+ @Resource
+ SysNewsMapper sysNewsMapper;
+
+ @ApiOperation(value = "广播通知--列表")
+ @ApiResponses(
+ @ApiResponse(code = 200, message = "success", response = SysNewsListVo.class)
+ )
+ @PostMapping(value = Constants.ADMIN_VIEW_PREFIX + "/sysNews/sysNewsList.json")
+ public JsonResult<Map<String, Object>> sysNewsService(@RequestBody SysNewsListDto sysNewsListDto) {
+ return JsonResult.success(sysNewsService.sysNewsService(sysNewsListDto));
+ }
+
+ @PostMapping(Constants.ADMIN_VIEW_PREFIX+"/sysNews/addSysNews.json")
+ @ApiOperation(value = "广播通知--添加", notes = "test: 仅0有正确返回")
+ public JsonResult<String> addSysNews(@RequestBody AddSysNewsDto model, HttpServletRequest request) {
+
+ model.setCreateUserId(getAdminName(request));
+ model.setCreateTime(new Date());
+ sysNewsService.addSysNews(model);
+ OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
+ .methodName(Constants.SCORESHOP_MODUL_NAME).operateAction("广播通知--添加-").build();
+ mqUtil.sendApp(build);
+ return JsonResult.success("操作成功!");
+ }
+
+ @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/sysNews/viewSysNews.json")
+ @ApiResponses({@ApiResponse( code = 200, message = "success", response = ViewSysNewsVo.class)})
+ @ApiOperation(value="广播通知--查看通知详情", notes="test: 仅0有正确返回")
+ public JsonResult<ViewSysNewsVo> viewSysNews(@RequestBody ViewSysNewsDto viewSysNewsDto) {
+ Long id = viewSysNewsDto.getId();
+ ViewSysNewsVo viewSysNewsVo = sysNewsService.viewSysNews(id);
+ return JsonResult.success(viewSysNewsVo);
+ }
+
+ @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/sysNews/updateSysNews.json")
+ @ApiOperation(value="广播通知--更新通知详情", notes="test: 仅0有正确返回")
+ public JsonResult updateSysNews(@RequestBody UpdateSysNewsDto model, HttpServletRequest request) {
+ long id = model.getId();
+ SysNews sysNews = sysNewsMapper.selectById(id);
+ if(ObjectUtil.isEmpty(sysNews)){
+ return JsonResult.failMessage("当前记录不存在!");
+ }
+ sysNewsService.updateSysNews(model);
+ OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
+ .methodName(Constants.SCORESHOP_MODUL_NAME).operateAction("广播通知--更新通知详情-" + id).build();
+ mqUtil.sendApp(build);
+ return JsonResult.success("操作成功!");
+ }
+
+ @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/sysNews/delSysNews.json")
+ @ApiOperation(value="广播通知--删除", notes="test: 仅0有正确返回")
+ public JsonResult delSysNews(@RequestBody DelSysNewsDto model, HttpServletRequest request) {
+ long id = model.getId();
+ SysNews sysNews = sysNewsMapper.selectById(id);
+ if(ObjectUtil.isEmpty(sysNews)){
+ return JsonResult.failMessage("当前记录不存在!");
+ }
+ sysNewsService.delSysNews(model);
+ OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
+ .methodName(Constants.SCORESHOP_MODUL_NAME).operateAction("广播通知--删除-" + id).build();
+ mqUtil.sendApp(build);
+ return JsonResult.success("操作成功!");
+ }
+
+ @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/sysNews/onOffSysNews.json")
+ @ApiOperation(value="广播通知--上下架", notes="test: 仅0有正确返回")
+ public JsonResult onOffSysNews(@RequestBody OnSysNewsDto model, HttpServletRequest request) {
+ long id = model.getId();
+ SysNews sysNews = sysNewsMapper.selectById(id);
+ if(ObjectUtil.isEmpty(sysNews)){
+ return JsonResult.failMessage("当前记录不存在!");
+ }
+ sysNewsService.onOffSysNews(model);
+ OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
+ .methodName(Constants.SCORESHOP_MODUL_NAME).operateAction("广播通知--删除-" + id).build();
+ mqUtil.sendApp(build);
+ return JsonResult.success("操作成功!");
+ }
+
+
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/AddSysNewsDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/AddSysNewsDto.java
new file mode 100644
index 0000000..0c12508
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/AddSysNewsDto.java
@@ -0,0 +1,30 @@
+package com.xzx.gc.system.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class AddSysNewsDto {
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "内容")
+ private String content;
+
+ @ApiModelProperty(value = "排序")
+ private Integer sort;
+
+ @ApiModelProperty(value = "状态:1:未发布 2:立即发布")
+ private Integer status;
+
+ @ApiModelProperty(value="创建人")
+ private String createUserId;
+
+ @ApiModelProperty(value="创建时间")
+ private Date createTime;
+
+
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysNewsDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysNewsDto.java
new file mode 100644
index 0000000..87da8d2
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysNewsDto.java
@@ -0,0 +1,10 @@
+package com.xzx.gc.system.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class DelSysNewsDto {
+ @ApiModelProperty(value = "Id")
+ private long id;
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysNewsDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysNewsDto.java
new file mode 100644
index 0000000..dc9fdd2
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysNewsDto.java
@@ -0,0 +1,15 @@
+package com.xzx.gc.system.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class OnSysNewsDto {
+
+ @ApiModelProperty(value = "Id")
+ private long id;
+
+ @ApiModelProperty(value = "状态 1:未发布 2:已发布")
+ private Integer status;
+
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/SysNewsListDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/SysNewsListDto.java
new file mode 100644
index 0000000..11a515a
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/SysNewsListDto.java
@@ -0,0 +1,15 @@
+package com.xzx.gc.system.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class SysNewsListDto {
+
+ @ApiModelProperty(value = "第几页", required = true)
+ private int page;
+
+ @ApiModelProperty(value = "每一页数量", required = true)
+ private int limit;
+
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/UpdateSysNewsDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/UpdateSysNewsDto.java
new file mode 100644
index 0000000..73f6723
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/UpdateSysNewsDto.java
@@ -0,0 +1,22 @@
+package com.xzx.gc.system.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class UpdateSysNewsDto {
+
+ @ApiModelProperty(value = "Id")
+ private long id;
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "内容")
+ private String content;
+
+ //排序
+ @ApiModelProperty(value = "排序")
+ private Integer sort;
+
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysNewsDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysNewsDto.java
new file mode 100644
index 0000000..bbbb7a2
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysNewsDto.java
@@ -0,0 +1,8 @@
+package com.xzx.gc.system.dto;
+
+import lombok.Data;
+
+@Data
+public class ViewSysNewsDto {
+ private Long id;
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/mapper/SysNewsMapper.java b/gc-sys/src/main/java/com/xzx/gc/system/mapper/SysNewsMapper.java
new file mode 100644
index 0000000..db8778f
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/mapper/SysNewsMapper.java
@@ -0,0 +1,24 @@
+package com.xzx.gc.system.mapper;
+
+import com.xzx.gc.entity.SysNews;
+import com.xzx.gc.system.dto.SysNewsListDto;
+import com.xzx.gc.system.vo.SysNewsListVo;
+import com.xzx.gc.util.GcMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface SysNewsMapper extends GcMapper<SysNews> {
+
+ List<SysNewsListVo> selectSysNewsListVo(SysNewsListDto sysNewsListDto);
+
+ SysNews selectById(@Param("id")Long id);
+
+ void updateById(@Param("newsId")long newsId);
+
+ void updateStatusById(@Param("newsId")long id, @Param("status")Integer status);
+
+ void updateSysNews(@Param("title")String title, @Param("content")String content,
+ @Param("sort")Integer sort, @Param("newsId")long id);
+
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/service/SysNewsService.java b/gc-sys/src/main/java/com/xzx/gc/system/service/SysNewsService.java
new file mode 100644
index 0000000..b61c0e9
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/service/SysNewsService.java
@@ -0,0 +1,77 @@
+package com.xzx.gc.system.service;
+
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.xzx.gc.entity.SysNews;
+import com.xzx.gc.system.dto.*;
+import com.xzx.gc.system.mapper.SysNewsMapper;
+import com.xzx.gc.system.vo.SysNewsListVo;
+import com.xzx.gc.system.vo.ViewSysNewsVo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+@Transactional
+public class SysNewsService {
+
+ @Resource
+ SysNewsMapper sysNewsMapper;
+
+ public Map<String, Object> sysNewsService(SysNewsListDto sysNewsListDto) {
+ PageHelper.startPage(sysNewsListDto.getPage(), sysNewsListDto.getLimit());
+ List<SysNewsListVo> sysNewsListVos = sysNewsMapper.selectSysNewsListVo(sysNewsListDto);
+ PageInfo<SysNewsListVo> pageInfo = new PageInfo<>(sysNewsListVos);
+
+ Map<String, Object> data = new HashMap<>();
+ int count = Convert.toInt(pageInfo.getTotal());
+ data.put("data", sysNewsListVos);
+ data.put("count", count);
+ data.put("code", 0);
+ return data;
+ }
+
+
+ public ViewSysNewsVo viewSysNews(Long id) {
+ SysNews sysNews = sysNewsMapper.selectById(id);
+ ViewSysNewsVo viewSysNewsVo = new ViewSysNewsVo();
+ viewSysNewsVo.setNewsId(id);
+ viewSysNewsVo.setTitle(sysNews.getTitle());
+ viewSysNewsVo.setContent(sysNews.getContent());
+ viewSysNewsVo.setSort(sysNews.getSort());
+ return viewSysNewsVo;
+ }
+
+ public void updateSysNews(UpdateSysNewsDto model) {
+ sysNewsMapper.updateSysNews(model.getTitle(),model.getContent(),model.getSort(),model.getId());
+ }
+
+ public void addSysNews(AddSysNewsDto model) {
+ SysNews sysNews = new SysNews();
+ sysNews.setCreateTime(DateUtil.format(model.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
+ sysNews.setCreateUserId(model.getCreateUserId());
+ sysNews.setStatus(model.getStatus());
+ sysNews.setSort(model.getSort());
+ sysNews.setDelFlag(0);
+ sysNews.setTitle(model.getTitle());
+ sysNews.setContent(model.getContent());
+ sysNewsMapper.insertSelective(sysNews);
+ }
+
+ public void delSysNews(DelSysNewsDto model) {
+ sysNewsMapper.updateById(model.getId());
+ }
+
+ public void onOffSysNews(OnSysNewsDto model) {
+ sysNewsMapper.updateStatusById(model.getId(),model.getStatus());
+ }
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/vo/SysNewsListVo.java b/gc-sys/src/main/java/com/xzx/gc/system/vo/SysNewsListVo.java
new file mode 100644
index 0000000..cf4afca
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/vo/SysNewsListVo.java
@@ -0,0 +1,39 @@
+package com.xzx.gc.system.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "SysNewsListVo", description = "返回参数类")
+public class SysNewsListVo {
+
+ @ApiModelProperty(value = "Id")
+ private long newsId;
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "内容")
+ private String content;
+
+ @ApiModelProperty(value = "创建时间")
+ private String createTime;
+
+ @ApiModelProperty(value = "创建人")
+ private String createUserId;
+
+ //删除0:未删除,1:删除
+ @ApiModelProperty(value = "删除0:未删除,1:删除")
+ private Integer delFlag;
+
+ //排序
+ @ApiModelProperty(value = "排序")
+ private Integer sort;
+
+ //状态 1:未发布 2:已发布
+ @ApiModelProperty(value = "状态 1:未发布 2:已发布")
+ private Integer status;
+
+
+}
diff --git a/gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysNewsVo.java b/gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysNewsVo.java
new file mode 100644
index 0000000..8f8f681
--- /dev/null
+++ b/gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysNewsVo.java
@@ -0,0 +1,24 @@
+package com.xzx.gc.system.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "ViewSysNewsVo", description = "返回参数类")
+public class ViewSysNewsVo {
+
+ @ApiModelProperty(value = "Id")
+ private long newsId;
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "内容")
+ private String content;
+
+ //排序
+ @ApiModelProperty(value = "排序")
+ private Integer sort;
+
+}
diff --git a/gc-sys/src/main/resources/mapper/system/SysNewsMapper.xml b/gc-sys/src/main/resources/mapper/system/SysNewsMapper.xml
new file mode 100644
index 0000000..1bb4a94
--- /dev/null
+++ b/gc-sys/src/main/resources/mapper/system/SysNewsMapper.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xzx.gc.system.mapper.SysNewsMapper">
+
+ <select id="selectSysNewsListVo" resultType="com.xzx.gc.system.vo.SysNewsListVo">
+ select * from xzx_sys_news
+ order by sort ASC
+ </select>
+
+ <select id="selectById" resultType="com.xzx.gc.entity.SysNews">
+ select * from xzx_sys_news where news_id = #{id}
+ order by sort ASC
+ </select>
+
+
+ <update id="updateById" parameterType="java.util.Map">
+ update xzx_sys_news
+ set del_flag=1
+ where news_id = #{newsId}
+ </update>
+
+
+ <update id="updateStatusById" parameterType="java.util.Map">
+ update xzx_sys_news
+ set status = #{status}
+ where news_id = #{newsId}
+ </update>
+
+ <update id="updateSysNews" parameterType="java.util.Map">
+ update xzx_sys_news
+ set title = #{title},
+ content = #{content},
+ sort = #{sort}
+ where news_id = #{newsId}
+ </update>
+
+
+</mapper>
\ No newline at end of file
--
Gitblit v1.9.1