From c2ce10948293d28281a882a4f214ed89724695bd Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Dec 2023 22:36:57 +0800 Subject: [PATCH 1/7] fetch: renamed SysConfig mapper --- ...ReceiptPurchaseSubMapper.xml => SysConfigService.xml} | 0 .../{ISysConfigService.java => SysConfigService.java} | 9 ++++++++- 2 files changed, 8 insertions(+), 1 deletion(-) rename core/dao/src/main/resources/mapper_xml/receipt/{ReceiptPurchaseSubMapper.xml => SysConfigService.xml} (100%) rename core/service/src/main/java/com/wansenai/service/system/{ISysConfigService.java => SysConfigService.java} (70%) diff --git a/core/dao/src/main/resources/mapper_xml/receipt/ReceiptPurchaseSubMapper.xml b/core/dao/src/main/resources/mapper_xml/receipt/SysConfigService.xml similarity index 100% rename from core/dao/src/main/resources/mapper_xml/receipt/ReceiptPurchaseSubMapper.xml rename to core/dao/src/main/resources/mapper_xml/receipt/SysConfigService.xml diff --git a/core/service/src/main/java/com/wansenai/service/system/ISysConfigService.java b/core/service/src/main/java/com/wansenai/service/system/SysConfigService.java similarity index 70% rename from core/service/src/main/java/com/wansenai/service/system/ISysConfigService.java rename to core/service/src/main/java/com/wansenai/service/system/SysConfigService.java index e55382b8..50b896ad 100644 --- a/core/service/src/main/java/com/wansenai/service/system/ISysConfigService.java +++ b/core/service/src/main/java/com/wansenai/service/system/SysConfigService.java @@ -12,14 +12,21 @@ */ package com.wansenai.service.system; +import com.wansenai.dto.system.SystemConfigDTO; import com.wansenai.entities.system.SysConfig; import com.baomidou.mybatisplus.extension.service.IService; +import com.wansenai.utils.response.Response; +import com.wansenai.vo.SystemConfigVO; /** *

* 系统参数 服务类 *

*/ -public interface ISysConfigService extends IService { +public interface SysConfigService extends IService { + + Response getSystemConfigInfo(); + + Response addOrUpdateCompanyInfo(SystemConfigDTO systemConfigDTO); } From e3e578c56a553ef45ee9bf165de8b9386ca21cef Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Dec 2023 22:37:14 +0800 Subject: [PATCH 2/7] fetch: add System config data object --- .../wansenai/dto/system/SystemConfigDTO.java | 35 ++++++++++++++++++ .../java/com/wansenai/vo/SystemConfigVO.java | 37 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 core/domain/src/main/java/com/wansenai/dto/system/SystemConfigDTO.java create mode 100644 core/domain/src/main/java/com/wansenai/vo/SystemConfigVO.java diff --git a/core/domain/src/main/java/com/wansenai/dto/system/SystemConfigDTO.java b/core/domain/src/main/java/com/wansenai/dto/system/SystemConfigDTO.java new file mode 100644 index 00000000..0cbfa0ac --- /dev/null +++ b/core/domain/src/main/java/com/wansenai/dto/system/SystemConfigDTO.java @@ -0,0 +1,35 @@ +/* + * 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.wansenai.dto.system; + +import lombok.Data; + +@Data +public class SystemConfigDTO { + + private Long id; + + private String companyName; + + private String companyContact; + + private String companyAddress; + + private String companyPhone; + + private String companyFax; + + private String companyPostCode; + + private String saleAgreement; +} diff --git a/core/domain/src/main/java/com/wansenai/vo/SystemConfigVO.java b/core/domain/src/main/java/com/wansenai/vo/SystemConfigVO.java new file mode 100644 index 00000000..dd3d62ca --- /dev/null +++ b/core/domain/src/main/java/com/wansenai/vo/SystemConfigVO.java @@ -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.wansenai.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +@Data +public class SystemConfigVO { + + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + + private String companyName; + + private String companyContact; + + private String companyAddress; + + private String companyPhone; + + private String companyFax; + + private String companyPostCode; + + private String saleAgreement; +} From a9a0e889889dd031f1af66c5946802f177e23b5c Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Dec 2023 22:37:36 +0800 Subject: [PATCH 3/7] fetch: add getCompanyInfo and add/update system config api --- .../api/system/SysConfigController.java | 35 ++++++++++----- .../wansenai/entities/system/SysConfig.java | 18 ++++---- .../system/impl/SysConfigServiceImpl.java | 43 ++++++++++++++++++- 3 files changed, 74 insertions(+), 22 deletions(-) diff --git a/core/api/src/main/java/com/wansenai/api/system/SysConfigController.java b/core/api/src/main/java/com/wansenai/api/system/SysConfigController.java index f8c0f093..35690ff7 100644 --- a/core/api/src/main/java/com/wansenai/api/system/SysConfigController.java +++ b/core/api/src/main/java/com/wansenai/api/system/SysConfigController.java @@ -12,20 +12,33 @@ */ package com.wansenai.api.system; -import org.springframework.web.bind.annotation.RequestMapping; - +import com.wansenai.dto.system.SystemConfigDTO; +import com.wansenai.service.system.SysConfigService; +import com.wansenai.utils.response.Response; +import com.wansenai.vo.SystemConfigVO; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; -/** - *

- * 系统参数 前端控制器 - *

- * - * @author James Zow - * @since 2023-09-05 - */ @RestController -@RequestMapping("/sys-config") +@RequestMapping("/sys/config") public class SysConfigController { + private final SysConfigService sysConfigService; + + public SysConfigController(SysConfigService sysConfigService) { + this.sysConfigService = sysConfigService; + } + + @GetMapping("getCompanyInfo") + public Response getSystemConfigInfo() { + return sysConfigService.getSystemConfigInfo(); + } + + @PostMapping("addOrUpdate") + public Response addOrUpdateCompanyInfo(@RequestBody SystemConfigDTO systemConfigDTO) { + return sysConfigService.addOrUpdateCompanyInfo(systemConfigDTO); + } } diff --git a/core/domain/src/main/java/com/wansenai/entities/system/SysConfig.java b/core/domain/src/main/java/com/wansenai/entities/system/SysConfig.java index 0399d7f9..a2f6ea2f 100644 --- a/core/domain/src/main/java/com/wansenai/entities/system/SysConfig.java +++ b/core/domain/src/main/java/com/wansenai/entities/system/SysConfig.java @@ -85,27 +85,27 @@ public class SysConfig implements Serializable { /** * 仓库启用标记,0未启用,1启用 */ - private Boolean warehouseStatus; + private Integer warehouseStatus; /** * 客户启用标记,0未启用,1启用 */ - private Boolean customerStatus; + private Integer customerStatus; /** * 负库存启用标记,0未启用,1启用 */ - private Boolean minusStockStatus; + private Integer minusStockStatus; /** * 以销定购启用标记,0未启用,1启用 */ - private Boolean purchaseBySaleStatus; + private Integer purchaseBySaleStatus; /** * 多级审核启用标记,0未启用,1启用 */ - private Boolean multiLevelApprovalStatus; + private Integer multiLevelApprovalStatus; /** * 流程类型,可多选 @@ -115,22 +115,22 @@ public class SysConfig implements Serializable { /** * 强审核启用标记,0未启用,1启用 */ - private Boolean forceApprovalStatus; + private Integer forceApprovalStatus; /** * 更新单价启用标记,0未启用,1启用 */ - private Boolean updateUnitPriceStatus; + private Integer updateUnitPriceStatus; /** * 超出关联单据启用标记,0未启用,1启用 */ - private Boolean overLinkBillStatus; + private Integer overLinkBillStatus; /** * 删除标记,0未删除,1删除 */ - private Boolean deleteFlag; + private Integer deleteFlag; } diff --git a/core/service/src/main/java/com/wansenai/service/system/impl/SysConfigServiceImpl.java b/core/service/src/main/java/com/wansenai/service/system/impl/SysConfigServiceImpl.java index 11e847ce..080404d6 100644 --- a/core/service/src/main/java/com/wansenai/service/system/impl/SysConfigServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/system/impl/SysConfigServiceImpl.java @@ -1,9 +1,17 @@ package com.wansenai.service.system.impl; -import com.wansenai.service.system.ISysConfigService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.wansenai.dto.system.SystemConfigDTO; +import com.wansenai.service.system.SysConfigService; import com.wansenai.entities.system.SysConfig; import com.wansenai.mappers.system.SysConfigMapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.wansenai.service.user.ISysUserService; +import com.wansenai.utils.constants.CommonConstants; +import com.wansenai.utils.enums.BaseCodeEnum; +import com.wansenai.utils.response.Response; +import com.wansenai.vo.SystemConfigVO; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; /** @@ -15,6 +23,37 @@ * @since 2023-09-05 */ @Service -public class SysConfigServiceImpl extends ServiceImpl implements ISysConfigService { +public class SysConfigServiceImpl extends ServiceImpl implements SysConfigService { + private final SysConfigMapper configMapper; + + public SysConfigServiceImpl(SysConfigMapper configMapper) { + this.configMapper = configMapper; + } + + @Override + public Response getSystemConfigInfo() { + var wrapper = new QueryWrapper(); + wrapper.eq("delete_flag", CommonConstants.NOT_DELETED); + var configData = configMapper.selectOne(wrapper); + var systemConfigVO = new SystemConfigVO(); + if (configData != null) { + BeanUtils.copyProperties(configData, systemConfigVO); + return Response.responseData(systemConfigVO); + } + return Response.responseData(systemConfigVO); + } + + @Override + public Response addOrUpdateCompanyInfo(SystemConfigDTO systemConfigDTO) { + var id = systemConfigDTO.getId(); + var config = new SysConfig(); + BeanUtils.copyProperties(systemConfigDTO, config); + if (id == null) { + configMapper.insert(config); + } else { + configMapper.updateById(config); + } + return Response.responseMsg(BaseCodeEnum.SUCCESS); + } } From 7f3601f0cb5b7b4fb3645a2dd9df7f98bf16d596 Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Dec 2023 22:37:55 +0800 Subject: [PATCH 4/7] fetch: add path patterns getCompanyInfo api --- .../main/java/com/wansenai/middleware/security/JWTConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/middleware/src/main/java/com/wansenai/middleware/security/JWTConfig.java b/core/middleware/src/main/java/com/wansenai/middleware/security/JWTConfig.java index 88f6e030..cce0567e 100644 --- a/core/middleware/src/main/java/com/wansenai/middleware/security/JWTConfig.java +++ b/core/middleware/src/main/java/com/wansenai/middleware/security/JWTConfig.java @@ -36,6 +36,7 @@ public void addInterceptors(InterceptorRegistry registry) { .excludePathPatterns("/user/mobileLogin") .excludePathPatterns("/user/updatePassword") .excludePathPatterns("/v2/common/sms/{type}/{phoneNumber}") - .excludePathPatterns("/v2/common/nextId/{type}"); + .excludePathPatterns("/v2/common/nextId/{type}") + .excludePathPatterns("/sys/config/getCompanyInfo"); } } \ No newline at end of file From 4e744f01a223eee866050824f69bc85aa49c1cac Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Dec 2023 22:38:29 +0800 Subject: [PATCH 5/7] fetch: update companyTitle show title --- web/src/api/sys/config.ts | 20 +++++ web/src/api/sys/model/dpetModel.ts | 2 - .../components/Application/src/AppLogo.vue | 11 ++- web/src/views/sys/config/config.data.ts | 82 ++++++++++++++++++ web/src/views/sys/config/index.vue | 86 +++++++++++++++++++ 5 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 web/src/api/sys/config.ts create mode 100644 web/src/views/sys/config/config.data.ts create mode 100644 web/src/views/sys/config/index.vue diff --git a/web/src/api/sys/config.ts b/web/src/api/sys/config.ts new file mode 100644 index 00000000..b7b4416a --- /dev/null +++ b/web/src/api/sys/config.ts @@ -0,0 +1,20 @@ +import { defHttp } from '/@/utils/http/axios'; +import {BaseDataResp, BaseResp} from "@/api/model/baseModel"; +import { + AddOrUpdateSystemConfigModel, + GetSystemConfigModel, +} from '@/api/sys/model/configModel'; + +enum Api { + GetConfigInfo = '/sys/config/getCompanyInfo', + AddOrUpdateConfigInfo = '/sys/config/addOrUpdate', +} + +export function getConfigInfo() { + return defHttp.get>({url: Api.GetConfigInfo}) +} + +export function addOrUpdateConfigInfo(params: AddOrUpdateSystemConfigModel) { + return defHttp.post({url: Api.AddOrUpdateConfigInfo, params}) +} + diff --git a/web/src/api/sys/model/dpetModel.ts b/web/src/api/sys/model/dpetModel.ts index 88d92ab0..ba021380 100644 --- a/web/src/api/sys/model/dpetModel.ts +++ b/web/src/api/sys/model/dpetModel.ts @@ -1,5 +1,3 @@ -import {BasicFetchResult} from "@/api/model/baseModel"; - export interface DeptListItem { deptName: string; } diff --git a/web/src/components/Application/src/AppLogo.vue b/web/src/components/Application/src/AppLogo.vue index 8abeb6cd..306e2ba0 100644 --- a/web/src/components/Application/src/AppLogo.vue +++ b/web/src/components/Application/src/AppLogo.vue @@ -2,18 +2,20 @@
- {{ title }} + {{ companyTitle == undefined ? title : companyTitle}}
+ From c96f0607576f54a3ad766b6135a2bee0555d3d15 Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Dec 2023 22:38:34 +0800 Subject: [PATCH 6/7] fetch: update companyTitle show title --- web/src/api/sys/model/configModel.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 web/src/api/sys/model/configModel.ts diff --git a/web/src/api/sys/model/configModel.ts b/web/src/api/sys/model/configModel.ts new file mode 100644 index 00000000..83d5f409 --- /dev/null +++ b/web/src/api/sys/model/configModel.ts @@ -0,0 +1,20 @@ +export interface GetSystemConfigModel { + companyName: string; + companyContact: string; + companyAddress: string; + companyPhone: string; + companyFax: string; + companyPostCode: string; + companyLogo: string; +} + +export interface AddOrUpdateSystemConfigModel { + id: number | string; + companyName: string; + companyContact: string; + companyAddress: string; + companyPhone: string; + companyFax: string; + companyPostCode: string; + companyLogo: string; +} \ No newline at end of file From c9199e10d1b7c4a6e66884fde92d9f82ecd44e65 Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Dec 2023 22:39:02 +0800 Subject: [PATCH 7/7] fetch: new add avatar support --- web/src/components/Cropper/index.ts | 7 + web/src/components/Cropper/src/Cropper.vue | 188 ++++++++++++ .../components/Cropper/src/CropperAvatar.vue | 166 ++++++++++ .../components/Cropper/src/CropperModal.vue | 289 ++++++++++++++++++ web/src/components/Cropper/src/typing.ts | 8 + web/src/utils/file/base64Conver.ts | 41 +++ 6 files changed, 699 insertions(+) create mode 100644 web/src/components/Cropper/index.ts create mode 100644 web/src/components/Cropper/src/Cropper.vue create mode 100644 web/src/components/Cropper/src/CropperAvatar.vue create mode 100644 web/src/components/Cropper/src/CropperModal.vue create mode 100644 web/src/components/Cropper/src/typing.ts create mode 100644 web/src/utils/file/base64Conver.ts diff --git a/web/src/components/Cropper/index.ts b/web/src/components/Cropper/index.ts new file mode 100644 index 00000000..88d6d1d5 --- /dev/null +++ b/web/src/components/Cropper/index.ts @@ -0,0 +1,7 @@ +import { withInstall } from '/@/utils'; +import cropperImage from './src/Cropper.vue'; +import avatarCropper from './src/CropperAvatar.vue'; + +export * from './src/typing'; +export const CropperImage = withInstall(cropperImage); +export const CropperAvatar = withInstall(avatarCropper); diff --git a/web/src/components/Cropper/src/Cropper.vue b/web/src/components/Cropper/src/Cropper.vue new file mode 100644 index 00000000..4523ad43 --- /dev/null +++ b/web/src/components/Cropper/src/Cropper.vue @@ -0,0 +1,188 @@ + + + diff --git a/web/src/components/Cropper/src/CropperAvatar.vue b/web/src/components/Cropper/src/CropperAvatar.vue new file mode 100644 index 00000000..ee157574 --- /dev/null +++ b/web/src/components/Cropper/src/CropperAvatar.vue @@ -0,0 +1,166 @@ + + + + diff --git a/web/src/components/Cropper/src/CropperModal.vue b/web/src/components/Cropper/src/CropperModal.vue new file mode 100644 index 00000000..0cbe69f3 --- /dev/null +++ b/web/src/components/Cropper/src/CropperModal.vue @@ -0,0 +1,289 @@ + + + + diff --git a/web/src/components/Cropper/src/typing.ts b/web/src/components/Cropper/src/typing.ts new file mode 100644 index 00000000..e76cc6f8 --- /dev/null +++ b/web/src/components/Cropper/src/typing.ts @@ -0,0 +1,8 @@ +import type Cropper from 'cropperjs'; + +export interface CropendResult { + imgBase64: string; + imgInfo: Cropper.Data; +} + +export type { Cropper }; diff --git a/web/src/utils/file/base64Conver.ts b/web/src/utils/file/base64Conver.ts new file mode 100644 index 00000000..6751d977 --- /dev/null +++ b/web/src/utils/file/base64Conver.ts @@ -0,0 +1,41 @@ +/** + * @description: base64 to blob + */ +export function dataURLtoBlob(base64Buf: string): Blob { + const arr = base64Buf.split(','); + const typeItem = arr[0]; + const mime = typeItem.match(/:(.*?);/)![1]; + const bstr = window.atob(arr[1]); + let n = bstr.length; + const u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + return new Blob([u8arr], { type: mime }); +} + +/** + * img url to base64 + * @param url + */ +export function urlToBase64(url: string, mineType?: string): Promise { + return new Promise((resolve, reject) => { + let canvas = document.createElement('CANVAS') as Nullable; + const ctx = canvas!.getContext('2d'); + + const img = new Image(); + img.crossOrigin = ''; + img.onload = function () { + if (!canvas || !ctx) { + return reject(); + } + canvas.height = img.height; + canvas.width = img.width; + ctx.drawImage(img, 0, 0); + const dataURL = canvas.toDataURL(mineType || 'image/png'); + canvas = null; + resolve(dataURL); + }; + img.src = url; + }); +}