- 增加:banner
This commit is contained in:
39
promotion/promotion-rest/pom.xml
Normal file
39
promotion/promotion-rest/pom.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>promotion</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>promotion-rest</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>promotion-biz</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-web</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-security</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-swagger</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,84 @@
|
||||
package cn.iocoder.mall.promotion.rest.controller.banner;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.biz.bo.banner.BannerListBO;
|
||||
import cn.iocoder.mall.promotion.biz.dto.banner.BannerAddDTO;
|
||||
import cn.iocoder.mall.promotion.biz.dto.banner.BannerListDTO;
|
||||
import cn.iocoder.mall.promotion.biz.dto.banner.BannerUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.biz.service.banner.BannerService;
|
||||
import cn.iocoder.mall.promotion.rest.convert.BannerConvert;
|
||||
import cn.iocoder.mall.promotion.rest.request.banner.BannerAddRequest;
|
||||
import cn.iocoder.mall.promotion.rest.request.banner.BannerListRequest;
|
||||
import cn.iocoder.mall.promotion.rest.request.banner.BannerUpdateRequest;
|
||||
import cn.iocoder.mall.promotion.rest.request.banner.BannerUpdateStatusRequest;
|
||||
import cn.iocoder.mall.promotion.rest.response.banner.BannerListResponse;
|
||||
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Banner(管理员API)
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admins/banner")
|
||||
@Api(tags = "Banner(管理员API)")
|
||||
public class AdminsBannerController {
|
||||
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
@PostMapping("/list")
|
||||
@ApiOperation(value = "列表-banner列表")
|
||||
public CommonResult<PageResult<BannerListResponse>> page(@RequestBody @Valid BannerListRequest request) {
|
||||
// 获取数据
|
||||
BannerListDTO pageDTO = BannerConvert.INSTANCE.convert(request);
|
||||
PageResult<BannerListBO> pageResult = bannerService.listBanner(pageDTO);
|
||||
// 转换 response
|
||||
List<BannerListResponse> responseList = BannerConvert.INSTANCE.convert(pageResult.getList());
|
||||
return CommonResult.success(new PageResult<BannerListResponse>().setList(responseList).setTotal(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加-Banner")
|
||||
public CommonResult<Void> add(@RequestBody @Valid BannerAddRequest request) {
|
||||
BannerAddDTO bannerAddDTO = BannerConvert.INSTANCE.convert(request);
|
||||
bannerAddDTO.setAdminId(AdminSecurityContextHolder.getContext().getAdminId());
|
||||
bannerService.addBanner(bannerAddDTO);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation(value = "更新-Banner信息")
|
||||
public CommonResult<Void> update(@RequestBody @Valid BannerUpdateRequest request) {
|
||||
BannerUpdateDTO bannerUpdateDTO = BannerConvert.INSTANCE.convert(request);
|
||||
bannerUpdateDTO.setAdminId(AdminSecurityContextHolder.getContext().getAdminId());
|
||||
bannerService.updateBanner(bannerUpdateDTO);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@ApiOperation(value = "更新-banner状态")
|
||||
public CommonResult<Void> updateStatus(@RequestBody @Valid BannerUpdateStatusRequest request) {
|
||||
Integer adminId = AdminSecurityContextHolder.getContext().getAdminId();
|
||||
bannerService.updateBannerStatus(adminId, request.getBannerId(), request.getStatus());
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation(value = "删除-根据id删除")
|
||||
@ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1")
|
||||
public CommonResult<Void> delete(@RequestParam("id") Integer id) {
|
||||
bannerService.deleteBanner(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.iocoder.mall.promotion.rest.controller.banner;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.biz.bo.banner.BannerListOnReleaseBO;
|
||||
import cn.iocoder.mall.promotion.biz.service.banner.BannerService;
|
||||
import cn.iocoder.mall.promotion.rest.convert.BannerConvert;
|
||||
import cn.iocoder.mall.promotion.rest.response.banner.BannerListOnReleaseResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Banner(用户API)
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/users/banner")
|
||||
@Api(tags = "Banner(用户API)")
|
||||
public class UsersBannerController {
|
||||
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
@GetMapping("/listBannerOnRelease")
|
||||
@ApiOperation("获取-已发布的banner")
|
||||
public CommonResult<List<BannerListOnReleaseResponse>> listBannerOnRelease() {
|
||||
List<BannerListOnReleaseBO> releaseBOList = bannerService.listBannerOnRelease();
|
||||
return CommonResult.success(BannerConvert.INSTANCE.convertReleaseResponse(releaseBOList));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:27
|
||||
*/
|
||||
package cn.iocoder.mall.promotion.rest.controller;
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.promotion.rest.convert;
|
||||
|
||||
import cn.iocoder.mall.promotion.biz.bo.banner.BannerListBO;
|
||||
import cn.iocoder.mall.promotion.biz.bo.banner.BannerListOnReleaseBO;
|
||||
import cn.iocoder.mall.promotion.biz.dto.banner.BannerAddDTO;
|
||||
import cn.iocoder.mall.promotion.biz.dto.banner.BannerUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.biz.dto.banner.BannerListDTO;
|
||||
import cn.iocoder.mall.promotion.rest.request.banner.BannerAddRequest;
|
||||
import cn.iocoder.mall.promotion.rest.request.banner.BannerListRequest;
|
||||
import cn.iocoder.mall.promotion.rest.request.banner.BannerUpdateRequest;
|
||||
import cn.iocoder.mall.promotion.rest.response.banner.BannerListResponse;
|
||||
import cn.iocoder.mall.promotion.rest.response.banner.BannerListOnReleaseResponse;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BannerConvert {
|
||||
|
||||
BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class);
|
||||
|
||||
BannerAddDTO convert(BannerAddRequest request);
|
||||
|
||||
BannerUpdateDTO convert(BannerUpdateRequest request);
|
||||
|
||||
BannerListDTO convert(BannerListRequest request);
|
||||
|
||||
List<BannerListResponse> convert(List<BannerListBO> bannerListBO);
|
||||
|
||||
List<BannerListOnReleaseResponse> convertReleaseResponse(List<BannerListOnReleaseBO> bannerListOnReleaseBOS);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.iocoder.mall.promotion.rest.request.banner;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* banner:更新 banner
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:44
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerAddRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("跳转链接")
|
||||
private Integer url;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("图片链接")
|
||||
private Integer picUrl;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("备注")
|
||||
private Integer memo;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.iocoder.mall.promotion.rest.request.banner;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* banner:更新 banner
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:44
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerListRequest extends PageParam {
|
||||
|
||||
@ApiModelProperty("标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.iocoder.mall.promotion.rest.request.banner;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* banner:更新 banner
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:44
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerUpdateRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("banner编号")
|
||||
private Integer bannerId;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("跳转链接")
|
||||
private Integer url;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("图片链接")
|
||||
private Integer picUrl;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("备注")
|
||||
private Integer memo;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.iocoder.mall.promotion.rest.request.banner;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* banner:更新 status
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:44
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerUpdateStatusRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("banner编号")
|
||||
private Integer bannerId;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("status状态")
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
/**
|
||||
* author: sin
|
||||
* time: 2020/5/14 17:00
|
||||
*/
|
||||
package cn.iocoder.mall.promotion.rest.request;
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.mall.promotion.rest.response.banner;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* banner - 已发布的banner
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 16:56
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerListOnReleaseResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 跳转链接
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 图片链接
|
||||
*/
|
||||
private String picUrl;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.iocoder.mall.promotion.rest.response.banner;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* banner:list
|
||||
*
|
||||
* author: sin
|
||||
* time: 2020/5/14 16:00
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerListResponse implements Serializable {
|
||||
|
||||
@ApiModelProperty("编号")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("跳转链接")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty("图片链接")
|
||||
private String picUrl;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String memo;
|
||||
|
||||
//
|
||||
// 其他
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updatedTime;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createdTime;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* author: sin
|
||||
* time: 2020/5/14 15:26
|
||||
*/
|
||||
package cn.iocoder.mall.promotion.rest.response;
|
||||
Reference in New Issue
Block a user