From 4e0e2808594c48896aa76c61b171bc83ae8089cd Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Thu, 22 Jul 2021 14:17:03 +0800 Subject: [PATCH] 202107022 --- gc-sys/src/main/java/com/xzx/gc/system/dto/UpdateSysBannerDto.java | 24 +++ gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysBannerDto.java | 8 + gc-sys/src/main/java/com/xzx/gc/system/service/BannerService.java | 57 ++++++++ gc-sys/src/main/resources/mapper/system/BannerMapper.xml | 31 ++++ gc-shop/src/main/resources/sql | 5 gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysBannerDto.java | 10 + gc-core/src/main/java/com/xzx/gc/entity/BannerInfo.java | 4 gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysBannerDto.java | 14 ++ gc-sys/src/main/java/com/xzx/gc/system/controller/AdminSysNewsController.java | 2 gc-sys/src/main/java/com/xzx/gc/system/dto/SysBannerListDto.java | 14 ++ gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysBannerVo.java | 35 +++++ gc-sys/src/main/java/com/xzx/gc/system/dto/AddSysBannerDto.java | 26 +++ gc-sys/src/main/java/com/xzx/gc/system/mapper/BannerMapper.java | 14 ++ gc-sys/src/main/java/com/xzx/gc/system/vo/SysBannerListVo.java | 37 +++++ gc-sys/src/main/java/com/xzx/gc/system/controller/AdminBannerController.java | 118 ++++++++++++++++ 15 files changed, 396 insertions(+), 3 deletions(-) diff --git a/gc-core/src/main/java/com/xzx/gc/entity/BannerInfo.java b/gc-core/src/main/java/com/xzx/gc/entity/BannerInfo.java index b3aedb9..526992e 100644 --- a/gc-core/src/main/java/com/xzx/gc/entity/BannerInfo.java +++ b/gc-core/src/main/java/com/xzx/gc/entity/BannerInfo.java @@ -8,7 +8,7 @@ @Data @Table(name="xzx_sys_banner") -public class BannerInfo { +public class BannerInfo extends SysNews { @Id private Long id; @ApiModelProperty("图片名称") @@ -26,6 +26,8 @@ private String partnerId; private Integer cityId; + //状态 1:未上架 2:已上架 + private Integer status; } diff --git a/gc-shop/src/main/resources/sql b/gc-shop/src/main/resources/sql index c6a337a..950c277 100644 --- a/gc-shop/src/main/resources/sql +++ b/gc-shop/src/main/resources/sql @@ -73,6 +73,11 @@ ALTER TABLE `xzx_sys_news` ADD COLUMN `status` int(1) NULL DEFAULT 1 COMMENT '状态 1:未发布 2:已发布' AFTER `sort`; +ALTER TABLE `xzx_sys_banner` +ADD COLUMN `status` int(1) NULL DEFAULT 1 COMMENT '状态 1:未上架 2:已上架' AFTER `city_id`; + + + diff --git a/gc-sys/src/main/java/com/xzx/gc/system/controller/AdminBannerController.java b/gc-sys/src/main/java/com/xzx/gc/system/controller/AdminBannerController.java new file mode 100644 index 0000000..56f8ad3 --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/controller/AdminBannerController.java @@ -0,0 +1,118 @@ +package com.xzx.gc.system.controller; + +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.BannerInfo; +import com.xzx.gc.model.JsonResult; +import com.xzx.gc.system.dto.*; +import com.xzx.gc.system.mapper.BannerMapper; +import com.xzx.gc.system.service.BannerService; +import com.xzx.gc.system.vo.SysBannerListVo; +import com.xzx.gc.system.vo.ViewSysBannerVo; +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 AdminBannerController extends BaseController { + + @Autowired + private BannerService bannerService; + + @Resource + BannerMapper bannerMapper; + + @ApiOperation(value = "轮播图--列表") + @ApiResponses( + @ApiResponse(code = 200, message = "success", response = SysBannerListVo.class) + ) + @PostMapping(value = Constants.ADMIN_VIEW_PREFIX + "/sysBanner/sysBannerList.json") + public JsonResult<Map<String, Object>> sysBannerList(@RequestBody SysBannerListDto sysBannerListDto) { + return JsonResult.success(bannerService.sysBannerList(sysBannerListDto)); + } + + @PostMapping(Constants.ADMIN_VIEW_PREFIX+"/sysBanner/addSysBanner.json") + @ApiOperation(value = "轮播图--添加", notes = "test: 仅0有正确返回") + public JsonResult<String> addSysBanner(@RequestBody AddSysBannerDto model, HttpServletRequest request) { + + model.setCreateTime(new Date()); + bannerService.addSysBanner(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 + "/sysBanner/viewSysBanner.json") + @ApiResponses({@ApiResponse( code = 200, message = "success", response = ViewSysBannerVo.class)}) + @ApiOperation(value="轮播图--查看详情", notes="test: 仅0有正确返回") + public JsonResult<ViewSysBannerVo> viewSysBanner(@RequestBody ViewSysBannerDto viewSysNewsDto) { + Long id = viewSysNewsDto.getId(); + ViewSysBannerVo viewSysBannerVo = bannerService.viewSysBanner(id); + return JsonResult.success(viewSysBannerVo); + } + + @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/sysBanner/updateSysBanner.json") + @ApiOperation(value="轮播图--更新详情", notes="test: 仅0有正确返回") + public JsonResult updateSysBanner(@RequestBody UpdateSysBannerDto model, HttpServletRequest request) { + long id = model.getId(); + BannerInfo bannerInfo = bannerMapper.selectBannerById(id); + if(ObjectUtil.isEmpty(bannerInfo)){ + return JsonResult.failMessage("当前记录不存在!"); + } + bannerService.updateSysBanner(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 + "/sysBanner/delSysBanner.json") + @ApiOperation(value="轮播图--删除", notes="test: 仅0有正确返回") + public JsonResult delSysBanner(@RequestBody DelSysBannerDto model, HttpServletRequest request) { + long id = model.getId(); + BannerInfo bannerInfo = bannerMapper.selectBannerById(id); + if(ObjectUtil.isEmpty(bannerInfo)){ + return JsonResult.failMessage("当前记录不存在!"); + } + bannerService.delSysBanner(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 + "/sysBanner/onOffSysBanner.json") + @ApiOperation(value="轮播图--上下架", notes="test: 仅0有正确返回") + public JsonResult onOffSysBanner(@RequestBody OnSysBannerDto model, HttpServletRequest request) { + long id = model.getId(); + BannerInfo bannerInfo = bannerMapper.selectBannerById(id); + if(ObjectUtil.isEmpty(bannerInfo)){ + return JsonResult.failMessage("当前记录不存在!"); + } + bannerService.onOffSysBanner(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/controller/AdminSysNewsController.java b/gc-sys/src/main/java/com/xzx/gc/system/controller/AdminSysNewsController.java index 2bdceef..e536c76 100644 --- 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 @@ -111,7 +111,7 @@ } sysNewsService.onOffSysNews(model); OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) - .methodName(Constants.SCORESHOP_MODUL_NAME).operateAction("广播通知--删除-" + id).build(); + .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/AddSysBannerDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/AddSysBannerDto.java new file mode 100644 index 0000000..e4063dd --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/AddSysBannerDto.java @@ -0,0 +1,26 @@ +package com.xzx.gc.system.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class AddSysBannerDto { + + @ApiModelProperty("图片名称") + private String picName; + + @ApiModelProperty("图片链接") + private String picUrl; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty(value="创建时间") + private Date createTime; + + @ApiModelProperty("状态 1:未上架 2:已上架") + private Integer status; + +} diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysBannerDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysBannerDto.java new file mode 100644 index 0000000..a3b5fb5 --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/DelSysBannerDto.java @@ -0,0 +1,10 @@ +package com.xzx.gc.system.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class DelSysBannerDto { + @ApiModelProperty(value = "Id") + private long id; +} diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysBannerDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysBannerDto.java new file mode 100644 index 0000000..9cb840c --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/OnSysBannerDto.java @@ -0,0 +1,14 @@ +package com.xzx.gc.system.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class OnSysBannerDto { + + @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/SysBannerListDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/SysBannerListDto.java new file mode 100644 index 0000000..5a187b1 --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/SysBannerListDto.java @@ -0,0 +1,14 @@ +package com.xzx.gc.system.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class SysBannerListDto { + + @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/UpdateSysBannerDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/UpdateSysBannerDto.java new file mode 100644 index 0000000..a49a8fa --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/UpdateSysBannerDto.java @@ -0,0 +1,24 @@ +package com.xzx.gc.system.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class UpdateSysBannerDto { + + @ApiModelProperty("id") + private Long id; + + @ApiModelProperty("图片名称") + private String picName; + +// @ApiModelProperty("图片路径") +// private String picPath; + + @ApiModelProperty("图片链接") + private String picUrl; + + @ApiModelProperty("排序") + private Integer sort; + +} diff --git a/gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysBannerDto.java b/gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysBannerDto.java new file mode 100644 index 0000000..de3dd67 --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/dto/ViewSysBannerDto.java @@ -0,0 +1,8 @@ +package com.xzx.gc.system.dto; + +import lombok.Data; + +@Data +public class ViewSysBannerDto { + private Long id; +} diff --git a/gc-sys/src/main/java/com/xzx/gc/system/mapper/BannerMapper.java b/gc-sys/src/main/java/com/xzx/gc/system/mapper/BannerMapper.java index 775cbe0..72040ac 100644 --- a/gc-sys/src/main/java/com/xzx/gc/system/mapper/BannerMapper.java +++ b/gc-sys/src/main/java/com/xzx/gc/system/mapper/BannerMapper.java @@ -3,7 +3,11 @@ import com.xzx.gc.entity.BannerInfo; import com.xzx.gc.model.admin.BannerModel; import com.xzx.gc.model.system.ConfigInfoVo; +import com.xzx.gc.system.dto.SysBannerListDto; +import com.xzx.gc.system.vo.SysBannerListVo; +import com.xzx.gc.system.vo.ViewSysBannerVo; import com.xzx.gc.util.GcMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -42,5 +46,15 @@ */ int delBanner(String id); + List<SysBannerListVo> selectSysBanner(SysBannerListDto sysBannerListDto); + + BannerInfo selectBannerById(@Param("id")Long id); + + void updateBannerById(@Param("sort")Integer sort, @Param("picUrl")String picUrl, + @Param("picName")String picName, @Param("id")Long id); + + void delSysBannerById(@Param("id")long id); + + void updateStatusById(@Param("id")long id, @Param("status")Integer status); } diff --git a/gc-sys/src/main/java/com/xzx/gc/system/service/BannerService.java b/gc-sys/src/main/java/com/xzx/gc/system/service/BannerService.java index 98c9b53..4ada7e8 100644 --- a/gc-sys/src/main/java/com/xzx/gc/system/service/BannerService.java +++ b/gc-sys/src/main/java/com/xzx/gc/system/service/BannerService.java @@ -1,16 +1,23 @@ 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.BannerInfo; import com.xzx.gc.entity.CityPartner; import com.xzx.gc.entity.CoreUser; import com.xzx.gc.model.JsonResult; import com.xzx.gc.model.admin.BannerModel; +import com.xzx.gc.system.dto.*; import com.xzx.gc.system.mapper.BannerMapper; +import com.xzx.gc.system.vo.SysBannerListVo; +import com.xzx.gc.system.vo.SysNewsListVo; +import com.xzx.gc.system.vo.ViewSysBannerVo; import com.xzx.gc.util.SessionUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.Banner; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -96,5 +103,53 @@ public int delBannerApi(String id) { return bannerMapper.delBanner(id); } - + + public Map<String, Object> sysBannerList(SysBannerListDto sysBannerListDto) { + PageHelper.startPage(sysBannerListDto.getPage(), sysBannerListDto.getLimit()); + List<SysBannerListVo> sysBannerListVos = bannerMapper.selectSysBanner(sysBannerListDto); + PageInfo<SysBannerListVo> pageInfo = new PageInfo<>(sysBannerListVos); + + Map<String, Object> data = new HashMap<>(); + int count = Convert.toInt(pageInfo.getTotal()); + data.put("data", sysBannerListVos); + data.put("count", count); + data.put("code", 0); + return data; + } + + public void addSysBanner(AddSysBannerDto model) { + BannerInfo bannerInfo = new BannerInfo(); + bannerInfo.setCreateTime(DateUtil.format(model.getCreateTime(),"yyyy-MM-dd HH:mm:ss")); + bannerInfo.setStatus(model.getStatus()); + bannerInfo.setDelFlag(0); + bannerInfo.setPicName(model.getPicName()); + bannerInfo.setPicUrl(model.getPicUrl()); + bannerInfo.setSort(model.getSort()); + bannerMapper.insertSelective(bannerInfo); + } + + public ViewSysBannerVo viewSysBanner(Long id) { + BannerInfo bannerInfo = bannerMapper.selectBannerById(id); + ViewSysBannerVo viewSysBannerVo = new ViewSysBannerVo(); + viewSysBannerVo.setSort(bannerInfo.getSort()); + viewSysBannerVo.setStatus(bannerInfo.getStatus()); + viewSysBannerVo.setCreateTime(bannerInfo.getCreateTime()); + viewSysBannerVo.setId(bannerInfo.getId()); + viewSysBannerVo.setPicName(bannerInfo.getPicName()); + viewSysBannerVo.setPicUrl(bannerInfo.getPicUrl()); + return viewSysBannerVo; + } + + public void updateSysBanner(UpdateSysBannerDto model) { + + bannerMapper.updateBannerById(model.getSort(),model.getPicUrl(),model.getPicName(),model.getId()); + } + + public void delSysBanner(DelSysBannerDto model) { + bannerMapper.delSysBannerById(model.getId()); + } + + public void onOffSysBanner(OnSysBannerDto model) { + bannerMapper.updateStatusById(model.getId(),model.getStatus()); + } } diff --git a/gc-sys/src/main/java/com/xzx/gc/system/vo/SysBannerListVo.java b/gc-sys/src/main/java/com/xzx/gc/system/vo/SysBannerListVo.java new file mode 100644 index 0000000..f15e058 --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/vo/SysBannerListVo.java @@ -0,0 +1,37 @@ +package com.xzx.gc.system.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.persistence.Id; + +@Data +@ApiModel(value = "SysBannerListVo", description = "返回参数类") +public class SysBannerListVo { + + @ApiModelProperty("id") + private Long id; + + @ApiModelProperty("图片名称") + private String picName; + +// @ApiModelProperty("图片路径") +// private String picPath; + + @ApiModelProperty("图片链接") + private String picUrl; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("删除0:未删除,1:删除") + private Integer delFlag; + + @ApiModelProperty("创建时间") + private String createTime; + + @ApiModelProperty("状态 1:未上架 2:已上架") + private Integer status; + +} diff --git a/gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysBannerVo.java b/gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysBannerVo.java new file mode 100644 index 0000000..6322828 --- /dev/null +++ b/gc-sys/src/main/java/com/xzx/gc/system/vo/ViewSysBannerVo.java @@ -0,0 +1,35 @@ +package com.xzx.gc.system.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "ViewSysBannerVo", description = "返回参数类") +public class ViewSysBannerVo { + + @ApiModelProperty("id") + private Long id; + + @ApiModelProperty("图片名称") + private String picName; + +// @ApiModelProperty("图片路径") +// private String picPath; + + @ApiModelProperty("图片链接") + private String picUrl; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("删除0:未删除,1:删除") + private Integer delFlag; + + @ApiModelProperty("创建时间") + private String createTime; + + @ApiModelProperty("状态 1:未上架 2:已上架") + private Integer status; + +} diff --git a/gc-sys/src/main/resources/mapper/system/BannerMapper.xml b/gc-sys/src/main/resources/mapper/system/BannerMapper.xml index 3a08b1d..339e9c6 100644 --- a/gc-sys/src/main/resources/mapper/system/BannerMapper.xml +++ b/gc-sys/src/main/resources/mapper/system/BannerMapper.xml @@ -89,4 +89,35 @@ SET del_flag = 1 WHERE id = #{id} </delete> + + <select id="selectSysBanner" resultType="com.xzx.gc.system.vo.SysBannerListVo"> + select * from xzx_sys_banner + order by sort ASC + </select> + + <select id="selectBannerById" resultType="com.xzx.gc.entity.BannerInfo"> + select * from xzx_sys_banner where id = #{id} + order by sort ASC + </select> + + <update id="updateBannerById" parameterType="java.util.Map"> + update xzx_sys_banner + set sort = #{sort}, + pic_name = #{picName}, + pic_url = #{picUrl} + where id = #{id} + </update> + + <update id="delSysBannerById" parameterType="java.util.Map"> + update xzx_sys_banner + set del_flag = 1 + where id = #{id} + </update> + + + <update id="updateStatusById" parameterType="java.util.Map"> + update xzx_sys_banner + set status = #{status} + where id = #{id} + </update> </mapper> \ No newline at end of file -- Gitblit v1.9.1