diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.http b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.http deleted file mode 100644 index ed65d0b86..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.http +++ /dev/null @@ -1,19 +0,0 @@ -### 请求 /infra/test-demo/get 接口 => 成功 -GET {{baseUrl}}/infra/test-demo/get?id=106 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /infra/test-demo/update 接口 => 成功 -PUT {{baseUrl}}/infra/test-demo/update -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - - -{ - "id": 106, - "name": "测试", - "status": "0", - "type": 1, - "category": 1 -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.java deleted file mode 100755 index b64b49178..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.*; -import cn.iocoder.yudao.module.infra.convert.test.TestDemoConvert; -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO; -import cn.iocoder.yudao.module.infra.service.test.TestDemoService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - 字典类型") -@RestController -@RequestMapping("/infra/test-demo") -@Validated -public class TestDemoController { - - @Resource - private TestDemoService testDemoService; - - @PostMapping("/create") - @Operation(summary = "创建字典类型") - @PreAuthorize("@ss.hasPermission('infra:test-demo:create')") - public CommonResult createTestDemo(@Valid @RequestBody TestDemoCreateReqVO createReqVO) { - return success(testDemoService.createTestDemo(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新字典类型") - @PreAuthorize("@ss.hasPermission('infra:test-demo:update')") - public CommonResult updateTestDemo(@Valid @RequestBody TestDemoUpdateReqVO updateReqVO) { - testDemoService.updateTestDemo(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除字典类型") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:test-demo:delete')") - public CommonResult deleteTestDemo(@RequestParam("id") Long id) { - testDemoService.deleteTestDemo(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得字典类型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:test-demo:query')") - public CommonResult getTestDemo(@RequestParam("id") Long id) { - TestDemoDO testDemo = testDemoService.getTestDemo(id); - return success(TestDemoConvert.INSTANCE.convert(testDemo)); - } - - @GetMapping("/list") - @Operation(summary = "获得字典类型列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('infra:test-demo:query')") - public CommonResult> getTestDemoList(@RequestParam("ids") Collection ids) { - List list = testDemoService.getTestDemoList(ids); - return success(TestDemoConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得字典类型分页") - @PreAuthorize("@ss.hasPermission('infra:test-demo:query')") public CommonResult> getTestDemoPage(@Valid TestDemoPageReqVO pageVO) { - PageResult pageResult = testDemoService.getTestDemoPage(pageVO); - return success(TestDemoConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出字典类型 Excel") - @PreAuthorize("@ss.hasPermission('infra:test-demo:export')") @OperateLog(type = EXPORT) - public void exportTestDemoExcel(@Valid TestDemoExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = testDemoService.getTestDemoList(exportReqVO); - // 导出 Excel - List datas = TestDemoConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "字典类型.xls", "数据", TestDemoExcelVO.class, datas); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java deleted file mode 100755 index 660c31c78..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -/** -* 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class TestDemoBaseVO { - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "名字不能为空") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "类型不能为空") - private Integer type; - - @Schema(description = "分类", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "分类不能为空") - private Integer category; - - @Schema(description = "备注") - private String remark; - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java deleted file mode 100755 index 3b46fd1cd..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 字典类型创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TestDemoCreateReqVO extends TestDemoBaseVO { - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExcelVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExcelVO.java deleted file mode 100755 index a135885fe..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExcelVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; - -import lombok.*; - -import java.time.LocalDateTime; - -import com.alibaba.excel.annotation.ExcelProperty; - -/** - * 字典类型 Excel VO - * - * @author 芋道源码 - */ -@Data -public class TestDemoExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("名字") - private String name; - - @ExcelProperty("状态") - private Integer status; - - @ExcelProperty("类型") - private Integer type; - - @ExcelProperty("分类") - private Integer category; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java deleted file mode 100755 index f219499ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 字典类型 Excel 导出 Request VO,参数和 TestDemoPageReqVO 是一致的") -@Data -public class TestDemoExportReqVO { - - @Schema(description = "名字") - private String name; - - @Schema(description = "状态") - private Integer status; - - @Schema(description = "类型") - private Integer type; - - @Schema(description = "分类") - private Integer category; - - @Schema(description = "备注") - private String remark; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java deleted file mode 100755 index abb5843db..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 字典类型分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TestDemoPageReqVO extends PageParam { - - @Schema(description = "名字") - private String name; - - @Schema(description = "状态") - private Integer status; - - @Schema(description = "类型") - private Integer type; - - @Schema(description = "分类") - private Integer category; - - @Schema(description = "备注") - private String remark; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java deleted file mode 100755 index eaef24df3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 字典类型 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TestDemoRespVO extends TestDemoBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java deleted file mode 100755 index 25af58ed7..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 字典类型更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TestDemoUpdateReqVO extends TestDemoBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/test/TestDemoConvert.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/test/TestDemoConvert.java deleted file mode 100755 index 07a29f5a2..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/test/TestDemoConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.infra.convert.test; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoCreateReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExcelVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoRespVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoUpdateReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 字典类型 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface TestDemoConvert { - - TestDemoConvert INSTANCE = Mappers.getMapper(TestDemoConvert.class); - - TestDemoDO convert(TestDemoCreateReqVO bean); - - TestDemoDO convert(TestDemoUpdateReqVO bean); - - TestDemoRespVO convert(TestDemoDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/test/TestDemoDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/test/TestDemoDO.java deleted file mode 100755 index da1f4cb53..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/test/TestDemoDO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.test; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 字典类型 DO - * - * @author 芋道源码 - */ -@TableName("infra_test_demo") -@KeySequence("infra_test_demo_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TestDemoDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 类型 - */ - private Integer type; - /** - * 分类 - */ - private Integer category; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/test/TestDemoMapper.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/test/TestDemoMapper.java deleted file mode 100755 index d600b3f4b..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/test/TestDemoMapper.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.test; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExportReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoPageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 字典类型 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface TestDemoMapper extends BaseMapperX { - - default PageResult selectPage(TestDemoPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(TestDemoDO::getName, reqVO.getName()) - .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TestDemoDO::getType, reqVO.getType()) - .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) - .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(TestDemoDO::getId)); - } - - default List selectList(TestDemoExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(TestDemoDO::getName, reqVO.getName()) - .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TestDemoDO::getType, reqVO.getType()) - .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) - .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(TestDemoDO::getId)); - } - - List selectList2(); - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoService.java deleted file mode 100755 index 8b33f2824..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoService.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.test; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoCreateReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExportReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoUpdateReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 字典类型 Service 接口 - * - * @author 芋道源码 - */ -public interface TestDemoService { - - /** - * 创建字典类型 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createTestDemo(@Valid TestDemoCreateReqVO createReqVO); - - /** - * 更新字典类型 - * - * @param updateReqVO 更新信息 - */ - void updateTestDemo(@Valid TestDemoUpdateReqVO updateReqVO); - - /** - * 删除字典类型 - * - * @param id 编号 - */ - void deleteTestDemo(Long id); - - /** - * 获得字典类型 - * - * @param id 编号 - * @return 字典类型 - */ - TestDemoDO getTestDemo(Long id); - - /** - * 获得字典类型列表 - * - * @param ids 编号 - * @return 字典类型列表 - */ - List getTestDemoList(Collection ids); - - /** - * 获得字典类型分页 - * - * @param pageReqVO 分页查询 - * @return 字典类型分页 - */ - PageResult getTestDemoPage(TestDemoPageReqVO pageReqVO); - - /** - * 获得字典类型列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 字典类型列表 - */ - List getTestDemoList(TestDemoExportReqVO exportReqVO); - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java deleted file mode 100755 index f476b5a72..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.test; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoCreateReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExportReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoUpdateReqVO; -import cn.iocoder.yudao.module.infra.convert.test.TestDemoConvert; -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO; -import cn.iocoder.yudao.module.infra.dal.mysql.test.TestDemoMapper; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.TEST_DEMO_NOT_EXISTS; - -/** - * 字典类型 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class TestDemoServiceImpl implements TestDemoService { - - @Resource - private TestDemoMapper testDemoMapper; - - @Override - public Long createTestDemo(TestDemoCreateReqVO createReqVO) { - // 插入 - TestDemoDO testDemo = TestDemoConvert.INSTANCE.convert(createReqVO); - testDemoMapper.insert(testDemo); - // 返回 - return testDemo.getId(); - } - - @Override - @CacheEvict(value = "test", key = "#updateReqVO.id") - public void updateTestDemo(TestDemoUpdateReqVO updateReqVO) { - // 校验存在 - validateTestDemoExists(updateReqVO.getId()); - // 更新 - TestDemoDO updateObj = TestDemoConvert.INSTANCE.convert(updateReqVO); - testDemoMapper.updateById(updateObj); - } - - @Override - @CacheEvict(value = "test", key = "#id") - public void deleteTestDemo(Long id) { - // 校验存在 - validateTestDemoExists(id); - // 删除 - testDemoMapper.deleteById(id); - } - - private void validateTestDemoExists(Long id) { - if (testDemoMapper.selectById(id) == null) { - throw exception(TEST_DEMO_NOT_EXISTS); - } - } - - @Override - @Cacheable(cacheNames = "test", key = "#id") - public TestDemoDO getTestDemo(Long id) { - return testDemoMapper.selectById(id); - } - - @Override - public List getTestDemoList(Collection ids) { - return testDemoMapper.selectBatchIds(ids); - } - - @Override - public PageResult getTestDemoPage(TestDemoPageReqVO pageReqVO) { -// testDemoMapper.selectList2(); - return testDemoMapper.selectPage(pageReqVO); - } - - @Override - public List getTestDemoList(TestDemoExportReqVO exportReqVO) { - return testDemoMapper.selectList(exportReqVO); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/null/.gitkeep b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/null/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/test/TestDemoMapper.xml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/test/TestDemoMapper.xml deleted file mode 100644 index 287f58d82..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/test/TestDemoMapper.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImplTest.java deleted file mode 100755 index c4a7fb46e..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImplTest.java +++ /dev/null @@ -1,186 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.test; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoCreateReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExportReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoUpdateReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO; -import cn.iocoder.yudao.module.infra.dal.mysql.test.TestDemoMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.TEST_DEMO_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link TestDemoServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(TestDemoServiceImpl.class) -public class TestDemoServiceImplTest extends BaseDbUnitTest { - - @Resource - private TestDemoServiceImpl testDemoService; - - @Resource - private TestDemoMapper testDemoMapper; - - @Test - public void testCreateTestDemo_success() { - // 准备参数 - TestDemoCreateReqVO reqVO = randomPojo(TestDemoCreateReqVO.class); - - // 调用 - Long testDemoId = testDemoService.createTestDemo(reqVO); - // 断言 - assertNotNull(testDemoId); - // 校验记录的属性是否正确 - TestDemoDO testDemo = testDemoMapper.selectById(testDemoId); - assertPojoEquals(reqVO, testDemo); - } - - @Test - public void testUpdateTestDemo_success() { - // mock 数据 - TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class); - testDemoMapper.insert(dbTestDemo);// @Sql: 先插入出一条存在的数据 - // 准备参数 - TestDemoUpdateReqVO reqVO = randomPojo(TestDemoUpdateReqVO.class, o -> { - o.setId(dbTestDemo.getId()); // 设置更新的 ID - }); - - // 调用 - testDemoService.updateTestDemo(reqVO); - // 校验是否更新正确 - TestDemoDO testDemo = testDemoMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, testDemo); - } - - @Test - public void testUpdateTestDemo_notExists() { - // 准备参数 - TestDemoUpdateReqVO reqVO = randomPojo(TestDemoUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> testDemoService.updateTestDemo(reqVO), TEST_DEMO_NOT_EXISTS); - } - - @Test - public void testDeleteTestDemo_success() { - // mock 数据 - TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class); - testDemoMapper.insert(dbTestDemo);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTestDemo.getId(); - - // 调用 - testDemoService.deleteTestDemo(id); - // 校验数据不存在了 - assertNull(testDemoMapper.selectById(id)); - } - - @Test - public void testDeleteTestDemo_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> testDemoService.deleteTestDemo(id), TEST_DEMO_NOT_EXISTS); - } - - @Test - public void testGetTestDemoPage() { - // mock 数据 - TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setType(1); - o.setCategory(2); - o.setRemark("哈哈哈"); - o.setCreateTime(buildTime(2021, 11, 11)); - }); - testDemoMapper.insert(dbTestDemo); - // 测试 name 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName("不匹配"))); - // 测试 status 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 type 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(2))); - // 测试 category 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(1))); - // 测试 remark 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark("呵呵呵"))); - // 测试 createTime 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - TestDemoPageReqVO reqVO = new TestDemoPageReqVO(); - reqVO.setName("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setType(1); - reqVO.setCategory(2); - reqVO.setRemark("哈哈哈"); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)})); - - // 调用 - PageResult pageResult = testDemoService.getTestDemoPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTestDemo, pageResult.getList().get(0)); - } - - @Test - public void testGetTestDemoList() { - // mock 数据 - TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setType(1); - o.setCategory(2); - o.setRemark("哈哈哈"); - o.setCreateTime(buildTime(2021, 11, 11)); - }); - testDemoMapper.insert(dbTestDemo); - // 测试 name 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName("不匹配"))); - // 测试 status 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 type 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(2))); - // 测试 category 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(1))); - // 测试 remark 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark("呵呵呵"))); - // 测试 createTime 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - TestDemoExportReqVO reqVO = new TestDemoExportReqVO(); - reqVO.setName("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setType(1); - reqVO.setCategory(2); - reqVO.setRemark("哈哈哈"); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)})); - - // 调用 - List list = testDemoService.getTestDemoList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbTestDemo, list.get(0)); - } - -}