From 4a231ca8d921fd539c0c66b04270eeb08a9edc2f Mon Sep 17 00:00:00 2001 From: jameszow Date: Sun, 8 Oct 2023 20:12:59 +0800 Subject: [PATCH 1/9] Remove java product unit api --- .../api/product/ProductUnitController.java | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 api/src/main/java/com/wansensoft/api/product/ProductUnitController.java diff --git a/api/src/main/java/com/wansensoft/api/product/ProductUnitController.java b/api/src/main/java/com/wansensoft/api/product/ProductUnitController.java deleted file mode 100644 index a7cc10005..000000000 --- a/api/src/main/java/com/wansensoft/api/product/ProductUnitController.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://opensource.wansenai.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.wansensoft.api.product; - -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; - -/** - *

- * 多单位表 前端控制器 - *

- * - * @author James Zow - * @since 2023-09-05 - */ -@RestController -@RequestMapping("/product-unit") -public class ProductUnitController { - -} From 59aacd593665fa0e096846baeecedaf7c0e7ce25 Mon Sep 17 00:00:00 2001 From: jameszow Date: Sun, 8 Oct 2023 20:13:42 +0800 Subject: [PATCH 2/9] Add License to the file header --- .../api/product/ProductAttributeController.kt | 12 ++++++++++++ .../api/product/ProductCategoryController.kt | 12 ++++++++++++ .../src/main/java/com/wansensoft/bo/SmsInfoBO.java | 14 ++++++++++++-- .../dto/department/AddOrUpdateDeptDTO.kt | 12 ++++++++++++ .../com/wansensoft/dto/department/DeptListDTO.java | 12 ++++++++++++ .../dto/product/AddOrUpdateProductAttributeDTO.kt | 12 ++++++++++++ .../dto/product/AddOrUpdateProductCategoryDTO.kt | 12 ++++++++++++ .../dto/product/ProductAttributeQueryDTO.kt | 12 ++++++++++++ .../com/wansensoft/dto/role/AddOrUpdateRoleDTO.kt | 12 ++++++++++++ .../java/com/wansensoft/dto/role/RoleListDTO.java | 12 ++++++++++++ .../com/wansensoft/dto/role/RolePermissionDTO.kt | 12 ++++++++++++ .../wansensoft/dto/user/AddOrUpdateUserDTO.java | 12 ++++++++++++ .../com/wansensoft/dto/user/MobileLoginDTO.java | 12 ++++++++++++ .../java/com/wansensoft/dto/user/UserListDTO.java | 12 ++++++++++++ .../wansensoft/entities/product/ProductUnit.java | 8 ++++---- .../wansensoft/vo/product/ProductAttributeVO.kt | 12 ++++++++++++ 16 files changed, 184 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/com/wansensoft/api/product/ProductAttributeController.kt b/api/src/main/java/com/wansensoft/api/product/ProductAttributeController.kt index f5f86cc3b..c0c003fd3 100644 --- a/api/src/main/java/com/wansensoft/api/product/ProductAttributeController.kt +++ b/api/src/main/java/com/wansensoft/api/product/ProductAttributeController.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.api.product import com.baomidou.mybatisplus.extension.plugins.pagination.Page diff --git a/api/src/main/java/com/wansensoft/api/product/ProductCategoryController.kt b/api/src/main/java/com/wansensoft/api/product/ProductCategoryController.kt index f0cb92025..44cdf9033 100644 --- a/api/src/main/java/com/wansensoft/api/product/ProductCategoryController.kt +++ b/api/src/main/java/com/wansensoft/api/product/ProductCategoryController.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.api.product import com.wansensoft.dto.product.AddOrUpdateProductCategoryDTO diff --git a/domain/src/main/java/com/wansensoft/bo/SmsInfoBO.java b/domain/src/main/java/com/wansensoft/bo/SmsInfoBO.java index 85ed25996..a566a41d2 100644 --- a/domain/src/main/java/com/wansensoft/bo/SmsInfoBO.java +++ b/domain/src/main/java/com/wansensoft/bo/SmsInfoBO.java @@ -1,9 +1,19 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.bo; -import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; @Data @Builder diff --git a/domain/src/main/java/com/wansensoft/dto/department/AddOrUpdateDeptDTO.kt b/domain/src/main/java/com/wansensoft/dto/department/AddOrUpdateDeptDTO.kt index cb2098370..2873d46c6 100644 --- a/domain/src/main/java/com/wansensoft/dto/department/AddOrUpdateDeptDTO.kt +++ b/domain/src/main/java/com/wansensoft/dto/department/AddOrUpdateDeptDTO.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.department import lombok.Data diff --git a/domain/src/main/java/com/wansensoft/dto/department/DeptListDTO.java b/domain/src/main/java/com/wansensoft/dto/department/DeptListDTO.java index 36c307af1..067d36055 100644 --- a/domain/src/main/java/com/wansensoft/dto/department/DeptListDTO.java +++ b/domain/src/main/java/com/wansensoft/dto/department/DeptListDTO.java @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.department; import com.wansensoft.dto.PageSizeDTO; diff --git a/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductAttributeDTO.kt b/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductAttributeDTO.kt index 39d006c6c..9f0d6f1ff 100644 --- a/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductAttributeDTO.kt +++ b/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductAttributeDTO.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.product import lombok.Data diff --git a/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductCategoryDTO.kt b/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductCategoryDTO.kt index 1e92743df..6bfee1324 100644 --- a/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductCategoryDTO.kt +++ b/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductCategoryDTO.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.product import lombok.Data diff --git a/domain/src/main/java/com/wansensoft/dto/product/ProductAttributeQueryDTO.kt b/domain/src/main/java/com/wansensoft/dto/product/ProductAttributeQueryDTO.kt index 98312a573..abc1972aa 100644 --- a/domain/src/main/java/com/wansensoft/dto/product/ProductAttributeQueryDTO.kt +++ b/domain/src/main/java/com/wansensoft/dto/product/ProductAttributeQueryDTO.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.product import com.wansensoft.dto.PageSizeDTO diff --git a/domain/src/main/java/com/wansensoft/dto/role/AddOrUpdateRoleDTO.kt b/domain/src/main/java/com/wansensoft/dto/role/AddOrUpdateRoleDTO.kt index 9c7182c8b..dd30e2c0f 100644 --- a/domain/src/main/java/com/wansensoft/dto/role/AddOrUpdateRoleDTO.kt +++ b/domain/src/main/java/com/wansensoft/dto/role/AddOrUpdateRoleDTO.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.role import com.wansensoft.dto.PageSizeDTO diff --git a/domain/src/main/java/com/wansensoft/dto/role/RoleListDTO.java b/domain/src/main/java/com/wansensoft/dto/role/RoleListDTO.java index 624ed26f2..f3aa9227f 100644 --- a/domain/src/main/java/com/wansensoft/dto/role/RoleListDTO.java +++ b/domain/src/main/java/com/wansensoft/dto/role/RoleListDTO.java @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.role; import com.wansensoft.dto.PageSizeDTO; diff --git a/domain/src/main/java/com/wansensoft/dto/role/RolePermissionDTO.kt b/domain/src/main/java/com/wansensoft/dto/role/RolePermissionDTO.kt index f45eae9cc..ea9254cd0 100644 --- a/domain/src/main/java/com/wansensoft/dto/role/RolePermissionDTO.kt +++ b/domain/src/main/java/com/wansensoft/dto/role/RolePermissionDTO.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.role import lombok.Data diff --git a/domain/src/main/java/com/wansensoft/dto/user/AddOrUpdateUserDTO.java b/domain/src/main/java/com/wansensoft/dto/user/AddOrUpdateUserDTO.java index 88c71e1b7..45fe2e169 100644 --- a/domain/src/main/java/com/wansensoft/dto/user/AddOrUpdateUserDTO.java +++ b/domain/src/main/java/com/wansensoft/dto/user/AddOrUpdateUserDTO.java @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.user; import lombok.Data; diff --git a/domain/src/main/java/com/wansensoft/dto/user/MobileLoginDTO.java b/domain/src/main/java/com/wansensoft/dto/user/MobileLoginDTO.java index 8cb2e327b..40ba27171 100644 --- a/domain/src/main/java/com/wansensoft/dto/user/MobileLoginDTO.java +++ b/domain/src/main/java/com/wansensoft/dto/user/MobileLoginDTO.java @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.user; import lombok.Data; diff --git a/domain/src/main/java/com/wansensoft/dto/user/UserListDTO.java b/domain/src/main/java/com/wansensoft/dto/user/UserListDTO.java index 9f63f027d..9d076a364 100644 --- a/domain/src/main/java/com/wansensoft/dto/user/UserListDTO.java +++ b/domain/src/main/java/com/wansensoft/dto/user/UserListDTO.java @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.dto.user; import com.wansensoft.dto.PageSizeDTO; diff --git a/domain/src/main/java/com/wansensoft/entities/product/ProductUnit.java b/domain/src/main/java/com/wansensoft/entities/product/ProductUnit.java index 3a4966f61..a503572e9 100644 --- a/domain/src/main/java/com/wansensoft/entities/product/ProductUnit.java +++ b/domain/src/main/java/com/wansensoft/entities/product/ProductUnit.java @@ -47,9 +47,9 @@ public class ProductUnit implements Serializable { private Long tenantId; /** - * 名称,支持多单位 + * 计量单位,计算得出 */ - private String name; + private String computeUnit; /** * 基础单位 @@ -89,7 +89,7 @@ public class ProductUnit implements Serializable { /** * 启用 */ - private Boolean status; + private Integer status; /** * 创建时间 @@ -114,7 +114,7 @@ public class ProductUnit implements Serializable { /** * 删除标记,0未删除,1删除 */ - private Boolean deleteFlag; + private Integer deleteFlag; } diff --git a/domain/src/main/java/com/wansensoft/vo/product/ProductAttributeVO.kt b/domain/src/main/java/com/wansensoft/vo/product/ProductAttributeVO.kt index edb0ee2a9..bcec944a4 100644 --- a/domain/src/main/java/com/wansensoft/vo/product/ProductAttributeVO.kt +++ b/domain/src/main/java/com/wansensoft/vo/product/ProductAttributeVO.kt @@ -1,3 +1,15 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ package com.wansensoft.vo.product import com.fasterxml.jackson.annotation.JsonFormat From 5530d4150962adb63afb08b820e6c41cf6dbae9f Mon Sep 17 00:00:00 2001 From: jameszow Date: Sun, 8 Oct 2023 22:53:00 +0800 Subject: [PATCH 3/9] Delete ProductUnit Java code --- .../service/product/IProductUnitService.java | 25 ---------------- .../product/impl/ProductUnitServiceImpl.java | 29 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 service/src/main/java/com/wansensoft/service/product/IProductUnitService.java delete mode 100644 service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.java diff --git a/service/src/main/java/com/wansensoft/service/product/IProductUnitService.java b/service/src/main/java/com/wansensoft/service/product/IProductUnitService.java deleted file mode 100644 index ee929f535..000000000 --- a/service/src/main/java/com/wansensoft/service/product/IProductUnitService.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://opensource.wansenai.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.wansensoft.service.product; - -import com.wansensoft.entities.product.ProductUnit; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - *

- * 多单位表 服务类 - *

- */ -public interface IProductUnitService extends IService { - -} diff --git a/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.java b/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.java deleted file mode 100644 index 71fdf8804..000000000 --- a/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://opensource.wansenai.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.wansensoft.service.product.impl; - -import com.wansensoft.service.product.IProductUnitService; -import com.wansensoft.entities.product.ProductUnit; -import com.wansensoft.mappers.product.ProductUnitMapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 多单位表 服务实现类 - *

- */ -@Service -public class ProductUnitServiceImpl extends ServiceImpl implements IProductUnitService { - -} From 25ce512f78fe30ec4febc59c368171d1dde352e3 Mon Sep 17 00:00:00 2001 From: jameszow Date: Sun, 8 Oct 2023 22:53:17 +0800 Subject: [PATCH 4/9] Add Project Unit business code --- .../api/product/ProductUnitController.kt | 45 ++++++ .../dto/product/AddOrUpdateProductUnitDTO.kt | 36 +++++ .../dto/product/ProductUnitQueryDTO.kt | 22 +++ .../wansensoft/vo/product/ProductUnitVO.kt | 37 +++++ .../service/product/ProductUnitService.kt | 30 ++++ .../product/impl/ProductUnitServiceImpl.kt | 142 ++++++++++++++++++ 6 files changed, 312 insertions(+) create mode 100644 api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt create mode 100644 domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductUnitDTO.kt create mode 100644 domain/src/main/java/com/wansensoft/dto/product/ProductUnitQueryDTO.kt create mode 100644 domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt create mode 100644 service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt create mode 100644 service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt diff --git a/api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt b/api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt new file mode 100644 index 000000000..09ef745cd --- /dev/null +++ b/api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansensoft.api.product + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page +import com.wansensoft.dto.product.AddOrUpdateProductUnitDTO +import com.wansensoft.dto.product.ProductUnitQueryDTO +import com.wansensoft.service.product.ProductUnitService +import com.wansensoft.utils.response.Response +import com.wansensoft.vo.product.ProductUnitVO +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/product/unit") +class ProductUnitController(private val productUnitService: ProductUnitService) { + + @PostMapping("/list") + fun productUnitList(@RequestBody productUnitQuery: ProductUnitQueryDTO): Response> { + return productUnitService.productUnitList(productUnitQuery) + } + + @PostMapping("/addOrUpdate") + fun addOrUpdateProductUnit(@RequestBody productUnit: AddOrUpdateProductUnitDTO): Response { + return productUnitService.addOrUpdateProductUnit(productUnit) + } + + @DeleteMapping("/deleteBatch") + fun deleteProductUnit(@RequestBody ids: List): Response { + return productUnitService.deleteProductUnit(ids) + } +} \ No newline at end of file diff --git a/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductUnitDTO.kt b/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductUnitDTO.kt new file mode 100644 index 000000000..1a9df5b0f --- /dev/null +++ b/domain/src/main/java/com/wansensoft/dto/product/AddOrUpdateProductUnitDTO.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansensoft.dto.product + +import java.math.BigDecimal + +data class AddOrUpdateProductUnitDTO ( + + val id : Long? = null, + + var basicUnit: String? = null, + + var otherUnit: String? = null, + + var otherUnitTwo: String? = null, + + var otherUnitThree: String? = null, + + var ratio: BigDecimal? = null, + + var ratioTwo: BigDecimal? = null, + + var ratioThree: BigDecimal? = null, + + var status: Int? = null +) \ No newline at end of file diff --git a/domain/src/main/java/com/wansensoft/dto/product/ProductUnitQueryDTO.kt b/domain/src/main/java/com/wansensoft/dto/product/ProductUnitQueryDTO.kt new file mode 100644 index 000000000..6397353a6 --- /dev/null +++ b/domain/src/main/java/com/wansensoft/dto/product/ProductUnitQueryDTO.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansensoft.dto.product + +import com.wansensoft.dto.PageSizeDTO + +data class ProductUnitQueryDTO ( + + val page: PageSizeDTO? = null, + + val computeUnit: String? = null, +) \ No newline at end of file diff --git a/domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt b/domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt new file mode 100644 index 000000000..85d9267e5 --- /dev/null +++ b/domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansensoft.vo.product + +import com.fasterxml.jackson.annotation.JsonFormat +import java.time.LocalDateTime + +data class ProductUnitVO ( + + @JsonFormat(shape = JsonFormat.Shape.STRING) + var id : Long? = null, + + var computeUnit : String? = null, + + var basicUnit: String? = null, + + var otherUnit: String? = null, + + var otherUnitTwo: String? = null, + + var otherUnitThree: String? = null, + + var status: Int? = null, + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + var createTime: LocalDateTime? = null +) \ No newline at end of file diff --git a/service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt b/service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt new file mode 100644 index 000000000..b1881a040 --- /dev/null +++ b/service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansensoft.service.product + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page +import com.baomidou.mybatisplus.extension.service.IService +import com.wansensoft.dto.product.AddOrUpdateProductUnitDTO +import com.wansensoft.dto.product.ProductUnitQueryDTO +import com.wansensoft.entities.product.ProductUnit +import com.wansensoft.utils.response.Response +import com.wansensoft.vo.product.ProductUnitVO + +interface ProductUnitService: IService { + + fun productUnitList(productUnitQuery: ProductUnitQueryDTO?): Response> + + fun addOrUpdateProductUnit(productUnit: AddOrUpdateProductUnitDTO?): Response + + fun deleteProductUnit(ids: List?): Response +} \ No newline at end of file diff --git a/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt b/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt new file mode 100644 index 000000000..3e295462e --- /dev/null +++ b/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt @@ -0,0 +1,142 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansensoft.service.product.impl + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper +import com.baomidou.mybatisplus.extension.plugins.pagination.Page +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import com.wansensoft.dto.product.AddOrUpdateProductUnitDTO +import com.wansensoft.dto.product.ProductUnitQueryDTO +import com.wansensoft.entities.product.ProductUnit +import com.wansensoft.mappers.product.ProductUnitMapper +import com.wansensoft.service.product.ProductUnitService +import com.wansensoft.utils.SnowflakeIdUtil +import com.wansensoft.utils.constants.CommonConstants +import com.wansensoft.utils.enums.BaseCodeEnum +import com.wansensoft.utils.enums.ProdcutCodeEnum +import com.wansensoft.utils.response.Response +import com.wansensoft.vo.product.ProductUnitVO +import org.springframework.stereotype.Service + +@Service +open class ProductUnitServiceImpl( + private val productUnitMapper: ProductUnitMapper +) :ServiceImpl(), ProductUnitService { + + override fun productUnitList(productUnitQuery: ProductUnitQueryDTO?): Response> { + val page = productUnitQuery?.let { query -> + val pageSizeDTO = query.page + val page = pageSizeDTO?.page ?: 0L + val pageSize = pageSizeDTO?.pageSize ?: 10L + Page(page, pageSize) + } + val wrapper = LambdaQueryWrapper().apply { + productUnitQuery?.computeUnit?.let { like(ProductUnit::getComputeUnit, it) } + eq(ProductUnit::getDeleteFlag, CommonConstants.NOT_DELETED) + } + + val result = page?.run { + productUnitMapper.selectPage(this, wrapper) + val listVo = records.map { unit -> + ProductUnitVO( + id = unit.id, + computeUnit = unit.computeUnit, + basicUnit = unit.basicUnit, + otherUnit = unit.otherUnit, + otherUnitTwo = unit.otherUnitTwo, + otherUnitThree = unit.otherUnitThree, + status = unit.status, + createTime = unit.createTime, + ) + } + Page().apply { + records = listVo + total = this@run.total + pages = this@run.pages + size = this@run.size + } + } ?: Page() + + return Response.responseData(result) + } + + + override fun addOrUpdateProductUnit(productUnit: AddOrUpdateProductUnitDTO?): Response { + productUnit?.let { unit -> + val unitId = unit.id ?: SnowflakeIdUtil.nextId() + val unitWrapper = LambdaQueryWrapper().apply { + eq(ProductUnit::getComputeUnit, buildComputeUnit(unit)) + eq(ProductUnit::getDeleteFlag, CommonConstants.NOT_DELETED) + unit.id?.let { ne(ProductUnit::getId, it) } + } + val unitExists = productUnitMapper.exists(unitWrapper) + if (unitExists) { + return Response.responseMsg(ProdcutCodeEnum.PRODUCT_COMPUTE_UNIT_EXIST) + } + + val result = if (unit.id == null) { + save(buildProductUnit(unitId, unit)) + } else { + updateById(buildProductUnit(unitId, unit)) + } + + return if (result) { + if (unit.id == null) { + Response.responseMsg(ProdcutCodeEnum.PRODUCT_UNIT_ADD_SUCCESS) + } else { + Response.responseMsg(ProdcutCodeEnum.PRODUCT_UNIT_UPDATE_SUCCESS) + } + } else { + if (unit.id == null) { + Response.responseMsg(ProdcutCodeEnum.PRODUCT_UNIT_ADD_ERROR) + } else { + Response.responseMsg(ProdcutCodeEnum.PRODUCT_UNIT_UPDATE_ERROR) + } + } + } ?: return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL) + } + + private fun buildProductUnit(id: Long, unit: AddOrUpdateProductUnitDTO): ProductUnit { + return ProductUnit().apply { + this.id = id + computeUnit = buildComputeUnit(unit) + basicUnit = unit.basicUnit + otherUnit = unit.otherUnit + otherUnitTwo = unit.otherUnitTwo + otherUnitThree = unit.otherUnitThree + ratio = unit.ratio + ratioTwo = unit.ratioTwo + ratioThree = unit.ratioThree + status = unit.status + } + } + + private fun buildComputeUnit(productUnit: AddOrUpdateProductUnitDTO): String { + val computeUnit = StringBuilder() + computeUnit.append("${productUnit.basicUnit}/(${productUnit.otherUnit}=${productUnit.ratio})") + productUnit.otherUnitTwo?.let { computeUnit.append("/(${it}=${productUnit.ratioTwo})") } + productUnit.otherUnitThree?.let { computeUnit.append("/(${it}=${productUnit.ratioThree})") } + return computeUnit.toString() + } + + override fun deleteProductUnit(ids: List?): Response { + ids?.let { + val deleteResult = productUnitMapper.deleteBatchIds(ids) + if(deleteResult == 0) { + return Response.responseMsg(ProdcutCodeEnum.PRODUCT_UNIT_DELETE_ERROR) + } + return Response.responseMsg(ProdcutCodeEnum.PRODUCT_UNIT_DELETE_SUCCESS) + }?: return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL) + } + +} \ No newline at end of file From 11ae5784415738d827cd5644007e1b74c3e6530e Mon Sep 17 00:00:00 2001 From: jameszow Date: Sun, 8 Oct 2023 22:53:38 +0800 Subject: [PATCH 5/9] Delete redundant empty judgments --- .../impl/ProductAttributeServiceImpl.kt | 27 +++++++++---------- .../utils/enums/ProdcutCodeEnum.java | 17 +++++++++++- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/service/src/main/java/com/wansensoft/service/product/impl/ProductAttributeServiceImpl.kt b/service/src/main/java/com/wansensoft/service/product/impl/ProductAttributeServiceImpl.kt index fa5b9955f..7d743c0c6 100644 --- a/service/src/main/java/com/wansensoft/service/product/impl/ProductAttributeServiceImpl.kt +++ b/service/src/main/java/com/wansensoft/service/product/impl/ProductAttributeServiceImpl.kt @@ -21,6 +21,7 @@ import com.wansensoft.entities.product.ProductAttribute import com.wansensoft.mappers.product.ProductAttributeMapper import com.wansensoft.service.product.ProductAttributeService import com.wansensoft.service.user.ISysUserService +import com.wansensoft.utils.SnowflakeIdUtil import com.wansensoft.utils.constants.CommonConstants import com.wansensoft.utils.enums.BaseCodeEnum import com.wansensoft.utils.enums.ProdcutCodeEnum @@ -45,23 +46,18 @@ open class ProductAttributeServiceImpl( val result = page?.run { productAttributeMapper.selectPage(this, wrapper) - if (records.isNotEmpty()) { - val listVo = records.map { attribute -> - ProductAttributeVO().apply { - BeanUtils.copyProperties(attribute, this) - } - } - Page().apply { - records = listVo - total = this@run.total - pages = this@run.pages - size = this@run.size + val listVo = records.map { attribute -> + ProductAttributeVO().apply { + BeanUtils.copyProperties(attribute, this) } - - } else { - Page() } - }?: Page() + Page().apply { + records = listVo + total = this@run.total + pages = this@run.pages + size = this@run.size + } + } ?: Page() return Response.responseData(result) } @@ -79,6 +75,7 @@ open class ProductAttributeServiceImpl( if (count > 0) { return Response.responseMsg(ProdcutCodeEnum.PRODUCT_ATTRIBUTE_NAME_EXIST) } + attribute.id = SnowflakeIdUtil.nextId() attribute.createTime = LocalDateTime.now() attribute.createBy = userId val saveResult = saveAttribute(attribute) diff --git a/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java b/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java index 7b3768883..b3e91583f 100644 --- a/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java +++ b/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java @@ -30,7 +30,22 @@ public enum ProdcutCodeEnum { DELETE_PRODUCT_ATTRIBUTE_SUCCESS("P0005", "删除商品属性成功"), - DELETE_PRODUCT_ATTRIBUTE_ERROR("P0505", "删除商品属性失败"); + DELETE_PRODUCT_ATTRIBUTE_ERROR("P0505", "删除商品属性失败"), + + // Product Unit Code + PRODUCT_COMPUTE_UNIT_EXIST("P0507", "商品计量单位已存在"), + + PRODUCT_UNIT_ADD_SUCCESS("P0006", "添加商品单位成功"), + + PRODUCT_UNIT_ADD_ERROR("P0506", "添加商品单位失败"), + + PRODUCT_UNIT_UPDATE_SUCCESS("P0007", "修改商品单位成功"), + + PRODUCT_UNIT_UPDATE_ERROR("P0507", "修改商品单位失败"), + + PRODUCT_UNIT_DELETE_SUCCESS("P0008", "删除商品单位成功"), + + PRODUCT_UNIT_DELETE_ERROR("P0508", "删除商品单位失败"); private final String code; From 786ea49645cf459dd8976962792e49c8fb577a2f Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 9 Oct 2023 01:21:18 +0800 Subject: [PATCH 6/9] Add updateUnitStatus api --- .../api/product/ProductUnitController.kt | 14 ++-- .../service/product/ProductUnitService.kt | 3 + .../product/impl/ProductUnitServiceImpl.kt | 76 +++++++++++++++---- .../utils/enums/ProdcutCodeEnum.java | 6 +- 4 files changed, 77 insertions(+), 22 deletions(-) diff --git a/api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt b/api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt index 09ef745cd..c814b0608 100644 --- a/api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt +++ b/api/src/main/java/com/wansensoft/api/product/ProductUnitController.kt @@ -15,14 +15,11 @@ package com.wansensoft.api.product import com.baomidou.mybatisplus.extension.plugins.pagination.Page import com.wansensoft.dto.product.AddOrUpdateProductUnitDTO import com.wansensoft.dto.product.ProductUnitQueryDTO +import com.wansensoft.dto.product.ProductUnitStatusDTO import com.wansensoft.service.product.ProductUnitService import com.wansensoft.utils.response.Response import com.wansensoft.vo.product.ProductUnitVO -import org.springframework.web.bind.annotation.DeleteMapping -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* @RestController @RequestMapping("/product/unit") @@ -39,7 +36,12 @@ class ProductUnitController(private val productUnitService: ProductUnitService) } @DeleteMapping("/deleteBatch") - fun deleteProductUnit(@RequestBody ids: List): Response { + fun deleteProductUnit(@RequestParam ids: List): Response { return productUnitService.deleteProductUnit(ids) } + + @PostMapping("/updateUnitStatus") + fun updateUnitStatus(@RequestBody productUnitStatus: ProductUnitStatusDTO): Response { + return productUnitService.updateUnitStatus(productUnitStatus) + } } \ No newline at end of file diff --git a/service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt b/service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt index b1881a040..43703c6cf 100644 --- a/service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt +++ b/service/src/main/java/com/wansensoft/service/product/ProductUnitService.kt @@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page import com.baomidou.mybatisplus.extension.service.IService import com.wansensoft.dto.product.AddOrUpdateProductUnitDTO import com.wansensoft.dto.product.ProductUnitQueryDTO +import com.wansensoft.dto.product.ProductUnitStatusDTO import com.wansensoft.entities.product.ProductUnit import com.wansensoft.utils.response.Response import com.wansensoft.vo.product.ProductUnitVO @@ -27,4 +28,6 @@ interface ProductUnitService: IService { fun addOrUpdateProductUnit(productUnit: AddOrUpdateProductUnitDTO?): Response fun deleteProductUnit(ids: List?): Response + + fun updateUnitStatus(productUnitStatus: ProductUnitStatusDTO?): Response } \ No newline at end of file diff --git a/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt b/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt index 3e295462e..1a3dea2fa 100644 --- a/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt +++ b/service/src/main/java/com/wansensoft/service/product/impl/ProductUnitServiceImpl.kt @@ -17,8 +17,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl import com.wansensoft.dto.product.AddOrUpdateProductUnitDTO import com.wansensoft.dto.product.ProductUnitQueryDTO +import com.wansensoft.dto.product.ProductUnitStatusDTO import com.wansensoft.entities.product.ProductUnit import com.wansensoft.mappers.product.ProductUnitMapper +import com.wansensoft.service.BaseService import com.wansensoft.service.product.ProductUnitService import com.wansensoft.utils.SnowflakeIdUtil import com.wansensoft.utils.constants.CommonConstants @@ -27,10 +29,14 @@ import com.wansensoft.utils.enums.ProdcutCodeEnum import com.wansensoft.utils.response.Response import com.wansensoft.vo.product.ProductUnitVO import org.springframework.stereotype.Service +import java.math.BigDecimal +import java.math.RoundingMode +import java.time.LocalDateTime @Service open class ProductUnitServiceImpl( - private val productUnitMapper: ProductUnitMapper + private val productUnitMapper: ProductUnitMapper, + private val baseService: BaseService ) :ServiceImpl(), ProductUnitService { override fun productUnitList(productUnitQuery: ProductUnitQueryDTO?): Response> { @@ -49,27 +55,44 @@ open class ProductUnitServiceImpl( productUnitMapper.selectPage(this, wrapper) val listVo = records.map { unit -> ProductUnitVO( - id = unit.id, - computeUnit = unit.computeUnit, - basicUnit = unit.basicUnit, - otherUnit = unit.otherUnit, - otherUnitTwo = unit.otherUnitTwo, - otherUnitThree = unit.otherUnitThree, - status = unit.status, - createTime = unit.createTime, + id = unit.id, + computeUnit = unit.computeUnit, + basicUnit = unit.basicUnit, + otherUnit = unit.otherUnit, + otherUnitTwo = unit.otherUnitTwo, + otherUnitThree = unit.otherUnitThree, + ratio = unit.ratio, + ratioTwo = unit.ratioTwo, + ratioThree = unit.ratioThree, + status = unit.status, + createTime = unit.createTime, + otherComputeUnit = formatBigDecimal(unit.ratio, unit.otherUnit, unit.basicUnit), + otherComputeUnitTwo = formatBigDecimal(unit.ratioTwo, unit.otherUnitTwo, unit.basicUnit), + otherComputeUnitThree = formatBigDecimal(unit.ratioThree, unit.otherUnitThree, unit.basicUnit) ) } Page().apply { records = listVo - total = this@run.total - pages = this@run.pages - size = this@run.size + total = this@run.total + pages = this@run.pages + size = this@run.size } } ?: Page() return Response.responseData(result) } + private fun formatBigDecimal(ratio: BigDecimal?, otherUnit: String?, basicUnit: String?): String? { + return ratio?.let { + val scaledValue = it.setScale(3, RoundingMode.HALF_UP) + val formattedValue = if (scaledValue.stripTrailingZeros().scale() <= 0) { + scaledValue.toBigInteger().toString() + } else { + scaledValue.toString() + } + "$otherUnit=$formattedValue$basicUnit" + } + } override fun addOrUpdateProductUnit(productUnit: AddOrUpdateProductUnitDTO?): Response { productUnit?.let { unit -> @@ -107,6 +130,7 @@ open class ProductUnitServiceImpl( } private fun buildProductUnit(id: Long, unit: AddOrUpdateProductUnitDTO): ProductUnit { + val creator = baseService.currentUserId return ProductUnit().apply { this.id = id computeUnit = buildComputeUnit(unit) @@ -118,14 +142,22 @@ open class ProductUnitServiceImpl( ratioTwo = unit.ratioTwo ratioThree = unit.ratioThree status = unit.status + // 如果id为空,说明是新增,需要设置创建时间 + if (unit.id == null) { + createTime = LocalDateTime.now() + createBy = creator + } else { + updateTime = LocalDateTime.now() + updateBy = creator + } } } private fun buildComputeUnit(productUnit: AddOrUpdateProductUnitDTO): String { val computeUnit = StringBuilder() - computeUnit.append("${productUnit.basicUnit}/(${productUnit.otherUnit}=${productUnit.ratio})") - productUnit.otherUnitTwo?.let { computeUnit.append("/(${it}=${productUnit.ratioTwo})") } - productUnit.otherUnitThree?.let { computeUnit.append("/(${it}=${productUnit.ratioThree})") } + computeUnit.append("${productUnit.basicUnit}/(${productUnit.otherUnit}=${productUnit.ratio}${productUnit.basicUnit})") + productUnit.otherUnitTwo?.let { computeUnit.append("/(${it}=${productUnit.ratioTwo}${productUnit.basicUnit})") } + productUnit.otherUnitThree?.let { computeUnit.append("/(${it}=${productUnit.ratioThree}${productUnit.basicUnit})") } return computeUnit.toString() } @@ -139,4 +171,18 @@ open class ProductUnitServiceImpl( }?: return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL) } + override fun updateUnitStatus(productUnitStatus: ProductUnitStatusDTO?): Response { + return productUnitStatus?.let { item -> + val unit = ProductUnit().apply { + id = item.id + status = item.status + } + val updateResult = productUnitMapper.updateById(unit) + if (updateResult == 0) { + Response.responseMsg(ProdcutCodeEnum.UPDATE_PRODUCT_UNIT_STATUS_ERROR) + } else { + Response.responseMsg(ProdcutCodeEnum.UPDATE_PRODUCT_UNIT_STATUS_SUCCESS) + } + } ?: Response.responseMsg(BaseCodeEnum.PARAMETER_NULL) + } } \ No newline at end of file diff --git a/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java b/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java index b3e91583f..62c5ddf32 100644 --- a/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java +++ b/utils/src/main/java/com/wansensoft/utils/enums/ProdcutCodeEnum.java @@ -45,7 +45,11 @@ public enum ProdcutCodeEnum { PRODUCT_UNIT_DELETE_SUCCESS("P0008", "删除商品单位成功"), - PRODUCT_UNIT_DELETE_ERROR("P0508", "删除商品单位失败"); + PRODUCT_UNIT_DELETE_ERROR("P0508", "删除商品单位失败"), + + UPDATE_PRODUCT_UNIT_STATUS_SUCCESS("P0009", "修改商品单位状态成功"), + + UPDATE_PRODUCT_UNIT_STATUS_ERROR("P0509", "修改商品单位状态失败"); private final String code; From 7a2ce0c26df1b10a937a317ec4f6758d1be36c74 Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 9 Oct 2023 01:21:33 +0800 Subject: [PATCH 7/9] Fix the issue of inconsistent measurement unit fields --- .../wansensoft/vo/product/ProductUnitVO.kt | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt b/domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt index 85d9267e5..7d49483fe 100644 --- a/domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt +++ b/domain/src/main/java/com/wansensoft/vo/product/ProductUnitVO.kt @@ -13,6 +13,9 @@ package com.wansensoft.vo.product import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.wansensoft.bo.BigDecimalSerializerBO +import java.math.BigDecimal import java.time.LocalDateTime data class ProductUnitVO ( @@ -20,16 +23,35 @@ data class ProductUnitVO ( @JsonFormat(shape = JsonFormat.Shape.STRING) var id : Long? = null, - var computeUnit : String? = null, - var basicUnit: String? = null, var otherUnit: String? = null, + // Table All Unit Assembly Text Data + var computeUnit : String? = null, + + // Table Multiple Unit Text Data + var otherComputeUnit : String? = null, + var otherUnitTwo: String? = null, + // Table Multiple Unit 2 Text Data + var otherComputeUnitTwo : String? = null, + var otherUnitThree: String? = null, + // Table Multiple Unit 3 Text Data + var otherComputeUnitThree : String? = null, + + @JsonSerialize(using = BigDecimalSerializerBO::class) + var ratio: BigDecimal? = null, + + @JsonSerialize(using = BigDecimalSerializerBO::class) + var ratioTwo: BigDecimal? = null, + + @JsonSerialize(using = BigDecimalSerializerBO::class) + var ratioThree: BigDecimal? = null, + var status: Int? = null, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") From db8df4a5c567347e22b4d71d5cd5fd1131c8c48d Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 9 Oct 2023 01:21:54 +0800 Subject: [PATCH 8/9] Add jackson that supports kotlin package --- utils/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/pom.xml b/utils/pom.xml index 72badc5b4..fa42c01e5 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -73,6 +73,12 @@ kaptcha 2.3.2 + + + com.fasterxml.jackson.module + jackson-module-kotlin + 2.14.2 + \ No newline at end of file From bb8b140d037e632229e8c744f95c836da00d753f Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 9 Oct 2023 01:22:10 +0800 Subject: [PATCH 9/9] Add custom filters --- .../wansensoft/bo/BigDecimalSerializerBO.kt | 34 +++++++++++++ .../dto/product/ProductUnitStatusDTO.kt | 8 ++++ .../com/wansensoft/service/BaseService.java | 48 +++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 domain/src/main/java/com/wansensoft/bo/BigDecimalSerializerBO.kt create mode 100644 domain/src/main/java/com/wansensoft/dto/product/ProductUnitStatusDTO.kt create mode 100644 service/src/main/java/com/wansensoft/service/BaseService.java diff --git a/domain/src/main/java/com/wansensoft/bo/BigDecimalSerializerBO.kt b/domain/src/main/java/com/wansensoft/bo/BigDecimalSerializerBO.kt new file mode 100644 index 000000000..f65429d32 --- /dev/null +++ b/domain/src/main/java/com/wansensoft/bo/BigDecimalSerializerBO.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansensoft.bo + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider +import java.math.BigDecimal +import java.math.RoundingMode + +class BigDecimalSerializerBO : JsonSerializer() { + override fun serialize(value: BigDecimal?, gen: JsonGenerator, serializers: SerializerProvider) { + if (value != null) { + val scaledValue = value.setScale(3, RoundingMode.HALF_UP) + if (scaledValue.stripTrailingZeros().scale() <= 0) { + gen.writeNumber(scaledValue.toBigInteger()) + } else { + gen.writeNumber(scaledValue) + } + } else { + gen.writeNull() + } + } +} \ No newline at end of file diff --git a/domain/src/main/java/com/wansensoft/dto/product/ProductUnitStatusDTO.kt b/domain/src/main/java/com/wansensoft/dto/product/ProductUnitStatusDTO.kt new file mode 100644 index 000000000..3bf928452 --- /dev/null +++ b/domain/src/main/java/com/wansensoft/dto/product/ProductUnitStatusDTO.kt @@ -0,0 +1,8 @@ +package com.wansensoft.dto.product + +data class ProductUnitStatusDTO( + + val id: Long? = null, + + var status: Int? = null +) diff --git a/service/src/main/java/com/wansensoft/service/BaseService.java b/service/src/main/java/com/wansensoft/service/BaseService.java new file mode 100644 index 000000000..5d74894fe --- /dev/null +++ b/service/src/main/java/com/wansensoft/service/BaseService.java @@ -0,0 +1,48 @@ +package com.wansensoft.service; + +import com.wansensoft.utils.redis.RedisUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Optional; + +@Service +@Slf4j +public class BaseService { + + private final RedisUtil redisUtil; + + public BaseService(RedisUtil redisUtil) { + this.redisUtil = redisUtil; + } + + public Long getCurrentUserId() { + var token = httpServletRequestContextToken(); + return Long.parseLong(redisUtil.getString(token + ":userId")); + } + + public Long getCurrentTenantId() { + var token = httpServletRequestContextToken(); + return Long.parseLong(redisUtil.getString(token + ":tenantId")); + } + + public String getCurrentUserName() { + var token = httpServletRequestContextToken(); + return redisUtil.getString(token + ":userName"); + } + + public String getCurrentUserAccount() { + var token = httpServletRequestContextToken(); + return redisUtil.getString(token + ":userAccount"); + } + + private String httpServletRequestContextToken() { + var sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (sra == null) { + log.error("[异常]获取HttpServletRequest为空"); + } + return Optional.ofNullable(sra.getRequest().getHeader("Authorization")).orElseThrow(null); + } +}