From 650c6066ca3401c1ae4bc60b56f35b55a68e92a1 Mon Sep 17 00:00:00 2001 From: aikai Date: Thu, 1 Aug 2024 10:03:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9D=97wms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 3 +- yudao-module-wms/pom.xml | 25 + yudao-module-wms/yudao-module-wms-api/pom.xml | 47 ++ .../yudao/module/wms/api/package-info.java | 4 + .../yudao/module/wms/enums/ApiConstants.java | 21 + .../module/wms/enums/DictTypeConstants.java | 11 + .../module/wms/enums/ErrorCodeConstants.java | 11 + .../yudao-module-wms-biz/Dockerfile | 19 + yudao-module-wms/yudao-module-wms-biz/pom.xml | 170 ++++++ .../module/wms/WmsServerApplication.java | 30 + .../yudao/module/wms/api/package-info.java | 1 + .../admin/redis/RedisController.http | 4 + .../admin/redis/RedisController.java | 43 ++ .../admin/redis/vo/RedisMonitorRespVO.java | 43 ++ .../wms/controller/app/package-info.java | 4 + .../module/wms/controller/package-info.java | 6 + .../module/wms/convert/package-info.java | 6 + .../wms/convert/redis/RedisConvert.java | 29 + ...g Boot 对象转换 MapStruct 入门》.md | 1 + .../yudao/module/wms/enums/package-info.java | 4 + .../wms/framework/codegen/package-info.java | 4 + .../config/AdminServerConfiguration.java | 9 + .../wms/framework/monitor/package-info.java | 4 + ...pring Boot 监控工具 Admin 入门》.md | 1 + .../module/wms/framework/package-info.java | 6 + .../rpc/config/RpcConfiguration.java | 14 + .../wms/framework/rpc/package-info.java | 4 + .../config/SecurityConfiguration.java | 48 ++ .../framework/security/core/package-info.java | 4 + .../yudao/module/wms/job/package-info.java | 4 + .../module/wms/mq/consumer/package-info.java | 4 + .../module/wms/mq/message/package-info.java | 4 + .../module/wms/mq/producer/package-info.java | 4 + .../yudao/module/wms/package-info.java | 9 + .../src/main/resources/application-dev.yaml | 130 ++++ .../src/main/resources/application-local.yaml | 152 +++++ .../src/main/resources/application-prod.yaml | 152 +++++ .../src/main/resources/application.yaml | 162 +++++ .../src/main/resources/bootstrap-dev.yaml | 23 + .../src/main/resources/bootstrap-local.yaml | 23 + .../src/main/resources/bootstrap-prod.yaml | 23 + .../src/main/resources/bootstrap.yaml | 15 + .../codegen/java/controller/controller.vm | 233 ++++++++ .../codegen/java/controller/vo/listReqVO.vm | 45 ++ .../codegen/java/controller/vo/pageReqVO.vm | 47 ++ .../codegen/java/controller/vo/respVO.vm | 54 ++ .../codegen/java/controller/vo/saveReqVO.vm | 65 ++ .../src/main/resources/codegen/java/dal/do.vm | 52 ++ .../main/resources/codegen/java/dal/do_sub.vm | 49 ++ .../main/resources/codegen/java/dal/mapper.vm | 82 +++ .../resources/codegen/java/dal/mapper.xml.vm | 12 + .../resources/codegen/java/dal/mapper_sub.vm | 51 ++ .../resources/codegen/java/enums/errorcode.vm | 22 + .../resources/codegen/java/service/service.vm | 147 +++++ .../codegen/java/service/serviceImpl.vm | 350 +++++++++++ .../codegen/java/test/serviceTest.vm | 168 ++++++ .../src/main/resources/codegen/sql/h2.vm | 37 ++ .../src/main/resources/codegen/sql/sql.vm | 28 + .../main/resources/codegen/vue/api/api.js.vm | 147 +++++ .../vue/views/components/form_sub_erp.vue.vm | 205 +++++++ .../views/components/form_sub_inner.vue.vm | 2 + .../views/components/form_sub_normal.vue.vm | 347 +++++++++++ .../vue/views/components/list_sub_erp.vue.vm | 165 ++++++ .../views/components/list_sub_inner.vue.vm | 4 + .../resources/codegen/vue/views/form.vue.vm | 320 ++++++++++ .../resources/codegen/vue/views/index.vue.vm | 340 +++++++++++ .../main/resources/codegen/vue3/api/api.ts.vm | 111 ++++ .../vue3/views/components/form_sub_erp.vue.vm | 205 +++++++ .../views/components/form_sub_inner.vue.vm | 2 + .../views/components/form_sub_normal.vue.vm | 362 ++++++++++++ .../vue3/views/components/list_sub_erp.vue.vm | 181 ++++++ .../views/components/list_sub_inner.vue.vm | 4 + .../resources/codegen/vue3/views/form.vue.vm | 298 ++++++++++ .../resources/codegen/vue3/views/index.vue.vm | 373 ++++++++++++ .../codegen/vue3_schema/api/api.ts.vm | 46 ++ .../codegen/vue3_schema/views/data.ts.vm | 124 ++++ .../codegen/vue3_schema/views/form.vue.vm | 65 ++ .../codegen/vue3_schema/views/index.vue.vm | 85 +++ .../resources/codegen/vue3_vben/api/api.ts.vm | 32 + .../codegen/vue3_vben/views/data.ts.vm | 236 ++++++++ .../codegen/vue3_vben/views/form.vue.vm | 58 ++ .../codegen/vue3_vben/views/index.vue.vm | 91 +++ .../src/main/resources/file/erweima.jpg | Bin 0 -> 18385 bytes .../src/main/resources/logback-spring.xml | 76 +++ .../service/DefaultDatabaseQueryTest.java | 37 ++ .../codegen/CodegenServiceImplTest.java | 558 ++++++++++++++++++ .../codegen/inner/CodegenBuilderTest.java | 90 +++ .../inner/CodegenEngineAbstractTest.java | 128 ++++ .../codegen/inner/CodegenEngineTest.java | 203 +++++++ .../codegen/inner/CodegenEngineVue2Test.java | 99 ++++ .../codegen/inner/CodegenEngineVue3Test.java | 96 +++ .../service/config/ConfigServiceImplTest.java | 220 +++++++ .../db/DataSourceConfigServiceImplTest.java | 206 +++++++ .../db/DatabaseTableServiceImplTest.java | 91 +++ .../file/FileConfigServiceImplTest.java | 282 +++++++++ .../service/file/FileServiceImplTest.java | 146 +++++ .../logger/ApiAccessLogServiceImplTest.java | 110 ++++ .../logger/ApiErrorLogServiceImplTest.java | 164 +++++ .../test/resources/application-unit-test.yaml | 53 ++ .../resources/codegen/table/category.json | 53 ++ .../test/resources/codegen/table/contact.json | 144 +++++ .../test/resources/codegen/table/student.json | 135 +++++ .../test/resources/codegen/table/teacher.json | 144 +++++ .../codegen/vue2_master_erp/assert.json | 73 +++ .../java/ErrorCodeConstants_手动操作 | 6 + .../java/InfraStudentContactDO | 71 +++ .../java/InfraStudentContactMapper | 30 + .../java/InfraStudentController | 183 ++++++ .../vue2_master_erp/java/InfraStudentDO | 67 +++ .../vue2_master_erp/java/InfraStudentMapper | 30 + .../java/InfraStudentPageReqVO | 34 ++ .../vue2_master_erp/java/InfraStudentRespVO | 60 ++ .../java/InfraStudentSaveReqVO | 52 ++ .../vue2_master_erp/java/InfraStudentService | 139 +++++ .../java/InfraStudentServiceImpl | 180 ++++++ .../java/InfraStudentServiceImplTest | 146 +++++ .../java/InfraStudentTeacherDO | 71 +++ .../java/InfraStudentTeacherMapper | 30 + .../codegen/vue2_master_erp/js/student | 141 +++++ .../resources/codegen/vue2_master_erp/sql/h2 | 17 + .../resources/codegen/vue2_master_erp/sql/sql | 55 ++ .../vue2_master_erp/vue/StudentContactForm | 151 +++++ .../vue2_master_erp/vue/StudentContactList | 129 ++++ .../codegen/vue2_master_erp/vue/StudentForm | 149 +++++ .../vue2_master_erp/vue/StudentTeacherForm | 151 +++++ .../vue2_master_erp/vue/StudentTeacherList | 129 ++++ .../codegen/vue2_master_erp/vue/index | 233 ++++++++ .../vue2_master_erp/xml/InfraStudentMapper | 12 + .../codegen/vue2_master_inner/assert.json | 73 +++ .../java/ErrorCodeConstants_手动操作 | 3 + .../java/InfraStudentContactDO | 71 +++ .../java/InfraStudentContactMapper | 28 + .../java/InfraStudentController | 117 ++++ .../vue2_master_inner/java/InfraStudentDO | 67 +++ .../vue2_master_inner/java/InfraStudentMapper | 30 + .../java/InfraStudentPageReqVO | 34 ++ .../vue2_master_inner/java/InfraStudentRespVO | 60 ++ .../java/InfraStudentSaveReqVO | 58 ++ .../java/InfraStudentService | 77 +++ .../java/InfraStudentServiceImpl | 147 +++++ .../java/InfraStudentServiceImplTest | 146 +++++ .../java/InfraStudentTeacherDO | 71 +++ .../java/InfraStudentTeacherMapper | 28 + .../codegen/vue2_master_inner/js/student | 74 +++ .../codegen/vue2_master_inner/sql/h2 | 17 + .../codegen/vue2_master_inner/sql/sql | 55 ++ .../vue2_master_inner/vue/StudentContactForm | 177 ++++++ .../vue2_master_inner/vue/StudentContactList | 89 +++ .../codegen/vue2_master_inner/vue/StudentForm | 180 ++++++ .../vue2_master_inner/vue/StudentTeacherForm | 127 ++++ .../vue2_master_inner/vue/StudentTeacherList | 93 +++ .../codegen/vue2_master_inner/vue/index | 222 +++++++ .../vue2_master_inner/xml/InfraStudentMapper | 12 + .../codegen/vue2_master_normal/assert.json | 67 +++ .../java/ErrorCodeConstants_手动操作 | 3 + .../java/InfraStudentContactDO | 71 +++ .../java/InfraStudentContactMapper | 28 + .../java/InfraStudentController | 117 ++++ .../vue2_master_normal/java/InfraStudentDO | 67 +++ .../java/InfraStudentMapper | 30 + .../java/InfraStudentPageReqVO | 34 ++ .../java/InfraStudentRespVO | 60 ++ .../java/InfraStudentSaveReqVO | 58 ++ .../java/InfraStudentService | 77 +++ .../java/InfraStudentServiceImpl | 147 +++++ .../java/InfraStudentServiceImplTest | 146 +++++ .../java/InfraStudentTeacherDO | 71 +++ .../java/InfraStudentTeacherMapper | 28 + .../codegen/vue2_master_normal/js/student | 74 +++ .../codegen/vue2_master_normal/sql/h2 | 17 + .../codegen/vue2_master_normal/sql/sql | 55 ++ .../vue2_master_normal/vue/StudentContactForm | 177 ++++++ .../vue2_master_normal/vue/StudentForm | 180 ++++++ .../vue2_master_normal/vue/StudentTeacherForm | 127 ++++ .../codegen/vue2_master_normal/vue/index | 205 +++++++ .../vue2_master_normal/xml/InfraStudentMapper | 12 + .../resources/codegen/vue2_one/assert.json | 49 ++ .../java/ErrorCodeConstants_手动操作 | 3 + .../vue2_one/java/InfraStudentController | 95 +++ .../codegen/vue2_one/java/InfraStudentDO | 67 +++ .../codegen/vue2_one/java/InfraStudentMapper | 30 + .../vue2_one/java/InfraStudentPageReqVO | 34 ++ .../codegen/vue2_one/java/InfraStudentRespVO | 60 ++ .../vue2_one/java/InfraStudentSaveReqVO | 50 ++ .../codegen/vue2_one/java/InfraStudentService | 55 ++ .../vue2_one/java/InfraStudentServiceImpl | 74 +++ .../vue2_one/java/InfraStudentServiceImplTest | 146 +++++ .../resources/codegen/vue2_one/js/student | 53 ++ .../test/resources/codegen/vue2_one/sql/h2 | 17 + .../test/resources/codegen/vue2_one/sql/sql | 55 ++ .../codegen/vue2_one/vue/StudentForm | 149 +++++ .../test/resources/codegen/vue2_one/vue/index | 205 +++++++ .../codegen/vue2_one/xml/InfraStudentMapper | 12 + .../resources/codegen/vue2_tree/assert.json | 49 ++ .../java/ErrorCodeConstants_手动操作 | 8 + .../vue2_tree/java/InfraCategoryController | 94 +++ .../codegen/vue2_tree/java/InfraCategoryDO | 39 ++ .../vue2_tree/java/InfraCategoryListReqVO | 15 + .../vue2_tree/java/InfraCategoryMapper | 34 ++ .../vue2_tree/java/InfraCategoryRespVO | 26 + .../vue2_tree/java/InfraCategorySaveReqVO | 24 + .../vue2_tree/java/InfraCategoryService | 55 ++ .../vue2_tree/java/InfraCategoryServiceImpl | 136 +++++ .../java/InfraCategoryServiceImplTest | 129 ++++ .../resources/codegen/vue2_tree/js/category | 53 ++ .../test/resources/codegen/vue2_tree/sql/h2 | 10 + .../test/resources/codegen/vue2_tree/sql/sql | 55 ++ .../codegen/vue2_tree/vue/CategoryForm | 130 ++++ .../resources/codegen/vue2_tree/vue/index | 161 +++++ .../codegen/vue2_tree/xml/InfraCategoryMapper | 12 + .../codegen/vue3_master_erp/assert.json | 73 +++ .../java/ErrorCodeConstants_手动操作 | 6 + .../java/InfraStudentContactDO | 71 +++ .../java/InfraStudentContactMapper | 30 + .../java/InfraStudentController | 183 ++++++ .../vue3_master_erp/java/InfraStudentDO | 67 +++ .../vue3_master_erp/java/InfraStudentMapper | 30 + .../java/InfraStudentPageReqVO | 34 ++ .../vue3_master_erp/java/InfraStudentRespVO | 60 ++ .../java/InfraStudentSaveReqVO | 52 ++ .../vue3_master_erp/java/InfraStudentService | 139 +++++ .../java/InfraStudentServiceImpl | 180 ++++++ .../java/InfraStudentServiceImplTest | 146 +++++ .../java/InfraStudentTeacherDO | 71 +++ .../java/InfraStudentTeacherMapper | 30 + .../resources/codegen/vue3_master_erp/sql/h2 | 17 + .../resources/codegen/vue3_master_erp/sql/sql | 55 ++ .../codegen/vue3_master_erp/ts/index | 95 +++ .../vue3_master_erp/vue/StudentContactForm | 155 +++++ .../vue3_master_erp/vue/StudentContactList | 146 +++++ .../codegen/vue3_master_erp/vue/StudentForm | 152 +++++ .../vue3_master_erp/vue/StudentTeacherForm | 155 +++++ .../vue3_master_erp/vue/StudentTeacherList | 146 +++++ .../codegen/vue3_master_erp/vue/index | 278 +++++++++ .../vue3_master_erp/xml/InfraStudentMapper | 12 + .../codegen/vue3_master_inner/assert.json | 73 +++ .../java/ErrorCodeConstants_手动操作 | 3 + .../java/InfraStudentContactDO | 71 +++ .../java/InfraStudentContactMapper | 28 + .../java/InfraStudentController | 117 ++++ .../vue3_master_inner/java/InfraStudentDO | 67 +++ .../vue3_master_inner/java/InfraStudentMapper | 30 + .../java/InfraStudentPageReqVO | 34 ++ .../vue3_master_inner/java/InfraStudentRespVO | 60 ++ .../java/InfraStudentSaveReqVO | 58 ++ .../java/InfraStudentService | 77 +++ .../java/InfraStudentServiceImpl | 147 +++++ .../java/InfraStudentServiceImplTest | 146 +++++ .../java/InfraStudentTeacherDO | 71 +++ .../java/InfraStudentTeacherMapper | 28 + .../codegen/vue3_master_inner/sql/h2 | 17 + .../codegen/vue3_master_inner/sql/sql | 55 ++ .../codegen/vue3_master_inner/ts/index | 57 ++ .../vue3_master_inner/vue/StudentContactForm | 174 ++++++ .../vue3_master_inner/vue/StudentContactList | 72 +++ .../codegen/vue3_master_inner/vue/StudentForm | 184 ++++++ .../vue3_master_inner/vue/StudentTeacherForm | 122 ++++ .../vue3_master_inner/vue/StudentTeacherList | 76 +++ .../codegen/vue3_master_inner/vue/index | 267 +++++++++ .../vue3_master_inner/xml/InfraStudentMapper | 12 + .../codegen/vue3_master_normal/assert.json | 67 +++ .../java/ErrorCodeConstants_手动操作 | 3 + .../java/InfraStudentContactDO | 71 +++ .../java/InfraStudentContactMapper | 28 + .../java/InfraStudentController | 117 ++++ .../vue3_master_normal/java/InfraStudentDO | 67 +++ .../java/InfraStudentMapper | 30 + .../java/InfraStudentPageReqVO | 34 ++ .../java/InfraStudentRespVO | 60 ++ .../java/InfraStudentSaveReqVO | 58 ++ .../java/InfraStudentService | 77 +++ .../java/InfraStudentServiceImpl | 147 +++++ .../java/InfraStudentServiceImplTest | 146 +++++ .../java/InfraStudentTeacherDO | 71 +++ .../java/InfraStudentTeacherMapper | 28 + .../codegen/vue3_master_normal/sql/h2 | 17 + .../codegen/vue3_master_normal/sql/sql | 55 ++ .../codegen/vue3_master_normal/ts/index | 57 ++ .../vue3_master_normal/vue/StudentContactForm | 174 ++++++ .../vue3_master_normal/vue/StudentForm | 184 ++++++ .../vue3_master_normal/vue/StudentTeacherForm | 122 ++++ .../codegen/vue3_master_normal/vue/index | 252 ++++++++ .../vue3_master_normal/xml/InfraStudentMapper | 12 + .../resources/codegen/vue3_one/assert.json | 49 ++ .../java/ErrorCodeConstants_手动操作 | 3 + .../vue3_one/java/InfraStudentController | 95 +++ .../codegen/vue3_one/java/InfraStudentDO | 67 +++ .../codegen/vue3_one/java/InfraStudentMapper | 30 + .../vue3_one/java/InfraStudentPageReqVO | 34 ++ .../codegen/vue3_one/java/InfraStudentRespVO | 60 ++ .../vue3_one/java/InfraStudentSaveReqVO | 50 ++ .../codegen/vue3_one/java/InfraStudentService | 55 ++ .../vue3_one/java/InfraStudentServiceImpl | 74 +++ .../vue3_one/java/InfraStudentServiceImplTest | 146 +++++ .../test/resources/codegen/vue3_one/sql/h2 | 17 + .../test/resources/codegen/vue3_one/sql/sql | 55 ++ .../test/resources/codegen/vue3_one/ts/index | 43 ++ .../codegen/vue3_one/vue/StudentForm | 152 +++++ .../test/resources/codegen/vue3_one/vue/index | 252 ++++++++ .../codegen/vue3_one/xml/InfraStudentMapper | 12 + .../resources/codegen/vue3_tree/assert.json | 49 ++ .../java/ErrorCodeConstants_手动操作 | 8 + .../vue3_tree/java/InfraCategoryController | 94 +++ .../codegen/vue3_tree/java/InfraCategoryDO | 39 ++ .../vue3_tree/java/InfraCategoryListReqVO | 15 + .../vue3_tree/java/InfraCategoryMapper | 34 ++ .../vue3_tree/java/InfraCategoryRespVO | 26 + .../vue3_tree/java/InfraCategorySaveReqVO | 24 + .../vue3_tree/java/InfraCategoryService | 55 ++ .../vue3_tree/java/InfraCategoryServiceImpl | 136 +++++ .../java/InfraCategoryServiceImplTest | 129 ++++ .../test/resources/codegen/vue3_tree/sql/h2 | 10 + .../test/resources/codegen/vue3_tree/sql/sql | 55 ++ .../test/resources/codegen/vue3_tree/ts/index | 37 ++ .../codegen/vue3_tree/vue/CategoryForm | 114 ++++ .../resources/codegen/vue3_tree/vue/index | 185 ++++++ .../codegen/vue3_tree/xml/InfraCategoryMapper | 12 + .../src/test/resources/logback.xml | 4 + .../src/test/resources/sql/clean.sql | 12 + .../src/test/resources/sql/create_tables.sql | 228 +++++++ 320 files changed, 26756 insertions(+), 1 deletion(-) create mode 100644 yudao-module-wms/pom.xml create mode 100644 yudao-module-wms/yudao-module-wms-api/pom.xml create mode 100644 yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ApiConstants.java create mode 100644 yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/DictTypeConstants.java create mode 100644 yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/Dockerfile create mode 100644 yudao-module-wms/yudao-module-wms-biz/pom.xml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/WmsServerApplication.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.http create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/vo/RedisMonitorRespVO.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/app/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/redis/RedisConvert.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/enums/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/codegen/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/config/AdminServerConfiguration.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/config/RpcConfiguration.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/config/SecurityConfiguration.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/core/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/job/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/consumer/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/message/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/producer/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/package-info.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-dev.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-local.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-prod.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/application.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-dev.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-local.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-prod.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/controller.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/respVO.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do_sub.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.xml.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper_sub.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/enums/errorcode.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/service.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/serviceImpl.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/test/serviceTest.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/h2.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/sql.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/api/api.js.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/form.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/index.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/api/api.ts.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_erp.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_inner.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_normal.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_erp.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_inner.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/form.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/index.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/form.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/index.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/api/api.ts.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/file/erweima.jpg create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/main/resources/logback-spring.xml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java create mode 100755 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java create mode 100755 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/application-unit-test.yaml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/category.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/contact.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/student.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/teacher.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/js/student create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/js/student create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/js/student create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentContactForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/js/student create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryListReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategorySaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/js/category create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/CategoryForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/xml/InfraCategoryMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/ts/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/ts/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherList create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/ts/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentContactForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentTeacherForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentPageReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentSaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/ts/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/StudentForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/xml/InfraStudentMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/assert.json create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/ErrorCodeConstants_手动操作 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryController create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryDO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryListReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryRespVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategorySaveReqVO create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryService create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImpl create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImplTest create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/h2 create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/ts/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/CategoryForm create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/index create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/xml/InfraCategoryMapper create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/logback.xml create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/clean.sql create mode 100644 yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/create_tables.sql diff --git a/pom.xml b/pom.xml index 632ab9e5..e6c4b20a 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ yudao-module-mp yudao-module-mall zn-module-smartfactory + yudao-module-wms ${project.artifactId} @@ -172,4 +173,4 @@ - \ No newline at end of file + diff --git a/yudao-module-wms/pom.xml b/yudao-module-wms/pom.xml new file mode 100644 index 00000000..0a917531 --- /dev/null +++ b/yudao-module-wms/pom.xml @@ -0,0 +1,25 @@ + + + + cn.iocoder.cloud + yudao + ${revision} + + 4.0.0 + + yudao-module-wms-api + yudao-module-wms-biz + + yudao-module-wms + pom + + ${project.artifactId} + + infra 模块,主要提供两块能力: + 1. 我们放基础设施的运维与管理,支撑上层的通用与核心业务。 例如说:定时任务的管理、服务器的信息等等 + 2. 研发工具,提升研发效率与质量。 例如说:代码生成器、接口文档等等 + + + diff --git a/yudao-module-wms/yudao-module-wms-api/pom.xml b/yudao-module-wms/yudao-module-wms-api/pom.xml new file mode 100644 index 00000000..cb1847b6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-api/pom.xml @@ -0,0 +1,47 @@ + + + + cn.iocoder.cloud + yudao-module-wms + ${revision} + + 4.0.0 + yudao-module-wms-api + jar + + ${project.artifactId} + + infra 模块 API,暴露给其它模块调用 + + + + + cn.iocoder.cloud + yudao-common + + + + + org.springdoc + springdoc-openapi-ui + provided + + + + + org.springframework.boot + spring-boot-starter-validation + true + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + true + + + + diff --git a/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java new file mode 100644 index 00000000..299f681f --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java @@ -0,0 +1,4 @@ +/** + * infra API 包,定义暴露给其它模块的 API + */ +package cn.iocoder.yudao.module.wms.api; diff --git a/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ApiConstants.java b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ApiConstants.java new file mode 100644 index 00000000..3d534436 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ApiConstants.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.wms.enums; + +import cn.iocoder.yudao.framework.common.enums.RpcConstants; + +/** + * API 相关的枚举 + */ +public class ApiConstants { + + /** + * 服务名 + *

+ * 注意,需要保证和 spring.application.name 保持一致 + */ + public static final String NAME = "wms-server"; + + public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/wms"; + + public static final String VERSION = "1.0.0"; + +} diff --git a/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/DictTypeConstants.java b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/DictTypeConstants.java new file mode 100644 index 00000000..2a0e3085 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/DictTypeConstants.java @@ -0,0 +1,11 @@ +package cn.iocoder.yudao.module.wms.enums; + +/** + * Infra 字典类型的枚举类 + * + + */ +public interface DictTypeConstants { + + +} diff --git a/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java new file mode 100644 index 00000000..f4764657 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-api/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java @@ -0,0 +1,11 @@ +package cn.iocoder.yudao.module.wms.enums; + +/** + * Infra 错误码枚举类 + *

+ * infra 系统,使用 1-001-000-000 段 + */ +public interface ErrorCodeConstants { + + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/Dockerfile b/yudao-module-wms/yudao-module-wms-biz/Dockerfile new file mode 100644 index 00000000..578cba76 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/Dockerfile @@ -0,0 +1,19 @@ +## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 +## 感谢复旦核博士的建议!灰子哥,牛皮! +FROM eclipse-temurin:8-jre + +## 创建目录,并使用它作为工作目录 +RUN mkdir -p /yudao-module-infra-biz +WORKDIR /yudao-module-infra-biz +## 将后端项目的 Jar 文件,复制到镜像中 +COPY ./target/yudao-module-infra-biz.jar app.jar + +## 设置 TZ 时区 +## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 +ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" + +## 暴露后端项目的 48080 端口 +EXPOSE 48082 + +## 启动后端项目 +CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-wms/yudao-module-wms-biz/pom.xml b/yudao-module-wms/yudao-module-wms-biz/pom.xml new file mode 100644 index 00000000..1a44b3d5 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/pom.xml @@ -0,0 +1,170 @@ + + + + cn.iocoder.cloud + yudao-module-wms + ${revision} + + 4.0.0 + yudao-module-wms-biz + jar + + ${project.artifactId} + + infra 模块,主要提供两块能力: + 1. 我们放基础设施的运维与管理,支撑上层的通用与核心业务。 例如说:定时任务的管理、服务器的信息等等 + 2. 研发工具,提升研发效率与质量。 例如说:代码生成器、接口文档等等 + + + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + + + cn.iocoder.cloud + yudao-module-wms-api + ${revision} + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-banner + + + cn.iocoder.cloud + yudao-spring-boot-starter-biz-operatelog + + + cn.iocoder.cloud + yudao-spring-boot-starter-biz-tenant + + + cn.iocoder.cloud + yudao-spring-boot-starter-biz-error-code + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-security + + + + cn.iocoder.cloud + yudao-spring-boot-starter-websocket + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-mybatis + + + com.baomidou + mybatis-plus-generator + + + + cn.iocoder.cloud + yudao-spring-boot-starter-redis + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-rpc + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-job + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-mq + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-test + test + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-excel + + + + org.apache.velocity + velocity-engine-core + + + + cn.smallbun.screw + screw-core + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-monitor + + + + de.codecentric + spring-boot-admin-starter-server + + + + + cn.iocoder.cloud + yudao-spring-boot-starter-file + + + + + + ${project.artifactId} + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/WmsServerApplication.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/WmsServerApplication.java new file mode 100644 index 00000000..97ecf3a8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/WmsServerApplication.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.wms; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 项目的启动类 + *

+ * + * + * + * + + */ +@SpringBootApplication +public class WmsServerApplication { + + public static void main(String[] args) { + // + // + // + + SpringApplication.run(WmsServerApplication.class, args); + + // + // + // + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java new file mode 100644 index 00000000..b8122700 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/api/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.wms.api; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.http b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.http new file mode 100644 index 00000000..8a0e70fd --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.http @@ -0,0 +1,4 @@ +### 请求 /infra/redis/get-monitor-info 接口 => 成功 +GET {{baseUrl}}/infra/redis/get-monitor-info +Authorization: Bearer {{token}} +tenant-id: {{adminTenentId}} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.java new file mode 100644 index 00000000..76cc7ec3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/RedisController.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.wms.controller.admin.redis; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.wms.controller.admin.redis.vo.RedisMonitorRespVO; +import cn.iocoder.yudao.module.wms.convert.redis.RedisConvert; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Properties; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - Redis 监控") +@RestController +@RequestMapping("/infra/redis") +public class RedisController { + + @Resource + private StringRedisTemplate stringRedisTemplate; + + @GetMapping("/get-monitor-info") + @Operation(summary = "获得 Redis 监控信息") + @PreAuthorize("@ss.hasPermission('infra:redis:get-monitor-info')") + public CommonResult getRedisMonitorInfo() { + // 获得 Redis 统计信息 + Properties info = stringRedisTemplate.execute((RedisCallback) RedisServerCommands::info); + Long dbSize = stringRedisTemplate.execute(RedisServerCommands::dbSize); + Properties commandStats = stringRedisTemplate.execute(( + RedisCallback) connection -> connection.info("commandstats")); + assert commandStats != null; // 断言,避免警告 + // 拼接结果返回 + return success(RedisConvert.INSTANCE.build(info, dbSize, commandStats)); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/vo/RedisMonitorRespVO.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/vo/RedisMonitorRespVO.java new file mode 100644 index 00000000..5cb6f166 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/redis/vo/RedisMonitorRespVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.wms.controller.admin.redis.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.List; +import java.util.Properties; + +@Schema(description = "管理后台 - Redis 监控信息 Response VO") +@Data +@Builder +@AllArgsConstructor +public class RedisMonitorRespVO { + + @Schema(description = "Redis info 指令结果,具体字段,查看 Redis 文档", requiredMode = Schema.RequiredMode.REQUIRED) + private Properties info; + + @Schema(description = "Redis key 数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long dbSize; + + @Schema(description = "CommandStat 数组", requiredMode = Schema.RequiredMode.REQUIRED) + private List commandStats; + + @Schema(description = "Redis 命令统计结果") + @Data + @Builder + @AllArgsConstructor + public static class CommandStat { + + @Schema(description = "Redis 命令", requiredMode = Schema.RequiredMode.REQUIRED, example = "get") + private String command; + + @Schema(description = "调用次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long calls; + + @Schema(description = "消耗 CPU 秒数", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") + private Long usec; + + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/app/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/app/package-info.java new file mode 100644 index 00000000..fa43e8b6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/app/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.wms.controller.app; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/package-info.java new file mode 100644 index 00000000..c75d9df6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/controller/package-info.java @@ -0,0 +1,6 @@ +/** + * 提供 RESTful API 给前端: + * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 + * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 + */ +package cn.iocoder.yudao.module.wms.controller; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/package-info.java new file mode 100644 index 00000000..d5c4aaf1 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/package-info.java @@ -0,0 +1,6 @@ +/** + * 提供 POJO 类的实体转换 + * + * 目前使用 MapStruct 框架 + */ +package cn.iocoder.yudao.module.wms.convert; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/redis/RedisConvert.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/redis/RedisConvert.java new file mode 100644 index 00000000..9ef41d70 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/redis/RedisConvert.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.wms.convert.redis; + +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.module.wms.controller.admin.redis.vo.RedisMonitorRespVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.ArrayList; +import java.util.Properties; + +@Mapper +public interface RedisConvert { + + RedisConvert INSTANCE = Mappers.getMapper(RedisConvert.class); + + default RedisMonitorRespVO build(Properties info, Long dbSize, Properties commandStats) { + RedisMonitorRespVO respVO = RedisMonitorRespVO.builder().info(info).dbSize(dbSize) + .commandStats(new ArrayList<>(commandStats.size())).build(); + commandStats.forEach((key, value) -> { + respVO.getCommandStats().add(RedisMonitorRespVO.CommandStat.builder() + .command(StrUtil.subAfter((String) key, "cmdstat_", false)) + .calls(Long.valueOf(StrUtil.subBetween((String) value, "calls=", ","))) + .usec(Long.valueOf(StrUtil.subBetween((String) value, "usec=", ","))) + .build()); + }); + return respVO; + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md new file mode 100644 index 00000000..8153487b --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md @@ -0,0 +1 @@ + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/enums/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/enums/package-info.java new file mode 100644 index 00000000..2c311335 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/enums/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.wms.enums; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/codegen/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/codegen/package-info.java new file mode 100644 index 00000000..ce320958 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/codegen/package-info.java @@ -0,0 +1,4 @@ +/** + * 代码生成器 + */ +package cn.iocoder.yudao.module.wms.framework.codegen; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/config/AdminServerConfiguration.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/config/AdminServerConfiguration.java new file mode 100644 index 00000000..d7f5d1e3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/config/AdminServerConfiguration.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.module.wms.framework.monitor.config; + +import de.codecentric.boot.admin.server.config.EnableAdminServer; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@EnableAdminServer +public class AdminServerConfiguration { +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/package-info.java new file mode 100644 index 00000000..810c98dc --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/package-info.java @@ -0,0 +1,4 @@ +/** + * 使用 Spring Boot Admin 实现简单的监控平台 + */ +package cn.iocoder.yudao.module.wms.framework.monitor; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md new file mode 100644 index 00000000..a1e36768 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md @@ -0,0 +1 @@ + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/package-info.java new file mode 100644 index 00000000..2ea1946a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/package-info.java @@ -0,0 +1,6 @@ +/** + * 属于 infra 模块的 framework 封装 + * + + */ +package cn.iocoder.yudao.module.wms.framework; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/config/RpcConfiguration.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/config/RpcConfiguration.java new file mode 100644 index 00000000..034d8457 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/config/RpcConfiguration.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.wms.framework.rpc.config; + +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.PostApi; +import cn.iocoder.yudao.module.system.api.equipment.AttendanceMachineApi; +import cn.iocoder.yudao.module.system.api.social.SocialClientApi; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@EnableFeignClients(clients = { }) +public class RpcConfiguration { +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/package-info.java new file mode 100644 index 00000000..39346d8c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/rpc/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.wms.framework.rpc; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/config/SecurityConfiguration.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/config/SecurityConfiguration.java new file mode 100644 index 00000000..68ecd4a1 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/config/SecurityConfiguration.java @@ -0,0 +1,48 @@ +package cn.iocoder.yudao.module.wms.framework.security.config; + +import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; +import cn.iocoder.yudao.module.infra.enums.ApiConstants; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; + +/** + * Infra 模块的 Security 配置 + */ +@Configuration(proxyBeanMethods = false, value = "infraSecurityConfiguration") +public class SecurityConfiguration { + + @Value("${spring.boot.admin.context-path:''}") + private String adminSeverContextPath; + + @Bean("infraAuthorizeRequestsCustomizer") + public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { + return new AuthorizeRequestsCustomizer() { + + @Override + public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { + // Swagger 接口文档 + registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 + .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI + // Spring Boot Actuator 的安全配置 + registry.antMatchers("/actuator").anonymous() + .antMatchers("/actuator/**").anonymous(); + // Druid 监控 + registry.antMatchers("/druid/**").anonymous(); + // Spring Boot Admin Server 的安全配置 + registry.antMatchers(adminSeverContextPath).anonymous() + .antMatchers(adminSeverContextPath + "/**").anonymous(); + // 文件读取 + registry.antMatchers(buildAdminApi("/infra/file/*/get/**")).permitAll(); + + // TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案 + // RPC 服务的安全配置 + registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); + } + + }; + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/core/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/core/package-info.java new file mode 100644 index 00000000..0c573aa6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/framework/security/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.wms.framework.security.core; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/job/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/job/package-info.java new file mode 100644 index 00000000..79a140a7 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/job/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位,无特殊含义 + */ +package cn.iocoder.yudao.module.wms.job; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/consumer/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/consumer/package-info.java new file mode 100644 index 00000000..fda7b30a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/consumer/package-info.java @@ -0,0 +1,4 @@ +/** + * 消息队列的消费者 + */ +package cn.iocoder.yudao.module.wms.mq.consumer; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/message/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/message/package-info.java new file mode 100644 index 00000000..e8404c0a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/message/package-info.java @@ -0,0 +1,4 @@ +/** + * 消息队列的消息 + */ +package cn.iocoder.yudao.module.wms.mq.message; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/producer/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/producer/package-info.java new file mode 100644 index 00000000..69baf4eb --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/mq/producer/package-info.java @@ -0,0 +1,4 @@ +/** + * 消息队列的生产者 + */ +package cn.iocoder.yudao.module.wms.mq.producer; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/package-info.java b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/package-info.java new file mode 100644 index 00000000..14eb95dd --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/java/cn/iocoder/yudao/module/wms/package-info.java @@ -0,0 +1,9 @@ +/** + * infra 模块,主要提供两块能力: + * 1. 我们放基础设施的运维与管理,支撑上层的通用与核心业务。 例如说:定时任务的管理、服务器的信息等等 + * 2. 研发工具,提升研发效率与质量。 例如说:代码生成器、接口文档等等 + * + * 1. Controller URL:以 /infra/ 开头,避免和其它 Module 冲突 + * 2. DataObject 表名:以 infra_ 开头,方便在数据库中区分 + */ +package cn.iocoder.yudao.module.wms; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-dev.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-dev.yaml new file mode 100644 index 00000000..3f827691 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-dev.yaml @@ -0,0 +1,130 @@ +--- #################### 数据库相关配置 #################### +spring: + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 5 # 初始连接数 + min-idle: 10 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + name: ruoyi-vue-pro + url: jdbc:mysql://192.168.1.105:3306/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + driver-class-name: com.mysql.jdbc.Driver + username: root + password: yhtkj@2024! + slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 + name: ruoyi-vue-pro + url: jdbc:mysql://192.168.1.105:3306/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + driver-class-name: com.mysql.jdbc.Driver + username: root + password: yhtkj@2024! + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 192.168.1.105 # 地址 + port: 6379 # 端口 + database: 1 # 数据库索引 + password: yhtkj@2024! # 密码,建议生产环境开启 + +--- #################### MQ 消息队列相关配置 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv + +spring: + # RabbitMQ 配置项,对应 RabbitProperties 配置类 + rabbitmq: + host: 127.0.0.1 # RabbitMQ 服务的地址 + port: 5672 # RabbitMQ 服务的端口 + username: guest # RabbitMQ 服务的账号 + password: guest # RabbitMQ 服务的密码 + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 + +--- #################### 定时任务相关配置 #################### +xxl: + job: + enabled: false # 是否开启调度中心,默认为 true 开启 + admin: + addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 + +--- #################### 监控相关配置 #################### + +# Actuator 监控端点的配置项 +management: + endpoints: + web: + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator + exposure: + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 + +# Spring Boot Admin 配置项 +spring: + boot: + admin: + # Spring Boot Admin Client 客户端的相关配置 + client: + instance: + service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] + # Spring Boot Admin Server 服务端的相关配置 + context-path: /admin # 配置 Spring + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + env: # 多环境的配置项 + tag: ${HOSTNAME} + security: + mock-enable: true + xss: + enable: false + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + access-log: # 访问日志的配置项 + enable: false + error-code: # 错误码相关配置项 + enable: false + demo: false # 关闭演示模式 \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-local.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-local.yaml new file mode 100644 index 00000000..83fce03f --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-local.yaml @@ -0,0 +1,152 @@ +--- #################### 数据库相关配置 #################### +spring: + + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + - de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置 + - de.codecentric.boot.admin.server.cloud.config.AdminServerDiscoveryAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置 + - de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置 + - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 1 # 初始连接数 + min-idle: 1 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + name: ruoyi-vue-pro + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 + username: root + password: root + # username: sa + # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W + slave: # 模拟从库,可根据自己需要修改 + name: ruoyi-vue-pro + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 + username: root + password: root + # username: sa + # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 127.0.0.1 # 地址 + port: 6379 # 端口 + database: 0 # 数据库索引 +# password: 123456 # 密码,建议生产环境开启 + +--- #################### MQ 消息队列相关配置 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv + +spring: + # RabbitMQ 配置项,对应 RabbitProperties 配置类 + rabbitmq: + host: 127.0.0.1 # RabbitMQ 服务的地址 + port: 5672 # RabbitMQ 服务的端口 + username: guest # RabbitMQ 服务的账号 + password: guest # RabbitMQ 服务的密码 + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 + +--- #################### 定时任务相关配置 #################### +xxl: + job: + enabled: false # 是否开启调度中心,默认为 true 开启 + admin: + addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 + +--- #################### 监控相关配置 #################### + +# Actuator 监控端点的配置项 +management: + endpoints: + web: + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator + exposure: + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 + +# Spring Boot Admin 配置项 +spring: + boot: + admin: + # Spring Boot Admin Client 客户端的相关配置 + client: + instance: + service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] + # Spring Boot Admin Server 服务端的相关配置 + context-path: /admin # 配置 Spring + +# 日志文件配置 +logging: + level: + # 配置自己写的 MyBatis Mapper 打印日志 + cn.iocoder.yudao.module.wms.dal.mysql: debug + cn.iocoder.yudao.module.wms.dal.mysql.file.FileConfigMapper: INFO # 配置 FileConfigMapper 的日志级别为 info + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + env: # 多环境的配置项 + tag: ${HOSTNAME} + security: + mock-enable: true + xss: + enable: false + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + access-log: # 访问日志的配置项 + enable: false + error-code: # 错误码相关配置项 + enable: false + demo: false # 关闭演示模式 diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-prod.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-prod.yaml new file mode 100644 index 00000000..fcff149d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application-prod.yaml @@ -0,0 +1,152 @@ +--- #################### 数据库相关配置 #################### +spring: + + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + - de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置 + - de.codecentric.boot.admin.server.cloud.config.AdminServerDiscoveryAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置 + - de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置 + - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 1 # 初始连接数 + min-idle: 1 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + name: ruoyi-vue-pro + url: jdbc:mysql://rm-bp1yloyj508qld78jno.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 + username: root + password: Znalyrds2024 + # username: sa + # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W + slave: # 模拟从库,可根据自己需要修改 + name: ruoyi-vue-pro + url: jdbc:mysql://rm-bp1yloyj508qld78jno.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 + username: root + password: Znalyrds2024 + # username: sa + # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 127.0.0.1 # 地址 + port: 6379 # 端口 + database: 0 # 数据库索引 + password: ZNredis2024! # 密码,建议生产环境开启 + +--- #################### MQ 消息队列相关配置 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv + +spring: + # RabbitMQ 配置项,对应 RabbitProperties 配置类 + rabbitmq: + host: 127.0.0.1 # RabbitMQ 服务的地址 + port: 5672 # RabbitMQ 服务的端口 + username: guest # RabbitMQ 服务的账号 + password: guest # RabbitMQ 服务的密码 + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 + +--- #################### 定时任务相关配置 #################### +xxl: + job: + enabled: false # 是否开启调度中心,默认为 true 开启 + admin: + addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 + +--- #################### 监控相关配置 #################### + +# Actuator 监控端点的配置项 +management: + endpoints: + web: + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator + exposure: + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 + +# Spring Boot Admin 配置项 +spring: + boot: + admin: + # Spring Boot Admin Client 客户端的相关配置 + client: + instance: + service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] + # Spring Boot Admin Server 服务端的相关配置 + context-path: /admin # 配置 Spring + +# 日志文件配置 +logging: + level: + # 配置自己写的 MyBatis Mapper 打印日志 + cn.iocoder.yudao.module.wms.dal.mysql: debug + cn.iocoder.yudao.module.wms.dal.mysql.file.FileConfigMapper: INFO # 配置 FileConfigMapper 的日志级别为 info + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + env: # 多环境的配置项 + tag: ${HOSTNAME} + security: + mock-enable: true + xss: + enable: false + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + access-log: # 访问日志的配置项 + enable: false + error-code: # 错误码相关配置项 + enable: false + demo: false # 关闭演示模式 diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application.yaml new file mode 100644 index 00000000..c953f31d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/application.yaml @@ -0,0 +1,162 @@ +spring: + main: + allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 + allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 + + # Servlet 配置 + servlet: + # 文件上传相关配置项 + multipart: + max-file-size: 16MB # 单个文件大小 + max-request-size: 32MB # 设置总上传的文件大小 + mvc: + pathmatch: + matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 + + # Jackson 配置项 + jackson: + serialization: + write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 + fail-on-empty-beans: false # 允许序列化无属性的 Bean + + # Cache 配置项 + cache: + type: REDIS + redis: + time-to-live: 1h # 设置过期时间为 1 小时 + +--- #################### 接口文档配置 #################### + +springdoc: + api-docs: + enabled: true # 1. 是否开启 Swagger 接文档的元数据 + path: /v3/api-docs + swagger-ui: + enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 + path: /swagger-ui.html + default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 + +knife4j: + enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 + setting: + language: zh_cn + +# MyBatis Plus 的配置项 +mybatis-plus: + configuration: + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 + global-config: + db-config: + id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 + # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 + # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 + # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + banner: false # 关闭控制台的 Banner 打印 + type-aliases-package: ${yudao.info.base-package}.dal.dataobject + encryptor: + password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 + +mybatis-plus-join: + banner: false # 关闭控制台的 Banner 打印 + +# Spring Data Redis 配置 +spring: + data: + redis: + repositories: + enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 + +--- #################### RPC 远程调用相关配置 #################### + +--- #################### 消息队列相关 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + # Producer 配置项 + producer: + group: ${spring.application.name}_PRODUCER # 生产者分组 + +spring: + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + # Kafka Producer 配置项 + producer: + acks: 1 # 0-不应答。1-leader 应答。all-所有 leader 和 follower 应答。 + retries: 3 # 发送失败时,重试发送的次数 + value-serializer: org.springframework.kafka.support.serializer.JsonSerializer # 消息的 value 的序列化 + # Kafka Consumer 配置项 + consumer: + auto-offset-reset: earliest # 设置消费者分组最初的消费进度为 earliest 。可参考博客 https://blog.csdn.net/lishuangzhe7047/article/details/74530417 理解 + value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer + properties: + spring.json.trusted.packages: '*' + # Kafka Consumer Listener 监听器配置 + listener: + missing-topics-fatal: false # 消费监听接口监听的主题不存在时,默认会报错。所以通过设置为 false ,解决报错 + +--- #################### 定时任务相关配置 #################### + +xxl: + job: + executor: + appname: ${spring.application.name} # 执行器 AppName + logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 + accessToken: default_token # 执行器通讯TOKEN + +--- #################### 芋道相关配置 #################### + +yudao: + info: + version: 1.0.0 + base-package: cn.iocoder.yudao.module.wms + web: + admin-ui: + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 + websocket: + enable: true # websocket的开关 + path: /wms/ws # 路径 + sender-type: local # 消息发送的类型,可选值为 local、redis、rocketmq、kafka、rabbitmq + sender-rocketmq: + topic: ${spring.application.name}-websocket # 消息发送的 RocketMQ Topic + consumer-group: ${spring.application.name}-websocket-consumer # 消息发送的 RocketMQ Consumer Group + sender-rabbitmq: + exchange: ${spring.application.name}-websocket-exchange # 消息发送的 RabbitMQ Exchange + queue: ${spring.application.name}-websocket-queue # 消息发送的 RabbitMQ Queue + sender-kafka: + topic: ${spring.application.name}-websocket # 消息发送的 Kafka Topic + consumer-group: ${spring.application.name}-websocket-consumer # 消息发送的 Kafka Consumer Group + swagger: + title: wms管理后台 + description: 提供管理员管理的所有功能 + version: ${yudao.info.version} + base-package: ${yudao.info.base-package} + codegen: + base-package: cn.iocoder.yudao + db-schemas: ${spring.datasource.dynamic.datasource.master.name} + front-type: 10 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类 + error-code: # 错误码相关配置项 + constants-class-list: + - cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants + tenant: # 多租户相关配置项 + enable: true + ignore-urls: + - /admin-api/wms/file/*/get/** # 获取图片,和租户无关 + ignore-tables: + - wms_codegen_column + - wms_codegen_table + - wms_test_demo + - wms_config + - wms_file_config + - wms_file + - wms_file_content + - wms_job + - wms_job_log + - wms_job_log + - wms_data_source_config + - sys_region + +debug: false diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-dev.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-dev.yaml new file mode 100644 index 00000000..2de0efbf --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-dev.yaml @@ -0,0 +1,23 @@ +--- #################### 注册中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: 127.0.0.1:8848 + discovery: + namespace: dev # 命名空间。这里使用 dev 开发环境 + metadata: + version: 1.0.0 # 服务实例的版本号,可用于灰度发布 + +--- #################### 配置中心相关配置 #################### + +spring: + cloud: + nacos: + # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 + config: + server-addr: 127.0.0.1:8848 # Nacos 服务器地址 + namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name + file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-local.yaml new file mode 100644 index 00000000..2de0efbf --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-local.yaml @@ -0,0 +1,23 @@ +--- #################### 注册中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: 127.0.0.1:8848 + discovery: + namespace: dev # 命名空间。这里使用 dev 开发环境 + metadata: + version: 1.0.0 # 服务实例的版本号,可用于灰度发布 + +--- #################### 配置中心相关配置 #################### + +spring: + cloud: + nacos: + # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 + config: + server-addr: 127.0.0.1:8848 # Nacos 服务器地址 + namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name + file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-prod.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-prod.yaml new file mode 100644 index 00000000..4e48a732 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap-prod.yaml @@ -0,0 +1,23 @@ +--- #################### 注册中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: 47.97.8.94:8848 + discovery: + namespace: prod # 命名空间。这里使用 dev 开发环境 + metadata: + version: 1.0.0 # 服务实例的版本号,可用于灰度发布 + +--- #################### 配置中心相关配置 #################### + +spring: + cloud: + nacos: + # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 + config: + server-addr: 47.97.8.94:8848 # Nacos 服务器地址 + namespace: prod # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name + file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap.yaml b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap.yaml new file mode 100644 index 00000000..dd00255e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/bootstrap.yaml @@ -0,0 +1,15 @@ +spring: + application: + name: wms-server + + profiles: + active: local #local +# active: prod + +server: + port: 48088 + +# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/controller.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/controller.vm new file mode 100644 index 00000000..4c047c94 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/controller.vm @@ -0,0 +1,233 @@ +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +#if ($sceneEnum.scene == 1)import org.springframework.security.access.prepost.PreAuthorize;#end + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import ${PageParamClassName}; +import ${PageResultClassName}; +import ${CommonResultClassName}; +import ${BeanUtils}; +import static ${CommonResultClassName}.success; + +import ${ExcelUtilsClassName}; + +import ${OperateLogClassName}; +import static ${OperateTypeEnumClassName}.*; + +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO; +#end +import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; + +@Tag(name = "${sceneEnum.name} - ${table.classComment}") +@RestController +##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写 +@RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}") +@Validated +public class ${sceneEnum.prefixClass}${table.className}Controller { + + @Resource + private ${table.className}Service ${classNameVar}Service; + + @PostMapping("/create") + @Operation(summary = "创建${table.classComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')") +#end + public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO) { + return success(${classNameVar}Service.create${simpleClassName}(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新${table.classComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')") +#end + public CommonResult update${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO) { + ${classNameVar}Service.update${simpleClassName}(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除${table.classComment}") + @Parameter(name = "id", description = "编号", required = true) +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')") +#end + public CommonResult delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { + ${classNameVar}Service.delete${simpleClassName}(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得${table.classComment}") + @Parameter(name = "id", description = "编号", required = true, example = "1024") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") +#end + public CommonResult<${sceneEnum.prefixClass}${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { + ${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id); + return success(BeanUtils.toBean(${classNameVar}, ${sceneEnum.prefixClass}${table.className}RespVO.class)); + } + +#if ( $table.templateType != 2 ) + @GetMapping("/page") + @Operation(summary = "获得${table.classComment}分页") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") +#end + public CommonResult> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) { + PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageReqVO); + return success(BeanUtils.toBean(pageResult, ${sceneEnum.prefixClass}${table.className}RespVO.class)); + } + +## 特殊:树表专属逻辑(树不需要分页接口) +#else + @GetMapping("/list") + @Operation(summary = "获得${table.classComment}列表") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") +#end + public CommonResult> get${simpleClassName}List(@Valid ${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO) { + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(listReqVO); + return success(BeanUtils.toBean(list, ${sceneEnum.prefixClass}${table.className}RespVO.class)); + } + +#end + @GetMapping("/export-excel") + @Operation(summary = "导出${table.classComment} Excel") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')") +#end + @OperateLog(type = EXPORT) +#if ( $table.templateType != 2 ) + public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}Page(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}RespVO.class, + BeanUtils.toBean(list, ${table.className}RespVO.class)); + } +## 特殊:树表专属逻辑(树不需要分页接口) +#else + public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO, + HttpServletResponse response) throws IOException { + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(listReqVO); + // 导出 Excel + ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}RespVO.class, + BeanUtils.toBean(list, ${table.className}RespVO.class)); + } +#end + +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($subSimpleClassName = $subSimpleClassNames.get($index)) +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 +#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) +#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index)) +#set ($subClassNameVar = $subClassNameVars.get($index)) + // ==================== 子表($subTable.classComment) ==================== + +## 情况一:MASTER_ERP 时,需要分查询页子表 +#if ( $table.templateType == 11 ) + @GetMapping("/${subSimpleClassName_strikeCase}/page") + @Operation(summary = "获得${subTable.classComment}分页") + @Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") +#end + public CommonResult> get${subSimpleClassName}Page(PageParam pageReqVO, + @RequestParam("${subJoinColumn.javaField}") ${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return success(${classNameVar}Service.get${subSimpleClassName}Page(pageReqVO, ${subJoinColumn.javaField})); + } + +## 情况二:非 MASTER_ERP 时,需要列表查询子表 +#else + #if ( $subTable.subJoinMany ) + @GetMapping("/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}") + @Operation(summary = "获得${subTable.classComment}列表") + @Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") +#end + public CommonResult> get${subSimpleClassName}ListBy${SubJoinColumnName}(@RequestParam("${subJoinColumn.javaField}") ${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return success(${classNameVar}Service.get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaField})); + } + + #else + @GetMapping("/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}") + @Operation(summary = "获得${subTable.classComment}") + @Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") +#end + public CommonResult<${subTable.className}DO> get${subSimpleClassName}By${SubJoinColumnName}(@RequestParam("${subJoinColumn.javaField}") ${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return success(${classNameVar}Service.get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField})); + } + + #end +#end +## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作 +#if ( $table.templateType == 11 ) + @PostMapping("/${subSimpleClassName_strikeCase}/create") + @Operation(summary = "创建${subTable.classComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')") +#end + public CommonResult<${subPrimaryColumn.javaType}> create${subSimpleClassName}(@Valid @RequestBody ${subTable.className}DO ${subClassNameVar}) { + return success(${classNameVar}Service.create${subSimpleClassName}(${subClassNameVar})); + } + + @PutMapping("/${subSimpleClassName_strikeCase}/update") + @Operation(summary = "更新${subTable.classComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')") +#end + public CommonResult update${subSimpleClassName}(@Valid @RequestBody ${subTable.className}DO ${subClassNameVar}) { + ${classNameVar}Service.update${subSimpleClassName}(${subClassNameVar}); + return success(true); + } + + @DeleteMapping("/${subSimpleClassName_strikeCase}/delete") + @Parameter(name = "id", description = "编号", required = true) + @Operation(summary = "删除${subTable.classComment}") +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')") +#end + public CommonResult delete${subSimpleClassName}(@RequestParam("id") ${subPrimaryColumn.javaType} id) { + ${classNameVar}Service.delete${subSimpleClassName}(id); + return success(true); + } + + @GetMapping("/${subSimpleClassName_strikeCase}/get") + @Operation(summary = "获得${subTable.classComment}") + @Parameter(name = "id", description = "编号", required = true) +#if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") +#end + public CommonResult<${subTable.className}DO> get${subSimpleClassName}(@RequestParam("id") ${subPrimaryColumn.javaType} id) { + return success(${classNameVar}Service.get${subSimpleClassName}(id)); + } + +#end +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm new file mode 100644 index 00000000..46b6a259 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm @@ -0,0 +1,45 @@ +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import ${PageParamClassName}; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#break +#end +#end +## 处理 LocalDateTime 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDateTime") +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +#break +#end +#end +## 字段模板 +#macro(columnTpl $prefix $prefixStr) + @Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; +#end + +@Schema(description = "${sceneEnum.name} - ${table.classComment}列表 Request VO") +@Data +public class ${sceneEnum.prefixClass}${table.className}ListReqVO { + +#foreach ($column in $columns) +#if (${column.listOperation})##查询操作 +#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 + @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private ${column.javaType}[] ${column.javaField}; +#else##情况二,非 Between 的时间 + #columnTpl('', '') +#end + +#end +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm new file mode 100644 index 00000000..003bac90 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm @@ -0,0 +1,47 @@ +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import ${PageParamClassName}; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#break +#end +#end +## 处理 LocalDateTime 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperationCondition} && ${column.javaType} == "LocalDateTime") +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +#break +#end +#end +## 字段模板 +#macro(columnTpl $prefix $prefixStr) + @Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; +#end + +@Schema(description = "${sceneEnum.name} - ${table.classComment}分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam { + +#foreach ($column in $columns) +#if (${column.listOperation})##查询操作 +#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 + @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private ${column.javaType}[] ${column.javaField}; +#else##情况二,非 Between 的时间 + #columnTpl('', '') +#end + +#end +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/respVO.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/respVO.vm new file mode 100644 index 00000000..54c16671 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/respVO.vm @@ -0,0 +1,54 @@ +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +## 处理 BigDecimal 字段的引入 +import java.util.*; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#break +#end +#end +## 处理 LocalDateTime 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperationResult} && ${column.javaType} == "LocalDateTime") +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +#break +#end +#end +## 处理 Excel 导出 +import com.alibaba.excel.annotation.*; +#foreach ($column in $columns) +#if ("$!column.dictType" != "")## 有设置数据字典 +import ${DictFormatClassName}; +import ${DictConvertClassName}; +#break +#end +#end + +@Schema(description = "${sceneEnum.name} - ${table.classComment} Response VO") +@Data +@ExcelIgnoreUnannotated +public class ${sceneEnum.prefixClass}${table.className}RespVO { + +## 逐个处理字段 +#foreach ($column in $columns) +#if (${column.listOperationResult}) +## 1. 处理 Swagger 注解 + @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end) +## 2. 处理 Excel 导出 +#if ("$!column.dictType" != "")##处理枚举值 + @ExcelProperty(value = "${column.columnComment}", converter = DictConvert.class) + @DictFormat("${column.dictType}") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 +#else + @ExcelProperty("${column.columnComment}") +#end +## 3. 处理字段定义 + private ${column.javaType} ${column.javaField}; + +#end +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm new file mode 100644 index 00000000..89829cc9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm @@ -0,0 +1,65 @@ +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +## 处理 BigDecimal 字段的引入 +import java.util.*; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#break +#end +#end +## 处理 LocalDateTime 字段的引入 +#foreach ($column in $columns) +#if ((${column.createOperation} || ${column.updateOperation}) && ${column.javaType} == "LocalDateTime") +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +#break +#end +#end +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO; +#end + +@Schema(description = "${sceneEnum.name} - ${table.classComment}新增/修改 Request VO") +@Data +public class ${sceneEnum.prefixClass}${table.className}SaveReqVO { + +## 逐个处理字段 +#foreach ($column in $columns) +#if (${column.createOperation} || ${column.updateOperation}) +## 1. 处理 Swagger 注解 + @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end) +## 2. 处理 Validator 参数校验 +#if (!${column.nullable} && !${column.primaryKey}) +#if (${column.javaType} == 'String') + @NotEmpty(message = "${column.columnComment}不能为空") +#else + @NotNull(message = "${column.columnComment}不能为空") +#end +#end +## 3. 处理字段定义 + private ${column.javaType} ${column.javaField}; + +#end +#end +## 特殊:主子表专属逻辑(非 ERP 模式) +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 ) +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) + #if ( $subTable.subJoinMany) + @Schema(description = "${subTable.classComment}列表") + private List<${subTable.className}DO> ${subClassNameVars.get($index)}s; + + #else + @Schema(description = "${subTable.classComment}") + private ${subTable.className}DO ${subClassNameVars.get($index)}; + + #end +#end +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do.vm new file mode 100644 index 00000000..b019d6e1 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do.vm @@ -0,0 +1,52 @@ +package ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}; + +import lombok.*; +import java.util.*; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#end +#if (${column.javaType} == "LocalDateTime") +import java.time.LocalDateTime; +#end +#end +import com.baomidou.mybatisplus.annotation.*; +import ${BaseDOClassName}; + +/** + * ${table.classComment} DO + * + * @author ${table.author} + */ +@TableName("${table.tableName.toLowerCase()}") +@KeySequence("${table.tableName.toLowerCase()}_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ${table.className}DO extends BaseDO { + +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) + public static final Long ${treeParentColumn_javaField_underlineCase.toUpperCase()}_ROOT = 0L; + +#end +#foreach ($column in $columns) +#if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 + /** + * ${column.columnComment} + #if ("$!column.dictType" != "")##处理枚举值 + * + * 枚举 {@link TODO ${column.dictType} 对应的类} + #end + */ + #if (${column.primaryKey})##处理主键 + @TableId#if (${column.javaType} == 'String')(type = IdType.INPUT)#end + #end + private ${column.javaType} ${column.javaField}; +#end +#end + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do_sub.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do_sub.vm new file mode 100644 index 00000000..16be55e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/do_sub.vm @@ -0,0 +1,49 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +package ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}; + +import lombok.*; +import java.util.*; +#foreach ($column in $subColumns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#end +#if (${column.javaType} == "LocalDateTime") +import java.time.LocalDateTime; +#end +#end +import com.baomidou.mybatisplus.annotation.*; +import ${BaseDOClassName}; + +/** + * ${subTable.classComment} DO + * + * @author ${subTable.author} + */ +@TableName("${subTable.tableName.toLowerCase()}") +@KeySequence("${subTable.tableName.toLowerCase()}_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ${subTable.className}DO extends BaseDO { + +#foreach ($column in $subColumns) +#if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 + /** + * ${column.columnComment} + #if ("$!column.dictType" != "")##处理枚举值 + * + * 枚举 {@link TODO ${column.dictType} 对应的类} + #end + */ + #if (${column.primaryKey})##处理主键 + @TableId#if (${column.javaType} == 'String')(type = IdType.INPUT)#end + #end + private ${column.javaType} ${column.javaField}; +#end +#end + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.vm new file mode 100644 index 00000000..b98b471f --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.vm @@ -0,0 +1,82 @@ +package ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}; + +import java.util.*; + +import ${PageResultClassName}; +import ${QueryWrapperClassName}; +import ${BaseMapperClassName}; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import org.apache.ibatis.annotations.Mapper; +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; + +## 字段模板 +#macro(listCondition) +#foreach ($column in $columns) +#if (${column.listOperation}) +#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 +#if (${column.listOperationCondition} == "=")##情况一,= 的时候 + .eqIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#if (${column.listOperationCondition} == "!=")##情况二,!= 的时候 + .neIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#if (${column.listOperationCondition} == ">")##情况三,> 的时候 + .gtIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#if (${column.listOperationCondition} == ">=")##情况四,>= 的时候 + .geIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#if (${column.listOperationCondition} == "<")##情况五,< 的时候 + .ltIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#if (${column.listOperationCondition} == "<=")##情况五,<= 的时候 + .leIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#if (${column.listOperationCondition} == "LIKE")##情况七,Like 的时候 + .likeIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#if (${column.listOperationCondition} == "BETWEEN")##情况八,Between 的时候 + .betweenIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) +#end +#end +#end +#end +/** + * ${table.classComment} Mapper + * + * @author ${table.author} + */ +@Mapper +public interface ${table.className}Mapper extends BaseMapperX<${table.className}DO> { + +## 特殊:树表专属逻辑(树不需要分页接口) +#if ( $table.templateType != 2 ) + default PageResult<${table.className}DO> selectPage(${sceneEnum.prefixClass}${table.className}PageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX<${table.className}DO>() + #listCondition() + .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序 + + } +#else + default List<${table.className}DO> selectList(${sceneEnum.prefixClass}${table.className}ListReqVO reqVO) { + return selectList(new LambdaQueryWrapperX<${table.className}DO>() + #listCondition() + .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序 + + } +#end + +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写 + default ${table.className}DO selectBy${TreeParentJavaField}And${TreeNameJavaField}(Long ${treeParentColumn.javaField}, String ${treeNameColumn.javaField}) { + return selectOne(${table.className}DO::get${TreeParentJavaField}, ${treeParentColumn.javaField}, ${table.className}DO::get${TreeNameJavaField}, ${treeNameColumn.javaField}); + } + + default Long selectCountBy${TreeParentJavaField}(${treeParentColumn.javaType} ${treeParentColumn.javaField}) { + return selectCount(${table.className}DO::get${TreeParentJavaField}, ${treeParentColumn.javaField}); + } + +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.xml.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.xml.vm new file mode 100644 index 00000000..290378d3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper.xml.vm @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper_sub.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper_sub.vm new file mode 100644 index 00000000..e5589e99 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/dal/mapper_sub.vm @@ -0,0 +1,51 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subJoinColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 +package ${basePackage}.module.${subTable.moduleName}.dal.mysql.${subTable.businessName}; + +import java.util.*; + +import ${PageResultClassName}; +import ${PageParamClassName}; +import ${QueryWrapperClassName}; +import ${BaseMapperClassName}; +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO; +import org.apache.ibatis.annotations.Mapper; + +/** + * ${subTable.classComment} Mapper + * + * @author ${subTable.author} + */ +@Mapper +public interface ${subTable.className}Mapper extends BaseMapperX<${subTable.className}DO> { + +## 情况一:MASTER_ERP 时,需要分查询页子表 +#if ( $table.templateType == 11 ) + default PageResult<${subTable.className}DO> selectPage(PageParam reqVO, ${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return selectPage(reqVO, new LambdaQueryWrapperX<${subTable.className}DO>() + .eq(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}) + .orderByDesc(${subTable.className}DO::getId));## 大多数情况下,id 倒序 + + } + +## 情况二:非 MASTER_ERP 时,需要列表查询子表 +#else + #if ( $subTable.subJoinMany) + default List<${subTable.className}DO> selectListBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return selectList(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}); + } + + #else + default ${subTable.className}DO selectBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return selectOne(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}); + } + + #end + #end + default int deleteBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/enums/errorcode.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/enums/errorcode.vm new file mode 100644 index 00000000..b7e21e63 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/enums/errorcode.vm @@ -0,0 +1,22 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-${table.moduleName}-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== ${table.classComment} TODO 补充编号 ========== +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在"); +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子${table.classComment},无法删除"); +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级${table.classComment}不存在"); +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父${table.classComment}"); +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该${treeNameColumn.columnComment}的${table.classComment}"); +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子${table.className}为父${table.className}"); +#end +## 特殊:主子表专属逻辑 +#if ( $table.templateType == 11 )## 特殊:ERP 情况 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($simpleClassNameUnderlineCase = $simpleClassNameUnderlineCases.get($index)) +ErrorCode ${simpleClassNameUnderlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${subTable.classComment}不存在"); +#if ( !$subTable.subJoinMany ) +ErrorCode ${simpleClassNameUnderlineCase.toUpperCase()}_EXISTS = new ErrorCode(TODO 补充编号, "${subTable.classComment}已存在"); +#end +#end +#end \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/service.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/service.vm new file mode 100644 index 00000000..4085889d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/service.vm @@ -0,0 +1,147 @@ +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; + +import java.util.*; +import javax.validation.*; +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO; +#end +import ${PageResultClassName}; +import ${PageParamClassName}; + +/** + * ${table.classComment} Service 接口 + * + * @author ${table.author} + */ +public interface ${table.className}Service { + + /** + * 创建${table.classComment} + * + * @param createReqVO 创建信息 + * @return 编号 + */ + ${primaryColumn.javaType} create${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO); + + /** + * 更新${table.classComment} + * + * @param updateReqVO 更新信息 + */ + void update${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO); + + /** + * 删除${table.classComment} + * + * @param id 编号 + */ + void delete${simpleClassName}(${primaryColumn.javaType} id); + + /** + * 获得${table.classComment} + * + * @param id 编号 + * @return ${table.classComment} + */ + ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id); + +## 特殊:树表专属逻辑(树不需要分页接口) +#if ( $table.templateType != 2 ) + /** + * 获得${table.classComment}分页 + * + * @param pageReqVO 分页查询 + * @return ${table.classComment}分页 + */ + PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO); +#else + /** + * 获得${table.classComment}列表 + * + * @param listReqVO 查询条件 + * @return ${table.classComment}列表 + */ + List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO); +#end + +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($subSimpleClassName = $subSimpleClassNames.get($index)) +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 +#set ($subClassNameVar = $subClassNameVars.get($index)) + // ==================== 子表($subTable.classComment) ==================== + +## 情况一:MASTER_ERP 时,需要分查询页子表 +#if ( $table.templateType == 11 ) + /** + * 获得${subTable.classComment}分页 + * + * @param pageReqVO 分页查询 + * @param ${subJoinColumn.javaField} ${subJoinColumn.columnComment} + * @return ${subTable.classComment}分页 + */ + PageResult<${subTable.className}DO> get${subSimpleClassName}Page(PageParam pageReqVO, ${subJoinColumn.javaType} ${subJoinColumn.javaField}); + +## 情况二:非 MASTER_ERP 时,需要列表查询子表 +#else + #if ( $subTable.subJoinMany ) + /** + * 获得${subTable.classComment}列表 + * + * @param ${subJoinColumn.javaField} ${subJoinColumn.columnComment} + * @return ${subTable.classComment}列表 + */ + List<${subTable.className}DO> get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}); + + #else + /** + * 获得${subTable.classComment} + * + * @param ${subJoinColumn.javaField} ${subJoinColumn.columnComment} + * @return ${subTable.classComment} + */ + ${subTable.className}DO get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}); + + #end +#end +## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作 +#if ( $table.templateType == 11 ) + /** + * 创建${subTable.classComment} + * + * @param ${subClassNameVar} 创建信息 + * @return 编号 + */ + ${subPrimaryColumn.javaType} create${subSimpleClassName}(@Valid ${subTable.className}DO ${subClassNameVar}); + + /** + * 更新${subTable.classComment} + * + * @param ${subClassNameVar} 更新信息 + */ + void update${subSimpleClassName}(@Valid ${subTable.className}DO ${subClassNameVar}); + + /** + * 删除${subTable.classComment} + * + * @param id 编号 + */ + void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id); + + /** + * 获得${subTable.classComment} + * + * @param id 编号 + * @return ${subTable.classComment} + */ + ${subTable.className}DO get${subSimpleClassName}(${subPrimaryColumn.javaType} id); + +#end +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/serviceImpl.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/serviceImpl.vm new file mode 100644 index 00000000..6aa2fb2e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/service/serviceImpl.vm @@ -0,0 +1,350 @@ +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO; +#end +import ${PageResultClassName}; +import ${PageParamClassName}; +import ${BeanUtils}; + +import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +import ${basePackage}.module.${subTable.moduleName}.dal.mysql.${subTable.businessName}.${subTable.className}Mapper; +#end + +import static ${ServiceExceptionUtilClassName}.exception; +import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; + +/** + * ${table.classComment} Service 实现类 + * + * @author ${table.author} + */ +@Service +@Validated +public class ${table.className}ServiceImpl implements ${table.className}Service { + + @Resource + private ${table.className}Mapper ${classNameVar}Mapper; +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) + @Resource + private ${subTable.className}Mapper ${subClassNameVars.get($index)}Mapper; +#end + + @Override +## 特殊:主子表专属逻辑(非 ERP 模式) +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 ) + @Transactional(rollbackFor = Exception.class) +#end + public ${primaryColumn.javaType} create${simpleClassName}(${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO) { +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写 + // 校验${treeParentColumn.columnComment}的有效性 + validateParent${simpleClassName}(null, createReqVO.get${TreeParentJavaField}()); + // 校验${treeNameColumn.columnComment}的唯一性 + validate${simpleClassName}${TreeNameJavaField}Unique(null, createReqVO.get${TreeParentJavaField}(), createReqVO.get${TreeNameJavaField}()); + +#end + // 插入 + ${table.className}DO ${classNameVar} = BeanUtils.toBean(createReqVO, ${table.className}DO.class); + ${classNameVar}Mapper.insert(${classNameVar}); +## 特殊:主子表专属逻辑(非 ERP 模式) +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 ) + + // 插入子表 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($subSimpleClassName = $subSimpleClassNames.get($index)) +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + #if ( $subTable.subJoinMany) + create${subSimpleClassName}List(${classNameVar}.getId(), createReqVO.get${subSimpleClassNames.get($index)}s()); + #else + create${subSimpleClassName}(${classNameVar}.getId(), createReqVO.get${subSimpleClassNames.get($index)}()); + #end +#end +#end + // 返回 + return ${classNameVar}.getId(); + } + + @Override +## 特殊:主子表专属逻辑(非 ERP 模式) +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 ) + @Transactional(rollbackFor = Exception.class) +#end + public void update${simpleClassName}(${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO) { + // 校验存在 + validate${simpleClassName}Exists(updateReqVO.getId()); +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写 + // 校验${treeParentColumn.columnComment}的有效性 + validateParent${simpleClassName}(updateReqVO.getId(), updateReqVO.get${TreeParentJavaField}()); + // 校验${treeNameColumn.columnComment}的唯一性 + validate${simpleClassName}${TreeNameJavaField}Unique(updateReqVO.getId(), updateReqVO.get${TreeParentJavaField}(), updateReqVO.get${TreeNameJavaField}()); + +#end + // 更新 + ${table.className}DO updateObj = BeanUtils.toBean(updateReqVO, ${table.className}DO.class); + ${classNameVar}Mapper.updateById(updateObj); +## 特殊:主子表专属逻辑(非 ERP 模式) +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11) + + // 更新子表 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($subSimpleClassName = $subSimpleClassNames.get($index)) +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + #if ( $subTable.subJoinMany) + update${subSimpleClassName}List(updateReqVO.getId(), updateReqVO.get${subSimpleClassNames.get($index)}s()); + #else + update${subSimpleClassName}(updateReqVO.getId(), updateReqVO.get${subSimpleClassNames.get($index)}()); + #end +#end +#end + } + + @Override +## 特殊:主子表专属逻辑 +#if ( $subTables && $subTables.size() > 0) + @Transactional(rollbackFor = Exception.class) +#end + public void delete${simpleClassName}(${primaryColumn.javaType} id) { + // 校验存在 + validate${simpleClassName}Exists(id); +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) +#set ($ParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写 + // 校验是否有子${table.classComment} + if (${classNameVar}Mapper.selectCountBy${ParentJavaField}(id) > 0) { + throw exception(${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN); + } +#end + // 删除 + ${classNameVar}Mapper.deleteById(id); +## 特殊:主子表专属逻辑 +#if ( $subTables && $subTables.size() > 0) + + // 删除子表 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($subSimpleClassName = $subSimpleClassNames.get($index)) +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + delete${subSimpleClassName}By${SubJoinColumnName}(id); +#end +#end + } + + private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) { + if (${classNameVar}Mapper.selectById(id) == null) { + throw exception(${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS); + } + } + +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写 + private void validateParent${simpleClassName}(Long id, Long ${treeParentColumn.javaField}) { + if (${treeParentColumn.javaField} == null || ${simpleClassName}DO.${treeParentColumn_javaField_underlineCase.toUpperCase()}_ROOT.equals(${treeParentColumn.javaField})) { + return; + } + // 1. 不能设置自己为父${table.classComment} + if (Objects.equals(id, ${treeParentColumn.javaField})) { + throw exception(${simpleClassName_underlineCase.toUpperCase()}_PARENT_ERROR); + } + // 2. 父${table.classComment}不存在 + ${simpleClassName}DO parent${simpleClassName} = ${classNameVar}Mapper.selectById(${treeParentColumn.javaField}); + if (parent${simpleClassName} == null) { + throw exception(${simpleClassName_underlineCase.toUpperCase()}_PARENT_NOT_EXITS); + } + // 3. 递归校验父${table.classComment},如果父${table.classComment}是自己的子${table.classComment},则报错,避免形成环路 + if (id == null) { // id 为空,说明新增,不需要考虑环路 + return; + } + for (int i = 0; i < Short.MAX_VALUE; i++) { + // 3.1 校验环路 + ${treeParentColumn.javaField} = parent${simpleClassName}.get${TreeParentJavaField}(); + if (Objects.equals(id, ${treeParentColumn.javaField})) { + throw exception(${simpleClassName_underlineCase.toUpperCase()}_PARENT_IS_CHILD); + } + // 3.2 继续递归下一级父${table.classComment} + if (${treeParentColumn.javaField} == null || ${simpleClassName}DO.${treeParentColumn_javaField_underlineCase.toUpperCase()}_ROOT.equals(${treeParentColumn.javaField})) { + break; + } + parent${simpleClassName} = ${classNameVar}Mapper.selectById(${treeParentColumn.javaField}); + if (parent${simpleClassName} == null) { + break; + } + } + } + + private void validate${simpleClassName}${TreeNameJavaField}Unique(Long id, Long ${treeParentColumn.javaField}, String ${treeNameColumn.javaField}) { + ${simpleClassName}DO ${classNameVar} = ${classNameVar}Mapper.selectBy${TreeParentJavaField}And${TreeNameJavaField}(${treeParentColumn.javaField}, ${treeNameColumn.javaField}); + if (${classNameVar} == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的${table.classComment} + if (id == null) { + throw exception(${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE); + } + if (!Objects.equals(${classNameVar}.getId(), id)) { + throw exception(${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE); + } + } + +#end + @Override + public ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id) { + return ${classNameVar}Mapper.selectById(id); + } + +## 特殊:树表专属逻辑(树不需要分页接口) +#if ( $table.templateType != 2 ) + @Override + public PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) { + return ${classNameVar}Mapper.selectPage(pageReqVO); + } +#else + @Override + public List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO) { + return ${classNameVar}Mapper.selectList(listReqVO); + } +#end + +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($subSimpleClassName = $subSimpleClassNames.get($index)) +#set ($simpleClassNameUnderlineCase = $simpleClassNameUnderlineCases.get($index)) +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 +#set ($subClassNameVar = $subClassNameVars.get($index)) + // ==================== 子表($subTable.classComment) ==================== + +## 情况一:MASTER_ERP 时,需要分查询页子表 +#if ( $table.templateType == 11 ) + @Override + public PageResult<${subTable.className}DO> get${subSimpleClassName}Page(PageParam pageReqVO, ${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return ${subClassNameVars.get($index)}Mapper.selectPage(pageReqVO, ${subJoinColumn.javaField}); + } + +## 情况二:非 MASTER_ERP 时,需要列表查询子表 +#else + #if ( $subTable.subJoinMany ) + @Override + public List<${subTable.className}DO> get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return ${subClassNameVars.get($index)}Mapper.selectListBy${SubJoinColumnName}(${subJoinColumn.javaField}); + } + + #else + @Override + public ${subTable.className}DO get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) { + return ${subClassNameVars.get($index)}Mapper.selectBy${SubJoinColumnName}(${subJoinColumn.javaField}); + } + + #end +#end +## 情况一:MASTER_ERP 时,支持单个的新增、修改、删除操作 +#if ( $table.templateType == 11 ) + @Override + public ${subPrimaryColumn.javaType} create${subSimpleClassName}(${subTable.className}DO ${subClassNameVar}) { +## 特殊:一对一时,需要保证只有一条,不能重复插入 +#if ( !$subTable.subJoinMany) + // 校验是否已经存在 + if (${subClassNameVars.get($index)}Mapper.selectBy${SubJoinColumnName}(${subClassNameVar}.get${SubJoinColumnName}()) != null) { + throw exception(${simpleClassNameUnderlineCase.toUpperCase()}_EXISTS); + } + // 插入 +#end + ${subClassNameVars.get($index)}Mapper.insert(${subClassNameVar}); + return ${subClassNameVar}.getId(); + } + + @Override + public void update${subSimpleClassName}(${subTable.className}DO ${subClassNameVar}) { + // 校验存在 + validate${subSimpleClassName}Exists(${subClassNameVar}.getId()); + // 更新 + ${subClassNameVars.get($index)}Mapper.updateById(${subClassNameVar}); + } + + @Override + public void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id) { + // 校验存在 + validate${subSimpleClassName}Exists(id); + // 删除 + ${subClassNameVars.get($index)}Mapper.deleteById(id); + } + + @Override + public ${subTable.className}DO get${subSimpleClassName}(${subPrimaryColumn.javaType} id) { + return ${subClassNameVars.get($index)}Mapper.selectById(id); + } + + private void validate${subSimpleClassName}Exists(${subPrimaryColumn.javaType} id) { + if (${subClassNameVar}Mapper.selectById(id) == null) { + throw exception(${simpleClassNameUnderlineCase.toUpperCase()}_NOT_EXISTS); + } + } + +## 情况二:非 MASTER_ERP 时,支持批量的新增、修改操作 +#else + #if ( $subTable.subJoinMany) + private void create${subSimpleClassName}List(${primaryColumn.javaType} ${subJoinColumn.javaField}, List<${subTable.className}DO> list) { + list.forEach(o -> o.set$SubJoinColumnName(${subJoinColumn.javaField})); + ${subClassNameVars.get($index)}Mapper.insertBatch(list); + } + + private void update${subSimpleClassName}List(${primaryColumn.javaType} ${subJoinColumn.javaField}, List<${subTable.className}DO> list) { + delete${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField}); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + create${subSimpleClassName}List(${subJoinColumn.javaField}, list); + } + + #else + private void create${subSimpleClassName}(${primaryColumn.javaType} ${subJoinColumn.javaField}, ${subTable.className}DO ${subClassNameVar}) { + if (${subClassNameVar} == null) { + return; + } + ${subClassNameVar}.set$SubJoinColumnName(${subJoinColumn.javaField}); + ${subClassNameVars.get($index)}Mapper.insert(${subClassNameVar}); + } + + private void update${subSimpleClassName}(${primaryColumn.javaType} ${subJoinColumn.javaField}, ${subTable.className}DO ${subClassNameVar}) { + if (${subClassNameVar} == null) { + return; + } + ${subClassNameVar}.set$SubJoinColumnName(${subJoinColumn.javaField}); + ${subClassNameVar}.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + ${subClassNameVars.get($index)}Mapper.insertOrUpdate(${subClassNameVar}); + } + + #end +#end + private void delete${subSimpleClassName}By${SubJoinColumnName}(${primaryColumn.javaType} ${subJoinColumn.javaField}) { + ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}(${subJoinColumn.javaField}); + } + +#end +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/test/serviceTest.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/test/serviceTest.vm new file mode 100644 index 00000000..eeac3ce6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/java/test/serviceTest.vm @@ -0,0 +1,168 @@ +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import ${baseFrameworkPackage}.test.core.ut.BaseDbUnitTest; + +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; +import ${PageResultClassName}; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; +import static ${baseFrameworkPackage}.test.core.util.AssertUtils.*; +import static ${baseFrameworkPackage}.test.core.util.RandomUtils.*; +import static ${LocalDateTimeUtilsClassName}.*; +import static ${ObjectUtilsClassName}.*; +import static ${DateUtilsClassName}.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +## 字段模板 +#macro(getPageCondition $VO) + // mock 数据 + ${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class, o -> { // 等会查询到 + #foreach ($column in $columns) + #if (${column.listOperation}) + #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 + o.set$JavaField(null); + #end + #end + }); + ${classNameVar}Mapper.insert(db${simpleClassName}); + #foreach ($column in $columns) + #if (${column.listOperation}) + #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 + // 测试 ${column.javaField} 不匹配 + ${classNameVar}Mapper.insert(cloneIgnoreId(db${simpleClassName}, o -> o.set$JavaField(null))); + #end + #end + // 准备参数 + ${sceneEnum.prefixClass}${table.className}${VO} reqVO = new ${sceneEnum.prefixClass}${table.className}${VO}(); + #foreach ($column in $columns) + #if (${column.listOperation}) + #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 + #if (${column.listOperationCondition} == "BETWEEN")## BETWEEN 的情况 + reqVO.set${JavaField}(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + #else + reqVO.set$JavaField(null); + #end + #end + #end +#end +/** + * {@link ${table.className}ServiceImpl} 的单元测试类 + * + * @author ${table.author} + */ +@Import(${table.className}ServiceImpl.class) +public class ${table.className}ServiceImplTest extends BaseDbUnitTest { + + @Resource + private ${table.className}ServiceImpl ${classNameVar}Service; + + @Resource + private ${table.className}Mapper ${classNameVar}Mapper; + + @Test + public void testCreate${simpleClassName}_success() { + // 准备参数 + ${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO = randomPojo(${sceneEnum.prefixClass}${table.className}SaveReqVO.class).setId(null); + + // 调用 + ${primaryColumn.javaType} ${classNameVar}Id = ${classNameVar}Service.create${simpleClassName}(createReqVO); + // 断言 + assertNotNull(${classNameVar}Id); + // 校验记录的属性是否正确 + ${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(${classNameVar}Id); + assertPojoEquals(createReqVO, ${classNameVar}, "id"); + } + + @Test + public void testUpdate${simpleClassName}_success() { + // mock 数据 + ${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class); + ${classNameVar}Mapper.insert(db${simpleClassName});// @Sql: 先插入出一条存在的数据 + // 准备参数 + ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO = randomPojo(${sceneEnum.prefixClass}${table.className}SaveReqVO.class, o -> { + o.setId(db${simpleClassName}.getId()); // 设置更新的 ID + }); + + // 调用 + ${classNameVar}Service.update${simpleClassName}(updateReqVO); + // 校验是否更新正确 + ${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, ${classNameVar}); + } + + @Test + public void testUpdate${simpleClassName}_notExists() { + // 准备参数 + ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO = randomPojo(${sceneEnum.prefixClass}${table.className}SaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> ${classNameVar}Service.update${simpleClassName}(updateReqVO), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS); + } + + @Test + public void testDelete${simpleClassName}_success() { + // mock 数据 + ${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class); + ${classNameVar}Mapper.insert(db${simpleClassName});// @Sql: 先插入出一条存在的数据 + // 准备参数 + ${primaryColumn.javaType} id = db${simpleClassName}.getId(); + + // 调用 + ${classNameVar}Service.delete${simpleClassName}(id); + // 校验数据不存在了 + assertNull(${classNameVar}Mapper.selectById(id)); + } + + @Test + public void testDelete${simpleClassName}_notExists() { + // 准备参数 + ${primaryColumn.javaType} id = random${primaryColumn.javaType}Id(); + + // 调用, 并断言异常 + assertServiceException(() -> ${classNameVar}Service.delete${simpleClassName}(id), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS); + } + +## 特殊:树表专属逻辑(树不需要分页接口) +#if ( $table.templateType != 2 ) + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGet${simpleClassName}Page() { + #getPageCondition("PageReqVO") + + // 调用 + PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(db${simpleClassName}, pageResult.getList().get(0)); + } +#else + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGet${simpleClassName}List() { + #getPageCondition("ListReqVO") + + // 调用 + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(db${simpleClassName}, list.get(0)); + } +#end + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/h2.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/h2.vm new file mode 100644 index 00000000..b22389b0 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/h2.vm @@ -0,0 +1,37 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-${table.moduleName}-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "${table.tableName.toLowerCase()}" ( +#foreach ($column in $columns) +#if (${column.javaType} == 'Long') + #set ($dataType='bigint') +#elseif (${column.javaType} == 'Integer') + #set ($dataType='int') +#elseif (${column.javaType} == 'Boolean') + #set ($dataType='bit') +#elseif (${column.javaType} == 'Date') + #set ($dataType='datetime') +#else + #set ($dataType='varchar') +#end + #if (${column.primaryKey})##处理主键 + "${column.javaField}"#if (${column.javaType} == 'String') ${dataType} NOT NULL#else ${dataType} NOT NULL GENERATED BY DEFAULT AS IDENTITY#end, + #else + #if (${column.columnName} == 'create_time') + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + #elseif (${column.columnName} == 'update_time') + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + #elseif (${column.columnName} == 'creator' || ${column.columnName} == 'updater') + "${column.columnName}" ${dataType} DEFAULT '', + #elseif (${column.columnName} == 'deleted') + "deleted" bit NOT NULL DEFAULT FALSE, + #elseif (${column.columnName} == 'tenantId') + "tenant_id" bigint NOT NULL DEFAULT 0, + #else + "${column.columnName.toLowerCase()}" ${dataType}#if (${column.nullable} == false) NOT NULL#end, + #end + #end +#end + PRIMARY KEY ("${primaryColumn.columnName.toLowerCase()}") +) COMMENT '${table.tableComment}'; + +-- 将该删表 SQL 语句,添加到 yudao-module-${table.moduleName}-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "${table.tableName}"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/sql.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/sql.vm new file mode 100644 index 00000000..41b107db --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/sql/sql.vm @@ -0,0 +1,28 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '${table.classComment}管理', '', 2, 0, ${table.parentMenuId}, + '${simpleClassName_strikeCase}', '', '${table.moduleName}/${table.businessName}/index', 0, '${table.className}' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +#set ($functionNames = ['查询', '创建', '更新', '删除', '导出']) +#set ($functionOps = ['query', 'create', 'update', 'delete', 'export']) +#foreach ($functionName in $functionNames) +#set ($index = $foreach.count - 1) +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '${table.classComment}${functionName}', '${permissionPrefix}:${functionOps.get($index)}', 3, $foreach.count, @parentId, + '', '', '', 0 +); +#end \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/api/api.js.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/api/api.js.vm new file mode 100644 index 00000000..bfe2dc00 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/api/api.js.vm @@ -0,0 +1,147 @@ +import request from '@/utils/request' +#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") + +// 创建${table.classComment} +export function create${simpleClassName}(data) { + return request({ + url: '${baseURL}/create', + method: 'post', + data: data + }) +} + +// 更新${table.classComment} +export function update${simpleClassName}(data) { + return request({ + url: '${baseURL}/update', + method: 'put', + data: data + }) +} + +// 删除${table.classComment} +export function delete${simpleClassName}(id) { + return request({ + url: '${baseURL}/delete?id=' + id, + method: 'delete' + }) +} + +// 获得${table.classComment} +export function get${simpleClassName}(id) { + return request({ + url: '${baseURL}/get?id=' + id, + method: 'get' + }) +} + +#if ( $table.templateType != 2 ) +// 获得${table.classComment}分页 +export function get${simpleClassName}Page(params) { + return request({ + url: '${baseURL}/page', + method: 'get', + params + }) +} +#else +// 获得${table.classComment}列表 +export function get${simpleClassName}List(params) { + return request({ + url: '${baseURL}/list', + method: 'get', + params + }) +} +#end +// 导出${table.classComment} Excel +export function export${simpleClassName}Excel(params) { + return request({ + url: '${baseURL}/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} +## 特殊:主子表专属逻辑 TODO @puhui999:下面方法的【空格】不太对 +#foreach ($subTable in $subTables) + #set ($index = $foreach.count - 1) + #set ($subSimpleClassName = $subSimpleClassNames.get($index)) + #set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 + #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 + #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) + #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index)) + #set ($subClassNameVar = $subClassNameVars.get($index)) + +// ==================== 子表($subTable.classComment) ==================== + ## 情况一:MASTER_ERP 时,需要分查询页子表 + #if ( $table.templateType == 11 ) + + // 获得${subTable.classComment}分页 + export function get${subSimpleClassName}Page(params) { + return request({ + url: '${baseURL}/${subSimpleClassName_strikeCase}/page', + method: 'get', + params + }) + } + ## 情况二:非 MASTER_ERP 时,需要列表查询子表 + #else + #if ( $subTable.subJoinMany ) + + // 获得${subTable.classComment}列表 + export function get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaField}) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField}, + method: 'get' + }) + } + #else + + // 获得${subTable.classComment} + export function get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField}) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField}, + method: 'get' + }) + } + #end + #end + ## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作 + #if ( $table.templateType == 11 ) + // 新增${subTable.classComment} + export function create${subSimpleClassName}(data) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, + method: 'post', + data + }) + } + + // 修改${subTable.classComment} + export function update${subSimpleClassName}(data) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, + method: 'post', + data + }) + } + + // 删除${subTable.classComment} + export function delete${subSimpleClassName}(id) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id, + method: 'delete' + }) + } + + // 获得${subTable.classComment} + export function get${subSimpleClassName}(id) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id, + method: 'get' + }) + } + #end +#end \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm new file mode 100644 index 00000000..99aa91af --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm @@ -0,0 +1,205 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm new file mode 100644 index 00000000..ca266be9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm @@ -0,0 +1,2 @@ +## 主表的 normal 和 inner 使用相同的 form 表单 +#parse("codegen/vue/views/components/form_sub_normal.vue.vm") \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm new file mode 100644 index 00000000..48a404a3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm @@ -0,0 +1,347 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm new file mode 100644 index 00000000..589736b6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm @@ -0,0 +1,165 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm new file mode 100644 index 00000000..90b8e415 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm @@ -0,0 +1,4 @@ +## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点: +## 1)inner 使用 list 不分页,erp 使用 page 分页 +## 2)erp 支持单个子表的新增、修改、删除,inner 不支持 +#parse("codegen/vue/views/components/list_sub_erp.vue.vm") \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/form.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/form.vue.vm new file mode 100644 index 00000000..634d05d3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/form.vue.vm @@ -0,0 +1,320 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/index.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/index.vue.vm new file mode 100644 index 00000000..2328007a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue/views/index.vue.vm @@ -0,0 +1,340 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/api/api.ts.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/api/api.ts.vm new file mode 100644 index 00000000..c4b0b433 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/api/api.ts.vm @@ -0,0 +1,111 @@ +import request from '@/config/axios' +#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") + +export interface ${simpleClassName}VO { +#foreach ($column in $columns) +#if ($column.createOperation || $column.updateOperation) +#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal") + ${column.javaField}: number +#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime") + ${column.javaField}: Date +#else + ${column.javaField}: ${column.javaType.toLowerCase()} +#end +#end +#end +} + +#if ( $table.templateType != 2 ) +// 查询${table.classComment}分页 +export const get${simpleClassName}Page = async (params) => { + return await request.get({ url: `${baseURL}/page`, params }) +} +#else +// 查询${table.classComment}列表 +export const get${simpleClassName}List = async (params) => { + return await request.get({ url: `${baseURL}/list`, params }) +} +#end + +// 查询${table.classComment}详情 +export const get${simpleClassName} = async (id: number) => { + return await request.get({ url: `${baseURL}/get?id=` + id }) +} + +// 新增${table.classComment} +export const create${simpleClassName} = async (data: ${simpleClassName}VO) => { + return await request.post({ url: `${baseURL}/create`, data }) +} + +// 修改${table.classComment} +export const update${simpleClassName} = async (data: ${simpleClassName}VO) => { + return await request.put({ url: `${baseURL}/update`, data }) +} + +// 删除${table.classComment} +export const delete${simpleClassName} = async (id: number) => { + return await request.delete({ url: `${baseURL}/delete?id=` + id }) +} + +// 导出${table.classComment} Excel +export const export${simpleClassName} = async (params) => { + return await request.download({ url: `${baseURL}/export-excel`, params }) +} +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) +#set ($index = $foreach.count - 1) +#set ($subSimpleClassName = $subSimpleClassNames.get($index)) +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 +#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) +#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index)) +#set ($subClassNameVar = $subClassNameVars.get($index)) + +// ==================== 子表($subTable.classComment) ==================== +## 情况一:MASTER_ERP 时,需要分查询页子表 +#if ( $table.templateType == 11 ) + +// 获得${subTable.classComment}分页 +export const get${subSimpleClassName}Page = async (params) => { + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/page`, params }) +} +## 情况二:非 MASTER_ERP 时,需要列表查询子表 +#else + #if ( $subTable.subJoinMany ) + +// 获得${subTable.classComment}列表 +export const get${subSimpleClassName}ListBy${SubJoinColumnName} = async (${subJoinColumn.javaField}) => { + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} }) +} + #else + +// 获得${subTable.classComment} +export const get${subSimpleClassName}By${SubJoinColumnName} = async (${subJoinColumn.javaField}) => { + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} }) +} + #end +#end +## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作 +#if ( $table.templateType == 11 ) +// 新增${subTable.classComment} +export const create${subSimpleClassName} = async (data) => { + return await request.post({ url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, data }) +} + +// 修改${subTable.classComment} +export const update${subSimpleClassName} = async (data) => { + return await request.put({ url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, data }) +} + +// 删除${subTable.classComment} +export const delete${subSimpleClassName} = async (id: number) => { + return await request.delete({ url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id }) +} + +// 获得${subTable.classComment} +export const get${subSimpleClassName} = async (id: number) => { + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id }) +} +#end +#end \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_erp.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_erp.vue.vm new file mode 100644 index 00000000..ed318875 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_erp.vue.vm @@ -0,0 +1,205 @@ +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_inner.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_inner.vue.vm new file mode 100644 index 00000000..d8542c3d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_inner.vue.vm @@ -0,0 +1,2 @@ +## 主表的 normal 和 inner 使用相同的 form 表单 +#parse("codegen/vue3/views/components/form_sub_normal.vue.vm") \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_normal.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_normal.vue.vm new file mode 100644 index 00000000..90df7981 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/form_sub_normal.vue.vm @@ -0,0 +1,362 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_erp.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_erp.vue.vm new file mode 100644 index 00000000..5ad208b3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_erp.vue.vm @@ -0,0 +1,181 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_inner.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_inner.vue.vm new file mode 100644 index 00000000..3fe64889 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/components/list_sub_inner.vue.vm @@ -0,0 +1,4 @@ +## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点: +## 1)inner 使用 list 不分页,erp 使用 page 分页 +## 2)erp 支持单个子表的新增、修改、删除,inner 不支持 +#parse("codegen/vue3/views/components/list_sub_erp.vue.vm") \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/form.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/form.vue.vm new file mode 100644 index 00000000..1c155362 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/form.vue.vm @@ -0,0 +1,298 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/index.vue.vm new file mode 100644 index 00000000..092b54ce --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3/views/index.vue.vm @@ -0,0 +1,373 @@ + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm new file mode 100644 index 00000000..48cd5422 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/api/api.ts.vm @@ -0,0 +1,46 @@ +import request from '@/config/axios' +#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") + +export interface ${simpleClassName}VO { + #foreach ($column in $columns) + #if ($column.createOperation || $column.updateOperation) + #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal") + ${column.javaField}: number + #elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime") + ${column.javaField}: Date + #else + ${column.javaField}: ${column.javaType.toLowerCase()} + #end + #end + #end +} + +// 查询${table.classComment}列表 +export const get${simpleClassName}Page = async (params) => { + return await request.get({ url: '${baseURL}/page', params }) +} + +// 查询${table.classComment}详情 +export const get${simpleClassName} = async (id: number) => { + return await request.get({ url: '${baseURL}/get?id=' + id }) +} + +// 新增${table.classComment} +export const create${simpleClassName} = async (data: ${simpleClassName}VO) => { + return await request.post({ url: '${baseURL}/create', data }) +} + +// 修改${table.classComment} +export const update${simpleClassName} = async (data: ${simpleClassName}VO) => { + return await request.put({ url: '${baseURL}/update', data }) +} + +// 删除${table.classComment} +export const delete${simpleClassName} = async (id: number) => { + return await request.delete({ url: '${baseURL}/delete?id=' + id }) +} + +// 导出${table.classComment} Excel +export const export${simpleClassName}Api = async (params) => { + return await request.download({ url: '${baseURL}/export-excel', params }) +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm new file mode 100644 index 00000000..ff4fa810 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm @@ -0,0 +1,124 @@ +import type { CrudSchema } from '@/hooks/web/useCrudSchemas' +import { dateFormatter } from '@/utils/formatTime' + +// 表单校验 +export const rules = reactive({ +#foreach ($column in $columns) +#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 +#set($comment=$column.columnComment) + $column.javaField: [required], +#end +#end +}) + +// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/ +const crudSchemas = reactive([ +#foreach($column in $columns) +#if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation) +#set ($dictType = $column.dictType) +#set ($javaField = $column.javaField) +#set ($javaType = $column.javaType) + { + label: '${column.columnComment}', + field: '${column.javaField}', +## ========= 字典部分 ========= + #if ("" != $dictType)## 有数据字典 + dictType: DICT_TYPE.$dictType.toUpperCase(), + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") + dictClass: 'number', + #elseif ($javaType == "String") + dictClass: 'string', + #elseif ($javaType == "Boolean") + dictClass: 'boolean', + #end + #end +## ========= Table 表格部分 ========= + #if (!$column.listOperationResult) + isTable: false, + #else + #if ($column.htmlType == "datetime") + formatter: dateFormatter, + #end + #end +## ========= Search 表格部分 ========= + #if ($column.listOperation) + isSearch: true, + #if ($column.htmlType == "datetime") + search: { + component: 'DatePicker', + componentProps: { + valueFormat: 'YYYY-MM-DD HH:mm:ss', + type: 'daterange', + defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] + } + }, + #end + #end +## ========= Form 表单部分 ========= + #if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey) + isForm: false, + #else + #if($column.htmlType == "imageUpload")## 图片上传 + form: { + component: 'UploadImg' + }, + #elseif($column.htmlType == "fileUpload")## 文件上传 + form: { + component: 'UploadFile' + }, + #elseif($column.htmlType == "editor")## 文本编辑器 + form: { + component: 'Editor', + componentProps: { + valueHtml: '', + height: 200 + } + }, + #elseif($column.htmlType == "select")## 下拉框 + form: { + component: 'SelectV2' + }, + #elseif($column.htmlType == "checkbox")## 多选框 + form: { + component: 'Checkbox' + }, + #elseif($column.htmlType == "radio")## 单选框 + form: { + component: 'Radio' + }, + #elseif($column.htmlType == "datetime")## 时间框 + form: { + component: 'DatePicker', + componentProps: { + type: 'datetime', + valueFormat: 'x' + } + }, + #elseif($column.htmlType == "textarea")## 文本框 + form: { + component: 'Input', + componentProps: { + type: 'textarea', + rows: 4 + }, + colProps: { + span: 24 + } + }, + #elseif(${javaType.toLowerCase()} == "long" || ${javaType.toLowerCase()} == "integer")## 文本框 + form: { + component: 'InputNumber', + value: 0 + }, + #end + #end + }, +#end +#end + { + label: '操作', + field: 'action', + isForm: false + } +]) +export const { allSchemas } = useCrudSchemas(crudSchemas) diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/form.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/form.vue.vm new file mode 100644 index 00000000..52f20a2f --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/form.vue.vm @@ -0,0 +1,65 @@ + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/index.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/index.vue.vm new file mode 100644 index 00000000..6e8f1403 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_schema/views/index.vue.vm @@ -0,0 +1,85 @@ + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/api/api.ts.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/api/api.ts.vm new file mode 100644 index 00000000..b7f26510 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/api/api.ts.vm @@ -0,0 +1,32 @@ +import { defHttp } from '@/utils/http/axios' +#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") + +// 查询${table.classComment}列表 +export function get${simpleClassName}Page(params) { + return defHttp.get({ url: '${baseURL}/page', params }) +} + +// 查询${table.classComment}详情 +export function get${simpleClassName}(id: number) { + return defHttp.get({ url: `${baseURL}/get?id=${id}` }) +} + +// 新增${table.classComment} +export function create${simpleClassName}(data) { + return defHttp.post({ url: '${baseURL}/create', data }) +} + +// 修改${table.classComment} +export function update${simpleClassName}(data) { + return defHttp.put({ url: '${baseURL}/update', data }) +} + +// 删除${table.classComment} +export function delete${simpleClassName}(id: number) { + return defHttp.delete({ url: `${baseURL}/delete?id=${id}` }) +} + +// 导出${table.classComment} Excel +export function export${simpleClassName}(params) { + return defHttp.download({ url: '${baseURL}/export-excel', params }, '${table.classComment}.xls') +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm new file mode 100644 index 00000000..92d3b2d7 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm @@ -0,0 +1,236 @@ +import type {BasicColumn, FormSchema} from '@/components/Table' +import {useRender} from '@/components/Table' +import {DICT_TYPE, getDictOptions} from '@/utils/dict' + +export const columns: BasicColumn[] = [ +#foreach($column in $columns) +#if ($column.listOperationResult) + #set ($dictType=$column.dictType) + #set ($javaField = $column.javaField) + #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #set ($comment=$column.columnComment) +#if ($column.javaType == "LocalDateTime")## 时间类型 + { + title: '${comment}', + dataIndex: '${javaField}', + width: 180, + customRender: ({ text }) => { + return useRender.renderDate(text) + }, + }, +#elseif("" != $column.dictType)## 数据字典 + { + title: '${comment}', + dataIndex: '${javaField}', + width: 180, + customRender: ({ text }) => { + return useRender.renderDict(text, DICT_TYPE.$dictType.toUpperCase()) + }, + }, +#else + { + title: '${comment}', + dataIndex: '${javaField}', + width: 160, + }, +#end +#end +#end +] + +export const searchFormSchema: FormSchema[] = [ +#foreach($column in $columns) +#if ($column.listOperation) + #set ($dictType=$column.dictType) + #set ($javaField = $column.javaField) + #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #set ($comment=$column.columnComment) + { + label: '${comment}', + field: '${javaField}', + #if ($column.htmlType == "input") + component: 'Input', + #elseif ($column.htmlType == "select") + component: 'Select', + componentProps: { + #if ("" != $dictType)## 设置了 dictType 数据字典的情况 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()), + #else## 未设置 dictType 数据字典的情况 + options: [], + #end + }, + #elseif ($column.htmlType == "radio") + component: 'Radio', + componentProps: { + #if ("" != $dictType)## 设置了 dictType 数据字典的情况 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()), + #else## 未设置 dictType 数据字典的情况 + options: [], + #end + }, + #elseif($column.htmlType == "datetime") + component: 'RangePicker', + #end + colProps: { span: 8 }, + }, +#end +#end +] + +export const createFormSchema: FormSchema[] = [ + { + label: '编号', + field: 'id', + show: false, + component: 'Input', + }, +#foreach($column in $columns) +#if ($column.createOperation) + #set ($dictType = $column.dictType) + #set ($javaField = $column.javaField) + #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #set ($comment = $column.columnComment) +#if (!$column.primaryKey)## 忽略主键,不用在表单里 + { + label: '${comment}', + field: '${javaField}', + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 + required: true, + #end + #if ($column.htmlType == "input") + component: 'Input', + #elseif($column.htmlType == "imageUpload")## 图片上传 + component: 'FileUpload', + componentProps: { + fileType: 'image', + maxCount: 1, + }, + #elseif($column.htmlType == "fileUpload")## 文件上传 + component: 'FileUpload', + componentProps: { + fileType: 'file', + maxCount: 1, + }, + #elseif($column.htmlType == "editor")## 文本编辑器 + component: 'Editor', + #elseif($column.htmlType == "select")## 下拉框 + component: 'Select', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), + #else##没数据字典 + options:[], + #end + }, + #elseif($column.htmlType == "checkbox")## 多选框 + component: 'Checkbox', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), + #else##没数据字典 + options:[], + #end + }, + #elseif($column.htmlType == "radio")## 单选框 + component: 'RadioButtonGroup', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), + #else##没数据字典 + options:[], + #end + }, + #elseif($column.htmlType == "datetime")## 时间框 + component: 'DatePicker', + componentProps: { + showTime: true, + format: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x', + }, + #elseif($column.htmlType == "textarea")## 文本域 + component: 'InputTextArea', + #end + }, +#end +#end +#end +] + +export const updateFormSchema: FormSchema[] = [ + { + label: '编号', + field: 'id', + show: false, + component: 'Input', + }, +#foreach($column in $columns) +#if ($column.updateOperation) +#set ($dictType = $column.dictType) +#set ($javaField = $column.javaField) +#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#set ($comment = $column.columnComment) + #if (!$column.primaryKey)## 忽略主键,不用在表单里 + { + label: '${comment}', + field: '${javaField}', + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 + required: true, + #end + #if ($column.htmlType == "input") + component: 'Input', + #elseif($column.htmlType == "imageUpload")## 图片上传 + component: 'FileUpload', + componentProps: { + fileType: 'image', + maxCount: 1, + }, + #elseif($column.htmlType == "fileUpload")## 文件上传 + component: 'FileUpload', + componentProps: { + fileType: 'file', + maxCount: 1, + }, + #elseif($column.htmlType == "editor")## 文本编辑器 + component: 'Editor', + #elseif($column.htmlType == "select")## 下拉框 + component: 'Select', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), + #else##没数据字典 + options:[], + #end + }, + #elseif($column.htmlType == "checkbox")## 多选框 + component: 'Checkbox', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), + #else##没数据字典 + options:[], + #end + }, + #elseif($column.htmlType == "radio")## 单选框 + component: 'RadioButtonGroup', + componentProps: { + #if ("" != $dictType)## 有数据字典 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), + #else##没数据字典 + options:[], + #end + }, + #elseif($column.htmlType == "datetime")## 时间框 + component: 'DatePicker', + componentProps: { + showTime: true, + format: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x', + }, + #elseif($column.htmlType == "textarea")## 文本域 + component: 'InputTextArea', + #end + }, + #end +#end +#end +] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm new file mode 100644 index 00000000..18043651 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm @@ -0,0 +1,58 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm new file mode 100644 index 00000000..84ec4bf5 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm @@ -0,0 +1,91 @@ + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/main/resources/file/erweima.jpg b/yudao-module-wms/yudao-module-wms-biz/src/main/resources/file/erweima.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1447283cdf1b49b51c1204a160e01cb789e957a8 GIT binary patch literal 18385 zcmb7s2Rzm9+yCL%A+xNq$sv0yBYV$7${yL72_=by>^(#Fv7$0Ev!kp?5wb^FWrg_P zpQHMH%lG#@|3|%E9nLwQao^YbdXMYm@crQ@7>SC4vH}bP0|vtYe_)5BFj*KJ6BGIi zzOcYwY&>jiEG%pSTwEMHLIOg<69gwt5D}A+5D}9SpEyBsiiDJ$f|8Pw@Z@Q#QxsHW z6qFRuK``LpJy_WI*x2|KL??(S{?A{B%`j3t3``76I0h*UlN19^igDNqI}3xsF@Ao* zj=u2laWQZRFtM=V;CVW5C*U2>{rvjEz{bSF!G+@;j=%`v;8_wl33v)+_Urjy|Kg$_ zEYOL&EWqgCnJzFG_?HFa?p@d+?8NuGcTew3GT`ns5n#fwFfbc17@A-w_F=eqSjKR; zC??8VnnQ-OJ&kBTmB9>~jf6qSOyt`gO6|87%2A|djZH9@yYjjWB&Ro!>ROqY1@<|Y zc|P4G(mthFSx+S#-!Mn8dyS3^ETUjdRAj&UIql~S&E5+R@66)&C29)F?Sy-m-fmrFjj`}75A z#U0`pyj^w}Jn#_4-||4(p0Hr(zTObg<@h{(A+|jGdrzzt^sksBg=A19CU2m;|q@V?(-Q-TUlUHCcE>k7!N!Q88=Kd@gvmHAV_*V?R zN)s3OQ!d<})?>Y&3!RfW5R+#OM#n&EN(jqjk3PEK0z7ZcUYu)B7S=2Vo-*QoNoCHn zw@GBdFntXheD%!tA`GJ$<5XH#(337KtVKju9-?hsD(4U;Fr8o=__^`&>jU+xHuPUx z)gHq2tu1#E?ICdG819;K7EXX(_bCpU`;0zj6^>9*kVL8@Z05s-n{0 z5%j%t)VuM_a-GwVRAceS^+OoF%pr_@=(cg-7kl#MVz(AuXj4h}TM+zD7v*5YWUw1@ zcugl%%y3{*?J(R2vfk|@2Y%eU_?uy-#btxv!)J9j8cAhuA=GGOPN}P*tT5q=3#n{* zS|l)0X{JLMwak(dp}5=#{o}@TlJ)l74~H__P1{z|61w{qU&{J% z?lfX7g*|Cfh8cW~y9<{3s{WQ)XGGX-5ek{~>uZz2sO?l>3nSq-^WKlL{%$~b=IpI+b3}vH?rA4U|84`l&A1d141Arr=m8v&nim7z^G_L#>Re*LqX;SlZY5E-z6<=Gjq!T(CYC3 z1z?bY*4?>XxivmIddt~qxxT9M5EgL=3knw(+^-$owB0!^5zRp&v3 zOMEV?+A*vsQ4cBh@!e8rzC_BHw%)w^RTLs^#lc*oKy8*iMJ$Z1y5Lz2j>(DE4c2(C z1sY;HZCRHO)CSxIDEFF@Axe##LN6W{_RQ@Y+*`khZ*3xu6YzjS>!Yv&@|8FBl$$ks zgo5-=I+Y?}bewNN$A);cz*AH4G+8(m0(6x}deZ z44=nrlCxEMavdMr+i2e>r%uztdFmgLCf*~yNE~k>P7S}infXyg0lA6GFx{7c{A3>0 zdQzUK#U?L9lTzVw-V(PZe#yx2S($hOV*!2F1vb%FO>aIK;j`Ll=Uys!$eJdPAJXii z?nRBMd`0gxL13K?+w1<CvsnKCQ)ZGB}`NLRl94D ztUvT$l%qFotTR|7%YHf-nc+8dHO2NjC|5E6a z6*#SyNur8-rPIKohUc4@C1U~YkOgYd9^N;PjBw^q<;BP$e2bi~jofm>l&1g)8U0|mE{Q4mqt~RertE&QOi!2o9(B~{F!a02`znU zM%Fhv-El$K6zpC`4-~CE;!Bdm``@Id1dtX&9(qL@UcYI$Ko-wcMMZ&+Z+3_5|!PQ8QI%Oh7#>n;oaizjrJ(G_ET9ua(s8Z2v-oc z{pewsq1IpP?n|vrTK9_7!eZ|E^>?|x>TX#LYFz2l4(+q)I~L(z)ZVOz`)7>z;=O;o zwUMIF+8E>oejL7iPS46{={XApISL{t%+GSzV#Zxh7) ztoBDKKfm5!gGKeZ2)Zf|%X(Fms&@90$8ub7l;#{++ zGl5-augrriUaXKX1!*5%H`?YDUuK;TX*mwwZq(HUb@*GVsNf0(7A@N}(bjj~Q8X#2 zmueeSKIAZ^q*g23Y+S}Vj{E^JZtAW}Rf&wLK@VSMSW1_Ylf$c%M6C(4@g~93TVUnuX#LAFYJR~59Ig~d7oXzcM6{x~h^X#KbW;?Gz#rnRFGqAO3g^ie6_UIzJ zDV!}p^*V9@RHO~eDK2@ z`>Qy08dCeZzgc<+?7tr)Y!nue<#`hpq&3WTx@z@m`)rK0%zZ_Eo6My4H?(fgITx!R z-=a8zMiqcYb4D_ApPJ>h@R}bMQr^b`~M6~TKSj}8@@ zs_BUqyR*rMJWMNv&YJI^KR$ui6+jSS)hojno+3PJfAuXA2eJPu+QMRu9sm&WfRh4^$3@mkm*J=oraIo z=Kt2&;nF39X`ht9ex4}CWisN(XYJ0<8;bAFUmu&lXnY-_j$&KNtk^Vs&>*vJ+?`Rq zFE~4}%(vD5!Z=Uz!#>`S+_k)saib8>eldNc%pb9f#dy(K@rJyUa}`^xde@xHa|)p; z=uRa75eZ>k=-NyEq7H_>+x%g4K}ua>pu25|HAVBfbh;W6%T?=Y$k}HL#NKe`mV3AC z5FmMsZ9ZE(DF~bS5dYnct;zwZy!Br&82TbhAoiNUY-h??36gyj;z{T3M$d3@k3(4Y zv5u;yko#6h>D|{EaFJf*Uu-FxEzE90_Zx>MgxMidzHPqXA*IWOG~iB45j>c_VViUE zvG9T=-o4}*tS{|Sovp2PXX6yuplTWD;KQ@~To(f|I zoR^kL>G8sbgR87N>P?$GO0&XPPde>Zr5eA^=yr2=0yk3)CI;$=1_yDq6T@MIcgZ_cvl=!*%6# z>7qWOEmQ7u4ZC3zRIgmZ=ae>xP74)zJ{MXtRil#PyQYd@?nXmU+i7I5EN=r8`oxCm zep@nEK_s_TB*2w?l>>i6QewHmoEmtqnDKS}JYP-E$N@C)pcfngkCJq@+wK$_UqKb+ zDTBA-vv~Q^h!{# zjb)X~Z@;tg`o(n?)%{R&HEX4%fQrh{;BA|BGD_iLQZwl89Z^lJD=`3av^M3bM=F@mdIJbt*}Jv?UJBIl_rUjQhAM22Gr zyKHppGf)baiCda)%1!EeFPY&J;ldRu%w|L$B4+Bs*2VZ^JD3@6Yk*5v>XMw)C?FjA zEp3T#d=*kZFh5eL)cC@ z`W$8Sps7z#mZgb|jgMOX++-)<$8CstucDcEhcv{aM+aF~P54pI1Z$6VNY0R%?3|zm zorS}NP9k-r*^}E`6h-^$AKqTa^1SaTJOVn2@g^bDw%qk8uE9E?w#X@Jj&|+$W;hhy zJ5EO z)FssO1~au>nB$aq0$!$@R?Mj=GCW*ta~Q2Pg7ac>mdMXw>!tiVz_dd!e;m z*mg7?5d3ZhjZs?C_~=W6@NSl_;IE)vky8y`^#Qse9dr=>8PGvKnASVfCftbGqS${$ zYMzbmAj5eGCXr+&E;XZfB};(z4`KZezMZnFVm4OxD;OQ+Ue#PLi}n0L<6&oc5r@=9 zbcv0R${(1hL;}0b<7hN$9JTM7?cG`0cvQwuD9}33uL%zeA{Fn9V81B5`)^QDn`KQA zi})`tkcG+sl25oeVT|!nGe8=2hO6erI6y*^7`k&f%V@cx_t%S^NJW6^pN-L&K`KS+`uiaTN|OhWd-%y!Gx_jp6_Jc(OG;( z`a#NfSp?~b?)SGujdK+xzWT3huf*F+NRFt39PGl&POFX4MH*lcnXh(73$@9A(yTlZ z=C6){VHmQfm7L)uuX?b8!eq)-n%r31;(eEbllGFjQ#Ex|ITNL3RJna#9HYL=9KHnK zBz`Qu%v20sV6k&#P@s64T|54EWAOuaAT7CGhqs^4U8!($(g*XW=kqNOXy)YQ9&tH6 z$`R0EpbKtvV)Sp$p{4hwl=f`8SjS_1^1XyZZTO_6Xq{*SQ3`P+?Q~Rl!h@t#!nn)l zu+}j>L+cwI>e|!hKUPYYZ{WQlw#Spz96Bd4p11t4Ygr~gYoO=>Gh|(9LzKE2D*s_h z!qI;9Nj~VAj=)i&du9L+79C`gJos@jJ_C~!R`l6itw5FH0~9z^Ip~4FLBY#x4mlki zCCLsXT#hyU9V8^SA;AoZ?emKn`m(Btu_q?B)TiBEi2yW6{X|19Xb((4N&jjOjj4v* zq;-|i=8xx|yJ}ynR|em`I_nREh-7{&Stf3o27^WpamZSZvicH{C3m;3HwBn1*)+QWUg;QnFR(^aWhTodzth2yBp6z6AGVw zwm}Xw6L`atAL5vkMdQa2Ik0Y#%HPN>E4*x9DB0%o?IJ!J6Li`E5GG=dB{lcOvjpN2 zfc66^!oUo*7Y{iISEe&tXSmbcld{}udQzmVYghYRTdj)9BDOurAD2C=DMGwC&FZ zJ!V2(O8pSFk8x6D3?p2zKZj%0ysV^hcyQ47L?~l66trQamw5|94wo_Y;$dicnvtY=Z7!!XT**3G)920ZUw%&)#9;0thF<^ z&SeLG$)mLF$Y$=OVB1>FW6Hg3IcIDpMmDJ~#%+92_)96sek011m%gzMzA)sPIw$Cw zW}e#ANv4jp1j-fi>eOo&kfc_r1vO!;RSrhpILA7HOpupZGV+saR5Lrs4cPN040yJg zD{9;ixz%3D?!thh0)k}^{&i8D>Bi=ex zjx0F|ufBNkVnpcKlKq#>8>tjhzBr~~KyyZ3GBogqG$(}!5zw3y*&D0JbA~eD{CmWM z0{mM-J0n0_bi06Lw1CzM^a!w4M@{mjSG0|a))}}=OK4vND>GuYCdzG{>6KL`4o;XN zg*KhAk6rg{+vy4I)M;uSi?Y|r3pCvPFFuy2`y2%`tY7p2v|8kQ42(Ps%XC!(ok5qe z1^W7VVVUl(SGr$REkav9yR}rc4S5Y!2j}!Bv{yAsU-lZ< z6)*2rr`qI7LESJZ4(f(aITs6WQQooYmF{x)0z--sur?Y3KB<909r#%6Gr`i|rEpo~=7ti-wA#DA9*+b1G@ ztutaR+qh35R30Wxra~41O|gyzI*V3eN?CmE8aR&M7=$=g!p|b2dUOPhpb*XELcp;A zOdZO!ggeD>Nx}ZX34<7X!2Vqn+^r*V1ridYuagcJNXQEQvc@7+hK*ASXO!iL1*q;h zU@C!7ZAxFO9kWfc1skK5{zZ2=-H^`7P?RxOtO>B^_WoB;nw3;hxTj~tuR2wZp4r{q zWE&)ueJ;4#x0-#+;&C2fPIvt732oLY@WP`wxp{iR&}L?o@`fBpamxT}*Mg@ijDecz zVG2;BZl|sz^k*5;7y2U}>>xMt0P!I80`Ehy4sE{R)|0>>RO@OM{T=PCP%H)Z=on@v zO##oP8U^w=O;G<4P#y>BALMc0MOOOrH8M7iVc?eqB5c_5()7=?g#?M31%IeE5F`|D zmuCA1V}PFfeySVjx#M2{eKG5_n6h<{QP6e7c^%(lVmtL8*=V~SBDlh^RVyit9c$P> ziX}c*Mr(L$q`oHXK)i0o_B=YTIGz>ecK>+g2=%#Wu9~H9G}talNoQI?8?>fUBm!-a z1}E4m2~)0}`CKlY82Eu?G%C1UN2ngV6UvxverC+p$Mf{uuC(RU<9?};5FPdl%t65x z%dePjJgI;WnD~d}r>TL7&-GO%;?_`I_4@#{Hq)59AAZ$^bY-c0PIm4x&9A0;gi=XQ zS%JSm$Iu0poAw58MXLIbTywh~mG0N~@*yDpt6r#RND4}1XWef2g#0Noeo5|}`ukGn z^D}J${30F-EGEtR#(r~5d{O|efe2772omb~KuX;S;<~x#&ftpBI>XrsN~vQUfx`jw zig+AOx_{((pKP|PntukkuUr6^ZxErmTxc;J;&NtRpm4g;dcS13QDOOfC{IJSNc-*X zmtKzoE6ULQ@7#4-X2eVY!P?8$MNOaj1Np%qp;x`eqBOCaVicrX)aZ0erc)GhZB$mk z@B-Jim_KwWQI*9)9zTNLMZhK*qwtEJ9g&~g)zPHhnXCK?_r|#2(mQ^@1vI{h{A6a^ z>UxE!H9s${+yG?cj$QlJwIn+`f*>JM~z1rnx$ zQ1_ZJFi)|18l2e=<|)o_24yf$LCX~jA?{Ngl~sutsh-c9GL8~%fyr#m#oYyqdhbVp zO=L90I1%Swb~>LzcB3aN!Qilr(d1WUGlxrEpiZX@G#YBxU;Nx3epo62T!^2M<`kD zIgQt~9m39xy9u%#6Az0X`4ZRO>*h|2315q_#BmxK;+8o+{_>`ra!+QDkjdP!wo)XI zj&ob|%$Kk|W;hi5AA=AlnlHGE0}63;HFNAAbLoXU%b@R>daI3g!Z3B3>R1{=dH>So zLarxhCxp`6-$9RM{+T<2P`!Y+;2$bg1U;v#0;*m_q@a74&#`g6w8k%RwA6W$P4&H= z+j}1zG(Ml2r2bqT^r*;}+KsW){Yy!UgXG8~t7?U>Bl1DO2DHhiY;xB$g14Ja3V%-B zQU14Rq2KDm)?lo~!`0%R^{_uu@|>WkVK$Mf)!)b+=PQ@nItM0VvbGLsd!t?>J(W4B zfHNn44wt}8A>>uuBWR}JVNS;nW(p{#G%$&Q>I@Vl7(5*fHYD+HXj2!7ZV<*kph{We zhJ-FRV$rKyy~Y&GMWEz;=l^$>Wc;7OE&4P^rgvbO-?Kk4+JuS?=`}-hG6)EE03VhY z1z|&JJ~+xPVd`F|p;D&^Q_T(i+q9!o`V#ci6%1C@+#{x-!D6O2O8P;~S{F|~aK$k7?tj~-yGhM`tvrA zMzH@F^@AY?n2a--O-4-tLUYMWL(c^z#RU&CN`pATljt1Bb_z@qK#mhSEe8_C$p8{Z zoujDQ=P^gm9RD#XCwPn}0fD4HI})>hPp4)SS)1EL^ub16e^*WZrS5bHa9Qhpf^?$5 zWmWK({*0i{a(Gne=oz&`Y43#q(5-pZQ0Q(Ark*kU5l1j3xN*sb<3j&ybC3+>cJd#y z-IPF1vf*m=2aBGBh8z`T)kP?BF=6XFM))ONLpr|bl{tj1_<;|QNRq%XFtIUk;J9!s z7#8%wK1?_{3 zxfJ;DNVH%I_Nbdbwr08>-cEA6f5i_$TUwsC3cnve5R=W1O z7DM4Tls`SWs5$GXTRm1}v^GO}Q;(4XFNdAst@Az2GPjE${;B;^FXF4{j|M6gaJAObxyr^<2Gs=yH#l0p;^=?mp zrjsUk)!;_|TwL__dXW~xv zQfpor6aOP2dsDV#LM<&*{1v@BLC}vDld}2AxYR>6eMVfj{V&TG^qsySH z4l_e)%}fum>Q%L)lvyryW)^-+bJ*hq=uT^u%_&;b2~!Hf{4>(o0;nNH1P~Q74%8B`iqt#nsee1vbuJB%;yb z_Oi`QpZv3i29ufA{BICSH{I@S+yCGTiR%_p<{6ndF;+5OFyP`^{(iS>bye!DjR6e~ zXRi+G!Oe5aHqLLS|I6zp(fctQ*Ff)g)>^YLW;z2ETUXNq z!Cf*dXBtlkGWi3h`PO$sVI@0 zwiEYXi$@)kSVa0oR!=_g{n6<*Lt3I6$L8dtydGOw7nChUq~OW5>t@gZ_GR+I<#=wsZEAq zM%hj5<7?I?iyIryitDC*H!p45X{5F+a*u`(Wc5UoXnZo4#FkKm)~-F;r1m-+!2@xn zqo1C&QzkF_eHImuae8IXk4i{lk6?6daEyR^=0%_$*_gE01T{+p}GF9B*-aFaMH1*HMv?N~1w6DXBPY;OD*5$De#H zo<*WY=GOB&N#DdT@BRG~r6Eu)UnTF=?)A2t939ey$Fu5%HO+x8*APpi0|k#~$q>CC z%|Flg$8$85#KMw_ebCvuyR1|6qE=S0SKe)_WxrmuT%DFa`q3=*%FwPQIY)whjOp`+ z)3y3basRmBpV!~`or(gWIC#RB`FXmiISbwOhAf5|B{^0zSRzIc8NgPb(sxQS0P5LR zOU#7$#EOq!SWef#eGZYrH-@5e~QBwe3XW z(&~Zj57y8Z1lw;A?q~0lG`y8xxYm@5@=l~(&GCGi|CW#?Abfa`g)Rgyuoy=6Ns@X~ zued&8-dwAG1kV?F)P8lC(_i=8RuK%vqI1%Mpsk_L3!wc!9p>o1hSB%cCv2J*&gPFx zn`sPM6ow=YslTe;H_`Cz0SUvm(4{)xQUZO199uS>1&`f@Hv@C+kJ|KQ9d%^{r)5Gn zw|q1v{>MtESH`6+lhK{m3uHBeXOID)Eo@B4+e~@$S7sgnT`PF z8Ggmz^JAtl1Q|&-SAV45xATCVmThEFea!`;W0?5#Opih52Q3%fUwzN(zMidpueWS- z>F=)j7xq9|{o4wCQP^9$ztaCV7H^Fks!}DZJyk*dC|Ro?snW~dx+tN!muS>`2vZfJ z_6E@eC^WoKMr!Grl)&ZfAtU zITGx2WNYJ2*BUH_)fqfOfwN4md>C6vZZAoXjq2!Eb-xh|p|?=)Cwhm!0w^Q*E@$0( ze!XDmiR=3NT>{YKY4i&pg#5sL-S9AVr_^)SX-|Re2)MT);DS~Fz=>`JU%O1{xzJ=o z1@)Z)NqITYcf?$&M}&^WyPr_{hcPpokf@my)&UN7b{R|P&jV|(NCi)vPg+Up4W4DlRAiIn@2 ztP%>b(x9DjgTlL;0Y6E^1{DgZP$VWO6u?D@UBHmt?oSF#ma+bRt7806$9sinpcbG5 z7LfML*+{YyveaHT$OPSyg}j=&JGdP!g=*1KNXTb{&WRW5^Oy8t_%8JHM}+&Ypm2vk z@gV5G$(C^l9(B{kpy%7}I#W?1-+!P~8Dd^9)IpNJ;LN%Gfby27f1K3Ek;^>;hcLLP zihtl@MEU_)dHTw}u44x|j$N!Q%CmkXoQ_!$uOK(Y{@kWYQO`8T75$XTdrGq$s{1|t z87cwJ7D6`hC&sb?r~#wp+DGpU79v8%C2qVb1B+Z}yRU zH=mgy4J@sYoO+S%xypJP3#HLt>Fk6SM8|vxz(V19VC>ileXgAKS%MhJgG#~oyr-}{ z;#t8y4H9{IrD746L2=p3+tKp&XKv@IveEh~#*IX$*85uXO2OzhlwQBemHWF^M|xI0 zdW0OmgoQ+P3p!pco{H-5f4NiE;b zZ$OJYS&5YcKVPCZY=zyf_x?O*m;QZrbBwq$u^#sW)^o+meIC4j4w6-*guf#?9p{GZvQ=yMF28O5M%(C z4IzGV=RdA{Y$?8szI<`S@8gTPo4bYu1JBhiXf8-v&lpX#xmOBLRMi&^XHMJQlj)3^ zB6|W;y$kB>?{e>0Nlps0y#4LXignrO^Xv*wNtiD&YJagofWTv*ihaFPw|;)NJFrCJ%UH$ZG6vQUaOJ5m*0cJ^0lEk7~JG5Th`P? zKY%no{qxD$#@Mf1VvV5>+_pZ3-8XP*QwP)%JnycR-wKhDX&yui6R*CXqMK-wt+{nw z;Sz8GdBAVTxz`lvPU%+F=NOcZhTH>E4~x8-O4DDKpma2j67m;7A_i6yLW=quphEzG z#X6ux|3!4$((1ld5HAoN$vaX+c{)@4XkB;&h)3pVKvd31#w=Gyq39M#(e$QUbVJy_jF32h^zgECx7T?77EvL$0 zOo6)CM}<|2P@T9Oed->>9UEINl$8RCQXn zLH8zK29N_{*F7mE4Eq3u0-XTr1?ehwxupdYRXFDcG!L*v|Dzt9EHZ;|KnW2Ir(R3z zLBO1e{F{9P3Cq9e0TNyo7Im9CMO#(9o;{-|SKtr?QDsL?qEI0=ATly~b7*4x&V`D^ zCaKUIf=A`_2LYild{P#>d|_oFtk#wU-EtN8xScMS>bqQevDA5SEy;ou_1iP}gt?5| z4)H7L7HXLSOk+w3BtGU&A6}oSqK;I<@*9IJhow_!MAgj5+yIoh2 zAhZu;B=XL?b0*7IQIgF<`#|r3Z#hN);`ktkhTOY43CX%2ks5CgW`_kD2i_>eqs*uL zWWMn*%^h&2*Id0b4jC;8dKu#%^V1`Z&7r3IvWR%vLl}PiIi>jnky%=Wm@FZkL)cX{ z92ye@sjlnAX%gBIzgHw()K@tAbj$X^a zv+0OwYooG?PF(IEj0!ou0n|?yI5`^^oe8=HqTr@m#5>O)d^z)0R(yXWsdh+oOZS`Q zPX#bO^tsRV*-J=H;$McbHd%HpO-q9CCG{qx?r@PmaaL4bfr!by`e_J(V)ro66KnpD zChfanA{Yw1x-OJB0NEq9&U5m~pDJ~z2rT#p)JYi@1b{*XoVz(dESCT{ml-qV{=N?q z1w_=VyaGcjGHzV*vO<)1nnG>Ync~Hcz{I1=ITF}ZO~CYjLF?;2 zAbkImzDfOU^dbdwA{*B_0ATcfYdq=^DTkJBOWOHlcR$KIW6L%FqB|!uK=*kczC8pe z^KTcnwzmWHLK7C?&^cT$M(KVu(AuIu-U^WJXGD9~zs`|JXxK+n>i=01W}iVG zr6@<>wy{meMso6qPWXalkxYfsBWxs)NIFQ>+x9sza$KPV8Dj1APcNz+*Q)f9@dLL; z{+F1cABq{a%GR=xL%i!!rQfesmDQWcjCv^S@GNyl4tqusw&{caR5|5LkTjh^z zX+R%Ht(Dm`;4>VSUznlvA{TsnEWHS4$EBxd{#?{px9@GucSuuBjIMY2M^rLXeQaKYy$kR|hq3IuZRO7x-jYE?3+5MwjMUAz| z+UsAFkxr-xha_((Mcfo3xUJ&3){Dxuo*Vmu0C~%hS5q#?26B(esp!l*V^B_iCCP$B ziHq5is0Zw4!LS+xuZ2vffCIpak${NF z2qZd@oJEmOA_a>c49K*9?gPDt5%jP5*6eMy*NR{7$Zu`)N3C4hTaN(I6BHf?gXk%) zIxO4t!<{^VMbJG!iVkE0=^r7t>>^0g7ZA6XqCmO?ZnW%6qwdL^+UqQc2jX%v68<2& zTBcem9SsFdCMvpT&YT-AA-8}iH1uxYTf|=J-x$A88pAhaTt$fm90iD>nvHNgL;C)c zK>q-ri_8VaOBgadP#1>k8OWiddS2ZZEa4I0*`-hRzP8Puwj2iq6+h+CAS&xf9(BA| zOdi^?6Z=3-=<87>ayd-xh^)S^d>Fl<0m&~2et>}fa)L%*(vF-UDZtyWoSEqJ^Xr8Q z@d4q#RU}Bd69kK)*A@fUND30my>SEOzy15K(E~b1-7(YYo0%RcLi<|Qd)*)frL!4A zLOpvEY}>wI3KrdU{~I7K!`h)zJeCdoF_!56L&;M+Q=JE)k8p!lp0#AlI2aLRd940xO8)2c;q%_wa_-fq4KiT0YSH z;4?Y@h~dHwAgk0kn+&Xy{$5Pwk7?zX9UYzMNy;Ch2pW+5E(Y|2Xb@+iprjwas~tlU zo8E85?$4g4)vQ`MrSLnT0;4d;UUd*IgE5xMK=zs)5*lN%(D|Q4fm}@QD9Sb?|D^q^ zT>1W1=HzAnOaumOPdjyCLE{kSDVwtf22gBWH=2GQ1Xbc?Cs98o2Qc8kx%|)b9Q#d> z2wwviTJy`-K-u)o-`Vu{3^3C~kisy)e}~7$!i4|)Pxa7mI>Evw#bG2P=abeZpBmvzi;Fz^^9|;={p08WvC3Y?8h*Mmb)Au)n#!f~?Z7 zm^h8Nwu#)$eeMx4t02Rv=Km$2x?*~9XIs%GUoWBOQuaOZk;mUfItJ>m6ii5*owGdg zUWZ1T9tJ1)p#K@!zXnertNBD2*YO}?A*|@jJy^$%qAs$3n53oR(HiID*A<@%g>Lsn zNQ<4-tFkqrW%lFY{3ux-7U-9&cH%OVl<_;4Q~5R<#EvS*7~D|DNuH%==|zgTdiZ2veKD@y07V|$L+%OoSyy2p^|K;kOJ?HXLNf&l|! zXF9be{VTevm)=RB+Fi#^MzooQH-G1%=X~%b(95*qLnG|Pov}k0SWs55pjgnKU+W2e z{|#7BQZONw<|kp2xl3`$9KDv{*U3o1_B`L^i{NL8Rj+(SNq;wC+0n6^h`M1pMLiUxm6zVxu^+(Dx0;X-q zTq>8_S*A7W8(3U)c~eXqzGG$a`R-OiC#P=WSEfxkG&=-_PhOeqmGvKK*CVHjxOBZ@ pEwzL`>i*8R__Kv1*C}gmHZq>QI%40h(qzO + + + + + + + + +       + + + ${PATTERN_DEFAULT} + + + + + + + + + + ${PATTERN_DEFAULT} + + + + ${LOG_FILE} + + + ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} + + ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} + + ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} + + ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} + + ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} + + + + + + 0 + + 256 + + + + + + + + ${PATTERN_DEFAULT} + + + + + + + + + + + + + + + + + + + + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java new file mode 100644 index 00000000..a6de8d9e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.infra.service; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.generator.query.DefaultQuery; +import com.baomidou.mybatisplus.generator.config.DataSourceConfig; +import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; +import com.baomidou.mybatisplus.generator.config.po.TableInfo; + +import java.util.List; + +public class DefaultDatabaseQueryTest { + + public static void main(String[] args) { +// DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:oracle:thin:@127.0.0.1:1521:xe", +// "root", "123456").build(); + DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro", + "root", "123456").build(); +// StrategyConfig strategyConfig = new StrategyConfig.Builder().build(); + + ConfigBuilder builder = new ConfigBuilder(null, dataSourceConfig, null, null, null, null); + + DefaultQuery query = new DefaultQuery(builder); + + long time = System.currentTimeMillis(); + List tableInfos = query.queryTables(); + for (TableInfo tableInfo : tableInfos) { + if (StrUtil.startWithAny(tableInfo.getName().toLowerCase(), "act_", "flw_", "qrtz_")) { + continue; + } + System.out.println(String.format("CREATE SEQUENCE %s_seq MINVALUE 1;", tableInfo.getName())); +// System.out.println(String.format("DELETE FROM %s WHERE deleted = '1';", tableInfo.getName())); + } + System.out.println(tableInfos.size()); + System.out.println(System.currentTimeMillis() - time); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java new file mode 100644 index 00000000..5d1cedbc --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java @@ -0,0 +1,558 @@ +package cn.iocoder.yudao.module.infra.service.codegen; + +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.map.MapUtil; +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.codegen.vo.CodegenCreateListReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenUpdateReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.column.CodegenColumnSaveReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.CodegenTablePageReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.DatabaseTableRespVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.wms.dal.mysql.codegen.CodegenColumnMapper; +import cn.iocoder.yudao.module.wms.dal.mysql.codegen.CodegenTableMapper; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenFrontTypeEnum; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenSceneEnum; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenTemplateTypeEnum; +import cn.iocoder.yudao.module.wms.framework.codegen.config.CodegenProperties; +import cn.iocoder.yudao.module.wms.service.codegen.CodegenServiceImpl; +import cn.iocoder.yudao.module.wms.service.codegen.inner.CodegenBuilder; +import cn.iocoder.yudao.module.wms.service.codegen.inner.CodegenEngine; +import cn.iocoder.yudao.module.wms.service.db.DatabaseTableService; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import com.baomidou.mybatisplus.generator.config.po.TableField; +import com.baomidou.mybatisplus.generator.config.po.TableInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +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.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * {@link CodegenServiceImpl} 的单元测试类 + * + + */ +@Import(CodegenServiceImpl.class) +public class CodegenServiceImplTest extends BaseDbUnitTest { + + @Resource + private CodegenServiceImpl codegenService; + + @Resource + private CodegenTableMapper codegenTableMapper; + @Resource + private CodegenColumnMapper codegenColumnMapper; + + @MockBean + private DatabaseTableService databaseTableService; + + @MockBean + private AdminUserApi userApi; + + @MockBean + private CodegenBuilder codegenBuilder; + @MockBean + private CodegenEngine codegenEngine; + + @MockBean + private CodegenProperties codegenProperties; + + @Test + public void testCreateCodegenList() { + // 准备参数 + Long userId = randomLongId(); + CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class, + o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai"))); + // mock 方法(TableInfo) + TableInfo tableInfo = mock(TableInfo.class); + when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) + .thenReturn(tableInfo); + when(tableInfo.getComment()).thenReturn("芋艿"); + // mock 方法(TableInfo fields) + TableField field01 = mock(TableField.class); + when(field01.getComment()).thenReturn("主键"); + TableField field02 = mock(TableField.class); + when(field02.getComment()).thenReturn("名字"); + List fields = Arrays.asList(field01, field02); + when(tableInfo.getFields()).thenReturn(fields); + // mock 方法(CodegenTableDO) + CodegenTableDO table = randomPojo(CodegenTableDO.class); + when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table); + // mock 方法(AdminUserRespDTO) + AdminUserRespDTO user = randomPojo(AdminUserRespDTO.class, o -> o.setNickname("芋头")); + when(userApi.getUser(eq(userId))).thenReturn(success(user)); + // mock 方法(CodegenColumnDO) + List columns = randomPojoList(CodegenColumnDO.class); + when(codegenBuilder.buildColumns(eq(table.getId()), same(fields))) + .thenReturn(columns); + // mock 方法(CodegenProperties) + when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3.getType()); + + // 调用 + List result = codegenService.createCodegenList(userId, reqVO); + // 断言 + assertEquals(1, result.size()); + // 断言(CodegenTableDO) + CodegenTableDO dbTable = codegenTableMapper.selectList().get(0); + assertPojoEquals(table, dbTable); + assertEquals(1L, dbTable.getDataSourceConfigId()); + assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene()); + assertEquals(CodegenFrontTypeEnum.VUE3.getType(), dbTable.getFrontType()); + assertEquals("芋头", dbTable.getAuthor()); + // 断言(CodegenColumnDO) + List dbColumns = codegenColumnMapper.selectList(); + assertEquals(columns.size(), dbColumns.size()); + assertTrue(dbColumns.get(0).getPrimaryKey()); + for (int i = 0; i < dbColumns.size(); i++) { + assertPojoEquals(columns.get(i), dbColumns.get(i)); + } + } + + @Test + public void testValidateTableInfo() { + // 情况一 + assertServiceException(() -> codegenService.validateTableInfo(null), + CODEGEN_IMPORT_TABLE_NULL); + // 情况二 + TableInfo tableInfo = mock(TableInfo.class); + assertServiceException(() -> codegenService.validateTableInfo(tableInfo), + CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL); + // 情况三 + when(tableInfo.getComment()).thenReturn("芋艿"); + assertServiceException(() -> codegenService.validateTableInfo(tableInfo), + CODEGEN_IMPORT_COLUMNS_NULL); + // 情况四 + TableField field = mock(TableField.class); + when(field.getName()).thenReturn("name"); + when(tableInfo.getFields()).thenReturn(Collections.singletonList(field)); + assertServiceException(() -> codegenService.validateTableInfo(tableInfo), + CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL, field.getName()); + } + + @Test + public void testUpdateCodegen_notExists() { + // 准备参数 + CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class); + // mock 方法 + + // 调用,并断言 + assertServiceException(() -> codegenService.updateCodegen(updateReqVO), + CODEGEN_TABLE_NOT_EXISTS); + } + + @Test + public void testUpdateCodegen_sub_masterNotExists() { + // mock 数据 + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(table); + // 准备参数 + CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, + o -> o.getTable().setId(table.getId()) + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType())); + + // 调用,并断言 + assertServiceException(() -> codegenService.updateCodegen(updateReqVO), + CODEGEN_MASTER_TABLE_NOT_EXISTS, updateReqVO.getTable().getMasterTableId()); + } + + @Test + public void testUpdateCodegen_sub_columnNotExists() { + // mock 数据 + CodegenTableDO subTable = randomPojo(CodegenTableDO.class, + o -> o.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(subTable); + // mock 数据(master) + CodegenTableDO masterTable = randomPojo(CodegenTableDO.class, + o -> o.setTemplateType(CodegenTemplateTypeEnum.MASTER_ERP.getType()) + .setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(masterTable); + // 准备参数 + CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, + o -> o.getTable().setId(subTable.getId()) + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setMasterTableId(masterTable.getId())); + + // 调用,并断言 + assertServiceException(() -> codegenService.updateCodegen(updateReqVO), + CODEGEN_SUB_COLUMN_NOT_EXISTS, updateReqVO.getTable().getSubJoinColumnId()); + } + + @Test + public void testUpdateCodegen_success() { + // mock 数据 + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setTemplateType(CodegenTemplateTypeEnum.ONE.getType()) + .setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(table); + CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column01); + CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column02); + // 准备参数 + CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, + o -> o.getTable().setId(table.getId()) + .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()) + .setScene(CodegenSceneEnum.ADMIN.getScene())); + CodegenColumnSaveReqVO columnVO01 = randomPojo(CodegenColumnSaveReqVO.class, + o -> o.setId(column01.getId()).setTableId(table.getId())); + CodegenColumnSaveReqVO columnVO02 = randomPojo(CodegenColumnSaveReqVO.class, + o -> o.setId(column02.getId()).setTableId(table.getId())); + updateReqVO.setColumns(Arrays.asList(columnVO01, columnVO02)); + + // 调用 + codegenService.updateCodegen(updateReqVO); + // 断言 + CodegenTableDO dbTable = codegenTableMapper.selectById(table.getId()); + assertPojoEquals(updateReqVO.getTable(), dbTable); + List dbColumns = codegenColumnMapper.selectList(); + assertEquals(2, dbColumns.size()); + assertPojoEquals(columnVO01, dbColumns.get(0)); + assertPojoEquals(columnVO02, dbColumns.get(1)); + } + + @Test + public void testSyncCodegenFromDB() { + // mock 数据(CodegenTableDO) + CodegenTableDO table = randomPojo(CodegenTableDO.class, o -> o.setTableName("t_yunai") + .setDataSourceConfigId(1L).setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(table); + CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()) + .setColumnName("id")); + codegenColumnMapper.insert(column01); + CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()) + .setColumnName("name")); + codegenColumnMapper.insert(column02); + // 准备参数 + Long tableId = table.getId(); + // mock 方法(TableInfo) + TableInfo tableInfo = mock(TableInfo.class); + when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) + .thenReturn(tableInfo); + when(tableInfo.getComment()).thenReturn("芋艿"); + // mock 方法(TableInfo fields) + TableField field01 = mock(TableField.class); + when(field01.getComment()).thenReturn("主键"); + TableField field03 = mock(TableField.class); + when(field03.getComment()).thenReturn("分类"); + List fields = Arrays.asList(field01, field03); + when(tableInfo.getFields()).thenReturn(fields); + when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) + .thenReturn(tableInfo); + // mock 方法(CodegenTableDO) + List newColumns = randomPojoList(CodegenColumnDO.class); + when(codegenBuilder.buildColumns(eq(table.getId()), argThat(tableFields -> { + assertEquals(2, tableFields.size()); + assertSame(tableInfo.getFields(), tableFields); + return true; + }))).thenReturn(newColumns); + + // 调用 + codegenService.syncCodegenFromDB(tableId); + // 断言 + List dbColumns = codegenColumnMapper.selectList(); + assertEquals(newColumns.size(), dbColumns.size()); + assertPojoEquals(newColumns.get(0), dbColumns.get(0)); + assertPojoEquals(newColumns.get(1), dbColumns.get(1)); + } + + @Test + public void testDeleteCodegen_notExists() { + assertServiceException(() -> codegenService.deleteCodegen(randomLongId()), + CODEGEN_TABLE_NOT_EXISTS); + } + + @Test + public void testDeleteCodegen_success() { + // mock 数据 + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(table); + CodegenColumnDO column = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column); + // 准备参数 + Long tableId = table.getId(); + + // 调用 + codegenService.deleteCodegen(tableId); + // 断言 + assertNull(codegenTableMapper.selectById(tableId)); + assertEquals(0, codegenColumnMapper.selectList().size()); + } + + @Test + public void testGetCodegenTableList() { + // mock 数据 + CodegenTableDO table01 = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(table01); + CodegenTableDO table02 = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(table02); + // 准备参数 + Long dataSourceConfigId = table01.getDataSourceConfigId(); + + // 调用 + List result = codegenService.getCodegenTableList(dataSourceConfigId); + // 断言 + assertEquals(1, result.size()); + assertPojoEquals(table01, result.get(0)); + } + + @Test + public void testGetCodegenTablePage() { + // mock 数据 + CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, o -> { + o.setTableName("t_yunai"); + o.setTableComment("芋艿"); + o.setClassName("SystemYunai"); + o.setCreateTime(buildTime(2021, 3, 10)); + }).setScene(CodegenSceneEnum.ADMIN.getScene()); + codegenTableMapper.insert(tableDO); + // 测试 tableName 不匹配 + codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setTableName(randomString()))); + // 测试 tableComment 不匹配 + codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setTableComment(randomString()))); + // 测试 className 不匹配 + codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setClassName(randomString()))); + // 测试 createTime 不匹配 + codegenTableMapper.insert(cloneIgnoreId(tableDO, logDO -> logDO.setCreateTime(buildTime(2021, 4, 10)))); + // 准备参数 + CodegenTablePageReqVO reqVO = new CodegenTablePageReqVO(); + reqVO.setTableName("yunai"); + reqVO.setTableComment("芋"); + reqVO.setClassName("Yunai"); + reqVO.setCreateTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31)); + + // 调用 + PageResult pageResult = codegenService.getCodegenTablePage(reqVO); + // 断言,只查到了一条符合条件的 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(tableDO, pageResult.getList().get(0)); + } + + @Test + public void testGetCodegenTable() { + // mock 数据 + CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); + codegenTableMapper.insert(tableDO); + // 准备参数 + Long id = tableDO.getId(); + + // 调用 + CodegenTableDO result = codegenService.getCodegenTable(id); + // 断言 + assertPojoEquals(tableDO, result); + } + + @Test + public void testGetCodegenColumnListByTableId() { + // mock 数据 + CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class); + codegenColumnMapper.insert(column01); + CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class); + codegenColumnMapper.insert(column02); + // 准备参数 + Long tableId = column01.getTableId(); + + // 调用 + List result = codegenService.getCodegenColumnListByTableId(tableId); + // 断言 + assertEquals(1, result.size()); + assertPojoEquals(column01, result.get(0)); + } + + @Test + public void testGenerationCodes_tableNotExists() { + assertServiceException(() -> codegenService.generationCodes(randomLongId()), + CODEGEN_TABLE_NOT_EXISTS); + } + + @Test + public void testGenerationCodes_columnNotExists() { + // mock 数据(CodegenTableDO) + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); + codegenTableMapper.insert(table); + // 准备参数 + Long tableId = table.getId(); + + // 调用,并断言 + assertServiceException(() -> codegenService.generationCodes(tableId), + CODEGEN_COLUMN_NOT_EXISTS); + } + + @Test + public void testGenerationCodes_sub_tableNotExists() { + // mock 数据(CodegenTableDO) + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); + codegenTableMapper.insert(table); + // mock 数据(CodegenColumnDO) + CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column01); + // 准备参数 + Long tableId = table.getId(); + + // 调用,并断言 + assertServiceException(() -> codegenService.generationCodes(tableId), + CODEGEN_MASTER_GENERATION_FAIL_NO_SUB_TABLE); + } + + @Test + public void testGenerationCodes_sub_columnNotExists() { + // mock 数据(CodegenTableDO) + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); + codegenTableMapper.insert(table); + // mock 数据(CodegenColumnDO) + CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column01); + // mock 数据(sub CodegenTableDO) + CodegenTableDO subTable = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setMasterTableId(table.getId())); + codegenTableMapper.insert(subTable); + // 准备参数 + Long tableId = table.getId(); + + // 调用,并断言 + assertServiceException(() -> codegenService.generationCodes(tableId), + CODEGEN_SUB_COLUMN_NOT_EXISTS, subTable.getId()); + } + + @Test + public void testGenerationCodes_one_success() { + // mock 数据(CodegenTableDO) + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTemplateType(CodegenTemplateTypeEnum.ONE.getType())); + codegenTableMapper.insert(table); + // mock 数据(CodegenColumnDO) + CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column01); + CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column02); + // mock 执行生成 + Map codes = MapUtil.of(randomString(), randomString()); + when(codegenEngine.execute(eq(table), argThat(columns -> { + assertEquals(2, columns.size()); + assertEquals(column01, columns.get(0)); + assertEquals(column02, columns.get(1)); + return true; + }), isNull(), isNull())).thenReturn(codes); + // 准备参数 + Long tableId = table.getId(); + + // 调用 + Map result = codegenService.generationCodes(tableId); + // 断言 + assertSame(codes, result); + } + + @Test + public void testGenerationCodes_master_success() { + // mock 数据(CodegenTableDO) + CodegenTableDO table = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); + codegenTableMapper.insert(table); + // mock 数据(CodegenColumnDO) + CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column01); + CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); + codegenColumnMapper.insert(column02); + // mock 数据(sub CodegenTableDO) + CodegenTableDO subTable = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setMasterTableId(table.getId()) + .setSubJoinColumnId(1024L)); + codegenTableMapper.insert(subTable); + // mock 数据(sub CodegenColumnDO) + CodegenColumnDO subColumn01 = randomPojo(CodegenColumnDO.class, o -> o.setId(1024L).setTableId(subTable.getId())); + codegenColumnMapper.insert(subColumn01); + // mock 执行生成 + Map codes = MapUtil.of(randomString(), randomString()); + when(codegenEngine.execute(eq(table), argThat(columns -> { + assertEquals(2, columns.size()); + assertEquals(column01, columns.get(0)); + assertEquals(column02, columns.get(1)); + return true; + }), argThat(tables -> { + assertEquals(1, tables.size()); + assertPojoEquals(subTable, tables.get(0)); + return true; + }), argThat(columns -> { + assertEquals(1, columns.size()); + assertPojoEquals(subColumn01, columns.size()); + return true; + }))).thenReturn(codes); + // 准备参数 + Long tableId = table.getId(); + + // 调用 + Map result = codegenService.generationCodes(tableId); + // 断言 + assertSame(codes, result); + } + + @Test + public void testGetDatabaseTableList() { + // 准备参数 + Long dataSourceConfigId = randomLongId(); + String name = randomString(); + String comment = randomString(); + // mock 方法 + TableInfo tableInfo01 = mock(TableInfo.class); + when(tableInfo01.getName()).thenReturn("t_yunai"); + when(tableInfo01.getComment()).thenReturn("芋艿"); + TableInfo tableInfo02 = mock(TableInfo.class); + when(tableInfo02.getName()).thenReturn("t_yunai_02"); + when(tableInfo02.getComment()).thenReturn("芋艿_02"); + when(databaseTableService.getTableList(eq(dataSourceConfigId), eq(name), eq(comment))) + .thenReturn(ListUtil.toList(tableInfo01, tableInfo02)); + // mock 数据 + CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, + o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) + .setTableName("t_yunai_02") + .setDataSourceConfigId(dataSourceConfigId)); + codegenTableMapper.insert(tableDO); + + // 调用 + List result = codegenService.getDatabaseTableList(dataSourceConfigId, name, comment); + // 断言 + assertEquals(1, result.size()); + assertEquals("t_yunai", result.get(0).getName()); + assertEquals("芋艿", result.get(0).getComment()); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java new file mode 100644 index 00000000..afe2beef --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java @@ -0,0 +1,90 @@ +package cn.iocoder.yudao.module.infra.service.codegen.inner; + +import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.wms.service.codegen.inner.CodegenBuilder; +import com.baomidou.mybatisplus.generator.config.po.TableField; +import com.baomidou.mybatisplus.generator.config.po.TableInfo; +import com.baomidou.mybatisplus.generator.config.rules.IColumnType; +import org.apache.ibatis.type.JdbcType; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; + +import java.util.Collections; +import java.util.List; + +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class CodegenBuilderTest extends BaseMockitoUnitTest { + + @InjectMocks + private CodegenBuilder codegenBuilder; + + @Test + public void testBuildTable() { + // 准备参数 + TableInfo tableInfo = mock(TableInfo.class); + // mock 方法 + when(tableInfo.getName()).thenReturn("system_user"); + when(tableInfo.getComment()).thenReturn("用户"); + + // 调用 + CodegenTableDO table = codegenBuilder.buildTable(tableInfo); + // 断言 + assertEquals("system_user", table.getTableName()); + assertEquals("用户", table.getTableComment()); + assertEquals("system", table.getModuleName()); + assertEquals("user", table.getBusinessName()); + assertEquals("User", table.getClassName()); + assertEquals("用户", table.getClassComment()); + } + + @Test + public void testBuildColumns() { + // 准备参数 + Long tableId = randomLongId(); + TableField tableField = mock(TableField.class); + List tableFields = Collections.singletonList(tableField); + // mock 方法 + TableField.MetaInfo metaInfo = mock(TableField.MetaInfo.class); + when(tableField.getMetaInfo()).thenReturn(metaInfo); + when(metaInfo.getJdbcType()).thenReturn(JdbcType.BIGINT); + when(tableField.getComment()).thenReturn("编号"); + when(tableField.isKeyFlag()).thenReturn(true); + when(tableField.isKeyIdentityFlag()).thenReturn(true); + IColumnType columnType = mock(IColumnType.class); + when(tableField.getColumnType()).thenReturn(columnType); + when(columnType.getType()).thenReturn("Long"); + when(tableField.getName()).thenReturn("id2"); + when(tableField.getPropertyName()).thenReturn("id"); + + // 调用 + List columns = codegenBuilder.buildColumns(tableId, tableFields); + // 断言 + assertEquals(1, columns.size()); + CodegenColumnDO column = columns.get(0); + assertEquals(tableId, column.getTableId()); + assertEquals("id2", column.getColumnName()); + assertEquals("BIGINT", column.getDataType()); + assertEquals("编号", column.getColumnComment()); + assertFalse(column.getNullable()); + assertTrue(column.getPrimaryKey()); + assertTrue(column.getAutoIncrement()); + assertEquals(1, column.getOrdinalPosition()); + assertEquals("Long", column.getJavaType()); + assertEquals("id", column.getJavaField()); + assertNull(column.getDictType()); + assertNotNull(column.getExample()); + assertFalse(column.getCreateOperation()); + assertTrue(column.getUpdateOperation()); + assertFalse(column.getListOperation()); + assertEquals("=", column.getListOperationCondition()); + assertTrue(column.getListOperationResult()); + assertEquals("input", column.getHtmlType()); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java new file mode 100644 index 00000000..a268a73c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java @@ -0,0 +1,128 @@ +package cn.iocoder.yudao.module.infra.service.codegen.inner; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.io.resource.ResourceUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ZipUtil; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.wms.framework.codegen.config.CodegenProperties; +import cn.iocoder.yudao.module.wms.service.codegen.inner.CodegenEngine; +import org.junit.jupiter.api.BeforeEach; +import org.mockito.InjectMocks; +import org.mockito.Spy; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * {@link CodegenEngine} 的单元测试抽象基类 + * + + */ +public abstract class CodegenEngineAbstractTest extends BaseMockitoUnitTest { + + @InjectMocks + protected CodegenEngine codegenEngine; + + @Spy + protected CodegenProperties codegenProperties = new CodegenProperties() + .setBasePackage("cn.iocoder.yudao"); + + @BeforeEach + public void setUp() { + codegenEngine.initGlobalBindingMap(); + } + + protected static CodegenTableDO getTable(String name) { + String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); + return JsonUtils.parseObject(content, "table", CodegenTableDO.class); + } + + protected static List getColumnList(String name) { + String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); + List list = JsonUtils.parseArray(content, "columns", CodegenColumnDO.class); + list.forEach(column -> { + if (column.getNullable() == null) { + column.setNullable(false); + } + if (column.getCreateOperation() == null) { + column.setCreateOperation(false); + } + if (column.getUpdateOperation() == null) { + column.setUpdateOperation(false); + } + if (column.getListOperation() == null) { + column.setListOperation(false); + } + if (column.getListOperationResult() == null) { + column.setListOperationResult(false); + } + }); + return list; + } + + @SuppressWarnings("rawtypes") + protected static void assertResult(Map result, String path) { + String assertContent = ResourceUtil.readUtf8Str(path + "/assert.json"); + List asserts = JsonUtils.parseArray(assertContent, HashMap.class); + assertEquals(asserts.size(), result.size()); + // 校验每个文件 + asserts.forEach(assertMap -> { + String contentPath = (String) assertMap.get("contentPath"); + String filePath = (String) assertMap.get("filePath"); + String content = ResourceUtil.readUtf8Str(path + "/" + contentPath); + assertEquals(content, result.get(filePath), filePath + ":不匹配"); + }); + } + + // ==================== 调试专用 ==================== + + /** + * 【调试使用】将生成的代码,写入到文件 + * + * @param result 生成的代码 + * @param path 写入文件的路径 + */ + protected void writeFile(Map result, String path) { + // 生成压缩包 + String[] paths = result.keySet().toArray(new String[0]); + ByteArrayInputStream[] ins = result.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipUtil.zip(outputStream, paths, ins); + // 写入文件 + FileUtil.writeBytes(outputStream.toByteArray(), path); + } + + /** + * 【调试使用】将生成的结果,写入到文件 + * + * @param result 生成的代码 + * @param basePath 写入文件的路径(绝对路径) + */ + protected void writeResult(Map result, String basePath) { + // 写入文件内容 + List> asserts = new ArrayList<>(); + result.forEach((filePath, fileContent) -> { + String lastFilePath = StrUtil.subAfter(filePath, '/', true); + String contentPath = StrUtil.subAfter(lastFilePath, '.', true) + + '/' + StrUtil.subBefore(lastFilePath, '.', true); + asserts.add(MapUtil.builder().put("filePath", filePath) + .put("contentPath", contentPath).build()); + FileUtil.writeUtf8String(fileContent, basePath + "/" + contentPath); + }); + // 写入 assert.json 文件 + FileUtil.writeUtf8String(JsonUtils.toJsonPrettyString(asserts), basePath +"/assert.json"); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java new file mode 100644 index 00000000..3512d1de --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java @@ -0,0 +1,203 @@ +package cn.iocoder.yudao.module.infra.service.codegen.inner; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.io.resource.ResourceUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ZipUtil; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenFrontTypeEnum; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenTemplateTypeEnum; +import cn.iocoder.yudao.module.wms.framework.codegen.config.CodegenProperties; +import cn.iocoder.yudao.module.wms.service.codegen.inner.CodegenEngine; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Spy; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * {@link CodegenEngine} 的单元测试 + * + + */ +public class CodegenEngineTest extends BaseMockitoUnitTest { + + @InjectMocks + private CodegenEngine codegenEngine; + + @Spy + private CodegenProperties codegenProperties = new CodegenProperties() + .setBasePackage("cn.iocoder.yudao"); + + @BeforeEach + public void setUp() { + codegenEngine.initGlobalBindingMap(); + } + + @Test + public void testExecute_vue3_one() { + // 准备参数 + CodegenTableDO table = getTable("student") + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); + List columns = getColumnList("student"); + + // 调用 + Map result = codegenEngine.execute(table, columns, null, null); + // 断言 + assertResult(result, "codegen/vue3_one"); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_one"); + } + + @Test + public void testExecute_vue3_tree() { + // 准备参数 + CodegenTableDO table = getTable("category") + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); + List columns = getColumnList("category"); + + // 调用 + Map result = codegenEngine.execute(table, columns, null, null); + // 断言 + assertResult(result, "codegen/vue3_tree"); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_tree"); +// writeFile(result, "/Users/yunai/test/demo66.zip"); + } + + @Test + public void testExecute_vue3_master_normal() { + testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "codegen/vue3_master_normal"); + } + + @Test + public void testExecute_vue3_master_erp() { + testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_ERP, "codegen/vue3_master_erp"); + } + + @Test + public void testExecute_vue3_master_inner() { + testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_INNER, "codegen/vue3_master_inner"); + } + + private void testExecute_vue3_master(CodegenTemplateTypeEnum templateType, + String path) { + // 准备参数 + CodegenTableDO table = getTable("student") + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setTemplateType(templateType.getType()); + List columns = getColumnList("student"); + // 准备参数(子表) + CodegenTableDO contactTable = getTable("contact") + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setSubJoinColumnId(100L).setSubJoinMany(true); + List contactColumns = getColumnList("contact"); + // 准备参数(班主任) + CodegenTableDO teacherTable = getTable("teacher") + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setSubJoinColumnId(200L).setSubJoinMany(false); + List teacherColumns = getColumnList("teacher"); + + // 调用 + Map result = codegenEngine.execute(table, columns, + Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); + // 断言 + assertResult(result, path); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/" + path); +// writeFile(result, "/Users/yunai/test/demo11.zip"); + } + + private static CodegenTableDO getTable(String name) { + String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); + return JsonUtils.parseObject(content, "table", CodegenTableDO.class); + } + + private static List getColumnList(String name) { + String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); + List list = JsonUtils.parseArray(content, "columns", CodegenColumnDO.class); + list.forEach(column -> { + if (column.getNullable() == null) { + column.setNullable(false); + } + if (column.getCreateOperation() == null) { + column.setCreateOperation(false); + } + if (column.getUpdateOperation() == null) { + column.setUpdateOperation(false); + } + if (column.getListOperation() == null) { + column.setListOperation(false); + } + if (column.getListOperationResult() == null) { + column.setListOperationResult(false); + } + }); + return list; + } + + @SuppressWarnings("rawtypes") + private static void assertResult(Map result, String path) { + String assertContent = ResourceUtil.readUtf8Str(path + "/assert.json"); + List asserts = JsonUtils.parseArray(assertContent, HashMap.class); + assertEquals(asserts.size(), result.size()); + // 校验每个文件 + asserts.forEach(assertMap -> { + String contentPath = (String) assertMap.get("contentPath"); + String filePath = (String) assertMap.get("filePath"); + String content = ResourceUtil.readUtf8Str(path + "/" + contentPath); + assertEquals(content, result.get(filePath), filePath + ":不匹配"); + }); + } + + // ==================== 调试专用 ==================== + + /** + * 【调试使用】将生成的代码,写入到文件 + * + * @param result 生成的代码 + * @param path 写入文件的路径 + */ + private void writeFile(Map result, String path) { + // 生成压缩包 + String[] paths = result.keySet().toArray(new String[0]); + ByteArrayInputStream[] ins = result.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipUtil.zip(outputStream, paths, ins); + // 写入文件 + FileUtil.writeBytes(outputStream.toByteArray(), path); + } + + /** + * 【调试使用】将生成的结果,写入到文件 + * + * @param result 生成的代码 + * @param basePath 写入文件的路径(绝对路径) + */ + private void writeResult(Map result, String basePath) { + // 写入文件内容 + List> asserts = new ArrayList<>(); + result.forEach((filePath, fileContent) -> { + String lastFilePath = StrUtil.subAfter(filePath, '/', true); + String contentPath = StrUtil.subAfter(lastFilePath, '.', true) + + '/' + StrUtil.subBefore(lastFilePath, '.', true); + asserts.add(MapUtil.builder().put("filePath", filePath) + .put("contentPath", contentPath).build()); + FileUtil.writeUtf8String(fileContent, basePath + "/" + contentPath); + }); + // 写入 assert.json 文件 + FileUtil.writeUtf8String(JsonUtils.toJsonPrettyString(asserts), basePath +"/assert.json"); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java new file mode 100644 index 00000000..8f498736 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java @@ -0,0 +1,99 @@ +package cn.iocoder.yudao.module.infra.service.codegen.inner; + +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenFrontTypeEnum; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenTemplateTypeEnum; +import cn.iocoder.yudao.module.wms.service.codegen.inner.CodegenEngine; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +// TODO @puhui999:单测需要 fix +/** + * {@link CodegenEngine} 的 Vue2 + Element UI 单元测试 + * + + */ +@Disabled +public class CodegenEngineVue2Test extends CodegenEngineAbstractTest { + + @Test + public void testExecute_vue2_one() { + // 准备参数 + CodegenTableDO table = getTable("student") + .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) + .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); + List columns = getColumnList("student"); + + // 调用 + Map result = codegenEngine.execute(table, columns, null, null); + // 断言 + assertResult(result, "codegen/vue2_one"); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one"); + } + + @Test + public void testExecute_vue2_tree() { + // 准备参数 + CodegenTableDO table = getTable("category") + .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) + .setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); + List columns = getColumnList("category"); + + // 调用 + Map result = codegenEngine.execute(table, columns, null, null); + // 断言 + assertResult(result, "codegen/vue2_tree"); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree"); +// writeFile(result, "/Users/yunai/test/demo66.zip"); + } + + @Test + public void testExecute_vue2_master_normal() { + testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "codegen/vue2_master_normal"); + } + + @Test + public void testExecute_vue2_master_erp() { + testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_ERP, "codegen/vue2_master_erp"); + } + + @Test + public void testExecute_vue2_master_inner() { + testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_INNER, "codegen/vue2_master_inner"); + } + + private void testExecute_vue2_master(CodegenTemplateTypeEnum templateType, + String path) { + // 准备参数 + CodegenTableDO table = getTable("student") + .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) + .setTemplateType(templateType.getType()); + List columns = getColumnList("student"); + // 准备参数(子表) + CodegenTableDO contactTable = getTable("contact") + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) + .setSubJoinColumnId(100L).setSubJoinMany(true); + List contactColumns = getColumnList("contact"); + // 准备参数(班主任) + CodegenTableDO teacherTable = getTable("teacher") + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) + .setSubJoinColumnId(200L).setSubJoinMany(false); + List teacherColumns = getColumnList("teacher"); + + // 调用 + Map result = codegenEngine.execute(table, columns, + Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); + // 断言 + assertResult(result, path); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/" + path); +// writeFile(result, "/Users/yunai/test/demo11.zip"); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java new file mode 100644 index 00000000..b32a05ba --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java @@ -0,0 +1,96 @@ +package cn.iocoder.yudao.module.infra.service.codegen.inner; + +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.wms.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenFrontTypeEnum; +import cn.iocoder.yudao.module.wms.enums.codegen.CodegenTemplateTypeEnum; +import cn.iocoder.yudao.module.wms.service.codegen.inner.CodegenEngine; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * {@link CodegenEngine} 的 Vue2 + Element Plus 单元测试 + * + + */ +public class CodegenEngineVue3Test extends CodegenEngineAbstractTest { + + @Test + public void testExecute_vue3_one() { + // 准备参数 + CodegenTableDO table = getTable("student") + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); + List columns = getColumnList("student"); + + // 调用 + Map result = codegenEngine.execute(table, columns, null, null); + // 断言 + assertResult(result, "codegen/vue3_one"); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_one"); + } + + @Test + public void testExecute_vue3_tree() { + // 准备参数 + CodegenTableDO table = getTable("category") + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); + List columns = getColumnList("category"); + + // 调用 + Map result = codegenEngine.execute(table, columns, null, null); + // 断言 + assertResult(result, "codegen/vue3_tree"); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_tree"); +// writeFile(result, "/Users/yunai/test/demo66.zip"); + } + + @Test + public void testExecute_vue3_master_normal() { + testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "codegen/vue3_master_normal"); + } + + @Test + public void testExecute_vue3_master_erp() { + testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_ERP, "codegen/vue3_master_erp"); + } + + @Test + public void testExecute_vue3_master_inner() { + testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_INNER, "codegen/vue3_master_inner"); + } + + private void testExecute_vue3_master(CodegenTemplateTypeEnum templateType, + String path) { + // 准备参数 + CodegenTableDO table = getTable("student") + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setTemplateType(templateType.getType()); + List columns = getColumnList("student"); + // 准备参数(子表) + CodegenTableDO contactTable = getTable("contact") + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setSubJoinColumnId(100L).setSubJoinMany(true); + List contactColumns = getColumnList("contact"); + // 准备参数(班主任) + CodegenTableDO teacherTable = getTable("teacher") + .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) + .setSubJoinColumnId(200L).setSubJoinMany(false); + List teacherColumns = getColumnList("teacher"); + + // 调用 + Map result = codegenEngine.execute(table, columns, + Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); + // 断言 + assertResult(result, path); +// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/" + path); +// writeFile(result, "/Users/yunai/test/demo11.zip"); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java new file mode 100644 index 00000000..0b0e64d6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java @@ -0,0 +1,220 @@ +package cn.iocoder.yudao.module.infra.service.config; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.config.ConfigDO; +import cn.iocoder.yudao.module.wms.dal.mysql.config.ConfigMapper; +import cn.iocoder.yudao.module.wms.enums.config.ConfigTypeEnum; +import cn.iocoder.yudao.module.wms.service.config.ConfigServiceImpl; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.function.Consumer; + +import static cn.hutool.core.util.RandomUtil.randomEle; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +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.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static org.junit.jupiter.api.Assertions.*; + +@Import(ConfigServiceImpl.class) +public class ConfigServiceImplTest extends BaseDbUnitTest { + + @Resource + private ConfigServiceImpl configService; + + @Resource + private ConfigMapper configMapper; + + @Test + public void testCreateConfig_success() { + // 准备参数 + ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class) + .setId(null); // 防止 id 被赋值,导致唯一性校验失败 + + // 调用 + Long configId = configService.createConfig(reqVO); + // 断言 + assertNotNull(configId); + // 校验记录的属性是否正确 + ConfigDO config = configMapper.selectById(configId); + assertPojoEquals(reqVO, config, "id"); + assertEquals(ConfigTypeEnum.CUSTOM.getType(), config.getType()); + } + + @Test + public void testUpdateConfig_success() { + // mock 数据 + ConfigDO dbConfig = randomConfigDO(); + configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class, o -> { + o.setId(dbConfig.getId()); // 设置更新的 ID + }); + + // 调用 + configService.updateConfig(reqVO); + // 校验是否更新正确 + ConfigDO config = configMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, config); + } + + @Test + public void testDeleteConfig_success() { + // mock 数据 + ConfigDO dbConfig = randomConfigDO(o -> { + o.setType(ConfigTypeEnum.CUSTOM.getType()); // 只能删除 CUSTOM 类型 + }); + configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbConfig.getId(); + + // 调用 + configService.deleteConfig(id); + // 校验数据不存在了 + assertNull(configMapper.selectById(id)); + } + + @Test + public void testDeleteConfig_canNotDeleteSystemType() { + // mock 数据 + ConfigDO dbConfig = randomConfigDO(o -> { + o.setType(ConfigTypeEnum.SYSTEM.getType()); // SYSTEM 不允许删除 + }); + configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbConfig.getId(); + + // 调用, 并断言异常 + assertServiceException(() -> configService.deleteConfig(id), CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE); + } + + @Test + public void testValidateConfigExists_success() { + // mock 数据 + ConfigDO dbConfigDO = randomConfigDO(); + configMapper.insert(dbConfigDO);// @Sql: 先插入出一条存在的数据 + + // 调用成功 + configService.validateConfigExists(dbConfigDO.getId()); + } + + @Test + public void testValidateConfigExist_notExists() { + assertServiceException(() -> configService.validateConfigExists(randomLongId()), CONFIG_NOT_EXISTS); + } + + @Test + public void testValidateConfigKeyUnique_success() { + // 调用,成功 + configService.validateConfigKeyUnique(randomLongId(), randomString()); + } + + @Test + public void testValidateConfigKeyUnique_keyDuplicateForCreate() { + // 准备参数 + String key = randomString(); + // mock 数据 + configMapper.insert(randomConfigDO(o -> o.setConfigKey(key))); + + // 调用,校验异常 + assertServiceException(() -> configService.validateConfigKeyUnique(null, key), + CONFIG_KEY_DUPLICATE); + } + + @Test + public void testValidateConfigKeyUnique_keyDuplicateForUpdate() { + // 准备参数 + Long id = randomLongId(); + String key = randomString(); + // mock 数据 + configMapper.insert(randomConfigDO(o -> o.setConfigKey(key))); + + // 调用,校验异常 + assertServiceException(() -> configService.validateConfigKeyUnique(id, key), + CONFIG_KEY_DUPLICATE); + } + + @Test + public void testGetConfigPage() { + // mock 数据 + ConfigDO dbConfig = randomConfigDO(o -> { // 等会查询到 + o.setName("芋艿"); + o.setConfigKey("yunai"); + o.setType(ConfigTypeEnum.SYSTEM.getType()); + o.setCreateTime(buildTime(2021, 2, 1)); + }); + configMapper.insert(dbConfig); + // 测试 name 不匹配 + configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setName("土豆"))); + // 测试 key 不匹配 + configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou"))); + // 测试 type 不匹配 + configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType()))); + // 测试 createTime 不匹配 + configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1)))); + // 准备参数 + ConfigPageReqVO reqVO = new ConfigPageReqVO(); + reqVO.setName("艿"); + reqVO.setKey("nai"); + reqVO.setType(ConfigTypeEnum.SYSTEM.getType()); + reqVO.setCreateTime(buildBetweenTime(2021, 1, 15, 2021, 2, 15)); + + // 调用 + PageResult pageResult = configService.getConfigPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbConfig, pageResult.getList().get(0)); + } + + @Test + public void testGetConfig() { + // mock 数据 + ConfigDO dbConfig = randomConfigDO(); + configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbConfig.getId(); + + // 调用 + ConfigDO config = configService.getConfig(id); + // 断言 + assertNotNull(config); + assertPojoEquals(dbConfig, config); + } + + @Test + public void testGetConfigByKey() { + // mock 数据 + ConfigDO dbConfig = randomConfigDO(); + configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + String key = dbConfig.getConfigKey(); + + // 调用 + ConfigDO config = configService.getConfigByKey(key); + // 断言 + assertNotNull(config); + assertPojoEquals(dbConfig, config); + } + + // ========== 随机对象 ========== + + @SafeVarargs + private static ConfigDO randomConfigDO(Consumer... consumers) { + Consumer consumer = (o) -> { + o.setType(randomEle(ConfigTypeEnum.values()).getType()); // 保证 key 的范围 + }; + return RandomUtils.randomPojo(ConfigDO.class, ArrayUtils.append(consumer, consumers)); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java new file mode 100755 index 00000000..9ea41b09 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java @@ -0,0 +1,206 @@ +package cn.iocoder.yudao.module.infra.service.db; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.crypto.symmetric.AES; +import cn.iocoder.yudao.framework.mybatis.core.type.EncryptTypeHandler; +import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.db.DataSourceConfigDO; +import cn.iocoder.yudao.module.wms.dal.mysql.db.DataSourceConfigMapper; +import cn.iocoder.yudao.module.wms.service.db.DataSourceConfigServiceImpl; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.stubbing.Answer; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +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.DATA_SOURCE_CONFIG_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; + +/** + * {@link DataSourceConfigServiceImpl} 的单元测试类 + * + + */ +@Import(DataSourceConfigServiceImpl.class) +public class DataSourceConfigServiceImplTest extends BaseDbUnitTest { + + @Resource + private DataSourceConfigServiceImpl dataSourceConfigService; + + @Resource + private DataSourceConfigMapper dataSourceConfigMapper; + + @MockBean + private AES aes; + + @MockBean + private DynamicDataSourceProperties dynamicDataSourceProperties; + + @BeforeEach + public void setUp() { + // mock 一个空实现的 StringEncryptor,避免 EncryptTypeHandler 报错 + ReflectUtil.setFieldValue(EncryptTypeHandler.class, "aes", aes); + when(aes.encryptBase64(anyString())).then((Answer) invocation -> invocation.getArgument(0)); + when(aes.decryptStr(anyString())).then((Answer) invocation -> invocation.getArgument(0)); + + // mock DynamicDataSourceProperties + when(dynamicDataSourceProperties.getPrimary()).thenReturn("primary"); + when(dynamicDataSourceProperties.getDatasource()).thenReturn(MapUtil.of("primary", + new DataSourceProperty().setUrl("http://localhost:3306").setUsername("yunai").setPassword("tudou"))); + } + + @Test + public void testCreateDataSourceConfig_success() { + try (MockedStatic databaseUtilsMock = mockStatic(JdbcUtils.class)) { + // 准备参数 + DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class) + .setId(null); // 避免 id 被设置 + // mock 方法 + databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()), + eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true); + + // 调用 + Long dataSourceConfigId = dataSourceConfigService.createDataSourceConfig(reqVO); + // 断言 + assertNotNull(dataSourceConfigId); + // 校验记录的属性是否正确 + DataSourceConfigDO dataSourceConfig = dataSourceConfigMapper.selectById(dataSourceConfigId); + assertPojoEquals(reqVO, dataSourceConfig, "id"); + } + } + + @Test + public void testUpdateDataSourceConfig_success() { + try (MockedStatic databaseUtilsMock = mockStatic(JdbcUtils.class)) { + // mock 数据 + DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); + dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class, o -> { + o.setId(dbDataSourceConfig.getId()); // 设置更新的 ID + }); + // mock 方法 + databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()), + eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true); + + // 调用 + dataSourceConfigService.updateDataSourceConfig(reqVO); + // 校验是否更新正确 + DataSourceConfigDO dataSourceConfig = dataSourceConfigMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, dataSourceConfig); + } + } + + @Test + public void testUpdateDataSourceConfig_notExists() { + // 准备参数 + DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> dataSourceConfigService.updateDataSourceConfig(reqVO), DATA_SOURCE_CONFIG_NOT_EXISTS); + } + + @Test + public void testDeleteDataSourceConfig_success() { + // mock 数据 + DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); + dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDataSourceConfig.getId(); + + // 调用 + dataSourceConfigService.deleteDataSourceConfig(id); + // 校验数据不存在了 + assertNull(dataSourceConfigMapper.selectById(id)); + } + + @Test + public void testDeleteDataSourceConfig_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> dataSourceConfigService.deleteDataSourceConfig(id), DATA_SOURCE_CONFIG_NOT_EXISTS); + } + + @Test // 测试使用 password 查询,可以查询到数据 + public void testSelectPassword() { + // mock 数据 + DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); + dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 + + // 调用 + DataSourceConfigDO result = dataSourceConfigMapper.selectOne(DataSourceConfigDO::getPassword, + EncryptTypeHandler.encrypt(dbDataSourceConfig.getPassword())); + assertPojoEquals(dbDataSourceConfig, result); + } + + @Test + public void testGetDataSourceConfig_master() { + // 准备参数 + Long id = 0L; + // mock 方法 + + // 调用 + DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id); + // 断言 + assertEquals(id, dataSourceConfig.getId()); + assertEquals("primary", dataSourceConfig.getName()); + assertEquals("http://localhost:3306", dataSourceConfig.getUrl()); + assertEquals("yunai", dataSourceConfig.getUsername()); + assertEquals("tudou", dataSourceConfig.getPassword()); + } + + @Test + public void testGetDataSourceConfig_normal() { + // mock 数据 + DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); + dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDataSourceConfig.getId(); + + // 调用 + DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id); + // 断言 + assertPojoEquals(dbDataSourceConfig, dataSourceConfig); + } + + @Test + public void testGetDataSourceConfigList() { + // mock 数据 + DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); + dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + + // 调用 + List dataSourceConfigList = dataSourceConfigService.getDataSourceConfigList(); + // 断言 + assertEquals(2, dataSourceConfigList.size()); + // master + assertEquals(0L, dataSourceConfigList.get(0).getId()); + assertEquals("primary", dataSourceConfigList.get(0).getName()); + assertEquals("http://localhost:3306", dataSourceConfigList.get(0).getUrl()); + assertEquals("yunai", dataSourceConfigList.get(0).getUsername()); + assertEquals("tudou", dataSourceConfigList.get(0).getPassword()); + // normal + assertPojoEquals(dbDataSourceConfig, dataSourceConfigList.get(1)); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java new file mode 100644 index 00000000..81b32c07 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java @@ -0,0 +1,91 @@ +package cn.iocoder.yudao.module.infra.service.db; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.wms.dal.dataobject.db.DataSourceConfigDO; +import cn.iocoder.yudao.module.wms.service.db.DataSourceConfigService; +import cn.iocoder.yudao.module.wms.service.db.DatabaseTableServiceImpl; +import com.baomidou.mybatisplus.generator.config.po.TableField; +import com.baomidou.mybatisplus.generator.config.po.TableInfo; +import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; +import org.apache.ibatis.type.JdbcType; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +@Import(DatabaseTableServiceImpl.class) +public class DatabaseTableServiceImplTest extends BaseDbUnitTest { + + @Resource + private DatabaseTableServiceImpl databaseTableService; + + @MockBean + private DataSourceConfigService dataSourceConfigService; + + @Test + public void testGetTableList() { + // 准备参数 + Long dataSourceConfigId = randomLongId(); + // mock 方法 + DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("") + .setUrl("jdbc:h2:mem:testdb"); + when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId))) + .thenReturn(dataSourceConfig); + + // 调用 + List tables = databaseTableService.getTableList(dataSourceConfigId, + "config", "参数"); + // 断言 + assertEquals(1, tables.size()); + assertTableInfo(tables.get(0)); + } + + @Test + public void testGetTable() { + // 准备参数 + Long dataSourceConfigId = randomLongId(); + // mock 方法 + DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("") + .setUrl("jdbc:h2:mem:testdb"); + when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId))) + .thenReturn(dataSourceConfig); + + // 调用 + TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, "infra_config"); + // 断言 + assertTableInfo(tableInfo); + } + + private void assertTableInfo(TableInfo tableInfo) { + assertEquals("infra_config", tableInfo.getName()); + assertEquals("参数配置表", tableInfo.getComment()); + assertEquals(13, tableInfo.getFields().size()); + // id 字段 + TableField idField = tableInfo.getFields().get(0); + assertEquals("id", idField.getName()); + assertEquals(JdbcType.BIGINT, idField.getMetaInfo().getJdbcType()); + assertEquals("编号", idField.getComment()); + assertFalse(idField.getMetaInfo().isNullable()); + assertTrue(idField.isKeyFlag()); + assertTrue(idField.isKeyIdentityFlag()); + assertEquals(DbColumnType.LONG, idField.getColumnType()); + assertEquals("id", idField.getPropertyName()); + // name 字段 + TableField nameField = tableInfo.getFields().get(3); + assertEquals("name", nameField.getName()); + assertEquals(JdbcType.VARCHAR, nameField.getMetaInfo().getJdbcType()); + assertEquals("名字", nameField.getComment()); + assertFalse(nameField.getMetaInfo().isNullable()); + assertFalse(nameField.isKeyFlag()); + assertFalse(nameField.isKeyIdentityFlag()); + assertEquals(DbColumnType.STRING, nameField.getColumnType()); + assertEquals("name", nameField.getPropertyName()); + } +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java new file mode 100755 index 00000000..a417d3b9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java @@ -0,0 +1,282 @@ +package cn.iocoder.yudao.module.infra.service.file; + +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.map.MapUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.file.core.client.FileClient; +import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; +import cn.iocoder.yudao.framework.file.core.client.FileClientFactory; +import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClient; +import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClientConfig; +import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.file.FileConfigDO; +import cn.iocoder.yudao.module.wms.dal.mysql.file.FileConfigMapper; +import cn.iocoder.yudao.module.wms.service.file.FileConfigServiceImpl; +import lombok.Data; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import javax.validation.Validator; +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Map; + +import static cn.hutool.core.util.RandomUtil.randomEle; +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.FILE_CONFIG_DELETE_FAIL_MASTER; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; + +/** + * {@link FileConfigServiceImpl} 的单元测试类 + * + + */ +@Import(FileConfigServiceImpl.class) +public class FileConfigServiceImplTest extends BaseDbUnitTest { + + @Resource + private FileConfigServiceImpl fileConfigService; + + @Resource + private FileConfigMapper fileConfigMapper; + + @MockBean + private Validator validator; + @MockBean + private FileClientFactory fileClientFactory; + + @Test + public void testCreateFileConfig_success() { + // 准备参数 + Map config = MapUtil.builder().put("basePath", "/yunai") + .put("domain", "https://www.iocoder.cn").build(); + FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class, + o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()).setConfig(config)) + .setId(null); // 避免 id 被赋值 + + // 调用 + Long fileConfigId = fileConfigService.createFileConfig(reqVO); + // 断言 + assertNotNull(fileConfigId); + // 校验记录的属性是否正确 + FileConfigDO fileConfig = fileConfigMapper.selectById(fileConfigId); + assertPojoEquals(reqVO, fileConfig, "id", "config"); + assertFalse(fileConfig.getMaster()); + assertEquals("/yunai", ((LocalFileClientConfig) fileConfig.getConfig()).getBasePath()); + assertEquals("https://www.iocoder.cn", ((LocalFileClientConfig) fileConfig.getConfig()).getDomain()); + // 验证 cache + assertNull(fileConfigService.getClientCache().getIfPresent(fileConfigId)); + } + + @Test + public void testUpdateFileConfig_success() { + // mock 数据 + FileConfigDO dbFileConfig = randomPojo(FileConfigDO.class, o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()) + .setConfig(new LocalFileClientConfig().setBasePath("/yunai").setDomain("https://www.iocoder.cn"))); + fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class, o -> { + o.setId(dbFileConfig.getId()); // 设置更新的 ID + o.setStorage(FileStorageEnum.LOCAL.getStorage()); + Map config = MapUtil.builder().put("basePath", "/yunai2") + .put("domain", "https://doc.iocoder.cn").build(); + o.setConfig(config); + }); + + // 调用 + fileConfigService.updateFileConfig(reqVO); + // 校验是否更新正确 + FileConfigDO fileConfig = fileConfigMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, fileConfig, "config"); + assertEquals("/yunai2", ((LocalFileClientConfig) fileConfig.getConfig()).getBasePath()); + assertEquals("https://doc.iocoder.cn", ((LocalFileClientConfig) fileConfig.getConfig()).getDomain()); + // 验证 cache + assertNull(fileConfigService.getClientCache().getIfPresent(fileConfig.getId())); + } + + @Test + public void testUpdateFileConfig_notExists() { + // 准备参数 + FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> fileConfigService.updateFileConfig(reqVO), FILE_CONFIG_NOT_EXISTS); + } + + @Test + public void testUpdateFileConfigMaster_success() { + // mock 数据 + FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); + fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 + FileConfigDO masterFileConfig = randomFileConfigDO().setMaster(true); + fileConfigMapper.insert(masterFileConfig);// @Sql: 先插入出一条存在的数据 + + // 调用 + fileConfigService.updateFileConfigMaster(dbFileConfig.getId()); + // 断言数据 + assertTrue(fileConfigMapper.selectById(dbFileConfig.getId()).getMaster()); + assertFalse(fileConfigMapper.selectById(masterFileConfig.getId()).getMaster()); + // 验证 cache + assertNull(fileConfigService.getClientCache().getIfPresent(0L)); + } + + @Test + public void testUpdateFileConfigMaster_notExists() { + // 调用, 并断言异常 + assertServiceException(() -> fileConfigService.updateFileConfigMaster(randomLongId()), FILE_CONFIG_NOT_EXISTS); + } + + @Test + public void testDeleteFileConfig_success() { + // mock 数据 + FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); + fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbFileConfig.getId(); + + // 调用 + fileConfigService.deleteFileConfig(id); + // 校验数据不存在了 + assertNull(fileConfigMapper.selectById(id)); + // 验证 cache + assertNull(fileConfigService.getClientCache().getIfPresent(id)); + } + + @Test + public void testDeleteFileConfig_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> fileConfigService.deleteFileConfig(id), FILE_CONFIG_NOT_EXISTS); + } + + @Test + public void testDeleteFileConfig_master() { + // mock 数据 + FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(true); + fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbFileConfig.getId(); + + // 调用, 并断言异常 + assertServiceException(() -> fileConfigService.deleteFileConfig(id), FILE_CONFIG_DELETE_FAIL_MASTER); + } + + @Test + public void testGetFileConfigPage() { + // mock 数据 + FileConfigDO dbFileConfig = randomFileConfigDO().setName("芋道源码") + .setStorage(FileStorageEnum.LOCAL.getStorage()); + dbFileConfig.setCreateTime(LocalDateTimeUtil.parse("2020-01-23", DatePattern.NORM_DATE_PATTERN));// 等会查询到 + fileConfigMapper.insert(dbFileConfig); + // 测试 name 不匹配 + fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setName("源码"))); + // 测试 storage 不匹配 + fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setStorage(FileStorageEnum.DB.getStorage()))); + // 测试 createTime 不匹配 + fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setCreateTime(LocalDateTimeUtil.parse("2020-11-23", DatePattern.NORM_DATE_PATTERN)))); + // 准备参数 + FileConfigPageReqVO reqVO = new FileConfigPageReqVO(); + reqVO.setName("芋道"); + reqVO.setStorage(FileStorageEnum.LOCAL.getStorage()); + reqVO.setCreateTime((new LocalDateTime[]{buildTime(2020, 1, 1), + buildTime(2020, 1, 24)})); + + // 调用 + PageResult pageResult = fileConfigService.getFileConfigPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbFileConfig, pageResult.getList().get(0)); + } + + @Test + public void testFileConfig() throws Exception { + // mock 数据 + FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); + fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbFileConfig.getId(); + // mock 获得 Client + FileClient fileClient = mock(FileClient.class); + when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient); + when(fileClient.upload(any(), any(), any())).thenReturn("https://www.iocoder.cn"); + + // 调用,并断言 + assertEquals("https://www.iocoder.cn", fileConfigService.testFileConfig(id)); + } + + @Test + public void testGetFileConfig() { + // mock 数据 + FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); + fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbFileConfig.getId(); + + // 调用,并断言 + assertPojoEquals(dbFileConfig, fileConfigService.getFileConfig(id)); + } + + @Test + public void testGetFileClient() { + // mock 数据 + FileConfigDO fileConfig = randomFileConfigDO().setMaster(false); + fileConfigMapper.insert(fileConfig); + // 准备参数 + Long id = fileConfig.getId(); + // mock 获得 Client + FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); + when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient); + + // 调用,并断言 + assertSame(fileClient, fileConfigService.getFileClient(id)); + // 断言缓存 + verify(fileClientFactory).createOrUpdateFileClient(eq(id), eq(fileConfig.getStorage()), + eq(fileConfig.getConfig())); + } + + @Test + public void testGetMasterFileClient() { + // mock 数据 + FileConfigDO fileConfig = randomFileConfigDO().setMaster(true); + fileConfigMapper.insert(fileConfig); + // 准备参数 + Long id = fileConfig.getId(); + // mock 获得 Client + FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); + when(fileClientFactory.getFileClient(eq(fileConfig.getId()))).thenReturn(fileClient); + + // 调用,并断言 + assertSame(fileClient, fileConfigService.getMasterFileClient()); + // 断言缓存 + verify(fileClientFactory).createOrUpdateFileClient(eq(fileConfig.getId()), eq(fileConfig.getStorage()), + eq(fileConfig.getConfig())); + } + + private FileConfigDO randomFileConfigDO() { + return randomPojo(FileConfigDO.class).setStorage(randomEle(FileStorageEnum.values()).getStorage()) + .setConfig(new EmptyFileClientConfig()); + } + + @Data + public static class EmptyFileClientConfig implements FileClientConfig, Serializable { + + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java new file mode 100644 index 00000000..0c7a6e36 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.file; + +import cn.hutool.core.io.resource.ResourceUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; +import cn.iocoder.yudao.framework.file.core.client.FileClient; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.framework.test.core.util.AssertUtils; +import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.file.FileDO; +import cn.iocoder.yudao.module.wms.dal.mysql.file.FileMapper; +import cn.iocoder.yudao.module.wms.service.file.FileConfigService; +import cn.iocoder.yudao.module.wms.service.file.FileService; +import cn.iocoder.yudao.module.wms.service.file.FileServiceImpl; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.*; + +@Import({FileServiceImpl.class}) +public class FileServiceImplTest extends BaseDbUnitTest { + + @Resource + private FileService fileService; + + @Resource + private FileMapper fileMapper; + + @MockBean + private FileConfigService fileConfigService; + + @Test + public void testGetFilePage() { + // mock 数据 + FileDO dbFile = randomPojo(FileDO.class, o -> { // 等会查询到 + o.setPath("yunai"); + o.setType("image/jpg"); + o.setCreateTime(buildTime(2021, 1, 15)); + }); + fileMapper.insert(dbFile); + // 测试 path 不匹配 + fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> o.setPath("tudou"))); + // 测试 type 不匹配 + fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> { + o.setType("image/png"); + })); + // 测试 createTime 不匹配 + fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> { + o.setCreateTime(buildTime(2020, 1, 15)); + })); + // 准备参数 + FilePageReqVO reqVO = new FilePageReqVO(); + reqVO.setPath("yunai"); + reqVO.setType("jp"); + reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 1, 10), buildTime(2021, 1, 20)})); + + // 调用 + PageResult pageResult = fileService.getFilePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + AssertUtils.assertPojoEquals(dbFile, pageResult.getList().get(0)); + } + + @Test + public void testCreateFile_success() throws Exception { + // 准备参数 + String path = randomString(); + byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); + // mock Master 文件客户端 + FileClient client = mock(FileClient.class); + when(fileConfigService.getMasterFileClient()).thenReturn(client); + String url = randomString(); + when(client.upload(same(content), same(path), eq("image/jpeg"))).thenReturn(url); + when(client.getId()).thenReturn(10L); + String name = "单测文件名"; + // 调用 + String result = fileService.createFile(name, path, content); + // 断言 + assertEquals(result, url); + // 校验数据 + FileDO file = fileMapper.selectOne(FileDO::getPath, path); + assertEquals(10L, file.getConfigId()); + assertEquals(path, file.getPath()); + assertEquals(url, file.getUrl()); + assertEquals("image/jpeg", file.getType()); + assertEquals(content.length, file.getSize()); + } + + @Test + public void testDeleteFile_success() throws Exception { + // mock 数据 + FileDO dbFile = randomPojo(FileDO.class, o -> o.setConfigId(10L).setPath("tudou.jpg")); + fileMapper.insert(dbFile);// @Sql: 先插入出一条存在的数据 + // mock Master 文件客户端 + FileClient client = mock(FileClient.class); + when(fileConfigService.getFileClient(eq(10L))).thenReturn(client); + // 准备参数 + Long id = dbFile.getId(); + + // 调用 + fileService.deleteFile(id); + // 校验数据不存在了 + assertNull(fileMapper.selectById(id)); + // 校验调用 + verify(client).delete(eq("tudou.jpg")); + } + + @Test + public void testDeleteFile_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> fileService.deleteFile(id), FILE_NOT_EXISTS); + } + + @Test + public void testGetFileContent() throws Exception { + // 准备参数 + Long configId = 10L; + String path = "tudou.jpg"; + // mock 方法 + FileClient client = mock(FileClient.class); + when(fileConfigService.getFileClient(eq(10L))).thenReturn(client); + byte[] content = new byte[]{}; + when(client.getContent(eq("tudou.jpg"))).thenReturn(content); + + // 调用 + byte[] result = fileService.getFileContent(configId, path); + // 断言 + assertSame(result, content); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java new file mode 100644 index 00000000..759a8d5e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java @@ -0,0 +1,110 @@ +package cn.iocoder.yudao.module.infra.service.logger; + +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; +import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.logger.ApiAccessLogDO; +import cn.iocoder.yudao.module.wms.dal.mysql.logger.ApiAccessLogMapper; +import cn.iocoder.yudao.module.wms.service.logger.ApiAccessLogServiceImpl; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.time.Duration; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +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.RandomUtils.randomPojo; +import static org.junit.jupiter.api.Assertions.assertEquals; + +@Import(ApiAccessLogServiceImpl.class) +public class ApiAccessLogServiceImplTest extends BaseDbUnitTest { + + @Resource + private ApiAccessLogServiceImpl apiAccessLogService; + + @Resource + private ApiAccessLogMapper apiAccessLogMapper; + + @Test + public void testGetApiAccessLogPage() { + ApiAccessLogDO apiAccessLogDO = randomPojo(ApiAccessLogDO.class, o -> { + o.setUserId(2233L); + o.setUserType(UserTypeEnum.ADMIN.getValue()); + o.setApplicationName("yudao-test"); + o.setRequestUrl("foo"); + o.setBeginTime(buildTime(2021, 3, 13)); + o.setDuration(1000); + o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode()); + }); + apiAccessLogMapper.insert(apiAccessLogDO); + // 测试 userId 不匹配 + apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserId(3344L))); + // 测试 userType 不匹配 + apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); + // 测试 applicationName 不匹配 + apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setApplicationName("test"))); + // 测试 requestUrl 不匹配 + apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setRequestUrl("bar"))); + // 测试 beginTime 不匹配:构造一个早期时间 2021-02-06 00:00:00 + apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setBeginTime(buildTime(2021, 2, 6)))); + // 测试 duration 不匹配 + apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setDuration(100))); + // 测试 resultCode 不匹配 + apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setResultCode(2))); + // 准备参数 + ApiAccessLogPageReqVO reqVO = new ApiAccessLogPageReqVO(); + reqVO.setUserId(2233L); + reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); + reqVO.setApplicationName("yudao-test"); + reqVO.setRequestUrl("foo"); + reqVO.setBeginTime(buildBetweenTime(2021, 3, 13, 2021, 3, 13)); + reqVO.setDuration(1000); + reqVO.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode()); + + // 调用 + PageResult pageResult = apiAccessLogService.getApiAccessLogPage(reqVO); + // 断言,只查到了一条符合条件的 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(apiAccessLogDO, pageResult.getList().get(0)); + } + + @Test + public void testCleanJobLog() { + // mock 数据 + ApiAccessLogDO log01 = randomPojo(ApiAccessLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-3)))); + apiAccessLogMapper.insert(log01); + ApiAccessLogDO log02 = randomPojo(ApiAccessLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-1)))); + apiAccessLogMapper.insert(log02); + // 准备参数 + Integer exceedDay = 2; + Integer deleteLimit = 1; + + // 调用 + Integer count = apiAccessLogService.cleanAccessLog(exceedDay, deleteLimit); + // 断言 + assertEquals(1, count); + List logs = apiAccessLogMapper.selectList(); + assertEquals(1, logs.size()); + assertEquals(log02, logs.get(0)); + } + + @Test + public void testCreateApiAccessLog() { + // 准备参数 + ApiAccessLogCreateReqDTO createDTO = randomPojo(ApiAccessLogCreateReqDTO.class); + + // 调用 + apiAccessLogService.createApiAccessLog(createDTO); + // 断言 + ApiAccessLogDO apiAccessLogDO = apiAccessLogMapper.selectOne(null); + assertPojoEquals(createDTO, apiAccessLogDO); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java new file mode 100644 index 00000000..dea46213 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java @@ -0,0 +1,164 @@ +package cn.iocoder.yudao.module.infra.service.logger; + +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; +import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.logger.ApiErrorLogDO; +import cn.iocoder.yudao.module.wms.dal.mysql.logger.ApiErrorLogMapper; +import cn.iocoder.yudao.module.wms.enums.logger.ApiErrorLogProcessStatusEnum; +import cn.iocoder.yudao.module.wms.service.logger.ApiErrorLogServiceImpl; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.time.Duration; +import java.util.List; + +import static cn.hutool.core.util.RandomUtil.randomEle; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +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.API_ERROR_LOG_NOT_FOUND; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@Import(ApiErrorLogServiceImpl.class) +public class ApiErrorLogServiceImplTest extends BaseDbUnitTest { + + @Resource + private ApiErrorLogServiceImpl apiErrorLogService; + + @Resource + private ApiErrorLogMapper apiErrorLogMapper; + + @Test + public void testGetApiErrorLogPage() { + // mock 数据 + ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, o -> { + o.setUserId(2233L); + o.setUserType(UserTypeEnum.ADMIN.getValue()); + o.setApplicationName("yudao-test"); + o.setRequestUrl("foo"); + o.setExceptionTime(buildTime(2021, 3, 13)); + o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); + }); + apiErrorLogMapper.insert(apiErrorLogDO); + // 测试 userId 不匹配 + apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserId(3344L))); + // 测试 userType 不匹配 + apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue()))); + // 测试 applicationName 不匹配 + apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setApplicationName("test"))); + // 测试 requestUrl 不匹配 + apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setRequestUrl("bar"))); + // 测试 exceptionTime 不匹配:构造一个早期时间 2021-02-06 00:00:00 + apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setExceptionTime(buildTime(2021, 2, 6)))); + // 测试 progressStatus 不匹配 + apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus()))); + // 准备参数 + ApiErrorLogPageReqVO reqVO = new ApiErrorLogPageReqVO(); + reqVO.setUserId(2233L); + reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); + reqVO.setApplicationName("yudao-test"); + reqVO.setRequestUrl("foo"); + reqVO.setExceptionTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31)); + reqVO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); + + // 调用 + PageResult pageResult = apiErrorLogService.getApiErrorLogPage(reqVO); + // 断言,只查到了一条符合条件的 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(apiErrorLogDO, pageResult.getList().get(0)); + } + + @Test + public void testCreateApiErrorLog() { + // 准备参数 + ApiErrorLogCreateReqDTO createDTO = randomPojo(ApiErrorLogCreateReqDTO.class); + + // 调用 + apiErrorLogService.createApiErrorLog(createDTO); + // 断言 + ApiErrorLogDO apiErrorLogDO = apiErrorLogMapper.selectOne(null); + assertPojoEquals(createDTO, apiErrorLogDO); + assertEquals(ApiErrorLogProcessStatusEnum.INIT.getStatus(), apiErrorLogDO.getProcessStatus()); + } + + @Test + public void testUpdateApiErrorLogProcess_success() { + // 准备参数 + ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, + o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus())); + apiErrorLogMapper.insert(apiErrorLogDO); + // 准备参数 + Long id = apiErrorLogDO.getId(); + Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); + Long processUserId = randomLongId(); + + // 调用 + apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId); + // 断言 + ApiErrorLogDO dbApiErrorLogDO = apiErrorLogMapper.selectById(apiErrorLogDO.getId()); + assertEquals(processStatus, dbApiErrorLogDO.getProcessStatus()); + assertEquals(processUserId, dbApiErrorLogDO.getProcessUserId()); + assertNotNull(dbApiErrorLogDO.getProcessTime()); + } + + @Test + public void testUpdateApiErrorLogProcess_processed() { + // 准备参数 + ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, + o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())); + apiErrorLogMapper.insert(apiErrorLogDO); + // 准备参数 + Long id = apiErrorLogDO.getId(); + Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); + Long processUserId = randomLongId(); + + // 调用,并断言异常 + assertServiceException(() -> + apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId), + API_ERROR_LOG_PROCESSED); + } + + @Test + public void testUpdateApiErrorLogProcess_notFound() { + // 准备参数 + Long id = randomLongId(); + Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); + Long processUserId = randomLongId(); + + // 调用,并断言异常 + assertServiceException(() -> + apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId), + API_ERROR_LOG_NOT_FOUND); + } + + @Test + public void testCleanJobLog() { + // mock 数据 + ApiErrorLogDO log01 = randomPojo(ApiErrorLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-3)))); + apiErrorLogMapper.insert(log01); + ApiErrorLogDO log02 = randomPojo(ApiErrorLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-1)))); + apiErrorLogMapper.insert(log02); + // 准备参数 + Integer exceedDay = 2; + Integer deleteLimit = 1; + + // 调用 + Integer count = apiErrorLogService.cleanErrorLog(exceedDay, deleteLimit); + // 断言 + assertEquals(1, count); + List logs = apiErrorLogMapper.selectList(); + assertEquals(1, logs.size()); + assertEquals(log02, logs.get(0)); + } + +} diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/application-unit-test.yaml b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/application-unit-test.yaml new file mode 100644 index 00000000..38e0a1c3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/application-unit-test.yaml @@ -0,0 +1,53 @@ +spring: + main: + lazy-initialization: true # 开启懒加载,加快速度 + banner-mode: off # 单元测试,禁用 Banner + +--- #################### 数据库相关配置 #################### + +spring: + # 数据源配置项 + datasource: + name: ruoyi-vue-pro + url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 + driver-class-name: org.h2.Driver + username: sa + password: + druid: + async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 + initial-size: 1 # 单元测试,配置为 1,提升启动速度 + sql: + init: + schema-locations: classpath:/sql/create_tables.sql + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 127.0.0.1 # 地址 + port: 16379 # 端口(单元测试,使用 16379 端口) + database: 0 # 数据库索引 + +mybatis-plus: + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 + type-aliases-package: ${yudao.info.base-package}.dal.dataobject + global-config: + db-config: + id-type: AUTO # H2 主键递增 + +--- #################### 定时任务相关配置 #################### + +--- #################### 配置中心相关配置 #################### + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项(单元测试,禁用 Lock4j) + +# Resilience4j 配置项 + +--- #################### 监控相关配置 #################### + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + info: + base-package: cn.iocoder.yudao.module.infra diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/category.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/category.json new file mode 100644 index 00000000..210613f5 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/category.json @@ -0,0 +1,53 @@ +{ + "table": { + "id": 10, + "scene" : 1, + "parentMenuId" : 888, + "tableName" : "infra_category", + "tableComment" : "分类表", + "moduleName" : "infra", + "businessName" : "demo", + "className" : "InfraCategory", + "classComment" : "分类", + "author" : "芋道源码", + "treeParentColumnId" : 22, + "treeNameColumnId" : 11 + }, + "columns": [ { + "columnName" : "id", + "dataType" : "BIGINT", + "columnComment" : "编号", + "primaryKey" : true, + "autoIncrement" : true, + "javaType" : "Long", + "javaField" : "id", + "example" : "1024", + "updateOperation" : true, + "listOperationResult" : true + }, { + "id" : 11, + "columnName" : "name", + "dataType" : "VARCHAR", + "columnComment" : "名字", + "javaType" : "String", + "javaField" : "name", + "example" : "芋头", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "LIKE", + "listOperationResult" : true, + "htmlType" : "input" + }, { + "id" : 22, + "columnName" : "description", + "dataType" : "VARCHAR", + "columnComment" : "父编号", + "javaType" : "Long", + "javaField" : "parentId", + "example" : "2048", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true + } ] +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/contact.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/contact.json new file mode 100644 index 00000000..6a310570 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/contact.json @@ -0,0 +1,144 @@ +{ + "table": { + "scene" : 1, + "tableName" : "infra_student_contact", + "tableComment" : "学生联系人表", + "moduleName" : "infra", + "businessName" : "demo", + "className" : "InfraStudentContact", + "classComment" : "学生联系人", + "author" : "芋道源码" + }, + "columns": [ { + "columnName" : "id", + "dataType" : "BIGINT", + "columnComment" : "编号", + "primaryKey" : true, + "autoIncrement" : true, + "javaType" : "Long", + "javaField" : "id", + "example" : "1024", + "updateOperation" : true, + "listOperationResult" : true + }, { + "id" : 100, + "columnName" : "student_id", + "dataType" : "BIGINT", + "columnComment" : "学生编号", + "javaType" : "Long", + "javaField" : "studentId", + "example" : "2048", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true + }, { + "columnName" : "name", + "dataType" : "VARCHAR", + "columnComment" : "名字", + "javaType" : "String", + "javaField" : "name", + "example" : "芋头", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "LIKE", + "listOperationResult" : true, + "htmlType" : "input" + }, { + "columnName" : "description", + "dataType" : "VARCHAR", + "columnComment" : "简介", + "javaType" : "String", + "javaField" : "description", + "example" : "我是介绍", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "textarea" + }, { + "columnName" : "birthday", + "dataType" : "DATE", + "columnComment" : "出生日期", + "javaType" : "LocalDateTime", + "javaField" : "birthday", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "datetime" + }, { + "columnName" : "sex", + "dataType" : "INTEGER", + "columnComment" : "性别", + "javaType" : "Integer", + "javaField" : "sex", + "dictType" : "system_user_sex", + "example" : "1", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "select" + }, { + "columnName" : "enabled", + "dataType" : "BOOLEAN", + "columnComment" : "是否有效", + "javaType" : "Boolean", + "javaField" : "enabled", + "dictType" : "infra_boolean_string", + "example" : "true", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "radio" + }, { + "columnName" : "avatar", + "dataType" : "VARCHAR", + "columnComment" : "头像", + "javaType" : "String", + "javaField" : "avatar", + "example" : "https://www.iocoder.cn/1.png", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "imageUpload" + }, { + "columnName" : "video", + "dataType" : "VARCHAR", + "columnComment" : "附件", + "nullable" : true, + "javaType" : "String", + "javaField" : "video", + "example" : "https://www.iocoder.cn/1.mp4", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "fileUpload" + }, { + "columnName" : "memo", + "dataType" : "VARCHAR", + "columnComment" : "备注", + "javaType" : "String", + "javaField" : "memo", + "example" : "我是备注", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "editor" + }, { + "columnName" : "create_time", + "dataType" : "DATE", + "columnComment" : "创建时间", + "nullable" : true, + "javaType" : "LocalDateTime", + "javaField" : "createTime", + "listOperation" : true, + "listOperationCondition" : "BETWEEN", + "listOperationResult" : true, + "htmlType" : "datetime" + } ] +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/student.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/student.json new file mode 100644 index 00000000..0cc29c5a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/student.json @@ -0,0 +1,135 @@ +{ + "table": { + "id": 1, + "scene" : 1, + "parentMenuId" : 888, + "tableName" : "infra_student", + "tableComment" : "学生表", + "moduleName" : "infra", + "businessName" : "demo", + "className" : "InfraStudent", + "classComment" : "学生", + "author" : "芋道源码" + }, + "columns": [ { + "id" : 100, + "columnName" : "id", + "dataType" : "BIGINT", + "columnComment" : "编号", + "primaryKey" : true, + "autoIncrement" : true, + "javaType" : "Long", + "javaField" : "id", + "example" : "1024", + "updateOperation" : true, + "listOperationResult" : true + }, { + "columnName" : "name", + "dataType" : "VARCHAR", + "columnComment" : "名字", + "javaType" : "String", + "javaField" : "name", + "example" : "芋头", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "LIKE", + "listOperationResult" : true, + "htmlType" : "input" + }, { + "columnName" : "description", + "dataType" : "VARCHAR", + "columnComment" : "简介", + "javaType" : "String", + "javaField" : "description", + "example" : "我是介绍", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "textarea" + }, { + "columnName" : "birthday", + "dataType" : "DATE", + "columnComment" : "出生日期", + "javaType" : "LocalDateTime", + "javaField" : "birthday", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "datetime" + }, { + "columnName" : "sex", + "dataType" : "INTEGER", + "columnComment" : "性别", + "javaType" : "Integer", + "javaField" : "sex", + "dictType" : "system_user_sex", + "example" : "1", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "select" + }, { + "columnName" : "enabled", + "dataType" : "BOOLEAN", + "columnComment" : "是否有效", + "javaType" : "Boolean", + "javaField" : "enabled", + "dictType" : "infra_boolean_string", + "example" : "true", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "radio" + }, { + "columnName" : "avatar", + "dataType" : "VARCHAR", + "columnComment" : "头像", + "javaType" : "String", + "javaField" : "avatar", + "example" : "https://www.iocoder.cn/1.png", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "imageUpload" + }, { + "columnName" : "video", + "dataType" : "VARCHAR", + "columnComment" : "附件", + "javaType" : "String", + "javaField" : "video", + "example" : "https://www.iocoder.cn/1.mp4", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "fileUpload" + }, { + "columnName" : "memo", + "dataType" : "VARCHAR", + "columnComment" : "备注", + "javaType" : "String", + "javaField" : "memo", + "example" : "我是备注", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "editor" + }, { + "columnName" : "create_time", + "dataType" : "DATE", + "columnComment" : "创建时间", + "nullable" : true, + "javaType" : "LocalDateTime", + "javaField" : "createTime", + "listOperation" : true, + "listOperationCondition" : "BETWEEN", + "listOperationResult" : true, + "htmlType" : "datetime" + } ] +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/teacher.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/teacher.json new file mode 100644 index 00000000..7ef46040 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/table/teacher.json @@ -0,0 +1,144 @@ +{ + "table": { + "scene" : 1, + "tableName" : "infra_student_teacher", + "tableComment" : "学生班主任表", + "moduleName" : "infra", + "businessName" : "demo", + "className" : "InfraStudentTeacher", + "classComment" : "学生班主任", + "author" : "芋道源码" + }, + "columns": [ { + "columnName" : "id", + "dataType" : "BIGINT", + "columnComment" : "编号", + "primaryKey" : true, + "autoIncrement" : true, + "javaType" : "Long", + "javaField" : "id", + "example" : "1024", + "updateOperation" : true, + "listOperationResult" : true + }, { + "id" : 200, + "columnName" : "student_id", + "dataType" : "BIGINT", + "columnComment" : "学生编号", + "javaType" : "Long", + "javaField" : "studentId", + "example" : "2048", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true + }, { + "columnName" : "name", + "dataType" : "VARCHAR", + "columnComment" : "名字", + "javaType" : "String", + "javaField" : "name", + "example" : "芋头", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "LIKE", + "listOperationResult" : true, + "htmlType" : "input" + }, { + "columnName" : "description", + "dataType" : "VARCHAR", + "columnComment" : "简介", + "javaType" : "String", + "javaField" : "description", + "example" : "我是介绍", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "textarea" + }, { + "columnName" : "birthday", + "dataType" : "DATE", + "columnComment" : "出生日期", + "javaType" : "LocalDateTime", + "javaField" : "birthday", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "datetime" + }, { + "columnName" : "sex", + "dataType" : "INTEGER", + "columnComment" : "性别", + "javaType" : "Integer", + "javaField" : "sex", + "dictType" : "system_user_sex", + "example" : "1", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "select" + }, { + "columnName" : "enabled", + "dataType" : "BOOLEAN", + "columnComment" : "是否有效", + "javaType" : "Boolean", + "javaField" : "enabled", + "dictType" : "infra_boolean_string", + "example" : "true", + "createOperation" : true, + "updateOperation" : true, + "listOperation" : true, + "listOperationCondition" : "=", + "listOperationResult" : true, + "htmlType" : "radio" + }, { + "columnName" : "avatar", + "dataType" : "VARCHAR", + "columnComment" : "头像", + "javaType" : "String", + "javaField" : "avatar", + "example" : "https://www.iocoder.cn/1.png", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "imageUpload" + }, { + "columnName" : "video", + "dataType" : "VARCHAR", + "columnComment" : "附件", + "nullable" : true, + "javaType" : "String", + "javaField" : "video", + "example" : "https://www.iocoder.cn/1.mp4", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "fileUpload" + }, { + "columnName" : "memo", + "dataType" : "VARCHAR", + "columnComment" : "备注", + "javaType" : "String", + "javaField" : "memo", + "example" : "我是备注", + "createOperation" : true, + "updateOperation" : true, + "listOperationResult" : true, + "htmlType" : "editor" + }, { + "columnName" : "create_time", + "dataType" : "DATE", + "columnComment" : "创建时间", + "nullable" : true, + "javaType" : "LocalDateTime", + "javaField" : "createTime", + "listOperation" : true, + "listOperationCondition" : "BETWEEN", + "listOperationResult" : true, + "htmlType" : "datetime" + } ] +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/assert.json new file mode 100644 index 00000000..f95ae9af --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/assert.json @@ -0,0 +1,73 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentContactDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" +}, { + "contentPath" : "java/InfraStudentTeacherDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "java/InfraStudentContactMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" +}, { + "contentPath" : "java/InfraStudentTeacherMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" +}, { + "contentPath" : "js/student", + "filePath" : "yudao-ui-admin-vue2/src/api/infra/student.js" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" +}, { + "contentPath" : "vue/StudentContactForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" +}, { + "contentPath" : "vue/StudentTeacherForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" +}, { + "contentPath" : "vue/StudentContactList", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactList.vue" +}, { + "contentPath" : "vue/StudentTeacherList", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherList.vue" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..d3201dec --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,6 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); +ErrorCode STUDENT_CONTACT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生联系人不存在"); +ErrorCode STUDENT_TEACHER_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任不存在"); +ErrorCode STUDENT_TEACHER_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任已存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactDO new file mode 100644 index 00000000..6e33a47a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生联系人 DO + * + + */ +@TableName("infra_student_contact") +@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentContactDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactMapper new file mode 100644 index 00000000..6cdaa924 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentContactMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生联系人 Mapper + * + + */ +@Mapper +public interface InfraStudentContactMapper extends BaseMapperX { + + default PageResult selectPage(PageParam reqVO, Long studentId) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(InfraStudentContactDO::getStudentId, studentId) + .orderByDesc(InfraStudentContactDO::getId)); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentContactDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentController new file mode 100644 index 00000000..d6f20183 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentController @@ -0,0 +1,183 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + + // ==================== 子表(学生联系人) ==================== + + @GetMapping("/student-contact/page") + @Operation(summary = "获得学生联系人分页") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentContactPage(PageParam pageReqVO, + @RequestParam("studentId") Long studentId) { + return success(studentService.getStudentContactPage(pageReqVO, studentId)); + } + + @PostMapping("/student-contact/create") + @Operation(summary = "创建学生联系人") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { + return success(studentService.createStudentContact(studentContact)); + } + + @PutMapping("/student-contact/update") + @Operation(summary = "更新学生联系人") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { + studentService.updateStudentContact(studentContact); + return success(true); + } + + @DeleteMapping("/student-contact/delete") + @Parameter(name = "id", description = "编号", required = true) + @Operation(summary = "删除学生联系人") + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudentContact(@RequestParam("id") Long id) { + studentService.deleteStudentContact(id); + return success(true); + } + + @GetMapping("/student-contact/get") + @Operation(summary = "获得学生联系人") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentContact(@RequestParam("id") Long id) { + return success(studentService.getStudentContact(id)); + } + + // ==================== 子表(学生班主任) ==================== + + @GetMapping("/student-teacher/page") + @Operation(summary = "获得学生班主任分页") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentTeacherPage(PageParam pageReqVO, + @RequestParam("studentId") Long studentId) { + return success(studentService.getStudentTeacherPage(pageReqVO, studentId)); + } + + @PostMapping("/student-teacher/create") + @Operation(summary = "创建学生班主任") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { + return success(studentService.createStudentTeacher(studentTeacher)); + } + + @PutMapping("/student-teacher/update") + @Operation(summary = "更新学生班主任") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { + studentService.updateStudentTeacher(studentTeacher); + return success(true); + } + + @DeleteMapping("/student-teacher/delete") + @Parameter(name = "id", description = "编号", required = true) + @Operation(summary = "删除学生班主任") + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudentTeacher(@RequestParam("id") Long id) { + studentService.deleteStudentTeacher(id); + return success(true); + } + + @GetMapping("/student-teacher/get") + @Operation(summary = "获得学生班主任") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentTeacher(@RequestParam("id") Long id) { + return success(studentService.getStudentTeacher(id)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..eaadf743 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentSaveReqVO @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentService new file mode 100644 index 00000000..a94ed062 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentService @@ -0,0 +1,139 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + + // ==================== 子表(学生联系人) ==================== + + /** + * 获得学生联系人分页 + * + * @param pageReqVO 分页查询 + * @param studentId 学生编号 + * @return 学生联系人分页 + */ + PageResult getStudentContactPage(PageParam pageReqVO, Long studentId); + + /** + * 创建学生联系人 + * + * @param studentContact 创建信息 + * @return 编号 + */ + Long createStudentContact(@Valid InfraStudentContactDO studentContact); + + /** + * 更新学生联系人 + * + * @param studentContact 更新信息 + */ + void updateStudentContact(@Valid InfraStudentContactDO studentContact); + + /** + * 删除学生联系人 + * + * @param id 编号 + */ + void deleteStudentContact(Long id); + + /** + * 获得学生联系人 + * + * @param id 编号 + * @return 学生联系人 + */ + InfraStudentContactDO getStudentContact(Long id); + + // ==================== 子表(学生班主任) ==================== + + /** + * 获得学生班主任分页 + * + * @param pageReqVO 分页查询 + * @param studentId 学生编号 + * @return 学生班主任分页 + */ + PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId); + + /** + * 创建学生班主任 + * + * @param studentTeacher 创建信息 + * @return 编号 + */ + Long createStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); + + /** + * 更新学生班主任 + * + * @param studentTeacher 更新信息 + */ + void updateStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); + + /** + * 删除学生班主任 + * + * @param id 编号 + */ + void deleteStudentTeacher(Long id); + + /** + * 获得学生班主任 + * + * @param id 编号 + * @return 学生班主任 + */ + InfraStudentTeacherDO getStudentTeacher(Long id); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImpl new file mode 100644 index 00000000..b8cf59c6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImpl @@ -0,0 +1,180 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + @Resource + private InfraStudentContactMapper studentContactMapper; + @Resource + private InfraStudentTeacherMapper studentTeacherMapper; + + @Override + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + // 返回 + return student.getId(); + } + + @Override + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + + // 删除子表 + deleteStudentContactByStudentId(id); + deleteStudentTeacherByStudentId(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生联系人) ==================== + + @Override + public PageResult getStudentContactPage(PageParam pageReqVO, Long studentId) { + return studentContactMapper.selectPage(pageReqVO, studentId); + } + + @Override + public Long createStudentContact(InfraStudentContactDO studentContact) { + studentContactMapper.insert(studentContact); + return studentContact.getId(); + } + + @Override + public void updateStudentContact(InfraStudentContactDO studentContact) { + // 校验存在 + validateStudentContactExists(studentContact.getId()); + // 更新 + studentContactMapper.updateById(studentContact); + } + + @Override + public void deleteStudentContact(Long id) { + // 校验存在 + validateStudentContactExists(id); + // 删除 + studentContactMapper.deleteById(id); + } + + @Override + public InfraStudentContactDO getStudentContact(Long id) { + return studentContactMapper.selectById(id); + } + + private void validateStudentContactExists(Long id) { + if (studentContactMapper.selectById(id) == null) { + throw exception(STUDENT_CONTACT_NOT_EXISTS); + } + } + + private void deleteStudentContactByStudentId(Long studentId) { + studentContactMapper.deleteByStudentId(studentId); + } + + // ==================== 子表(学生班主任) ==================== + + @Override + public PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId) { + return studentTeacherMapper.selectPage(pageReqVO, studentId); + } + + @Override + public Long createStudentTeacher(InfraStudentTeacherDO studentTeacher) { + // 校验是否已经存在 + if (studentTeacherMapper.selectByStudentId(studentTeacher.getStudentId()) != null) { + throw exception(STUDENT_TEACHER_EXISTS); + } + // 插入 + studentTeacherMapper.insert(studentTeacher); + return studentTeacher.getId(); + } + + @Override + public void updateStudentTeacher(InfraStudentTeacherDO studentTeacher) { + // 校验存在 + validateStudentTeacherExists(studentTeacher.getId()); + // 更新 + studentTeacherMapper.updateById(studentTeacher); + } + + @Override + public void deleteStudentTeacher(Long id) { + // 校验存在 + validateStudentTeacherExists(id); + // 删除 + studentTeacherMapper.deleteById(id); + } + + @Override + public InfraStudentTeacherDO getStudentTeacher(Long id) { + return studentTeacherMapper.selectById(id); + } + + private void validateStudentTeacherExists(Long id) { + if (studentTeacherMapper.selectById(id) == null) { + throw exception(STUDENT_TEACHER_NOT_EXISTS); + } + } + + private void deleteStudentTeacherByStudentId(Long studentId) { + studentTeacherMapper.deleteByStudentId(studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherDO new file mode 100644 index 00000000..6cc74d21 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生班主任 DO + * + + */ +@TableName("infra_student_teacher") +@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentTeacherDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherMapper new file mode 100644 index 00000000..a3226306 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/java/InfraStudentTeacherMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生班主任 Mapper + * + + */ +@Mapper +public interface InfraStudentTeacherMapper extends BaseMapperX { + + default PageResult selectPage(PageParam reqVO, Long studentId) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(InfraStudentTeacherDO::getStudentId, studentId) + .orderByDesc(InfraStudentTeacherDO::getId)); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentTeacherDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/js/student b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/js/student new file mode 100644 index 00000000..211d95e4 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/js/student @@ -0,0 +1,141 @@ +import request from '@/utils/request' + +// 创建学生 +export function createStudent(data) { + return request({ + url: '/infra/student/create', + method: 'post', + data: data + }) +} + +// 更新学生 +export function updateStudent(data) { + return request({ + url: '/infra/student/update', + method: 'put', + data: data + }) +} + +// 删除学生 +export function deleteStudent(id) { + return request({ + url: '/infra/student/delete?id=' + id, + method: 'delete' + }) +} + +// 获得学生 +export function getStudent(id) { + return request({ + url: '/infra/student/get?id=' + id, + method: 'get' + }) +} + +// 获得学生分页 +export function getStudentPage(params) { + return request({ + url: '/infra/student/page', + method: 'get', + params + }) +} +// 导出学生 Excel +export function exportStudentExcel(params) { + return request({ + url: '/infra/student/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} + +// ==================== 子表(学生联系人) ==================== + + // 获得学生联系人分页 + export function getStudentContactPage(params) { + return request({ + url: '/infra/student/student-contact/page', + method: 'get', + params + }) + } + // 新增学生联系人 + export function createStudentContact(data) { + return request({ + url: `/infra/student/student-contact/create`, + method: 'post', + data + }) + } + + // 修改学生联系人 + export function updateStudentContact(data) { + return request({ + url: `/infra/student/student-contact/update`, + method: 'post', + data + }) + } + + // 删除学生联系人 + export function deleteStudentContact(id) { + return request({ + url: `/infra/student/student-contact/delete?id=` + id, + method: 'delete' + }) + } + + // 获得学生联系人 + export function getStudentContact(id) { + return request({ + url: `/infra/student/student-contact/get?id=` + id, + method: 'get' + }) + } + +// ==================== 子表(学生班主任) ==================== + + // 获得学生班主任分页 + export function getStudentTeacherPage(params) { + return request({ + url: '/infra/student/student-teacher/page', + method: 'get', + params + }) + } + // 新增学生班主任 + export function createStudentTeacher(data) { + return request({ + url: `/infra/student/student-teacher/create`, + method: 'post', + data + }) + } + + // 修改学生班主任 + export function updateStudentTeacher(data) { + return request({ + url: `/infra/student/student-teacher/update`, + method: 'post', + data + }) + } + + // 删除学生班主任 + export function deleteStudentTeacher(id) { + return request({ + url: `/infra/student/student-teacher/delete?id=` + id, + method: 'delete' + }) + } + + // 获得学生班主任 + export function getStudentTeacher(id) { + return request({ + url: `/infra/student/student-teacher/get?id=` + id, + method: 'get' + }) + } \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/sql new file mode 100644 index 00000000..83df2792 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm new file mode 100644 index 00000000..de3b0a73 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm @@ -0,0 +1,151 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactList new file mode 100644 index 00000000..00f1ce04 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactList @@ -0,0 +1,129 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentForm new file mode 100644 index 00000000..d89e5066 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentForm @@ -0,0 +1,149 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm new file mode 100644 index 00000000..874a03bb --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm @@ -0,0 +1,151 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherList new file mode 100644 index 00000000..7d561a0e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherList @@ -0,0 +1,129 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/index new file mode 100644 index 00000000..9c7588f2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/vue/index @@ -0,0 +1,233 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_erp/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/assert.json new file mode 100644 index 00000000..f95ae9af --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/assert.json @@ -0,0 +1,73 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentContactDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" +}, { + "contentPath" : "java/InfraStudentTeacherDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "java/InfraStudentContactMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" +}, { + "contentPath" : "java/InfraStudentTeacherMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" +}, { + "contentPath" : "js/student", + "filePath" : "yudao-ui-admin-vue2/src/api/infra/student.js" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" +}, { + "contentPath" : "vue/StudentContactForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" +}, { + "contentPath" : "vue/StudentTeacherForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" +}, { + "contentPath" : "vue/StudentContactList", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactList.vue" +}, { + "contentPath" : "vue/StudentTeacherList", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherList.vue" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..f8be6620 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,3 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactDO new file mode 100644 index 00000000..6e33a47a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生联系人 DO + * + + */ +@TableName("infra_student_contact") +@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentContactDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactMapper new file mode 100644 index 00000000..32194d82 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentContactMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生联系人 Mapper + * + + */ +@Mapper +public interface InfraStudentContactMapper extends BaseMapperX { + + default List selectListByStudentId(Long studentId) { + return selectList(InfraStudentContactDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentContactDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentController new file mode 100644 index 00000000..b9a587b4 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentController @@ -0,0 +1,117 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + + // ==================== 子表(学生联系人) ==================== + + @GetMapping("/student-contact/list-by-student-id") + @Operation(summary = "获得学生联系人列表") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentContactListByStudentId(studentId)); + } + + // ==================== 子表(学生班主任) ==================== + + @GetMapping("/student-teacher/get-by-student-id") + @Operation(summary = "获得学生班主任") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentTeacherByStudentId(studentId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..faa491df --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentSaveReqVO @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + + @Schema(description = "学生联系人列表") + private List studentContacts; + + @Schema(description = "学生班主任") + private InfraStudentTeacherDO studentTeacher; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentService new file mode 100644 index 00000000..c6c94f41 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentService @@ -0,0 +1,77 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + + // ==================== 子表(学生联系人) ==================== + + /** + * 获得学生联系人列表 + * + * @param studentId 学生编号 + * @return 学生联系人列表 + */ + List getStudentContactListByStudentId(Long studentId); + + // ==================== 子表(学生班主任) ==================== + + /** + * 获得学生班主任 + * + * @param studentId 学生编号 + * @return 学生班主任 + */ + InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImpl new file mode 100644 index 00000000..40194d25 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImpl @@ -0,0 +1,147 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + @Resource + private InfraStudentContactMapper studentContactMapper; + @Resource + private InfraStudentTeacherMapper studentTeacherMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + + // 插入子表 + createStudentContactList(student.getId(), createReqVO.getStudentContacts()); + createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); + // 返回 + return student.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + + // 更新子表 + updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); + updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + + // 删除子表 + deleteStudentContactByStudentId(id); + deleteStudentTeacherByStudentId(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生联系人) ==================== + + @Override + public List getStudentContactListByStudentId(Long studentId) { + return studentContactMapper.selectListByStudentId(studentId); + } + + private void createStudentContactList(Long studentId, List list) { + list.forEach(o -> o.setStudentId(studentId)); + studentContactMapper.insertBatch(list); + } + + private void updateStudentContactList(Long studentId, List list) { + deleteStudentContactByStudentId(studentId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createStudentContactList(studentId, list); + } + + private void deleteStudentContactByStudentId(Long studentId) { + studentContactMapper.deleteByStudentId(studentId); + } + + // ==================== 子表(学生班主任) ==================== + + @Override + public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { + return studentTeacherMapper.selectByStudentId(studentId); + } + + private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacherMapper.insert(studentTeacher); + } + + private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + studentTeacherMapper.insertOrUpdate(studentTeacher); + } + + private void deleteStudentTeacherByStudentId(Long studentId) { + studentTeacherMapper.deleteByStudentId(studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherDO new file mode 100644 index 00000000..6cc74d21 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生班主任 DO + * + + */ +@TableName("infra_student_teacher") +@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentTeacherDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherMapper new file mode 100644 index 00000000..55025c3c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/java/InfraStudentTeacherMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生班主任 Mapper + * + + */ +@Mapper +public interface InfraStudentTeacherMapper extends BaseMapperX { + + default InfraStudentTeacherDO selectByStudentId(Long studentId) { + return selectOne(InfraStudentTeacherDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentTeacherDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/js/student b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/js/student new file mode 100644 index 00000000..b4e6ac5e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/js/student @@ -0,0 +1,74 @@ +import request from '@/utils/request' + +// 创建学生 +export function createStudent(data) { + return request({ + url: '/infra/student/create', + method: 'post', + data: data + }) +} + +// 更新学生 +export function updateStudent(data) { + return request({ + url: '/infra/student/update', + method: 'put', + data: data + }) +} + +// 删除学生 +export function deleteStudent(id) { + return request({ + url: '/infra/student/delete?id=' + id, + method: 'delete' + }) +} + +// 获得学生 +export function getStudent(id) { + return request({ + url: '/infra/student/get?id=' + id, + method: 'get' + }) +} + +// 获得学生分页 +export function getStudentPage(params) { + return request({ + url: '/infra/student/page', + method: 'get', + params + }) +} +// 导出学生 Excel +export function exportStudentExcel(params) { + return request({ + url: '/infra/student/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} + +// ==================== 子表(学生联系人) ==================== + + // 获得学生联系人列表 + export function getStudentContactListByStudentId(studentId) { + return request({ + url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId, + method: 'get' + }) + } + +// ==================== 子表(学生班主任) ==================== + + // 获得学生班主任 + export function getStudentTeacherByStudentId(studentId) { + return request({ + url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId, + method: 'get' + }) + } + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/sql new file mode 100644 index 00000000..83df2792 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactForm new file mode 100644 index 00000000..c953bfa1 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactForm @@ -0,0 +1,177 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactList new file mode 100644 index 00000000..c0a8710e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactList @@ -0,0 +1,89 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentForm new file mode 100644 index 00000000..6d93b612 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentForm @@ -0,0 +1,180 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm new file mode 100644 index 00000000..0dac19bb --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm @@ -0,0 +1,127 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherList new file mode 100644 index 00000000..9f572742 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherList @@ -0,0 +1,93 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/index new file mode 100644 index 00000000..ddeafdf2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/vue/index @@ -0,0 +1,222 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_inner/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/assert.json new file mode 100644 index 00000000..844cc753 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/assert.json @@ -0,0 +1,67 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentContactDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" +}, { + "contentPath" : "java/InfraStudentTeacherDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "java/InfraStudentContactMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" +}, { + "contentPath" : "java/InfraStudentTeacherMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" +}, { + "contentPath" : "js/student", + "filePath" : "yudao-ui-admin-vue2/src/api/infra/student.js" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" +}, { + "contentPath" : "vue/StudentContactForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" +}, { + "contentPath" : "vue/StudentTeacherForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..f8be6620 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,3 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactDO new file mode 100644 index 00000000..6e33a47a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生联系人 DO + * + + */ +@TableName("infra_student_contact") +@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentContactDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactMapper new file mode 100644 index 00000000..32194d82 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentContactMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生联系人 Mapper + * + + */ +@Mapper +public interface InfraStudentContactMapper extends BaseMapperX { + + default List selectListByStudentId(Long studentId) { + return selectList(InfraStudentContactDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentContactDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentController new file mode 100644 index 00000000..b9a587b4 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentController @@ -0,0 +1,117 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + + // ==================== 子表(学生联系人) ==================== + + @GetMapping("/student-contact/list-by-student-id") + @Operation(summary = "获得学生联系人列表") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentContactListByStudentId(studentId)); + } + + // ==================== 子表(学生班主任) ==================== + + @GetMapping("/student-teacher/get-by-student-id") + @Operation(summary = "获得学生班主任") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentTeacherByStudentId(studentId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..faa491df --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentSaveReqVO @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + + @Schema(description = "学生联系人列表") + private List studentContacts; + + @Schema(description = "学生班主任") + private InfraStudentTeacherDO studentTeacher; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentService new file mode 100644 index 00000000..c6c94f41 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentService @@ -0,0 +1,77 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + + // ==================== 子表(学生联系人) ==================== + + /** + * 获得学生联系人列表 + * + * @param studentId 学生编号 + * @return 学生联系人列表 + */ + List getStudentContactListByStudentId(Long studentId); + + // ==================== 子表(学生班主任) ==================== + + /** + * 获得学生班主任 + * + * @param studentId 学生编号 + * @return 学生班主任 + */ + InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImpl new file mode 100644 index 00000000..40194d25 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImpl @@ -0,0 +1,147 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + @Resource + private InfraStudentContactMapper studentContactMapper; + @Resource + private InfraStudentTeacherMapper studentTeacherMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + + // 插入子表 + createStudentContactList(student.getId(), createReqVO.getStudentContacts()); + createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); + // 返回 + return student.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + + // 更新子表 + updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); + updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + + // 删除子表 + deleteStudentContactByStudentId(id); + deleteStudentTeacherByStudentId(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生联系人) ==================== + + @Override + public List getStudentContactListByStudentId(Long studentId) { + return studentContactMapper.selectListByStudentId(studentId); + } + + private void createStudentContactList(Long studentId, List list) { + list.forEach(o -> o.setStudentId(studentId)); + studentContactMapper.insertBatch(list); + } + + private void updateStudentContactList(Long studentId, List list) { + deleteStudentContactByStudentId(studentId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createStudentContactList(studentId, list); + } + + private void deleteStudentContactByStudentId(Long studentId) { + studentContactMapper.deleteByStudentId(studentId); + } + + // ==================== 子表(学生班主任) ==================== + + @Override + public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { + return studentTeacherMapper.selectByStudentId(studentId); + } + + private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacherMapper.insert(studentTeacher); + } + + private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + studentTeacherMapper.insertOrUpdate(studentTeacher); + } + + private void deleteStudentTeacherByStudentId(Long studentId) { + studentTeacherMapper.deleteByStudentId(studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherDO new file mode 100644 index 00000000..6cc74d21 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生班主任 DO + * + + */ +@TableName("infra_student_teacher") +@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentTeacherDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherMapper new file mode 100644 index 00000000..55025c3c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/java/InfraStudentTeacherMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生班主任 Mapper + * + + */ +@Mapper +public interface InfraStudentTeacherMapper extends BaseMapperX { + + default InfraStudentTeacherDO selectByStudentId(Long studentId) { + return selectOne(InfraStudentTeacherDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentTeacherDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/js/student b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/js/student new file mode 100644 index 00000000..b4e6ac5e --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/js/student @@ -0,0 +1,74 @@ +import request from '@/utils/request' + +// 创建学生 +export function createStudent(data) { + return request({ + url: '/infra/student/create', + method: 'post', + data: data + }) +} + +// 更新学生 +export function updateStudent(data) { + return request({ + url: '/infra/student/update', + method: 'put', + data: data + }) +} + +// 删除学生 +export function deleteStudent(id) { + return request({ + url: '/infra/student/delete?id=' + id, + method: 'delete' + }) +} + +// 获得学生 +export function getStudent(id) { + return request({ + url: '/infra/student/get?id=' + id, + method: 'get' + }) +} + +// 获得学生分页 +export function getStudentPage(params) { + return request({ + url: '/infra/student/page', + method: 'get', + params + }) +} +// 导出学生 Excel +export function exportStudentExcel(params) { + return request({ + url: '/infra/student/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} + +// ==================== 子表(学生联系人) ==================== + + // 获得学生联系人列表 + export function getStudentContactListByStudentId(studentId) { + return request({ + url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId, + method: 'get' + }) + } + +// ==================== 子表(学生班主任) ==================== + + // 获得学生班主任 + export function getStudentTeacherByStudentId(studentId) { + return request({ + url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId, + method: 'get' + }) + } + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/sql new file mode 100644 index 00000000..83df2792 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentContactForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentContactForm new file mode 100644 index 00000000..c953bfa1 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentContactForm @@ -0,0 +1,177 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentForm new file mode 100644 index 00000000..6d93b612 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentForm @@ -0,0 +1,180 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm new file mode 100644 index 00000000..0dac19bb --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm @@ -0,0 +1,127 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/index new file mode 100644 index 00000000..46075812 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/vue/index @@ -0,0 +1,205 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_master_normal/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/assert.json new file mode 100644 index 00000000..ccb00a81 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/assert.json @@ -0,0 +1,49 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" +}, { + "contentPath" : "js/student", + "filePath" : "yudao-ui-admin-vue2/src/api/infra/student.js" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..f8be6620 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,3 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentController new file mode 100644 index 00000000..3796982c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentController @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..43e7f147 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentSaveReqVO @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentService new file mode 100644 index 00000000..12ccffe9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentService @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + * @author 姚君 + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImpl new file mode 100644 index 00000000..384a5df7 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImpl @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + + @Override + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + // 返回 + return student.getId(); + } + + @Override + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + } + + @Override + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/js/student b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/js/student new file mode 100644 index 00000000..44db4680 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/js/student @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 创建学生 +export function createStudent(data) { + return request({ + url: '/infra/student/create', + method: 'post', + data: data + }) +} + +// 更新学生 +export function updateStudent(data) { + return request({ + url: '/infra/student/update', + method: 'put', + data: data + }) +} + +// 删除学生 +export function deleteStudent(id) { + return request({ + url: '/infra/student/delete?id=' + id, + method: 'delete' + }) +} + +// 获得学生 +export function getStudent(id) { + return request({ + url: '/infra/student/get?id=' + id, + method: 'get' + }) +} + +// 获得学生分页 +export function getStudentPage(params) { + return request({ + url: '/infra/student/page', + method: 'get', + params + }) +} +// 导出学生 Excel +export function exportStudentExcel(params) { + return request({ + url: '/infra/student/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/sql new file mode 100644 index 00000000..83df2792 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/StudentForm new file mode 100644 index 00000000..d89e5066 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/StudentForm @@ -0,0 +1,149 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/index new file mode 100644 index 00000000..46075812 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/vue/index @@ -0,0 +1,205 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_one/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/assert.json new file mode 100644 index 00000000..470a9dec --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/assert.json @@ -0,0 +1,49 @@ +[ { + "contentPath" : "java/InfraCategoryListReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryListReqVO.java" +}, { + "contentPath" : "java/InfraCategoryRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryRespVO.java" +}, { + "contentPath" : "java/InfraCategorySaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategorySaveReqVO.java" +}, { + "contentPath" : "java/InfraCategoryController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraCategoryController.java" +}, { + "contentPath" : "java/InfraCategoryDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraCategoryDO.java" +}, { + "contentPath" : "java/InfraCategoryMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraCategoryMapper.java" +}, { + "contentPath" : "xml/InfraCategoryMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraCategoryMapper.xml" +}, { + "contentPath" : "java/InfraCategoryServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImpl.java" +}, { + "contentPath" : "java/InfraCategoryService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryService.java" +}, { + "contentPath" : "java/InfraCategoryServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" +}, { + "contentPath" : "js/category", + "filePath" : "yudao-ui-admin-vue2/src/api/infra/category.js" +}, { + "contentPath" : "vue/CategoryForm", + "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/CategoryForm.vue" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..36df6752 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,8 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 分类 TODO 补充编号 ========== +ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(TODO 补充编号, "分类不存在"); +ErrorCode CATEGORY_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子分类,无法删除"); +ErrorCode CATEGORY_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级分类不存在"); +ErrorCode CATEGORY_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父分类"); +ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该名字的分类"); +ErrorCode CATEGORY_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子InfraCategory为父InfraCategory"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryController new file mode 100644 index 00000000..a7b2f816 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryController @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraCategoryService; + +@Tag(name = "管理后台 - 分类") +@RestController +@RequestMapping("/infra/category") +@Validated +public class InfraCategoryController { + + @Resource + private InfraCategoryService categoryService; + + @PostMapping("/create") + @Operation(summary = "创建分类") + @PreAuthorize("@ss.hasPermission('infra:category:create')") + public CommonResult createCategory(@Valid @RequestBody InfraCategorySaveReqVO createReqVO) { + return success(categoryService.createCategory(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分类") + @PreAuthorize("@ss.hasPermission('infra:category:update')") + public CommonResult updateCategory(@Valid @RequestBody InfraCategorySaveReqVO updateReqVO) { + categoryService.updateCategory(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分类") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:category:delete')") + public CommonResult deleteCategory(@RequestParam("id") Long id) { + categoryService.deleteCategory(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分类") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:category:query')") + public CommonResult getCategory(@RequestParam("id") Long id) { + InfraCategoryDO category = categoryService.getCategory(id); + return success(BeanUtils.toBean(category, InfraCategoryRespVO.class)); + } + + @GetMapping("/list") + @Operation(summary = "获得分类列表") + @PreAuthorize("@ss.hasPermission('infra:category:query')") + public CommonResult> getCategoryList(@Valid InfraCategoryListReqVO listReqVO) { + List list = categoryService.getCategoryList(listReqVO); + return success(BeanUtils.toBean(list, InfraCategoryRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分类 Excel") + @PreAuthorize("@ss.hasPermission('infra:category:export')") + @OperateLog(type = EXPORT) + public void exportCategoryExcel(@Valid InfraCategoryListReqVO listReqVO, + HttpServletResponse response) throws IOException { + List list = categoryService.getCategoryList(listReqVO); + // 导出 Excel + ExcelUtils.write(response, "分类.xls", "数据", InfraCategoryRespVO.class, + BeanUtils.toBean(list, InfraCategoryRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryDO new file mode 100644 index 00000000..da457e96 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryDO @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分类 DO + * + + */ +@TableName("infra_category") +@KeySequence("infra_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraCategoryDO extends BaseDO { + + public static final Long PARENT_ID_ROOT = 0L; + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 父编号 + */ + private Long parentId; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryListReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryListReqVO new file mode 100644 index 00000000..e5c6f181 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryListReqVO @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +@Schema(description = "管理后台 - 分类列表 Request VO") +@Data +public class InfraCategoryListReqVO { + + @Schema(description = "名字", example = "芋头") + private String name; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryMapper new file mode 100644 index 00000000..07c05eab --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryMapper @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 分类 Mapper + * + + */ +@Mapper +public interface InfraCategoryMapper extends BaseMapperX { + + default List selectList(InfraCategoryListReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(InfraCategoryDO::getName, reqVO.getName()) + .orderByDesc(InfraCategoryDO::getId)); + } + + default InfraCategoryDO selectByParentIdAndName(Long parentId, String name) { + return selectOne(InfraCategoryDO::getParentId, parentId, InfraCategoryDO::getName, name); + } + + default Long selectCountByParentId(Long parentId) { + return selectCount(InfraCategoryDO::getParentId, parentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryRespVO new file mode 100644 index 00000000..6325d866 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryRespVO @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 分类 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraCategoryRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") + @ExcelProperty("父编号") + private Long parentId; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategorySaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategorySaveReqVO new file mode 100644 index 00000000..3c03b977 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategorySaveReqVO @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; + +@Schema(description = "管理后台 - 分类新增/修改 Request VO") +@Data +public class InfraCategorySaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") + @NotNull(message = "父编号不能为空") + private Long parentId; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryService new file mode 100644 index 00000000..f508ef33 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryService @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 分类 Service 接口 + * + * @author 姚君 + */ +public interface InfraCategoryService { + + /** + * 创建分类 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCategory(@Valid InfraCategorySaveReqVO createReqVO); + + /** + * 更新分类 + * + * @param updateReqVO 更新信息 + */ + void updateCategory(@Valid InfraCategorySaveReqVO updateReqVO); + + /** + * 删除分类 + * + * @param id 编号 + */ + void deleteCategory(Long id); + + /** + * 获得分类 + * + * @param id 编号 + * @return 分类 + */ + InfraCategoryDO getCategory(Long id); + + /** + * 获得分类列表 + * + * @param listReqVO 查询条件 + * @return 分类列表 + */ + List getCategoryList(InfraCategoryListReqVO listReqVO); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImpl new file mode 100644 index 00000000..2d594477 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImpl @@ -0,0 +1,136 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 分类 Service 实现类 + * + + */ +@Service +@Validated +public class InfraCategoryServiceImpl implements InfraCategoryService { + + @Resource + private InfraCategoryMapper categoryMapper; + + @Override + public Long createCategory(InfraCategorySaveReqVO createReqVO) { + // 校验父编号的有效性 + validateParentCategory(null, createReqVO.getParentId()); + // 校验名字的唯一性 + validateCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); + + // 插入 + InfraCategoryDO category = BeanUtils.toBean(createReqVO, InfraCategoryDO.class); + categoryMapper.insert(category); + // 返回 + return category.getId(); + } + + @Override + public void updateCategory(InfraCategorySaveReqVO updateReqVO) { + // 校验存在 + validateCategoryExists(updateReqVO.getId()); + // 校验父编号的有效性 + validateParentCategory(updateReqVO.getId(), updateReqVO.getParentId()); + // 校验名字的唯一性 + validateCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); + + // 更新 + InfraCategoryDO updateObj = BeanUtils.toBean(updateReqVO, InfraCategoryDO.class); + categoryMapper.updateById(updateObj); + } + + @Override + public void deleteCategory(Long id) { + // 校验存在 + validateCategoryExists(id); + // 校验是否有子分类 + if (categoryMapper.selectCountByParentId(id) > 0) { + throw exception(CATEGORY_EXITS_CHILDREN); + } + // 删除 + categoryMapper.deleteById(id); + } + + private void validateCategoryExists(Long id) { + if (categoryMapper.selectById(id) == null) { + throw exception(CATEGORY_NOT_EXISTS); + } + } + + private void validateParentCategory(Long id, Long parentId) { + if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { + return; + } + // 1. 不能设置自己为父分类 + if (Objects.equals(id, parentId)) { + throw exception(CATEGORY_PARENT_ERROR); + } + // 2. 父分类不存在 + CategoryDO parentCategory = categoryMapper.selectById(parentId); + if (parentCategory == null) { + throw exception(CATEGORY_PARENT_NOT_EXITS); + } + // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 + if (id == null) { // id 为空,说明新增,不需要考虑环路 + return; + } + for (int i = 0; i < Short.MAX_VALUE; i++) { + // 3.1 校验环路 + parentId = parentCategory.getParentId(); + if (Objects.equals(id, parentId)) { + throw exception(CATEGORY_PARENT_IS_CHILD); + } + // 3.2 继续递归下一级父分类 + if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { + break; + } + parentCategory = categoryMapper.selectById(parentId); + if (parentCategory == null) { + break; + } + } + } + + private void validateCategoryNameUnique(Long id, Long parentId, String name) { + CategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); + if (category == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的分类 + if (id == null) { + throw exception(CATEGORY_NAME_DUPLICATE); + } + if (!Objects.equals(category.getId(), id)) { + throw exception(CATEGORY_NAME_DUPLICATE); + } + } + + @Override + public InfraCategoryDO getCategory(Long id) { + return categoryMapper.selectById(id); + } + + @Override + public List getCategoryList(InfraCategoryListReqVO listReqVO) { + return categoryMapper.selectList(listReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImplTest new file mode 100644 index 00000000..3e4d0eb1 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/java/InfraCategoryServiceImplTest @@ -0,0 +1,129 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraCategoryServiceImpl} 的单元测试类 + * + + */ +@Import(InfraCategoryServiceImpl.class) +public class InfraCategoryServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraCategoryServiceImpl categoryService; + + @Resource + private InfraCategoryMapper categoryMapper; + + @Test + public void testCreateCategory_success() { + // 准备参数 + InfraCategorySaveReqVO createReqVO = randomPojo(InfraCategorySaveReqVO.class).setId(null); + + // 调用 + Long categoryId = categoryService.createCategory(createReqVO); + // 断言 + assertNotNull(categoryId); + // 校验记录的属性是否正确 + InfraCategoryDO category = categoryMapper.selectById(categoryId); + assertPojoEquals(createReqVO, category, "id"); + } + + @Test + public void testUpdateCategory_success() { + // mock 数据 + InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); + categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class, o -> { + o.setId(dbCategory.getId()); // 设置更新的 ID + }); + + // 调用 + categoryService.updateCategory(updateReqVO); + // 校验是否更新正确 + InfraCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, category); + } + + @Test + public void testUpdateCategory_notExists() { + // 准备参数 + InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); + } + + @Test + public void testDeleteCategory_success() { + // mock 数据 + InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); + categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbCategory.getId(); + + // 调用 + categoryService.deleteCategory(id); + // 校验数据不存在了 + assertNull(categoryMapper.selectById(id)); + } + + @Test + public void testDeleteCategory_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetCategoryList() { + // mock 数据 + InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class, o -> { // 等会查询到 + o.setName(null); + }); + categoryMapper.insert(dbCategory); + // 测试 name 不匹配 + categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); + // 准备参数 + InfraCategoryListReqVO reqVO = new InfraCategoryListReqVO(); + reqVO.setName(null); + + // 调用 + List list = categoryService.getCategoryList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbCategory, list.get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/js/category b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/js/category new file mode 100644 index 00000000..1e6ffdce --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/js/category @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 创建分类 +export function createCategory(data) { + return request({ + url: '/infra/category/create', + method: 'post', + data: data + }) +} + +// 更新分类 +export function updateCategory(data) { + return request({ + url: '/infra/category/update', + method: 'put', + data: data + }) +} + +// 删除分类 +export function deleteCategory(id) { + return request({ + url: '/infra/category/delete?id=' + id, + method: 'delete' + }) +} + +// 获得分类 +export function getCategory(id) { + return request({ + url: '/infra/category/get?id=' + id, + method: 'get' + }) +} + +// 获得分类列表 +export function getCategoryList(params) { + return request({ + url: '/infra/category/list', + method: 'get', + params + }) +} +// 导出分类 Excel +export function exportCategoryExcel(params) { + return request({ + url: '/infra/category/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/h2 new file mode 100644 index 00000000..4141766c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/h2 @@ -0,0 +1,10 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_category" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" bigint NOT NULL, + PRIMARY KEY ("id") +) COMMENT '分类表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_category"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/sql new file mode 100644 index 00000000..81409488 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '分类管理', '', 2, 0, 888, + 'category', '', 'infra/demo/index', 0, 'InfraCategory' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类查询', 'infra:category:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类创建', 'infra:category:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类更新', 'infra:category:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类删除', 'infra:category:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类导出', 'infra:category:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/CategoryForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/CategoryForm new file mode 100644 index 00000000..7fa06e8c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/CategoryForm @@ -0,0 +1,130 @@ + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/index new file mode 100644 index 00000000..88da6825 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/vue/index @@ -0,0 +1,161 @@ + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/xml/InfraCategoryMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/xml/InfraCategoryMapper new file mode 100644 index 00000000..025ac850 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue2_tree/xml/InfraCategoryMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/assert.json new file mode 100644 index 00000000..0937ba91 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/assert.json @@ -0,0 +1,73 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentContactDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" +}, { + "contentPath" : "java/InfraStudentTeacherDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "java/InfraStudentContactMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" +}, { + "contentPath" : "java/InfraStudentTeacherMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" +}, { + "contentPath" : "vue/StudentContactForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" +}, { + "contentPath" : "vue/StudentTeacherForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" +}, { + "contentPath" : "vue/StudentContactList", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactList.vue" +}, { + "contentPath" : "vue/StudentTeacherList", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherList.vue" +}, { + "contentPath" : "ts/index", + "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..5e64b117 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,6 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); +ErrorCode STUDENT_CONTACT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生联系人不存在"); +ErrorCode STUDENT_TEACHER_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任不存在"); +ErrorCode STUDENT_TEACHER_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任已存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactDO new file mode 100644 index 00000000..6e33a47a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生联系人 DO + * + + */ +@TableName("infra_student_contact") +@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentContactDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactMapper new file mode 100644 index 00000000..6cdaa924 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentContactMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生联系人 Mapper + * + + */ +@Mapper +public interface InfraStudentContactMapper extends BaseMapperX { + + default PageResult selectPage(PageParam reqVO, Long studentId) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(InfraStudentContactDO::getStudentId, studentId) + .orderByDesc(InfraStudentContactDO::getId)); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentContactDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentController new file mode 100644 index 00000000..d6f20183 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentController @@ -0,0 +1,183 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + + // ==================== 子表(学生联系人) ==================== + + @GetMapping("/student-contact/page") + @Operation(summary = "获得学生联系人分页") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentContactPage(PageParam pageReqVO, + @RequestParam("studentId") Long studentId) { + return success(studentService.getStudentContactPage(pageReqVO, studentId)); + } + + @PostMapping("/student-contact/create") + @Operation(summary = "创建学生联系人") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { + return success(studentService.createStudentContact(studentContact)); + } + + @PutMapping("/student-contact/update") + @Operation(summary = "更新学生联系人") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { + studentService.updateStudentContact(studentContact); + return success(true); + } + + @DeleteMapping("/student-contact/delete") + @Parameter(name = "id", description = "编号", required = true) + @Operation(summary = "删除学生联系人") + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudentContact(@RequestParam("id") Long id) { + studentService.deleteStudentContact(id); + return success(true); + } + + @GetMapping("/student-contact/get") + @Operation(summary = "获得学生联系人") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentContact(@RequestParam("id") Long id) { + return success(studentService.getStudentContact(id)); + } + + // ==================== 子表(学生班主任) ==================== + + @GetMapping("/student-teacher/page") + @Operation(summary = "获得学生班主任分页") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentTeacherPage(PageParam pageReqVO, + @RequestParam("studentId") Long studentId) { + return success(studentService.getStudentTeacherPage(pageReqVO, studentId)); + } + + @PostMapping("/student-teacher/create") + @Operation(summary = "创建学生班主任") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { + return success(studentService.createStudentTeacher(studentTeacher)); + } + + @PutMapping("/student-teacher/update") + @Operation(summary = "更新学生班主任") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { + studentService.updateStudentTeacher(studentTeacher); + return success(true); + } + + @DeleteMapping("/student-teacher/delete") + @Parameter(name = "id", description = "编号", required = true) + @Operation(summary = "删除学生班主任") + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudentTeacher(@RequestParam("id") Long id) { + studentService.deleteStudentTeacher(id); + return success(true); + } + + @GetMapping("/student-teacher/get") + @Operation(summary = "获得学生班主任") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentTeacher(@RequestParam("id") Long id) { + return success(studentService.getStudentTeacher(id)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..eaadf743 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentSaveReqVO @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentService new file mode 100644 index 00000000..a94ed062 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentService @@ -0,0 +1,139 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + + // ==================== 子表(学生联系人) ==================== + + /** + * 获得学生联系人分页 + * + * @param pageReqVO 分页查询 + * @param studentId 学生编号 + * @return 学生联系人分页 + */ + PageResult getStudentContactPage(PageParam pageReqVO, Long studentId); + + /** + * 创建学生联系人 + * + * @param studentContact 创建信息 + * @return 编号 + */ + Long createStudentContact(@Valid InfraStudentContactDO studentContact); + + /** + * 更新学生联系人 + * + * @param studentContact 更新信息 + */ + void updateStudentContact(@Valid InfraStudentContactDO studentContact); + + /** + * 删除学生联系人 + * + * @param id 编号 + */ + void deleteStudentContact(Long id); + + /** + * 获得学生联系人 + * + * @param id 编号 + * @return 学生联系人 + */ + InfraStudentContactDO getStudentContact(Long id); + + // ==================== 子表(学生班主任) ==================== + + /** + * 获得学生班主任分页 + * + * @param pageReqVO 分页查询 + * @param studentId 学生编号 + * @return 学生班主任分页 + */ + PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId); + + /** + * 创建学生班主任 + * + * @param studentTeacher 创建信息 + * @return 编号 + */ + Long createStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); + + /** + * 更新学生班主任 + * + * @param studentTeacher 更新信息 + */ + void updateStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); + + /** + * 删除学生班主任 + * + * @param id 编号 + */ + void deleteStudentTeacher(Long id); + + /** + * 获得学生班主任 + * + * @param id 编号 + * @return 学生班主任 + */ + InfraStudentTeacherDO getStudentTeacher(Long id); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImpl new file mode 100644 index 00000000..b8cf59c6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImpl @@ -0,0 +1,180 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + @Resource + private InfraStudentContactMapper studentContactMapper; + @Resource + private InfraStudentTeacherMapper studentTeacherMapper; + + @Override + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + // 返回 + return student.getId(); + } + + @Override + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + + // 删除子表 + deleteStudentContactByStudentId(id); + deleteStudentTeacherByStudentId(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生联系人) ==================== + + @Override + public PageResult getStudentContactPage(PageParam pageReqVO, Long studentId) { + return studentContactMapper.selectPage(pageReqVO, studentId); + } + + @Override + public Long createStudentContact(InfraStudentContactDO studentContact) { + studentContactMapper.insert(studentContact); + return studentContact.getId(); + } + + @Override + public void updateStudentContact(InfraStudentContactDO studentContact) { + // 校验存在 + validateStudentContactExists(studentContact.getId()); + // 更新 + studentContactMapper.updateById(studentContact); + } + + @Override + public void deleteStudentContact(Long id) { + // 校验存在 + validateStudentContactExists(id); + // 删除 + studentContactMapper.deleteById(id); + } + + @Override + public InfraStudentContactDO getStudentContact(Long id) { + return studentContactMapper.selectById(id); + } + + private void validateStudentContactExists(Long id) { + if (studentContactMapper.selectById(id) == null) { + throw exception(STUDENT_CONTACT_NOT_EXISTS); + } + } + + private void deleteStudentContactByStudentId(Long studentId) { + studentContactMapper.deleteByStudentId(studentId); + } + + // ==================== 子表(学生班主任) ==================== + + @Override + public PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId) { + return studentTeacherMapper.selectPage(pageReqVO, studentId); + } + + @Override + public Long createStudentTeacher(InfraStudentTeacherDO studentTeacher) { + // 校验是否已经存在 + if (studentTeacherMapper.selectByStudentId(studentTeacher.getStudentId()) != null) { + throw exception(STUDENT_TEACHER_EXISTS); + } + // 插入 + studentTeacherMapper.insert(studentTeacher); + return studentTeacher.getId(); + } + + @Override + public void updateStudentTeacher(InfraStudentTeacherDO studentTeacher) { + // 校验存在 + validateStudentTeacherExists(studentTeacher.getId()); + // 更新 + studentTeacherMapper.updateById(studentTeacher); + } + + @Override + public void deleteStudentTeacher(Long id) { + // 校验存在 + validateStudentTeacherExists(id); + // 删除 + studentTeacherMapper.deleteById(id); + } + + @Override + public InfraStudentTeacherDO getStudentTeacher(Long id) { + return studentTeacherMapper.selectById(id); + } + + private void validateStudentTeacherExists(Long id) { + if (studentTeacherMapper.selectById(id) == null) { + throw exception(STUDENT_TEACHER_NOT_EXISTS); + } + } + + private void deleteStudentTeacherByStudentId(Long studentId) { + studentTeacherMapper.deleteByStudentId(studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherDO new file mode 100644 index 00000000..6cc74d21 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生班主任 DO + * + + */ +@TableName("infra_student_teacher") +@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentTeacherDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherMapper new file mode 100644 index 00000000..a3226306 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/java/InfraStudentTeacherMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生班主任 Mapper + * + + */ +@Mapper +public interface InfraStudentTeacherMapper extends BaseMapperX { + + default PageResult selectPage(PageParam reqVO, Long studentId) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(InfraStudentTeacherDO::getStudentId, studentId) + .orderByDesc(InfraStudentTeacherDO::getId)); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentTeacherDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/sql new file mode 100644 index 00000000..4551d0de --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/ts/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/ts/index new file mode 100644 index 00000000..41eb94dd --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/ts/index @@ -0,0 +1,95 @@ +import request from '@/config/axios' + +export interface StudentVO { + id: number + name: string + description: string + birthday: Date + sex: number + enabled: boolean + avatar: string + video: string + memo: string +} + +// 查询学生分页 +export const getStudentPage = async (params) => { + return await request.get({ url: `/infra/student/page`, params }) +} + +// 查询学生详情 +export const getStudent = async (id: number) => { + return await request.get({ url: `/infra/student/get?id=` + id }) +} + +// 新增学生 +export const createStudent = async (data: StudentVO) => { + return await request.post({ url: `/infra/student/create`, data }) +} + +// 修改学生 +export const updateStudent = async (data: StudentVO) => { + return await request.put({ url: `/infra/student/update`, data }) +} + +// 删除学生 +export const deleteStudent = async (id: number) => { + return await request.delete({ url: `/infra/student/delete?id=` + id }) +} + +// 导出学生 Excel +export const exportStudent = async (params) => { + return await request.download({ url: `/infra/student/export-excel`, params }) +} + +// ==================== 子表(学生联系人) ==================== + +// 获得学生联系人分页 +export const getStudentContactPage = async (params) => { + return await request.get({ url: `/infra/student/student-contact/page`, params }) +} +// 新增学生联系人 +export const createStudentContact = async (data) => { + return await request.post({ url: `/infra/student/student-contact/create`, data }) +} + +// 修改学生联系人 +export const updateStudentContact = async (data) => { + return await request.put({ url: `/infra/student/student-contact/update`, data }) +} + +// 删除学生联系人 +export const deleteStudentContact = async (id: number) => { + return await request.delete({ url: `/infra/student/student-contact/delete?id=` + id }) +} + +// 获得学生联系人 +export const getStudentContact = async (id: number) => { + return await request.get({ url: `/infra/student/student-contact/get?id=` + id }) +} + +// ==================== 子表(学生班主任) ==================== + +// 获得学生班主任分页 +export const getStudentTeacherPage = async (params) => { + return await request.get({ url: `/infra/student/student-teacher/page`, params }) +} +// 新增学生班主任 +export const createStudentTeacher = async (data) => { + return await request.post({ url: `/infra/student/student-teacher/create`, data }) +} + +// 修改学生班主任 +export const updateStudentTeacher = async (data) => { + return await request.put({ url: `/infra/student/student-teacher/update`, data }) +} + +// 删除学生班主任 +export const deleteStudentTeacher = async (id: number) => { + return await request.delete({ url: `/infra/student/student-teacher/delete?id=` + id }) +} + +// 获得学生班主任 +export const getStudentTeacher = async (id: number) => { + return await request.get({ url: `/infra/student/student-teacher/get?id=` + id }) +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactForm new file mode 100644 index 00000000..3c98b67f --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactForm @@ -0,0 +1,155 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactList new file mode 100644 index 00000000..eada66a7 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentContactList @@ -0,0 +1,146 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentForm new file mode 100644 index 00000000..2e3fc038 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentForm @@ -0,0 +1,152 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherForm new file mode 100644 index 00000000..242fd57f --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherForm @@ -0,0 +1,155 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherList new file mode 100644 index 00000000..1eba0a3d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/StudentTeacherList @@ -0,0 +1,146 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/index new file mode 100644 index 00000000..c23fe439 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/vue/index @@ -0,0 +1,278 @@ + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_erp/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/assert.json new file mode 100644 index 00000000..0937ba91 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/assert.json @@ -0,0 +1,73 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentContactDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" +}, { + "contentPath" : "java/InfraStudentTeacherDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "java/InfraStudentContactMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" +}, { + "contentPath" : "java/InfraStudentTeacherMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" +}, { + "contentPath" : "vue/StudentContactForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" +}, { + "contentPath" : "vue/StudentTeacherForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" +}, { + "contentPath" : "vue/StudentContactList", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactList.vue" +}, { + "contentPath" : "vue/StudentTeacherList", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherList.vue" +}, { + "contentPath" : "ts/index", + "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..72162a85 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,3 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactDO new file mode 100644 index 00000000..6e33a47a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生联系人 DO + * + + */ +@TableName("infra_student_contact") +@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentContactDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactMapper new file mode 100644 index 00000000..32194d82 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentContactMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生联系人 Mapper + * + + */ +@Mapper +public interface InfraStudentContactMapper extends BaseMapperX { + + default List selectListByStudentId(Long studentId) { + return selectList(InfraStudentContactDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentContactDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentController new file mode 100644 index 00000000..b9a587b4 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentController @@ -0,0 +1,117 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + + // ==================== 子表(学生联系人) ==================== + + @GetMapping("/student-contact/list-by-student-id") + @Operation(summary = "获得学生联系人列表") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentContactListByStudentId(studentId)); + } + + // ==================== 子表(学生班主任) ==================== + + @GetMapping("/student-teacher/get-by-student-id") + @Operation(summary = "获得学生班主任") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentTeacherByStudentId(studentId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..faa491df --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentSaveReqVO @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + + @Schema(description = "学生联系人列表") + private List studentContacts; + + @Schema(description = "学生班主任") + private InfraStudentTeacherDO studentTeacher; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentService new file mode 100644 index 00000000..c6c94f41 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentService @@ -0,0 +1,77 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + + // ==================== 子表(学生联系人) ==================== + + /** + * 获得学生联系人列表 + * + * @param studentId 学生编号 + * @return 学生联系人列表 + */ + List getStudentContactListByStudentId(Long studentId); + + // ==================== 子表(学生班主任) ==================== + + /** + * 获得学生班主任 + * + * @param studentId 学生编号 + * @return 学生班主任 + */ + InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImpl new file mode 100644 index 00000000..40194d25 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImpl @@ -0,0 +1,147 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + @Resource + private InfraStudentContactMapper studentContactMapper; + @Resource + private InfraStudentTeacherMapper studentTeacherMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + + // 插入子表 + createStudentContactList(student.getId(), createReqVO.getStudentContacts()); + createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); + // 返回 + return student.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + + // 更新子表 + updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); + updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + + // 删除子表 + deleteStudentContactByStudentId(id); + deleteStudentTeacherByStudentId(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生联系人) ==================== + + @Override + public List getStudentContactListByStudentId(Long studentId) { + return studentContactMapper.selectListByStudentId(studentId); + } + + private void createStudentContactList(Long studentId, List list) { + list.forEach(o -> o.setStudentId(studentId)); + studentContactMapper.insertBatch(list); + } + + private void updateStudentContactList(Long studentId, List list) { + deleteStudentContactByStudentId(studentId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createStudentContactList(studentId, list); + } + + private void deleteStudentContactByStudentId(Long studentId) { + studentContactMapper.deleteByStudentId(studentId); + } + + // ==================== 子表(学生班主任) ==================== + + @Override + public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { + return studentTeacherMapper.selectByStudentId(studentId); + } + + private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacherMapper.insert(studentTeacher); + } + + private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + studentTeacherMapper.insertOrUpdate(studentTeacher); + } + + private void deleteStudentTeacherByStudentId(Long studentId) { + studentTeacherMapper.deleteByStudentId(studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherDO new file mode 100644 index 00000000..6cc74d21 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生班主任 DO + * + + */ +@TableName("infra_student_teacher") +@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentTeacherDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherMapper new file mode 100644 index 00000000..55025c3c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/java/InfraStudentTeacherMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生班主任 Mapper + * + + */ +@Mapper +public interface InfraStudentTeacherMapper extends BaseMapperX { + + default InfraStudentTeacherDO selectByStudentId(Long studentId) { + return selectOne(InfraStudentTeacherDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentTeacherDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/sql new file mode 100644 index 00000000..4551d0de --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/ts/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/ts/index new file mode 100644 index 00000000..6afca54c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/ts/index @@ -0,0 +1,57 @@ +import request from '@/config/axios' + +export interface StudentVO { + id: number + name: string + description: string + birthday: Date + sex: number + enabled: boolean + avatar: string + video: string + memo: string +} + +// 查询学生分页 +export const getStudentPage = async (params) => { + return await request.get({ url: `/infra/student/page`, params }) +} + +// 查询学生详情 +export const getStudent = async (id: number) => { + return await request.get({ url: `/infra/student/get?id=` + id }) +} + +// 新增学生 +export const createStudent = async (data: StudentVO) => { + return await request.post({ url: `/infra/student/create`, data }) +} + +// 修改学生 +export const updateStudent = async (data: StudentVO) => { + return await request.put({ url: `/infra/student/update`, data }) +} + +// 删除学生 +export const deleteStudent = async (id: number) => { + return await request.delete({ url: `/infra/student/delete?id=` + id }) +} + +// 导出学生 Excel +export const exportStudent = async (params) => { + return await request.download({ url: `/infra/student/export-excel`, params }) +} + +// ==================== 子表(学生联系人) ==================== + +// 获得学生联系人列表 +export const getStudentContactListByStudentId = async (studentId) => { + return await request.get({ url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId }) +} + +// ==================== 子表(学生班主任) ==================== + +// 获得学生班主任 +export const getStudentTeacherByStudentId = async (studentId) => { + return await request.get({ url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId }) +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactForm new file mode 100644 index 00000000..20f129e5 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactForm @@ -0,0 +1,174 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactList new file mode 100644 index 00000000..d0e89dac --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentContactList @@ -0,0 +1,72 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentForm new file mode 100644 index 00000000..d77df42d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentForm @@ -0,0 +1,184 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherForm new file mode 100644 index 00000000..6027db88 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherForm @@ -0,0 +1,122 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherList b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherList new file mode 100644 index 00000000..e510adcf --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/StudentTeacherList @@ -0,0 +1,76 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/index new file mode 100644 index 00000000..5bbb69b7 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/vue/index @@ -0,0 +1,267 @@ + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_inner/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/assert.json new file mode 100644 index 00000000..60e7f476 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/assert.json @@ -0,0 +1,67 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentContactDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" +}, { + "contentPath" : "java/InfraStudentTeacherDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "java/InfraStudentContactMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" +}, { + "contentPath" : "java/InfraStudentTeacherMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" +}, { + "contentPath" : "vue/StudentContactForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" +}, { + "contentPath" : "vue/StudentTeacherForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" +}, { + "contentPath" : "ts/index", + "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..72162a85 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,3 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactDO new file mode 100644 index 00000000..6e33a47a --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生联系人 DO + * + + */ +@TableName("infra_student_contact") +@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentContactDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactMapper new file mode 100644 index 00000000..32194d82 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentContactMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生联系人 Mapper + * + + */ +@Mapper +public interface InfraStudentContactMapper extends BaseMapperX { + + default List selectListByStudentId(Long studentId) { + return selectList(InfraStudentContactDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentContactDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentController new file mode 100644 index 00000000..b9a587b4 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentController @@ -0,0 +1,117 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + + // ==================== 子表(学生联系人) ==================== + + @GetMapping("/student-contact/list-by-student-id") + @Operation(summary = "获得学生联系人列表") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentContactListByStudentId(studentId)); + } + + // ==================== 子表(学生班主任) ==================== + + @GetMapping("/student-teacher/get-by-student-id") + @Operation(summary = "获得学生班主任") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { + return success(studentService.getStudentTeacherByStudentId(studentId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..faa491df --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentSaveReqVO @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + + @Schema(description = "学生联系人列表") + private List studentContacts; + + @Schema(description = "学生班主任") + private InfraStudentTeacherDO studentTeacher; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentService new file mode 100644 index 00000000..c6c94f41 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentService @@ -0,0 +1,77 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + + // ==================== 子表(学生联系人) ==================== + + /** + * 获得学生联系人列表 + * + * @param studentId 学生编号 + * @return 学生联系人列表 + */ + List getStudentContactListByStudentId(Long studentId); + + // ==================== 子表(学生班主任) ==================== + + /** + * 获得学生班主任 + * + * @param studentId 学生编号 + * @return 学生班主任 + */ + InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImpl new file mode 100644 index 00000000..40194d25 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImpl @@ -0,0 +1,147 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + @Resource + private InfraStudentContactMapper studentContactMapper; + @Resource + private InfraStudentTeacherMapper studentTeacherMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + + // 插入子表 + createStudentContactList(student.getId(), createReqVO.getStudentContacts()); + createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); + // 返回 + return student.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + + // 更新子表 + updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); + updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + + // 删除子表 + deleteStudentContactByStudentId(id); + deleteStudentTeacherByStudentId(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生联系人) ==================== + + @Override + public List getStudentContactListByStudentId(Long studentId) { + return studentContactMapper.selectListByStudentId(studentId); + } + + private void createStudentContactList(Long studentId, List list) { + list.forEach(o -> o.setStudentId(studentId)); + studentContactMapper.insertBatch(list); + } + + private void updateStudentContactList(Long studentId, List list) { + deleteStudentContactByStudentId(studentId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createStudentContactList(studentId, list); + } + + private void deleteStudentContactByStudentId(Long studentId) { + studentContactMapper.deleteByStudentId(studentId); + } + + // ==================== 子表(学生班主任) ==================== + + @Override + public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { + return studentTeacherMapper.selectByStudentId(studentId); + } + + private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacherMapper.insert(studentTeacher); + } + + private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { + if (studentTeacher == null) { + return; + } + studentTeacher.setStudentId(studentId); + studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + studentTeacherMapper.insertOrUpdate(studentTeacher); + } + + private void deleteStudentTeacherByStudentId(Long studentId) { + studentTeacherMapper.deleteByStudentId(studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherDO new file mode 100644 index 00000000..6cc74d21 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherDO @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生班主任 DO + * + + */ +@TableName("infra_student_teacher") +@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentTeacherDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 学生编号 + */ + private Long studentId; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherMapper new file mode 100644 index 00000000..55025c3c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/java/InfraStudentTeacherMapper @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生班主任 Mapper + * + + */ +@Mapper +public interface InfraStudentTeacherMapper extends BaseMapperX { + + default InfraStudentTeacherDO selectByStudentId(Long studentId) { + return selectOne(InfraStudentTeacherDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(InfraStudentTeacherDO::getStudentId, studentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/sql new file mode 100644 index 00000000..4551d0de --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/ts/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/ts/index new file mode 100644 index 00000000..6afca54c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/ts/index @@ -0,0 +1,57 @@ +import request from '@/config/axios' + +export interface StudentVO { + id: number + name: string + description: string + birthday: Date + sex: number + enabled: boolean + avatar: string + video: string + memo: string +} + +// 查询学生分页 +export const getStudentPage = async (params) => { + return await request.get({ url: `/infra/student/page`, params }) +} + +// 查询学生详情 +export const getStudent = async (id: number) => { + return await request.get({ url: `/infra/student/get?id=` + id }) +} + +// 新增学生 +export const createStudent = async (data: StudentVO) => { + return await request.post({ url: `/infra/student/create`, data }) +} + +// 修改学生 +export const updateStudent = async (data: StudentVO) => { + return await request.put({ url: `/infra/student/update`, data }) +} + +// 删除学生 +export const deleteStudent = async (id: number) => { + return await request.delete({ url: `/infra/student/delete?id=` + id }) +} + +// 导出学生 Excel +export const exportStudent = async (params) => { + return await request.download({ url: `/infra/student/export-excel`, params }) +} + +// ==================== 子表(学生联系人) ==================== + +// 获得学生联系人列表 +export const getStudentContactListByStudentId = async (studentId) => { + return await request.get({ url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId }) +} + +// ==================== 子表(学生班主任) ==================== + +// 获得学生班主任 +export const getStudentTeacherByStudentId = async (studentId) => { + return await request.get({ url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId }) +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentContactForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentContactForm new file mode 100644 index 00000000..20f129e5 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentContactForm @@ -0,0 +1,174 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentForm new file mode 100644 index 00000000..d77df42d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentForm @@ -0,0 +1,184 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentTeacherForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentTeacherForm new file mode 100644 index 00000000..6027db88 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/StudentTeacherForm @@ -0,0 +1,122 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/index new file mode 100644 index 00000000..4a65d8c3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/vue/index @@ -0,0 +1,252 @@ + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_master_normal/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/assert.json new file mode 100644 index 00000000..5a0eebde --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/assert.json @@ -0,0 +1,49 @@ +[ { + "contentPath" : "java/InfraStudentPageReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" +}, { + "contentPath" : "java/InfraStudentRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" +}, { + "contentPath" : "java/InfraStudentSaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" +}, { + "contentPath" : "java/InfraStudentController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" +}, { + "contentPath" : "java/InfraStudentDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" +}, { + "contentPath" : "java/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" +}, { + "contentPath" : "xml/InfraStudentMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" +}, { + "contentPath" : "java/InfraStudentServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" +}, { + "contentPath" : "java/InfraStudentService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" +}, { + "contentPath" : "java/InfraStudentServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" +}, { + "contentPath" : "vue/StudentForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" +}, { + "contentPath" : "ts/index", + "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..72162a85 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,3 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 学生 TODO 补充编号 ========== +ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentController new file mode 100644 index 00000000..3796982c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentController @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/student") +@Validated +public class InfraStudentController { + + @Resource + private InfraStudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:student:create')") + public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:student:update')") + public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + InfraStudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:student:query')") + public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:student:export')") + @OperateLog(type = EXPORT) + public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, + BeanUtils.toBean(list, InfraStudentRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentDO new file mode 100644 index 00000000..f4d757e8 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentDO @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + + */ +@TableName("infra_student") +@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraStudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 简介 + */ + private String description; + /** + * 出生日期 + */ + private LocalDateTime birthday; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 是否有效 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean enabled; + /** + * 头像 + */ + private String avatar; + /** + * 附件 + */ + private String video; + /** + * 备注 + */ + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentMapper new file mode 100644 index 00000000..e97fac22 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentMapper @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 学生 Mapper + * + + */ +@Mapper +public interface InfraStudentMapper extends BaseMapperX { + + default PageResult selectPage(InfraStudentPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) + .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) + .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) + .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) + .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(InfraStudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentPageReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentPageReqVO new file mode 100644 index 00000000..41a37301 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentPageReqVO @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +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 InfraStudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋头") + private String name; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", example = "1") + private Integer sex; + + @Schema(description = "是否有效", example = "true") + private Boolean enabled; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentRespVO new file mode 100644 index 00000000..c41a5501 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentRespVO @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraStudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @ExcelProperty("简介") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @ExcelProperty(value = "是否有效", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @ExcelProperty("附件") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @ExcelProperty("备注") + private String memo; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentSaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentSaveReqVO new file mode 100644 index 00000000..43e7f147 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentSaveReqVO @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class InfraStudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "是否有效不能为空") + private Boolean enabled; + + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") + @NotEmpty(message = "头像不能为空") + private String avatar; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") + @NotEmpty(message = "附件不能为空") + private String video; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") + @NotEmpty(message = "备注不能为空") + private String memo; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentService new file mode 100644 index 00000000..12ccffe9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentService @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + * @author 姚君 + */ +public interface InfraStudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + InfraStudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImpl new file mode 100644 index 00000000..384a5df7 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImpl @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + + */ +@Service +@Validated +public class InfraStudentServiceImpl implements InfraStudentService { + + @Resource + private InfraStudentMapper studentMapper; + + @Override + public Long createStudent(InfraStudentSaveReqVO createReqVO) { + // 插入 + InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); + studentMapper.insert(student); + // 返回 + return student.getId(); + } + + @Override + public void updateStudent(InfraStudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); + studentMapper.updateById(updateObj); + } + + @Override + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public InfraStudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImplTest new file mode 100644 index 00000000..61964ea9 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/java/InfraStudentServiceImplTest @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraStudentServiceImpl} 的单元测试类 + * + + */ +@Import(InfraStudentServiceImpl.class) +public class InfraStudentServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraStudentServiceImpl studentService; + + @Resource + private InfraStudentMapper studentMapper; + + @Test + public void testCreateStudent_success() { + // 准备参数 + InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); + + // 调用 + Long studentId = studentService.createStudent(createReqVO); + // 断言 + assertNotNull(studentId); + // 校验记录的属性是否正确 + InfraStudentDO student = studentMapper.selectById(studentId); + assertPojoEquals(createReqVO, student, "id"); + } + + @Test + public void testUpdateStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { + o.setId(dbStudent.getId()); // 设置更新的 ID + }); + + // 调用 + studentService.updateStudent(updateReqVO); + // 校验是否更新正确 + InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, student); + } + + @Test + public void testUpdateStudent_notExists() { + // 准备参数 + InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); + } + + @Test + public void testDeleteStudent_success() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); + studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStudent.getId(); + + // 调用 + studentService.deleteStudent(id); + // 校验数据不存在了 + assertNull(studentMapper.selectById(id)); + } + + @Test + public void testDeleteStudent_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStudentPage() { + // mock 数据 + InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 + o.setName(null); + o.setBirthday(null); + o.setSex(null); + o.setEnabled(null); + o.setCreateTime(null); + }); + studentMapper.insert(dbStudent); + // 测试 name 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); + // 测试 birthday 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); + // 测试 sex 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); + // 测试 enabled 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); + // 测试 createTime 不匹配 + studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); + // 准备参数 + InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); + reqVO.setName(null); + reqVO.setBirthday(null); + reqVO.setSex(null); + reqVO.setEnabled(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = studentService.getStudentPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStudent, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/h2 new file mode 100644 index 00000000..6c1875f6 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/h2 @@ -0,0 +1,17 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_student" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" varchar NOT NULL, + "birthday" varchar NOT NULL, + "sex" int NOT NULL, + "enabled" bit NOT NULL, + "avatar" varchar NOT NULL, + "video" varchar NOT NULL, + "memo" varchar NOT NULL, + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("id") +) COMMENT '学生表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/sql new file mode 100644 index 00000000..4551d0de --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '学生管理', '', 2, 0, 888, + 'student', '', 'infra/demo/index', 0, 'InfraStudent' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生查询', 'infra:student:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生创建', 'infra:student:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生更新', 'infra:student:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生删除', 'infra:student:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '学生导出', 'infra:student:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/ts/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/ts/index new file mode 100644 index 00000000..1ac86e52 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/ts/index @@ -0,0 +1,43 @@ +import request from '@/config/axios' + +export interface StudentVO { + id: number + name: string + description: string + birthday: Date + sex: number + enabled: boolean + avatar: string + video: string + memo: string +} + +// 查询学生分页 +export const getStudentPage = async (params) => { + return await request.get({ url: `/infra/student/page`, params }) +} + +// 查询学生详情 +export const getStudent = async (id: number) => { + return await request.get({ url: `/infra/student/get?id=` + id }) +} + +// 新增学生 +export const createStudent = async (data: StudentVO) => { + return await request.post({ url: `/infra/student/create`, data }) +} + +// 修改学生 +export const updateStudent = async (data: StudentVO) => { + return await request.put({ url: `/infra/student/update`, data }) +} + +// 删除学生 +export const deleteStudent = async (id: number) => { + return await request.delete({ url: `/infra/student/delete?id=` + id }) +} + +// 导出学生 Excel +export const exportStudent = async (params) => { + return await request.download({ url: `/infra/student/export-excel`, params }) +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/StudentForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/StudentForm new file mode 100644 index 00000000..2e3fc038 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/StudentForm @@ -0,0 +1,152 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/index new file mode 100644 index 00000000..4a65d8c3 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/vue/index @@ -0,0 +1,252 @@ + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/xml/InfraStudentMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/xml/InfraStudentMapper new file mode 100644 index 00000000..155aa5c2 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_one/xml/InfraStudentMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/assert.json b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/assert.json new file mode 100644 index 00000000..357df008 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/assert.json @@ -0,0 +1,49 @@ +[ { + "contentPath" : "java/InfraCategoryListReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryListReqVO.java" +}, { + "contentPath" : "java/InfraCategoryRespVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryRespVO.java" +}, { + "contentPath" : "java/InfraCategorySaveReqVO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategorySaveReqVO.java" +}, { + "contentPath" : "java/InfraCategoryController", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraCategoryController.java" +}, { + "contentPath" : "java/InfraCategoryDO", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraCategoryDO.java" +}, { + "contentPath" : "java/InfraCategoryMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraCategoryMapper.java" +}, { + "contentPath" : "xml/InfraCategoryMapper", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraCategoryMapper.xml" +}, { + "contentPath" : "java/InfraCategoryServiceImpl", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImpl.java" +}, { + "contentPath" : "java/InfraCategoryService", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryService.java" +}, { + "contentPath" : "java/InfraCategoryServiceImplTest", + "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImplTest.java" +}, { + "contentPath" : "java/ErrorCodeConstants_手动操作", + "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" +}, { + "contentPath" : "sql/sql", + "filePath" : "sql/sql.sql" +}, { + "contentPath" : "sql/h2", + "filePath" : "sql/h2.sql" +}, { + "contentPath" : "vue/index", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" +}, { + "contentPath" : "vue/CategoryForm", + "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/CategoryForm.vue" +}, { + "contentPath" : "ts/index", + "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" +} ] \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/ErrorCodeConstants_手动操作 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/ErrorCodeConstants_手动操作 new file mode 100644 index 00000000..a8626bdd --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/ErrorCodeConstants_手动操作 @@ -0,0 +1,8 @@ +// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! +// ========== 分类 TODO 补充编号 ========== +ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(TODO 补充编号, "分类不存在"); +ErrorCode CATEGORY_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子分类,无法删除"); +ErrorCode CATEGORY_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级分类不存在"); +ErrorCode CATEGORY_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父分类"); +ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该名字的分类"); +ErrorCode CATEGORY_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子InfraCategory为父InfraCategory"); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryController b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryController new file mode 100644 index 00000000..a7b2f816 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryController @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.module.infra.service.demo.InfraCategoryService; + +@Tag(name = "管理后台 - 分类") +@RestController +@RequestMapping("/infra/category") +@Validated +public class InfraCategoryController { + + @Resource + private InfraCategoryService categoryService; + + @PostMapping("/create") + @Operation(summary = "创建分类") + @PreAuthorize("@ss.hasPermission('infra:category:create')") + public CommonResult createCategory(@Valid @RequestBody InfraCategorySaveReqVO createReqVO) { + return success(categoryService.createCategory(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分类") + @PreAuthorize("@ss.hasPermission('infra:category:update')") + public CommonResult updateCategory(@Valid @RequestBody InfraCategorySaveReqVO updateReqVO) { + categoryService.updateCategory(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分类") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:category:delete')") + public CommonResult deleteCategory(@RequestParam("id") Long id) { + categoryService.deleteCategory(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分类") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:category:query')") + public CommonResult getCategory(@RequestParam("id") Long id) { + InfraCategoryDO category = categoryService.getCategory(id); + return success(BeanUtils.toBean(category, InfraCategoryRespVO.class)); + } + + @GetMapping("/list") + @Operation(summary = "获得分类列表") + @PreAuthorize("@ss.hasPermission('infra:category:query')") + public CommonResult> getCategoryList(@Valid InfraCategoryListReqVO listReqVO) { + List list = categoryService.getCategoryList(listReqVO); + return success(BeanUtils.toBean(list, InfraCategoryRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分类 Excel") + @PreAuthorize("@ss.hasPermission('infra:category:export')") + @OperateLog(type = EXPORT) + public void exportCategoryExcel(@Valid InfraCategoryListReqVO listReqVO, + HttpServletResponse response) throws IOException { + List list = categoryService.getCategoryList(listReqVO); + // 导出 Excel + ExcelUtils.write(response, "分类.xls", "数据", InfraCategoryRespVO.class, + BeanUtils.toBean(list, InfraCategoryRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryDO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryDO new file mode 100644 index 00000000..da457e96 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryDO @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; + +import lombok.*; +import java.util.*; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分类 DO + * + + */ +@TableName("infra_category") +@KeySequence("infra_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfraCategoryDO extends BaseDO { + + public static final Long PARENT_ID_ROOT = 0L; + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 父编号 + */ + private Long parentId; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryListReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryListReqVO new file mode 100644 index 00000000..e5c6f181 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryListReqVO @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +@Schema(description = "管理后台 - 分类列表 Request VO") +@Data +public class InfraCategoryListReqVO { + + @Schema(description = "名字", example = "芋头") + private String name; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryMapper new file mode 100644 index 00000000..07c05eab --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryMapper @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; + +/** + * 分类 Mapper + * + + */ +@Mapper +public interface InfraCategoryMapper extends BaseMapperX { + + default List selectList(InfraCategoryListReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(InfraCategoryDO::getName, reqVO.getName()) + .orderByDesc(InfraCategoryDO::getId)); + } + + default InfraCategoryDO selectByParentIdAndName(Long parentId, String name) { + return selectOne(InfraCategoryDO::getParentId, parentId, InfraCategoryDO::getName, name); + } + + default Long selectCountByParentId(Long parentId) { + return selectCount(InfraCategoryDO::getParentId, parentId); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryRespVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryRespVO new file mode 100644 index 00000000..6325d866 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryRespVO @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 分类 Response VO") +@Data +@ExcelIgnoreUnannotated +public class InfraCategoryRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @ExcelProperty("名字") + private String name; + + @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") + @ExcelProperty("父编号") + private Long parentId; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategorySaveReqVO b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategorySaveReqVO new file mode 100644 index 00000000..3c03b977 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategorySaveReqVO @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; + +@Schema(description = "管理后台 - 分类新增/修改 Request VO") +@Data +public class InfraCategorySaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") + @NotNull(message = "父编号不能为空") + private Long parentId; + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryService b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryService new file mode 100644 index 00000000..f508ef33 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryService @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 分类 Service 接口 + * + * @author 姚君 + */ +public interface InfraCategoryService { + + /** + * 创建分类 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCategory(@Valid InfraCategorySaveReqVO createReqVO); + + /** + * 更新分类 + * + * @param updateReqVO 更新信息 + */ + void updateCategory(@Valid InfraCategorySaveReqVO updateReqVO); + + /** + * 删除分类 + * + * @param id 编号 + */ + void deleteCategory(Long id); + + /** + * 获得分类 + * + * @param id 编号 + * @return 分类 + */ + InfraCategoryDO getCategory(Long id); + + /** + * 获得分类列表 + * + * @param listReqVO 查询条件 + * @return 分类列表 + */ + List getCategoryList(InfraCategoryListReqVO listReqVO); + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImpl b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImpl new file mode 100644 index 00000000..2d594477 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImpl @@ -0,0 +1,136 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 分类 Service 实现类 + * + + */ +@Service +@Validated +public class InfraCategoryServiceImpl implements InfraCategoryService { + + @Resource + private InfraCategoryMapper categoryMapper; + + @Override + public Long createCategory(InfraCategorySaveReqVO createReqVO) { + // 校验父编号的有效性 + validateParentCategory(null, createReqVO.getParentId()); + // 校验名字的唯一性 + validateCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); + + // 插入 + InfraCategoryDO category = BeanUtils.toBean(createReqVO, InfraCategoryDO.class); + categoryMapper.insert(category); + // 返回 + return category.getId(); + } + + @Override + public void updateCategory(InfraCategorySaveReqVO updateReqVO) { + // 校验存在 + validateCategoryExists(updateReqVO.getId()); + // 校验父编号的有效性 + validateParentCategory(updateReqVO.getId(), updateReqVO.getParentId()); + // 校验名字的唯一性 + validateCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); + + // 更新 + InfraCategoryDO updateObj = BeanUtils.toBean(updateReqVO, InfraCategoryDO.class); + categoryMapper.updateById(updateObj); + } + + @Override + public void deleteCategory(Long id) { + // 校验存在 + validateCategoryExists(id); + // 校验是否有子分类 + if (categoryMapper.selectCountByParentId(id) > 0) { + throw exception(CATEGORY_EXITS_CHILDREN); + } + // 删除 + categoryMapper.deleteById(id); + } + + private void validateCategoryExists(Long id) { + if (categoryMapper.selectById(id) == null) { + throw exception(CATEGORY_NOT_EXISTS); + } + } + + private void validateParentCategory(Long id, Long parentId) { + if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { + return; + } + // 1. 不能设置自己为父分类 + if (Objects.equals(id, parentId)) { + throw exception(CATEGORY_PARENT_ERROR); + } + // 2. 父分类不存在 + CategoryDO parentCategory = categoryMapper.selectById(parentId); + if (parentCategory == null) { + throw exception(CATEGORY_PARENT_NOT_EXITS); + } + // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 + if (id == null) { // id 为空,说明新增,不需要考虑环路 + return; + } + for (int i = 0; i < Short.MAX_VALUE; i++) { + // 3.1 校验环路 + parentId = parentCategory.getParentId(); + if (Objects.equals(id, parentId)) { + throw exception(CATEGORY_PARENT_IS_CHILD); + } + // 3.2 继续递归下一级父分类 + if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { + break; + } + parentCategory = categoryMapper.selectById(parentId); + if (parentCategory == null) { + break; + } + } + } + + private void validateCategoryNameUnique(Long id, Long parentId, String name) { + CategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); + if (category == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的分类 + if (id == null) { + throw exception(CATEGORY_NAME_DUPLICATE); + } + if (!Objects.equals(category.getId(), id)) { + throw exception(CATEGORY_NAME_DUPLICATE); + } + } + + @Override + public InfraCategoryDO getCategory(Long id) { + return categoryMapper.selectById(id); + } + + @Override + public List getCategoryList(InfraCategoryListReqVO listReqVO) { + return categoryMapper.selectList(listReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImplTest b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImplTest new file mode 100644 index 00000000..3e4d0eb1 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/java/InfraCategoryServiceImplTest @@ -0,0 +1,129 @@ +package cn.iocoder.yudao.module.infra.service.demo; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link InfraCategoryServiceImpl} 的单元测试类 + * + + */ +@Import(InfraCategoryServiceImpl.class) +public class InfraCategoryServiceImplTest extends BaseDbUnitTest { + + @Resource + private InfraCategoryServiceImpl categoryService; + + @Resource + private InfraCategoryMapper categoryMapper; + + @Test + public void testCreateCategory_success() { + // 准备参数 + InfraCategorySaveReqVO createReqVO = randomPojo(InfraCategorySaveReqVO.class).setId(null); + + // 调用 + Long categoryId = categoryService.createCategory(createReqVO); + // 断言 + assertNotNull(categoryId); + // 校验记录的属性是否正确 + InfraCategoryDO category = categoryMapper.selectById(categoryId); + assertPojoEquals(createReqVO, category, "id"); + } + + @Test + public void testUpdateCategory_success() { + // mock 数据 + InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); + categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 + // 准备参数 + InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class, o -> { + o.setId(dbCategory.getId()); // 设置更新的 ID + }); + + // 调用 + categoryService.updateCategory(updateReqVO); + // 校验是否更新正确 + InfraCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, category); + } + + @Test + public void testUpdateCategory_notExists() { + // 准备参数 + InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); + } + + @Test + public void testDeleteCategory_success() { + // mock 数据 + InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); + categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbCategory.getId(); + + // 调用 + categoryService.deleteCategory(id); + // 校验数据不存在了 + assertNull(categoryMapper.selectById(id)); + } + + @Test + public void testDeleteCategory_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetCategoryList() { + // mock 数据 + InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class, o -> { // 等会查询到 + o.setName(null); + }); + categoryMapper.insert(dbCategory); + // 测试 name 不匹配 + categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); + // 准备参数 + InfraCategoryListReqVO reqVO = new InfraCategoryListReqVO(); + reqVO.setName(null); + + // 调用 + List list = categoryService.getCategoryList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbCategory, list.get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/h2 b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/h2 new file mode 100644 index 00000000..4141766c --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/h2 @@ -0,0 +1,10 @@ +-- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 +CREATE TABLE IF NOT EXISTS "infra_category" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "description" bigint NOT NULL, + PRIMARY KEY ("id") +) COMMENT '分类表'; + +-- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "infra_category"; \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/sql new file mode 100644 index 00000000..01bf9905 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/sql/sql @@ -0,0 +1,55 @@ +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '分类管理', '', 2, 0, 888, + 'category', '', 'infra/demo/index', 0, 'InfraCategory' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类查询', 'infra:category:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类创建', 'infra:category:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类更新', 'infra:category:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类删除', 'infra:category:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '分类导出', 'infra:category:export', 3, 5, @parentId, + '', '', '', 0 +); \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/ts/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/ts/index new file mode 100644 index 00000000..5f81a63d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/ts/index @@ -0,0 +1,37 @@ +import request from '@/config/axios' + +export interface CategoryVO { + id: number + name: string + parentId: number +} + +// 查询分类列表 +export const getCategoryList = async (params) => { + return await request.get({ url: `/infra/category/list`, params }) +} + +// 查询分类详情 +export const getCategory = async (id: number) => { + return await request.get({ url: `/infra/category/get?id=` + id }) +} + +// 新增分类 +export const createCategory = async (data: CategoryVO) => { + return await request.post({ url: `/infra/category/create`, data }) +} + +// 修改分类 +export const updateCategory = async (data: CategoryVO) => { + return await request.put({ url: `/infra/category/update`, data }) +} + +// 删除分类 +export const deleteCategory = async (id: number) => { + return await request.delete({ url: `/infra/category/delete?id=` + id }) +} + +// 导出分类 Excel +export const exportCategory = async (params) => { + return await request.download({ url: `/infra/category/export-excel`, params }) +} \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/CategoryForm b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/CategoryForm new file mode 100644 index 00000000..90143c8d --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/CategoryForm @@ -0,0 +1,114 @@ + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/index b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/index new file mode 100644 index 00000000..6db6b152 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/vue/index @@ -0,0 +1,185 @@ + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/xml/InfraCategoryMapper b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/xml/InfraCategoryMapper new file mode 100644 index 00000000..025ac850 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/codegen/vue3_tree/xml/InfraCategoryMapper @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/logback.xml b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/logback.xml new file mode 100644 index 00000000..daf756bf --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/logback.xml @@ -0,0 +1,4 @@ + + + + diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/clean.sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/clean.sql new file mode 100644 index 00000000..a3e0fd02 --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/clean.sql @@ -0,0 +1,12 @@ +DELETE FROM "infra_config"; +DELETE FROM "infra_file_config"; +DELETE FROM "infra_file"; +DELETE FROM "infra_job"; +DELETE FROM "infra_job_log"; +DELETE FROM "infra_api_access_log"; +DELETE FROM "infra_api_error_log"; +DELETE FROM "infra_file_config"; +DELETE FROM "infra_test_demo"; +DELETE FROM "infra_data_source_config"; +DELETE FROM "infra_codegen_table"; +DELETE FROM "infra_codegen_column"; diff --git a/yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/create_tables.sql b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/create_tables.sql new file mode 100644 index 00000000..a5f896ce --- /dev/null +++ b/yudao-module-wms/yudao-module-wms-biz/src/test/resources/sql/create_tables.sql @@ -0,0 +1,228 @@ + +CREATE TABLE IF NOT EXISTS "infra_config" ( + "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号', + "category" varchar(50) NOT NULL, + "type" tinyint NOT NULL, + "name" varchar(100) NOT NULL DEFAULT '' COMMENT '名字', + "config_key" varchar(100) NOT NULL DEFAULT '', + "value" varchar(500) NOT NULL DEFAULT '', + "visible" bit NOT NULL, + "remark" varchar(500) DEFAULT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '参数配置表'; + +CREATE TABLE IF NOT EXISTS "infra_file_config" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar(63) NOT NULL, + "storage" tinyint NOT NULL, + "remark" varchar(255), + "master" bit(1) NOT NULL, + "config" varchar(4096) NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '文件配置表'; + +CREATE TABLE IF NOT EXISTS "infra_file" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "config_id" bigint NOT NULL, + "name" varchar(256), + "path" varchar(512), + "url" varchar(1024), + "type" varchar(63) DEFAULT NULL, + "size" bigint NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint not null default '0', + PRIMARY KEY ("id") +) COMMENT '文件表'; + +CREATE TABLE IF NOT EXISTS "infra_job" ( + "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '任务编号', + "name" varchar(32) NOT NULL COMMENT '任务名称', + "status" tinyint(4) NOT NULL COMMENT '任务状态', + "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', + "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', + "cron_expression" varchar(32) NOT NULL COMMENT 'CRON 表达式', + "retry_count" int(11) NOT NULL DEFAULT '0' COMMENT '重试次数', + "retry_interval" int(11) NOT NULL DEFAULT '0' COMMENT '重试间隔', + "monitor_timeout" int(11) NOT NULL DEFAULT '0' COMMENT '监控超时时间', + "creator" varchar(64) DEFAULT '' COMMENT '创建者', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + "updater" varchar(64) DEFAULT '' COMMENT '更新者', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + "deleted" bit NOT NULL DEFAULT FALSE COMMENT '是否删除', + PRIMARY KEY ("id") +) COMMENT='定时任务表'; + +CREATE TABLE IF NOT EXISTS "infra_job_log" ( + "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '日志编号', + "job_id" bigint(20) NOT NULL COMMENT '任务编号', + "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', + "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', + "execute_index" tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几次执行', + "begin_time" datetime NOT NULL COMMENT '开始执行时间', + "end_time" datetime DEFAULT NULL COMMENT '结束执行时间', + "duration" int(11) DEFAULT NULL COMMENT '执行时长', + "status" tinyint(4) NOT NULL COMMENT '任务状态', + "result" varchar(4000) DEFAULT '' COMMENT '结果数据', + "creator" varchar(64) DEFAULT '' COMMENT '创建者', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + "updater" varchar(64) DEFAULT '' COMMENT '更新者', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + "deleted" bit(1) NOT NULL DEFAULT FALSE COMMENT '是否删除', + PRIMARY KEY ("id") +)COMMENT='定时任务日志表'; + +CREATE TABLE IF NOT EXISTS "infra_api_access_log" ( + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, + "trace_id" varchar(64) not null default '', + "user_id" bigint not null default '0', + "user_type" tinyint not null default '0', + "application_name" varchar(50) not null, + "request_method" varchar(16) not null default '', + "request_url" varchar(255) not null default '', + "request_params" varchar(8000) not null default '', + "user_ip" varchar(50) not null, + "user_agent" varchar(512) not null, + "begin_time" timestamp not null, + "end_time" timestamp not null, + "duration" integer not null, + "result_code" integer not null default '0', + "result_msg" varchar(512) default '', + "creator" varchar(64) default '', + "create_time" timestamp not null default current_timestamp, + "updater" varchar(64) default '', + "update_time" timestamp not null default current_timestamp, + "deleted" bit not null default false, + "tenant_id" bigint not null default '0', + primary key ("id") + ) COMMENT 'API 访问日志表'; + +CREATE TABLE IF NOT EXISTS "infra_api_error_log" ( + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, + "trace_id" varchar(64) not null, + "user_id" bigint not null default '0', + "user_type" tinyint not null default '0', + "application_name" varchar(50) not null, + "request_method" varchar(16) not null, + "request_url" varchar(255) not null, + "request_params" varchar(8000) not null, + "user_ip" varchar(50) not null, + "user_agent" varchar(512) not null, + "exception_time" timestamp not null, + "exception_name" varchar(128) not null default '', + "exception_message" clob not null, + "exception_root_cause_message" clob not null, + "exception_stack_trace" clob not null, + "exception_class_name" varchar(512) not null, + "exception_file_name" varchar(512) not null, + "exception_method_name" varchar(512) not null, + "exception_line_number" integer not null, + "process_status" tinyint not null, + "process_time" timestamp default null, + "process_user_id" bigint default '0', + "creator" varchar(64) default '', + "create_time" timestamp not null default current_timestamp, + "updater" varchar(64) default '', + "update_time" timestamp not null default current_timestamp, + "deleted" bit not null default false, + "tenant_id" bigint not null default '0', + primary key ("id") +) COMMENT '系统异常日志'; + +CREATE TABLE IF NOT EXISTS "infra_test_demo" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar(100) NOT NULL, + "status" tinyint NOT NULL, + "type" tinyint NOT NULL, + "category" tinyint NOT NULL, + "remark" varchar(500), + "creator" varchar(64) DEFAULT '''', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '''', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '字典类型表'; + +CREATE TABLE IF NOT EXISTS "infra_data_source_config" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar(100) NOT NULL, + "url" varchar(1024) NOT NULL, + "username" varchar(255) NOT NULL, + "password" varchar(255) NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '数据源配置表'; + +CREATE TABLE IF NOT EXISTS "infra_codegen_table" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "data_source_config_id" bigint not null, + "scene" tinyint not null DEFAULT 1, + "table_name" varchar(200) NOT NULL, + "table_comment" varchar(500) NOT NULL, + "remark" varchar(500) NOT NULL, + "module_name" varchar(30) NOT NULL, + "business_name" varchar(30) NOT NULL, + "class_name" varchar(100) NOT NULL, + "class_comment" varchar(50) NOT NULL, + "author" varchar(50) NOT NULL, + "template_type" tinyint not null DEFAULT 1, + "front_type" tinyint not null, + "parent_menu_id" bigint not null, + "master_table_id" bigint not null, + "sub_join_column_id" bigint not null, + "sub_join_many" bit not null, + "tree_parent_column_id" bigint not null, + "tree_name_column_id" bigint not null, + "creator" varchar(64) DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '代码生成表定义表'; + +CREATE TABLE IF NOT EXISTS "infra_codegen_column" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "table_id" bigint not null, + "column_name" varchar(200) NOT NULL, + "data_type" varchar(100) NOT NULL, + "column_comment" varchar(500) NOT NULL, + "nullable" tinyint not null, + "primary_key" tinyint not null, + "auto_increment" varchar(5) not null, + "ordinal_position" int not null, + "java_type" varchar(32) NOT NULL, + "java_field" varchar(64) NOT NULL, + "dict_type" varchar(200) NOT NULL, + "example" varchar(64) NOT NULL, + "create_operation" bit not null, + "update_operation" bit not null, + "list_operation" bit not null, + "list_operation_condition" varchar(32) not null, + "list_operation_result" bit not null, + "html_type" varchar(32) NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '代码生成表字段定义表'; \ No newline at end of file