提交 3edf22ac 作者: 张小凤

module(add)

上级 c9e9a46b
package com.mmc.csf.infomation.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author small
* @Date 2023/5/23 14:25
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BannerInfoDTO implements Serializable {
private static final long serialVersionUID = -7448333029172826676L;
@ApiModelProperty(value = "banner的id")
private Integer id;
@ApiModelProperty(value = "模块id")
private Integer moduleId;
@ApiModelProperty(value = "banner名称")
private String bannerName;
@ApiModelProperty(value = "banner图片url")
private String bannerImg;
@ApiModelProperty(value = "banner海报url")
private String bannerPoster;
@ApiModelProperty(value = "banner类型")
private Integer bannerType;
@ApiModelProperty(value = "商品id")
private Integer goodsId;
@ApiModelProperty(value = "点击后的页面地址")
private String bannerUrl;
@ApiModelProperty(value = "描述信息")
private String detailInfo;
@ApiModelProperty(value = "顺序")
private Integer sort;
@ApiModelProperty(value = "富文本内容")
private String textContent;
@ApiModelProperty(value = "有效开始时间")
private Date startTime;
@ApiModelProperty(value = "有效结束时间")
private Date endTime;
@ApiModelProperty(value = "是否上架")
private Integer using;
@ApiModelProperty(value = "是否删除")
private Integer deleted;
@ApiModelProperty(value = "生成时间")
private Date createTime;
}
package com.mmc.csf.infomation.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author small
* @Date 2023/5/23 14:18
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.dto.ModuleInfoDTO", description = "宣传中心模块DTO")
public class ModuleInfoDTO implements Serializable {
private static final long serialVersionUID = 391158698553442158L;
@ApiModelProperty(value = "模块id")
private Integer id;
@ApiModelProperty(value = "模块名称")
private String moduleName;
@ApiModelProperty(value = "所属产品")
private Integer moduleType;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "是否删除")
private Integer deleted;
@ApiModelProperty(value = "code")
private String moduleCode;
@ApiModelProperty(value = "生成时间")
private Date createTime;
}
package com.mmc.csf.infomation.qo;
import com.mmc.csf.release.model.group.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @Author small
* @Date 2023/5/23 14:22
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.qo.BannerInfoQO", description = "banner查询QO")
public class BannerInfoQO implements Serializable {
private static final long serialVersionUID = 7376276027677051853L;
@ApiModelProperty(value = "关键字")
private String keyword;
@ApiModelProperty(value = "所属产品")
private Integer moduleType;
@ApiModelProperty(value = "宣传模块id")
private Integer moduleId;
@ApiModelProperty(value = "页码", required = true)
@NotNull(message = "页码不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true)
@NotNull(message = "每页显示数不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.csf.infomation.qo;
import com.mmc.csf.release.model.group.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @Author small
* @Date 2023/5/23 14:21
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.qo.ModuleInfoQO", description = "宣传中心模块查询QO")
public class ModuleInfoQO implements Serializable {
private static final long serialVersionUID = -681758664049977685L;
@ApiModelProperty(value = "关键字")
private String keyword;
@ApiModelProperty(value = "所属产品")
private Integer moduleType;
@ApiModelProperty(value = "关键字")
private String moduleCode;
@ApiModelProperty(value = "port:0云享飞,1无人机城")
private Integer port;
@ApiModelProperty(value = "页码", required = true)
@NotNull(message = "页码不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true)
@NotNull(message = "每页显示数不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.csf.infomation.vo;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Others;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
/**
* @Author small
* @Date 2023/5/23 14:23
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.vo.BannerInfoVO", description = "banner新增修改VO")
public class BannerInfoVO implements Serializable {
private static final long serialVersionUID = -8278140378110070217L;
@ApiModelProperty(value = "banner的id")
@NotNull(message = "id不能为空", groups = { Update.class, Others.class})
private Integer id;
@ApiModelProperty(value = "模块id")
@NotNull(message = "模块id不能为空", groups = {Create.class, Update.class})
private Integer moduleId;
@ApiModelProperty(value = "banner名称")
@Size(max = 70, message = "名称不能超过70个字符", groups = { Create.class, Update.class })
private String bannerName;
@ApiModelProperty(value = "banner类型")
private Integer bannerType;
@ApiModelProperty(value = "商品id")
private Integer goodsId;
@ApiModelProperty(value = "点击后的页面地址")
private String bannerUrl;
@ApiModelProperty(value = "banner图片url")
//@NotEmpty(message = "请先上传内容图片", groups = { Create.class})
private String bannerImg;
@ApiModelProperty(value = "banner海报url")
private String bannerPoster;
@ApiModelProperty(value = "顺序")
@NotNull(message = "sort不能为空", groups = { Others.class})
private Integer sort;
@ApiModelProperty(value = "有效开始时间")
private Date startTime;
@ApiModelProperty(value = "有效结束时间")
private Date endTime;
@ApiModelProperty(value = "是否使用")
private Integer using;
@ApiModelProperty(value = "描述信息")
private String detailInfo;
@ApiModelProperty(value = "富文本内容")
private String textContent;
}
package com.mmc.csf.release.flyer.vo;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* @Author small
* @Date 2023/5/23 14:14
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.vo.ModuleInfoVO", description = "宣传中心模块VO")
public class ModuleInfoVO implements Serializable {
private static final long serialVersionUID = 8806759177487648665L;
@ApiModelProperty(value = "模块id")
@NotNull(message = "id不能为空", groups = { Update.class})
private Integer id;
@ApiModelProperty(value = "模块名称")
@Size(max = 70, message = "模块名称不能超过70个字符", groups = { Create.class, Update.class })
private String moduleName;
@ApiModelProperty(value = "所属产品")
private Integer moduleType;
@ApiModelProperty(value = "code")
@NotEmpty(message = "moduleCode不能为空", groups = { Create.class, Update.class })
@Size(max = 15, message = "moduleCode不能超过15个字符", groups = { Create.class, Update.class })
private String moduleCode;
@ApiModelProperty(value = "备注")
private String remark;
}
...@@ -11,16 +11,16 @@ import lombok.Builder; ...@@ -11,16 +11,16 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* @author 作者 geDuo * @author 作者 geDuo
* @version 创建时间:2021年8月13日 上午9:31:43 * @version 创建时间:2021年8月13日 上午9:31:43
* @explain 类说明 * @explain 类说明
*/ */
@Builder @Builder
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value = "com.mmc.result.ResultBody", description = "请求响应体") //@ApiModel(value = "com.mmc.result.ResultBody", description = "请求响应体")
public class ResultBody<T> implements Serializable{ public class ResultBody<T> implements Serializable{
private static final long serialVersionUID = 6341937455634693363L; private static final long serialVersionUID = 6341937455634693363L;
......
package com.mmc.csf.release.controller;
import com.mmc.csf.common.util.group.Create;
import com.mmc.csf.common.util.group.Others;
import com.mmc.csf.common.util.group.Page;
import com.mmc.csf.common.util.group.Update;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.infomation.dto.BannerInfoDTO;
import com.mmc.csf.infomation.dto.ModuleInfoDTO;
import com.mmc.csf.infomation.qo.BannerInfoQO;
import com.mmc.csf.infomation.qo.ModuleInfoQO;
import com.mmc.csf.infomation.vo.BannerInfoVO;
import com.mmc.csf.release.flyer.vo.ModuleInfoVO;
import com.mmc.csf.release.service.ModuleInfoService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author small
* @Date 2023/5/23 14:11
* @Version 1.0
*/
@Api(tags = { "宣传中心-接口" })
@RestController
@RequestMapping("/module/")
public class ModuleInfoController {
@Autowired
private ModuleInfoService moduleInfoService;
@ApiOperation(value = "宣传模块-新增")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("insertModuleInfo")
public ResultBody insertModuleInfo(@Validated(Create.class) @RequestBody ModuleInfoVO moduleInfoVO) {
return moduleInfoService.insertModuleInfo(moduleInfoVO);
}
@ApiOperation(value = "宣传模块-修改")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("updateModuleInfo")
public ResultBody updateModuleInfo(@Validated(Update.class) @RequestBody ModuleInfoVO moduleInfoVO) {
return moduleInfoService.updateModuleInfo(moduleInfoVO);
}
@ApiOperation(value = "删除宣传模块")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("removeModuleInfo")
public ResultBody removeModuleInfo(@ApiParam(value = "id", required = true) @RequestParam Integer id) {
return moduleInfoService.removeModuleInfo(id);
}
@ApiOperation(value = "修改宣传备注")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("updateModuleInfoRemark")
public ResultBody updateModuleInfoRemark(@ApiParam(value = "id", required = true) @RequestParam Integer id,
@ApiParam(value = "备注") @RequestParam String remark) {
return moduleInfoService.updateModuleInfoRemark(id, remark);
}
@ApiOperation(value = "宣传模块管理-分页")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ModuleInfoDTO.class) })
@PostMapping("listModuleInfoPage")
public ResultBody<ModuleInfoDTO> listModuleInfoPage(
@ApiParam(value = "宣传模块查询QO", required = true) @Validated(Page.class) @RequestBody ModuleInfoQO param) {
return moduleInfoService.listModuleInfoPage(param);
}
@ApiOperation(value = "banner管理-分页")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = BannerInfoDTO.class) })
@PostMapping("listBannerInfoPage")
public ResultBody<BannerInfoDTO> listBannerInfoPage(
@ApiParam(value = "banner查询QO", required = true) @Validated(Page.class) @RequestBody BannerInfoQO param) {
return moduleInfoService.listBannerInfoPage(param);
}
@ApiOperation(value = "删除banner")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("removeBannerInfo")
public ResultBody removeBannerInfo(@ApiParam(value = "id", required = true) @RequestParam Integer id) {
return moduleInfoService.removeBannerInfo(id);
}
@ApiOperation(value = "banner-新增")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("insertBannerInfo")
public ResultBody insertBannerInfo(@Validated(Create.class) @RequestBody BannerInfoVO bannerInfoVO) {
return moduleInfoService.insertBannerInfo(bannerInfoVO);
}
@ApiOperation(value = "banner-修改")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("updateBannerInfo")
public ResultBody updateBannerInfo(@Validated(Update.class) @RequestBody BannerInfoVO bannerInfoVO) {
return moduleInfoService.updateBannerInfo(bannerInfoVO);
}
@ApiOperation(value = "banner-排序交换")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("exchangeBannerInfo")
public ResultBody exchangeBannerInfo(@Validated(Others.class) @RequestBody List<BannerInfoVO> list) {
return moduleInfoService.exchangeBannerInfo(list);
}
@ApiOperation(value = "获取图片-小程序")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = BannerInfoDTO.class) })
@GetMapping("listBannerImg")
public ResultBody listBannerImg(@ApiParam(value = "moduleCode", required = true) @RequestParam String moduleCode) {
return moduleInfoService.listBannerImg(moduleCode);
}
@ApiOperation(value = "banner批量删除")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("batchRemoveBannerInfo")
public ResultBody batchRemoveBannerInfo(
@ApiParam(value = "id数组", required = true,example = "[180,181]") @RequestBody List<Integer> list) {
return moduleInfoService.batchRemoveBannerInfo(list);
}
}
package com.mmc.csf.release.dao;
import com.mmc.csf.infomation.qo.BannerInfoQO;
import com.mmc.csf.infomation.qo.ModuleInfoQO;
import com.mmc.csf.release.entity.BannerInfoDO;
import com.mmc.csf.release.entity.ModuleInfoDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author small
* @Date 2023/5/23 14:24
* @Version 1.0
*/
@Mapper
public interface ModuleInfoDao {
void insertModuleInfo(ModuleInfoDO moduleInfoDO);
void updateModuleInfo(ModuleInfoDO moduleInfoDO);
void removeModuleInfo(Integer id);
void updateModuleInfoRemark(Integer id, String remark);
int countListModuleInfoPage(ModuleInfoQO param);
List<ModuleInfoDO> listModuleInfoPage(ModuleInfoQO param);
int countListBannerInfoPage(BannerInfoQO param);
List<BannerInfoDO> listBannerInfoPage(BannerInfoQO param);
void removeBannerInfo(Integer id);
int getCountBannerInfoOfModule(Integer moduleId);
void insertBannerInfo(BannerInfoDO bannerInfoDO);
void updateBannerInfo(BannerInfoDO bannerInfoDO);
int getCountSameNameOfModuleInfo(Integer moduleType, String moduleName);
int getCountSameNameOfBannerInfo(Integer moduleId, String bannerName);
int getCountSameNameNotItSelfOfModule(Integer id, Integer moduleType, String moduleName);
int getCountSameNameNotItSelfOfBanner(Integer id, Integer moduleId, String bannerName);
List<BannerInfoDO> listBannerImg(String moduleCode);
void removeBanners(Integer id);
int getCountSameCode(String moduleCode);
int getCountSameCodeOfItSelf(Integer id, String moduleCode);
void batchRemoveBannerInfo(List<Integer> list);
}
package com.mmc.csf.release.entity;
import com.mmc.csf.infomation.dto.BannerInfoDTO;
import com.mmc.csf.infomation.vo.BannerInfoVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author small
* @Date 2023/5/23 14:28
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BannerInfoDO implements Serializable {
private static final long serialVersionUID = 1041918314535866878L;
private Integer id;
private Integer moduleId;
private String bannerName;
private String bannerImg;
private Integer bannerType;
private Integer goodsId;
private String bannerPoster;
private String bannerUrl;
private String detailInfo;
private Integer sort;
private String textContent;
private Date startTime;
private Date endTime;
private Integer using;
private Integer deleted;
private Date createTime;
private Date updateTime;
public BannerInfoDTO buildBannerInfoDTO(){
Date now = new Date();
return BannerInfoDTO.builder().id(this.id).moduleId(this.moduleId).bannerName(this.bannerName).bannerImg(this.bannerImg)
.bannerPoster(this.bannerPoster).sort(this.sort).using(this.endTime != null ? ( now.before(this.endTime) ? (this.using == 1 ? 1 : 0) : 0 ) : (this.using == 1 ? 1 : 0))
.deleted(this.deleted).createTime(this.createTime).bannerType(this.bannerType).goodsId(this.goodsId).bannerUrl(this.bannerUrl).textContent(this.textContent)
.detailInfo(this.detailInfo).startTime(this.startTime).endTime(this.endTime).build();
}
public BannerInfoDO(BannerInfoVO bannerInfoVO){
this.id = bannerInfoVO.getId();
this.moduleId = bannerInfoVO.getModuleId();
this.bannerName = bannerInfoVO.getBannerName();
this.bannerImg = bannerInfoVO.getBannerImg();
this.bannerType = bannerInfoVO.getBannerType();
this.bannerPoster = bannerInfoVO.getBannerPoster();
this.bannerUrl = bannerInfoVO.getBannerUrl();
this.sort = bannerInfoVO.getSort();
this.using = bannerInfoVO.getUsing();
this.goodsId = bannerInfoVO.getGoodsId();
this.detailInfo = bannerInfoVO.getDetailInfo();
this.startTime = bannerInfoVO.getStartTime();
this.endTime = bannerInfoVO.getEndTime();
this.textContent = bannerInfoVO.getTextContent();
}
}
package com.mmc.csf.release.entity;
import com.mmc.csf.infomation.dto.ModuleInfoDTO;
import com.mmc.csf.release.flyer.vo.ModuleInfoVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author small
* @Date 2023/5/23 14:15
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModuleInfoDO implements Serializable {
private static final long serialVersionUID = 6637973426087317593L;
private Integer id;
private String moduleName;
private Integer moduleType;
private String moduleCode;
private String remark;
private Integer deleted;
private Date createTime;
private Date updateTime;
public ModuleInfoDTO buildModuleInfoDTO(){
return ModuleInfoDTO.builder().id(this.id).moduleName(this.moduleName).moduleType(this.moduleType).remark(this.remark)
.moduleCode(this.moduleCode).deleted(this.deleted).createTime(this.createTime).build();
}
public ModuleInfoDO(ModuleInfoVO moduleInfoVO){
this.id = moduleInfoVO.getId();
this.moduleCode = moduleInfoVO.getModuleCode();
this.moduleName = moduleInfoVO.getModuleName();
this.moduleType = moduleInfoVO.getModuleType();
this.remark = moduleInfoVO.getRemark();
}
}
package com.mmc.csf.release.service;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.infomation.qo.BannerInfoQO;
import com.mmc.csf.infomation.qo.ModuleInfoQO;
import com.mmc.csf.infomation.vo.BannerInfoVO;
import com.mmc.csf.release.flyer.vo.ModuleInfoVO;
import java.util.List;
/**
* @Author small
* @Date 2023/5/23 14:11
* @Version 1.0
*/
public interface ModuleInfoService {
ResultBody insertModuleInfo(ModuleInfoVO moduleInfoVO);
ResultBody updateModuleInfo(ModuleInfoVO moduleInfoVO);
ResultBody removeModuleInfo(Integer id);
ResultBody updateModuleInfoRemark(Integer id, String remark);
ResultBody listModuleInfoPage(ModuleInfoQO param);
ResultBody listBannerInfoPage(BannerInfoQO param);
ResultBody removeBannerInfo(Integer id);
ResultBody insertBannerInfo(BannerInfoVO bannerInfoVO);
ResultBody updateBannerInfo(BannerInfoVO bannerInfoVO);
ResultBody exchangeBannerInfo(List<BannerInfoVO> list);
ResultBody listBannerImg(String moduleCode);
ResultBody batchRemoveBannerInfo(List<Integer> list);
}
package com.mmc.csf.release.service.impl;
import com.mmc.csf.common.util.page.PageResult;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.common.util.web.ResultEnum;
import com.mmc.csf.infomation.dto.BannerInfoDTO;
import com.mmc.csf.infomation.dto.ModuleInfoDTO;
import com.mmc.csf.infomation.qo.BannerInfoQO;
import com.mmc.csf.infomation.qo.ModuleInfoQO;
import com.mmc.csf.infomation.vo.BannerInfoVO;
import com.mmc.csf.release.dao.ModuleInfoDao;
import com.mmc.csf.release.entity.BannerInfoDO;
import com.mmc.csf.release.entity.ModuleInfoDO;
import com.mmc.csf.release.flyer.vo.ModuleInfoVO;
import com.mmc.csf.release.service.ModuleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author small
* @Date 2023/5/23 14:12
* @Version 1.0
*/
@Service
public class ModuleInfoServiceImpl implements ModuleInfoService {
@Autowired
private ModuleInfoDao moduleInfoDao;
@Override
public ResultBody insertModuleInfo(ModuleInfoVO moduleInfoVO) {
int count = moduleInfoDao.getCountSameNameOfModuleInfo(moduleInfoVO.getModuleType(), moduleInfoVO.getModuleName());
if(count > 0){
return ResultBody.error(ResultEnum.EXIST_SAME_NAME_OF_MODULE_ERROR);
}
if(moduleInfoDao.getCountSameCode(moduleInfoVO.getModuleCode()) > 0){
return ResultBody.error(ResultEnum.EXIST_SAME_CODE_OF_MODULE_ERROR);
}
ModuleInfoDO moduleInfoDO = new ModuleInfoDO(moduleInfoVO);
moduleInfoDao.insertModuleInfo(moduleInfoDO);
return ResultBody.success();
}
@Override
public ResultBody updateModuleInfo(ModuleInfoVO moduleInfoVO) {
int count = moduleInfoDao.getCountSameNameNotItSelfOfModule(moduleInfoVO.getId(), moduleInfoVO.getModuleType(), moduleInfoVO.getModuleName());
if(count > 0){
return ResultBody.error(ResultEnum.EXIST_SAME_NAME_OF_MODULE_ERROR);
}
if(moduleInfoDao.getCountSameCodeOfItSelf(moduleInfoVO.getId() ,moduleInfoVO.getModuleCode()) > 0){
return ResultBody.error(ResultEnum.EXIST_SAME_CODE_OF_MODULE_ERROR);
}
//判断之前有没有修改过moduleType
ModuleInfoDO moduleInfoDO = new ModuleInfoDO(moduleInfoVO);
moduleInfoDao.updateModuleInfo(moduleInfoDO);
return ResultBody.success();
}
@Override
public ResultBody removeModuleInfo(Integer id) {
moduleInfoDao.removeModuleInfo(id);
moduleInfoDao.removeBanners(id);
return ResultBody.success();
}
@Override
public ResultBody updateModuleInfoRemark(Integer id, String remark) {
moduleInfoDao.updateModuleInfoRemark(id, remark);
return ResultBody.success();
}
@Override
public ResultBody listModuleInfoPage(ModuleInfoQO param) {
int count = moduleInfoDao.countListModuleInfoPage(param);
if (count == 0) {
return ResultBody.success(PageResult.buildPage(param.getPageNo(), param.getPageSize(), count));
}
int pageNo = param.getPageNo();
param.buildCurrentPage();
List<ModuleInfoDO> list = moduleInfoDao.listModuleInfoPage(param);
List<ModuleInfoDTO> pageList = list.stream().map(d->{
return d.buildModuleInfoDTO();
}).collect(Collectors.toList());
return ResultBody.success(PageResult.buildPage(pageNo, param.getPageSize(), count, pageList));
}
@Override
public ResultBody listBannerInfoPage(BannerInfoQO param) {
int count = moduleInfoDao.countListBannerInfoPage(param);
if (count == 0) {
return ResultBody.success(PageResult.buildPage(param.getPageNo(), param.getPageSize(), count));
}
int pageNo = param.getPageNo();
param.buildCurrentPage();
List<BannerInfoDO> list = moduleInfoDao.listBannerInfoPage(param);
List<BannerInfoDTO> pageList = list.stream().map(d->{
return d.buildBannerInfoDTO();
}).collect(Collectors.toList());
return ResultBody.success(PageResult.buildPage(pageNo, param.getPageSize(), count, pageList));
}
@Override
public ResultBody removeBannerInfo(Integer id) {
moduleInfoDao.removeBannerInfo(id);
return ResultBody.success();
}
@Override
public ResultBody insertBannerInfo(BannerInfoVO bannerInfoVO) {
int countSameName = moduleInfoDao.getCountSameNameOfBannerInfo(bannerInfoVO.getModuleId(), bannerInfoVO.getBannerName());
if(countSameName > 0){
return ResultBody.error(ResultEnum.EXIST_SAME_NAME_OF_BANNER_ERROR);
}
BannerInfoDO bannerInfoDO = new BannerInfoDO(bannerInfoVO);
//sort设置
int count = moduleInfoDao.getCountBannerInfoOfModule(bannerInfoVO.getModuleId());
bannerInfoDO.setSort(count+1);
moduleInfoDao.insertBannerInfo(bannerInfoDO);
return ResultBody.success();
}
@Override
public ResultBody updateBannerInfo(BannerInfoVO bannerInfoVO) {
int countSameName = moduleInfoDao.getCountSameNameNotItSelfOfBanner(bannerInfoVO.getId(), bannerInfoVO.getModuleId(), bannerInfoVO.getBannerName());
if(countSameName > 0){
return ResultBody.error(ResultEnum.EXIST_SAME_NAME_OF_BANNER_ERROR);
}
BannerInfoDO bannerInfoDO = new BannerInfoDO(bannerInfoVO);
System.out.println("----------->"+bannerInfoDO.toString());
if("0".equals(bannerInfoVO.getBannerType().toString())){
bannerInfoDO.setBannerUrl("");
bannerInfoDO.setBannerPoster("");
}else if("1".equals(bannerInfoVO.getBannerType().toString())){
bannerInfoDO.setBannerUrl("");
}else if("2".equals(bannerInfoVO.getBannerType().toString())){
bannerInfoDO.setBannerPoster("");
}
moduleInfoDao.updateBannerInfo(bannerInfoDO);
return ResultBody.success();
}
@Transactional
@Override
public ResultBody exchangeBannerInfo(List<BannerInfoVO> list) {
Integer sort = list.get(0).getSort();
BannerInfoDO bannerInfoDO0 = new BannerInfoDO();
bannerInfoDO0.setId(list.get(0).getId());
bannerInfoDO0.setSort(list.get(1).getSort());
moduleInfoDao.updateBannerInfo(bannerInfoDO0);
BannerInfoDO bannerInfoDO1 = new BannerInfoDO();
bannerInfoDO1.setId(list.get(1).getId());
bannerInfoDO1.setSort(sort);
moduleInfoDao.updateBannerInfo(bannerInfoDO1);
return ResultBody.success();
}
@Override
public ResultBody listBannerImg(String moduleCode) {
List<BannerInfoDO> list = moduleInfoDao.listBannerImg(moduleCode);
List<BannerInfoDTO> pageList = list.stream().map(d->{
return d.buildBannerInfoDTO();
}).collect(Collectors.toList());
return ResultBody.success(pageList);
}
@Override
public ResultBody batchRemoveBannerInfo(List<Integer> list) {
moduleInfoDao.batchRemoveBannerInfo(list);
return ResultBody.success();
}
}
<?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.mmc.csf.release.dao.ModuleInfoDao">
<resultMap id="moduleInfoResultMap" type="com.mmc.csf.release.entity.ModuleInfoDO">
<id column="id" property="id"/>
<result column="module_name" property="moduleName"/>
<result column="module_type" property="moduleType"/>
<result column="module_code" property="moduleCode"/>
<result column="remark" property="remark"/>
<result column="is_deleted" property="deleted"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<resultMap id="bannerInfoResultMap" type="com.mmc.csf.release.entity.BannerInfoDO">
<id column="id" property="id"/>
<result column="module_id" property="moduleId"/>
<result column="banner_name" property="bannerName"/>
<result column="banner_img" property="bannerImg"/>
<result column="banner_poster" property="bannerPoster"/>
<result column="banner_type" property="bannerType"/>
<result column="goods_id" property="goodsId"/>
<result column="detail_info" property="detailInfo"/>
<result column="banner_url" property="bannerUrl"/>
<result column="sort" property="sort"/>
<result column="text_content" property="textContent"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
<result column="is_using" property="using"/>
<result column="is_deleted" property="deleted"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<insert id="insertModuleInfo" useGeneratedKeys="true"
keyProperty="id" parameterType="com.mmc.csf.release.entity.ModuleInfoDO">
insert into module_info(module_name,module_code,module_type,remark,create_time)
values(#{moduleName},#{moduleCode},#{moduleType},#{remark},NOW())
</insert>
<update id="updateModuleInfo" parameterType="com.mmc.csf.release.entity.ModuleInfoDO">
update module_info
<set>
<if test=" moduleName != '' and moduleName != null ">
module_name = #{moduleName},
</if>
<if test=" moduleCode != '' and moduleCode != null ">
module_code = #{moduleCode},
</if>
<if test=" moduleType != null ">
module_type = #{moduleType},
</if>
<if test=" remark != null ">
remark = #{remark},
</if>
update_time = NOW()
</set>
where id = #{id}
</update>
<update id="removeModuleInfo" >
update module_info set is_deleted = 1 where id = #{id}
</update>
<update id="updateModuleInfoRemark" >
update module_info set remark = #{remark} where id = #{id}
</update>
<select id="listModuleInfoPage" resultMap="moduleInfoResultMap" parameterType="com.mmc.csf.infomation.qo.ModuleInfoQO">
select mi.id,mi.module_name,mi.module_type,mi.module_code,mi.remark,mi.is_deleted,mi.create_time,mi.update_time
from module_info mi
where mi.is_deleted = 0
<if test=" keyword != null and keyword != '' ">
and mi.module_name like CONCAT('%',#{keyword},'%')
</if>
<if test=" moduleCode != null and moduleCode != '' ">
and mi.module_code = #{moduleCode}
</if>
<if test=" moduleType != null ">
and mi.module_type = #{moduleType}
</if>
<if test=" port != null and port == 0 ">
and mi.module_type <![CDATA[<>]]> 3
</if>
<if test=" port != null and port == 1 ">
and mi.module_type = 3
</if>
limit #{pageNo},#{pageSize}
</select>
<select id="countListModuleInfoPage" resultType="int" parameterType="com.mmc.csf.infomation.qo.ModuleInfoQO">
select count(*) from module_info mi
where mi.is_deleted = 0
<if test=" keyword != null and keyword != '' ">
and mi.module_name like CONCAT('%',#{keyword},'%')
</if>
<if test=" moduleCode != null and moduleCode != '' ">
and mi.module_code = #{moduleCode}
</if>
<if test=" moduleType != null ">
and mi.module_type = #{moduleType}
</if>
<if test=" port != null and port == 0 ">
and mi.module_type <![CDATA[<>]]> 3
</if>
<if test=" port != null and port == 1 ">
and mi.module_type = 3
</if>
</select>
<select id="listBannerInfoPage" resultMap="bannerInfoResultMap" parameterType="com.mmc.csf.infomation.qo.BannerInfoQO">
select bi.id,bi.module_id,bi.banner_name,bi.banner_img,bi.banner_poster,bi.banner_type,bi.goods_id,bi.banner_url,bi.sort,
bi.start_time,bi.end_time,bi.is_using,bi.is_deleted,bi.create_time,bi.update_time,mi.module_name,bi.detail_info,bi.text_content
from banner_info bi INNER JOIN module_info mi ON bi.module_id = mi.id
where bi.is_deleted = 0
<if test=" keyword != null and keyword != '' ">
and mi.module_name like CONCAT('%',#{keyword},'%')
</if>
<if test=" moduleId != null ">
and bi.module_id = #{moduleId}
</if>
<if test=" moduleType != null ">
and mi.module_type = #{moduleType}
</if>
order by bi.sort asc
limit #{pageNo},#{pageSize}
</select>
<select id="countListBannerInfoPage" resultType="int" parameterType="com.mmc.csf.infomation.qo.BannerInfoQO">
select count(*)
from banner_info bi
where bi.is_deleted = 0
<if test=" moduleId != null ">
and bi.module_id = #{moduleId}
</if>
</select>
<update id="removeBannerInfo" >
update banner_info set is_deleted = 1 where id = #{id}
</update>
<select id="getCountBannerInfoOfModule" parameterType="java.lang.Integer" resultType="int">
select count(*) from banner_info bi where bi.module_id = #{moduleId}
</select>
<insert id="insertBannerInfo" useGeneratedKeys="true"
keyProperty="id" parameterType="com.mmc.csf.release.entity.BannerInfoDO">
insert into banner_info(module_id,banner_name,banner_img,banner_type,goods_id,detail_info,banner_poster,banner_url,start_time,end_time,text_content,sort,is_using,create_time)
values(#{moduleId},#{bannerName},#{bannerImg},#{bannerType},#{goodsId},#{detailInfo},#{bannerPoster},#{bannerUrl},#{startTime},#{endTime},#{textContent},#{sort},#{using},NOW())
</insert>
<update id="updateBannerInfo" parameterType="com.mmc.csf.release.entity.BannerInfoDO">
update banner_info
<set>
<if test=" moduleId != null ">
module_id = #{moduleId},
</if>
<if test=" bannerName != null and bannerName != '' ">
banner_name = #{bannerName},
</if>
<if test=" bannerImg != null ">
banner_img = #{bannerImg},
</if>
<if test=" bannerPoster != null ">
banner_poster = #{bannerPoster},
</if>
<if test=" bannerUrl != null ">
banner_url = #{bannerUrl},
</if>
<if test=" bannerType != null ">
banner_type = #{bannerType},
</if>
<if test=" goodsId != null ">
goods_id = #{goodsId},
</if>
<if test=" detailInfo != null ">
detail_info = #{detailInfo},
</if>
<if test=" sort != null ">
sort = #{sort},
</if>
<if test=" textContent != null ">
text_content = #{textContent},
</if>
<if test=" using != null ">
is_using = #{using},
</if>
end_time = #{endTime},
start_time = #{startTime},
update_time = NOW()
</set>
where id = #{id}
</update>
<select id="getCountSameNameOfModuleInfo" resultType="int">
select count(*) from module_info mi where mi.is_deleted = 0 and mi.module_type = #{moduleType} and mi.module_name = #{moduleName}
</select>
<select id="getCountSameNameOfBannerInfo" resultType="int">
select count(*) from banner_info bi where bi.is_deleted = 0 and bi.banner_name = #{bannerName} and bi.module_id = #{moduleId}
</select>
<select id="getCountSameNameNotItSelfOfModule" resultType="int">
select count(*) from module_info mi where mi.is_deleted = 0 and mi.id <![CDATA[<>]]> #{id} and mi.module_name = #{moduleName} and mi.module_type = #{moduleType}
</select>
<select id="getCountSameNameNotItSelfOfBanner" resultType="int">
select count(*) from banner_info bi where bi.is_deleted = 0 and bi.banner_name = #{bannerName} and bi.module_id = #{moduleId} and bi.id <![CDATA[<>]]> #{id}
</select>
<select id="listBannerImg" resultMap="bannerInfoResultMap" >
select bi.id,bi.module_id,bi.banner_name,bi.banner_img,bi.banner_poster,bi.banner_type,bi.goods_id,bi.detail_info,
bi.banner_url,bi.start_time,bi.end_time,bi.sort,bi.start_time,bi.end_time,bi.is_using,bi.is_deleted,bi.create_time,bi.update_time,bi.text_content
from banner_info bi INNER JOIN module_info mi ON bi.module_id = mi.id
where bi.is_deleted = 0 and bi.is_using = 1
and (bi.end_time is null
or
( now() > bi.start_time and bi.end_time > NOW() ) ) and mi.module_code = #{moduleCode}
order by bi.sort asc
</select>
<update id="removeBanners" >
update banner_info set is_deleted = 1 where module_id = #{moduleId}
</update>
<select id="getCountSameCode" resultType="int" >
select count(*) from module_info where module_code = #{moduleCode} and is_deleted = 0
</select>
<select id="getCountSameCodeOfItSelf" resultType="int" >
select count(*) from module_info where module_code = #{moduleCode} and id <![CDATA[<>]]> #{id} and is_deleted = 0
</select>
<update id="batchRemoveBannerInfo" parameterType="java.util.List">
update banner_info set is_deleted = 1 where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")" >
#{item}
</foreach>
</update>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论