From 342f843f2cb209b92b78cccc37b61686cb2985a2 Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Wed, 22 Jun 2022 09:14:03 +0800 Subject: [PATCH] mark --- .../controller/ProductTypeController.java | 116 ++++++++++++++++++ .../cnbm/generator/dto/ProductTypeDTO.java | 67 ++++++++++ .../cnbm/generator/entity/ProductType.java | 69 +++++++++++ .../generator/excel/ProductTypeExcel.java | 46 +++++++ .../generator/mapper/ProductTypeMapper.java | 16 +++ .../generator/mapper/ProductTypeMapper.xml | 5 + .../service/IProductTypeService.java | 15 +++ .../service/impl/ProductTypeServiceImpl.java | 34 +++++ 8 files changed, 368 insertions(+) create mode 100644 ym-generator/src/main/java/com/cnbm/generator/controller/ProductTypeController.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/dto/ProductTypeDTO.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/entity/ProductType.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/excel/ProductTypeExcel.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.xml create mode 100644 ym-generator/src/main/java/com/cnbm/generator/service/IProductTypeService.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/service/impl/ProductTypeServiceImpl.java diff --git a/ym-generator/src/main/java/com/cnbm/generator/controller/ProductTypeController.java b/ym-generator/src/main/java/com/cnbm/generator/controller/ProductTypeController.java new file mode 100644 index 0000000..74c8b90 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/controller/ProductTypeController.java @@ -0,0 +1,116 @@ +package com.cnbm.generator.controller; + +import com.cnbm.admin.annotation.LogOperation; +import com.cnbm.common.constant.Constant; +import com.cnbm.common.page.PageData; +import com.cnbm.common.utils.ExcelUtils; +import com.cnbm.common.utils.Result; +import com.cnbm.common.validator.AssertUtils; +import com.cnbm.common.validator.ValidatorUtils; +import com.cnbm.common.validator.group.AddGroup; +import com.cnbm.common.validator.group.DefaultGroup; +import com.cnbm.common.validator.group.UpdateGroup; +import com.cnbm.generator.dto.ProductTypeDTO; +import com.cnbm.generator.excel.ProductTypeExcel; +import com.cnbm.generator.service.IProductTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 产品类型 表 前端控制器 + * + * @author why + * @since 2022-06-21 + */ +@RestController +@RequestMapping("/generator/productType") +@Api(tags="产品类型 表") +public class ProductTypeController { + @Autowired + private IProductTypeService productTypeService; + + @GetMapping("page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") + }) + @PreAuthorize("@ex.hasAuthority('generator:productType:page')") + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = productTypeService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") + @PreAuthorize("@ex.hasAuthority('generator:productType:info')") + public Result get(@PathVariable("id") Long id){ + ProductTypeDTO data = productTypeService.get(id); + + return new Result().ok(data); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") + @PreAuthorize("@ex.hasAuthority('generator:productType:save')") + public Result save(@RequestBody ProductTypeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + productTypeService.save(dto); + + return new Result(); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") + @PreAuthorize("@ex.hasAuthority('generator:productType:update')") + public Result update(@RequestBody ProductTypeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + productTypeService.update(dto); + + return new Result(); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") + @PreAuthorize("@ex.hasAuthority('generator:productType:delete')") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + productTypeService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") + @PreAuthorize("@ex.hasAuthority('generator:productType:export')") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = productTypeService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, list, ProductTypeExcel.class); + } + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/dto/ProductTypeDTO.java b/ym-generator/src/main/java/com/cnbm/generator/dto/ProductTypeDTO.java new file mode 100644 index 0000000..1ebe97a --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/dto/ProductTypeDTO.java @@ -0,0 +1,67 @@ +package com.cnbm.generator.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.math.BigDecimal; + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * 产品类型 表 + * + * @author why + * @since 2022-06-21 + */ +@Data +@ApiModel(value = "产品类型 表DTO对象") +public class ProductTypeDTO implements Serializable { + private static final long serialVersionUID = 1L; + + + + @ApiModelProperty(value = "ID") + private BigDecimal id; + + @ApiModelProperty(value = "产品类型 名") + private String name; + + @ApiModelProperty(value = "产品类型 编码") + private String code; + + @ApiModelProperty(value = "描述") + private String desc; + + @ApiModelProperty(value = "1 可用,0 不可用") + private BigDecimal status; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "删除标志,是否有效:1 可用 0不可用") + private BigDecimal valid; + + @ApiModelProperty(value = "创建人") + private BigDecimal creatorId; + + @ApiModelProperty(value = "创建人姓名") + private String creatorName; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "更新人") + private BigDecimal updaterId; + + @ApiModelProperty(value = "更新人姓名") + private String updaterName; + + @ApiModelProperty(value = "更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty(value = "版本号") + private BigDecimal version; + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/entity/ProductType.java b/ym-generator/src/main/java/com/cnbm/generator/entity/ProductType.java new file mode 100644 index 0000000..6d62feb --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/entity/ProductType.java @@ -0,0 +1,69 @@ +package com.cnbm.generator.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * 产品类型 表 + *

+ * + * @author why + * @since 2022-06-21 + */ +@Data +@TableName("product_type") +@ApiModel(value = "ProductType对象", description = "产品类型 表") +public class ProductType implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("ID") + private BigDecimal id; + + @ApiModelProperty("产品类型 名") + private String name; + + @ApiModelProperty("产品类型 编码") + private String code; + + @ApiModelProperty("描述") + private String desc; + + @ApiModelProperty("1 可用,0 不可用") + private BigDecimal status; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("删除标志,是否有效:1 可用 0不可用") + private BigDecimal valid; + + @ApiModelProperty("创建人") + private BigDecimal creatorId; + + @ApiModelProperty("创建人姓名") + private String creatorName; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + @ApiModelProperty("更新人") + private BigDecimal updaterId; + + @ApiModelProperty("更新人姓名") + private String updaterName; + + @ApiModelProperty("更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty("版本号") + private BigDecimal version; + + +} diff --git a/ym-generator/src/main/java/com/cnbm/generator/excel/ProductTypeExcel.java b/ym-generator/src/main/java/com/cnbm/generator/excel/ProductTypeExcel.java new file mode 100644 index 0000000..6ad3ab6 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/excel/ProductTypeExcel.java @@ -0,0 +1,46 @@ +package com.cnbm.generator.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 产品类型 表 + * + * @author why + * @since 2022-06-21 + */ +@Data +public class ProductTypeExcel { + @Excel(name = "ID") + private BigDecimal id; + @Excel(name = "产品类型 名") + private String name; + @Excel(name = "产品类型 编码") + private String code; + @Excel(name = "描述") + private String desc; + @Excel(name = "1 可用,0 不可用") + private BigDecimal status; + @Excel(name = "备注") + private String remark; + @Excel(name = "删除标志,是否有效:1 可用 0不可用") + private BigDecimal valid; + @Excel(name = "创建人") + private BigDecimal creatorId; + @Excel(name = "创建人姓名") + private String creatorName; + @Excel(name = "创建时间") + private LocalDateTime createTime; + @Excel(name = "更新人") + private BigDecimal updaterId; + @Excel(name = "更新人姓名") + private String updaterName; + @Excel(name = "更新时间") + private LocalDateTime updateTime; + @Excel(name = "版本号") + private BigDecimal version; + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.java b/ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.java new file mode 100644 index 0000000..c33c3d7 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.java @@ -0,0 +1,16 @@ +package com.cnbm.generator.mapper; + +import com.cnbm.common.dao.BaseDao; +import com.cnbm.generator.entity.ProductType; +import org.apache.ibatis.annotations.Mapper; + +/** + * 产品类型 表 + * + * @author why + * @since 2022-06-21 + */ +@Mapper +public interface ProductTypeMapper extends BaseDao { + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.xml b/ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.xml new file mode 100644 index 0000000..816a329 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/mapper/ProductTypeMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ym-generator/src/main/java/com/cnbm/generator/service/IProductTypeService.java b/ym-generator/src/main/java/com/cnbm/generator/service/IProductTypeService.java new file mode 100644 index 0000000..08e6221 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/service/IProductTypeService.java @@ -0,0 +1,15 @@ +package com.cnbm.generator.service; + +import com.cnbm.common.service.CrudService; +import com.cnbm.generator.dto.ProductTypeDTO; +import com.cnbm.generator.entity.ProductType; + +/** + * 产品类型 表 + * + * @author why + * @since 2022-06-21 + */ +public interface IProductTypeService extends CrudService { + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/service/impl/ProductTypeServiceImpl.java b/ym-generator/src/main/java/com/cnbm/generator/service/impl/ProductTypeServiceImpl.java new file mode 100644 index 0000000..1572dd0 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/service/impl/ProductTypeServiceImpl.java @@ -0,0 +1,34 @@ +package com.cnbm.generator.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.cnbm.common.service.impl.CrudServiceImpl; +import com.cnbm.generator.dto.ProductTypeDTO; +import com.cnbm.generator.mapper.ProductTypeMapper; +import com.cnbm.generator.entity.ProductType; +import com.cnbm.generator.service.IProductTypeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 产品类型 表 + * + * @author why + * @since 2022-06-21 + */ +@Service +public class ProductTypeServiceImpl extends CrudServiceImpl implements IProductTypeService { + + @Override + public QueryWrapper getWrapper(Map params){ + String id = (String)params.get("id"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + +} \ No newline at end of file