From 0400e52c1f22aaa05b2c881c5674caf953f121f7 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 3 Jan 2023 15:34:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BF=AB=E7=85=A7crud?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SysDateSnapshotController.java | 115 ++++++++++++++++++ .../date_snapshot/dao/SysDateSnapshotDao.java | 16 +++ .../date_snapshot/dto/SysDateSnapshotDTO.java | 34 ++++++ .../entity/SysDateSnapshotEntity.java | 35 ++++++ .../excel/SysDateSnapshotExcel.java | 30 +++++ .../service/SysDateSnapshotService.java | 15 +++ .../impl/SysDateSnapshotServiceImpl.java | 31 +++++ .../date_snapshot/SysDateSnapshotDao.xml | 15 +++ 8 files changed, 291 insertions(+) create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/controller/SysDateSnapshotController.java create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/dao/SysDateSnapshotDao.java create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/dto/SysDateSnapshotDTO.java create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/excel/SysDateSnapshotExcel.java create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java create mode 100644 renren-admin/src/main/resources/mapper/date_snapshot/SysDateSnapshotDao.xml diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/controller/SysDateSnapshotController.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/controller/SysDateSnapshotController.java new file mode 100644 index 00000000..4a29d7bf --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/controller/SysDateSnapshotController.java @@ -0,0 +1,115 @@ +package io.renren.modules.date_snapshot.controller; + +import io.renren.common.annotation.LogOperation; +import io.renren.common.constant.Constant; +import io.renren.common.page.PageData; +import io.renren.common.utils.ExcelUtils; +import io.renren.common.utils.Result; +import io.renren.common.validator.AssertUtils; +import io.renren.common.validator.ValidatorUtils; +import io.renren.common.validator.group.AddGroup; +import io.renren.common.validator.group.DefaultGroup; +import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO; +import io.renren.modules.date_snapshot.excel.SysDateSnapshotExcel; +import io.renren.modules.date_snapshot.service.SysDateSnapshotService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +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 wangliwen wangliwen2@hisense.com + * @since 1.0 2023-01-03 + */ +@RestController +@RequestMapping("date_snapshot/sysdatesnapshot") +@Api(tags = "运行数据快照(资源数量、申请数量)") +public class SysDateSnapshotController { + @Autowired + private SysDateSnapshotService sysDateSnapshotService; + + @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") + }) +// @RequiresPermissions("date_snapshot:sysdatesnapshot:page") + public Result> page(@ApiIgnore @RequestParam Map params) { + PageData page = sysDateSnapshotService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") +// @RequiresPermissions("date_snapshot:sysdatesnapshot:info") + public Result get(@PathVariable("id") Long id) { + SysDateSnapshotDTO data = sysDateSnapshotService.get(id); + + return new Result().ok(data); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") +// @RequiresPermissions("date_snapshot:sysdatesnapshot:save") + public Result save(@RequestBody SysDateSnapshotDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + sysDateSnapshotService.save(dto); + + return new Result(); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") +// @RequiresPermissions("date_snapshot:sysdatesnapshot:update") + public Result update(@RequestBody SysDateSnapshotDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + sysDateSnapshotService.update(dto); + + return new Result(); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") +// @RequiresPermissions("date_snapshot:sysdatesnapshot:delete") + public Result delete(@RequestBody Long[] ids) { + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + sysDateSnapshotService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") +// @RequiresPermissions("date_snapshot:sysdatesnapshot:export") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = sysDateSnapshotService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, "运行数据快照(资源数量、申请数量)", list, SysDateSnapshotExcel.class); + } + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/dao/SysDateSnapshotDao.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/dao/SysDateSnapshotDao.java new file mode 100644 index 00000000..ddd204ae --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/dao/SysDateSnapshotDao.java @@ -0,0 +1,16 @@ +package io.renren.modules.date_snapshot.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 运行数据快照(资源数量、申请数量) + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2023-01-03 + */ +@Mapper +public interface SysDateSnapshotDao extends BaseDao { + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/dto/SysDateSnapshotDTO.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/dto/SysDateSnapshotDTO.java new file mode 100644 index 00000000..4200b455 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/dto/SysDateSnapshotDTO.java @@ -0,0 +1,34 @@ +package io.renren.modules.date_snapshot.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 运行数据快照(资源数量、申请数量) + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2023-01-03 + */ +@Data +@ApiModel(value = "运行数据快照(资源数量、申请数量)") +public class SysDateSnapshotDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + private Long id; + @ApiModelProperty(value = "数据快照类型(1:每周快照 2:每月快照)") + private Integer type; + @ApiModelProperty(value = "创建人") + private Long creator; + @ApiModelProperty(value = "创建时间") + private Date createDate; + @ApiModelProperty(value = "数据快照内容") + private List> snapshot; + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java new file mode 100644 index 00000000..9f0044f5 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/entity/SysDateSnapshotEntity.java @@ -0,0 +1,35 @@ +package io.renren.modules.date_snapshot.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; +import io.renren.common.entity.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * 运行数据快照(资源数量、申请数量) + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2023-01-03 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName(value = "sys_date_snapshot", autoResultMap = true) +public class SysDateSnapshotEntity extends BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 数据快照类型(1:每周快照 2:每月快照) + */ + private Integer type; + /** + * 数据快照内容 + */ + @TableField(value = "`snapshot`", typeHandler = FastjsonTypeHandler.class) + private List> snapshot; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/excel/SysDateSnapshotExcel.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/excel/SysDateSnapshotExcel.java new file mode 100644 index 00000000..e255c35f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/excel/SysDateSnapshotExcel.java @@ -0,0 +1,30 @@ +package io.renren.modules.date_snapshot.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; + +/** + * 运行数据快照(资源数量、申请数量) + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2023-01-03 + */ +@Data +@ContentRowHeight(20) +@HeadRowHeight(20) +@ColumnWidth(25) +public class SysDateSnapshotExcel { + @ExcelProperty(value = "主键", index = 0) + private Object id; + @ExcelProperty(value = "数据快照类型(1:每周快照 2:每月快照)", index = 1) + private Object type; + @ExcelProperty(value = "创建人", index = 2) + private Object creator; + @ExcelProperty(value = "创建时间", index = 3) + private Object createDate; + @ExcelProperty(value = "数据快照内容", index = 4) + private Object snapshot; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java new file mode 100644 index 00000000..13ef9005 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java @@ -0,0 +1,15 @@ +package io.renren.modules.date_snapshot.service; + +import io.renren.common.service.CrudService; +import io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO; +import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity; + +/** + * 运行数据快照(资源数量、申请数量) + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2023-01-03 + */ +public interface SysDateSnapshotService extends CrudService { + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java new file mode 100644 index 00000000..ead91d1a --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java @@ -0,0 +1,31 @@ +package io.renren.modules.date_snapshot.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.modules.date_snapshot.dao.SysDateSnapshotDao; +import io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO; +import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity; +import io.renren.modules.date_snapshot.service.SysDateSnapshotService; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 运行数据快照(资源数量、申请数量) + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2023-01-03 + */ +@Service +public class SysDateSnapshotServiceImpl extends CrudServiceImpl implements SysDateSnapshotService { + + @Override + public QueryWrapper getWrapper(Map params) { + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + } + + +} \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/date_snapshot/SysDateSnapshotDao.xml b/renren-admin/src/main/resources/mapper/date_snapshot/SysDateSnapshotDao.xml new file mode 100644 index 00000000..315a9e6b --- /dev/null +++ b/renren-admin/src/main/resources/mapper/date_snapshot/SysDateSnapshotDao.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file