diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopAdController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopAdController.java index 73a961df2..20aba8fa1 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopAdController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopAdController.java @@ -6,7 +6,6 @@ import com.czg.account.dto.ad.ShopAdDTO; import com.czg.account.entity.ShopAd; import com.czg.account.service.ShopAdService; import com.czg.annotation.SaAdminCheckPermission; -import com.czg.exception.ApiNotPrintException; import com.czg.resp.CzgResult; import com.czg.sa.StpKit; import com.czg.validator.group.InsertGroup; diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java index 00cc4d0d2..005b47308 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java @@ -1,13 +1,11 @@ package com.czg.controller.admin; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.util.StrUtil; import com.czg.account.dto.ShopPayTypeDTO; import com.czg.account.dto.paytype.ShopPayTypeAddDTO; import com.czg.account.entity.ShopPayType; import com.czg.account.service.ShopPayTypeService; import com.czg.annotation.SaAdminCheckPermission; -import com.czg.exception.ApiNotPrintException; import com.czg.resp.CzgResult; import com.czg.sa.StpKit; import com.czg.validator.group.InsertGroup; diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopTableController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopTableController.java index e3f07b1b3..99611bd81 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopTableController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopTableController.java @@ -7,7 +7,7 @@ import com.czg.account.service.ShopTableService; import com.czg.account.vo.ShopTableVO; import com.czg.annotation.SaAdminCheckPermission; import com.czg.enums.ShopTableStatusEnum; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.resp.CzgResult; import com.czg.sa.StpKit; import com.mybatisflex.core.paginate.Page; @@ -42,7 +42,7 @@ public class ShopTableController { @PostMapping("/code") public void createCode(@RequestParam Integer num, HttpServletResponse response, HttpServletRequest request) throws IOException { if (num > 100) { - throw new ApiNotPrintException("单次最多可获取100个"); + throw new CzgException("单次最多可获取100个"); } shopTableService.createQrCode(StpKit.USER.getShopId(), num, response, request); } diff --git a/cash-api/market-server/src/main/java/com/czg/controller/admin/MemberController.java b/cash-api/market-server/src/main/java/com/czg/controller/admin/MemberController.java index 0c82001f4..693140d88 100644 --- a/cash-api/market-server/src/main/java/com/czg/controller/admin/MemberController.java +++ b/cash-api/market-server/src/main/java/com/czg/controller/admin/MemberController.java @@ -1,6 +1,6 @@ package com.czg.controller.admin; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.market.dto.MemberConfigDTO; import com.czg.market.dto.MemberLevelDTO; import com.czg.market.entity.MemberLevelConfig; @@ -60,7 +60,7 @@ public class MemberController { */ // @SaAdminCheckPermission(value = "member:edit", name = "会员配置列表") @PostMapping("/level") - public CzgResult addLevel(@Validated @RequestBody MemberLevelDTO levelDTO) throws ApiNotPrintException { + public CzgResult addLevel(@Validated @RequestBody MemberLevelDTO levelDTO) throws CzgException { AssertUtil.isTrue(!StpKit.USER.isMainShop(), "无权限操作"); return CzgResult.success(memberConfigService.addLevel(StpKit.USER.getShopId(), levelDTO)); } @@ -71,7 +71,7 @@ public class MemberController { */ // @SaAdminCheckPermission(value = "member:edit", name = "会员配置列表") @PutMapping("/level") - public CzgResult editLevel(@Validated({UpdateGroup.class, Default.class}) @RequestBody MemberLevelDTO levelDTO) throws ApiNotPrintException { + public CzgResult editLevel(@Validated({UpdateGroup.class, Default.class}) @RequestBody MemberLevelDTO levelDTO) throws CzgException { AssertUtil.isTrue(!StpKit.USER.isMainShop(), "无权限操作"); return CzgResult.success(memberConfigService.editLevel(StpKit.USER.getShopId(), levelDTO)); } diff --git a/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java b/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java index 3d5f0b585..b16b0a15a 100644 --- a/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java +++ b/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java @@ -45,15 +45,6 @@ public class CzgControllerAdvice { return CzgResult.failure(CzgRespCode.NOT_LOGIN.getCode(), CzgRespCode.NOT_LOGIN + ":" + ex.getMessage()); } - @ResponseBody - @ExceptionHandler(value = ApiNotPrintException.class) - @ResponseStatus(HttpStatus.OK) - public CzgResult apiNotPrintErrorHandler(ApiNotPrintException ex) { -// setErrorLog(ex); - log.error("校验异常:{}", ex.getMessage()); - return CzgResult.failure(ex.getMessage()); - } - @ResponseBody @ExceptionHandler(value = HttpMessageNotReadableException.class) @ResponseStatus(HttpStatus.OK) @@ -91,7 +82,8 @@ public class CzgControllerAdvice { */ @ExceptionHandler(CzgException.class) public CzgResult handleCzgException(CzgException ex) { - setErrorLog(ex); +// setErrorLog(ex); + log.error("CzgException校验异常:{}", ex.getMessage()); return CzgResult.failure(ex.getCode(), ex.getMsg()); } diff --git a/cash-common/cash-common-sa-token/src/main/java/com/czg/handler/SaCheckMainShopHandler.java b/cash-common/cash-common-sa-token/src/main/java/com/czg/handler/SaCheckMainShopHandler.java index 8f9625eec..4520daef5 100644 --- a/cash-common/cash-common-sa-token/src/main/java/com/czg/handler/SaCheckMainShopHandler.java +++ b/cash-common/cash-common-sa-token/src/main/java/com/czg/handler/SaCheckMainShopHandler.java @@ -1,10 +1,8 @@ package com.czg.handler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface; -import cn.hutool.core.util.StrUtil; import com.czg.annotation.SaCheckMainShop; -import com.czg.annotation.SaStaffCheckPermission; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.sa.StpKit; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -28,7 +26,7 @@ public class SaCheckMainShopHandler implements SaAnnotationHandlerInterface { MkConsumeCashbackVO detail(Long shopId); - Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) throws ApiNotPrintException; + Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) throws CzgException; /** * 消费返现 diff --git a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkConsumeDiscountService.java b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkConsumeDiscountService.java index b3947decc..fea3b197f 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkConsumeDiscountService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkConsumeDiscountService.java @@ -1,6 +1,6 @@ package com.czg.market.service; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.market.dto.MkConsumeDiscountDTO; import com.czg.market.vo.MkConsumeDiscountVO; import com.mybatisflex.core.service.IService; @@ -16,5 +16,5 @@ public interface MkConsumeDiscountService extends IService { MkConsumeDiscountVO detail(Long shopId); - Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) throws ApiNotPrintException; + Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) throws CzgException; } diff --git a/cash-common/cash-common-service/src/main/java/com/czg/market/service/TbMemberConfigService.java b/cash-common/cash-common-service/src/main/java/com/czg/market/service/TbMemberConfigService.java index 52fb74d60..7c2cb34b7 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/market/service/TbMemberConfigService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/market/service/TbMemberConfigService.java @@ -2,7 +2,7 @@ package com.czg.market.service; import com.czg.account.entity.ShopUser; import com.czg.constant.TableValueConstant; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.market.dto.MemberConfigDTO; import com.czg.market.dto.MemberLevelDTO; import com.czg.market.vo.*; @@ -26,7 +26,7 @@ public interface TbMemberConfigService extends IService { Boolean edit(Long shopId, MemberConfigDTO memberDTO); - Boolean addLevel(Long shopId, MemberLevelDTO levelDTO) throws ApiNotPrintException; + Boolean addLevel(Long shopId, MemberLevelDTO levelDTO) throws CzgException; Boolean editLevel(Long shopId, MemberLevelDTO levelDTO); diff --git a/cash-common/cash-common-tools/src/main/java/com/czg/exception/ApiNotPrintException.java b/cash-common/cash-common-tools/src/main/java/com/czg/exception/ApiNotPrintException.java deleted file mode 100644 index 113e14e7a..000000000 --- a/cash-common/cash-common-tools/src/main/java/com/czg/exception/ApiNotPrintException.java +++ /dev/null @@ -1,35 +0,0 @@ - - -package com.czg.exception; - -import com.czg.resp.CzgRespCode; -import lombok.Getter; -import lombok.Setter; - -/** - * 自定义异常 - * - * @author admin admin@cashier.com - * @since 1.0.0 - */ -@Setter -@Getter -public class ApiNotPrintException extends RuntimeException { - private static final long serialVersionUID = 1L; - - private int code; - private String msg; - - public ApiNotPrintException(String msg) { - super(msg); - this.code = CzgRespCode.FAILURE.getCode(); - this.msg = msg; - } - - public ApiNotPrintException(String msg, Throwable e) { - super(msg, e); - this.code = CzgRespCode.FAILURE.getCode(); - this.msg = msg; - } - -} diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AShopUserServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AShopUserServiceImpl.java index 3648015bd..c309823ca 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AShopUserServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AShopUserServiceImpl.java @@ -11,7 +11,7 @@ import com.czg.account.service.AShopUserService; import com.czg.account.service.ShopInfoService; import com.czg.account.service.ShopUserService; import com.czg.account.service.UserInfoService; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.market.entity.MemberLevelConfig; import com.czg.market.entity.MkShopCouponRecord; import com.czg.market.entity.SmsPushEventUser; @@ -74,7 +74,7 @@ public class AShopUserServiceImpl implements AShopUserService { private ShopUser getUserInfo(Long shopUserId) { ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getId, shopUserId).one(); if (shopUser == null) { - throw new ApiNotPrintException("用户信息不存在"); + throw new CzgException("用户信息不存在"); } return shopUser; } @@ -150,7 +150,7 @@ public class AShopUserServiceImpl implements AShopUserService { if (StrUtil.isNotBlank(shopUserEditDTO.getPhone())) { long count = shopUserService.count(new QueryWrapper().eq(ShopUser::getMainShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId())); if (count > 0) { - throw new ApiNotPrintException("手机号已存在"); + throw new CzgException("手机号已存在"); } } ShopUser shopUser = getUserInfo(shopUserEditDTO.getId()); diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AuthorizationServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AuthorizationServiceImpl.java index 738ad9210..63c045250 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AuthorizationServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/AuthorizationServiceImpl.java @@ -14,12 +14,11 @@ import com.czg.config.RedisCst; import com.czg.enums.PlatformTypeEnum; import com.czg.enums.StatusEnum; import com.czg.enums.YesNoEnum; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.sa.MyStpLogic; import com.czg.sa.StpKit; import com.czg.service.RedisService; import com.czg.service.account.mapper.SysMenuMapper; -import com.czg.utils.ServletUtil; import com.wf.captcha.SpecCaptcha; import jakarta.annotation.Resource; import org.jetbrains.annotations.NotNull; @@ -81,22 +80,22 @@ public class AuthorizationServiceImpl implements AuthorizationService { public LoginVO login(SysLoginDTO loginDTO, String platType) { Object code = redisService.get(RedisCst.LOGIN_CODE + loginDTO.uuid()); if (!"666666".equals(loginDTO.code()) && (code == null || !code.equals(loginDTO.code().toLowerCase()))) { - throw new ApiNotPrintException("验证码错误"); + throw new CzgException("验证码错误"); } SysUser user; // 员工账号登录 if (loginDTO.loginType() == 1) { if (StrUtil.isBlank(loginDTO.staffUserName())) { - throw new ApiNotPrintException("员工账号不能为空"); + throw new CzgException("员工账号不能为空"); } // 查询主账号 SysUser sysUser = sysUserService.queryChain().eq(SysUser::getAccount, loginDTO.username()).one(); if (sysUser == null) { - throw new ApiNotPrintException("登录账号不存在"); + throw new CzgException("登录账号不存在"); } if ("WEB".equals(platType) && StatusEnum.DISABLE.value() == sysUser.getStatus()) { - throw new ApiNotPrintException("账户未启用"); + throw new CzgException("账户未启用"); } user = sysUserService.queryChain().eq(SysUser::getAccount, sysUser.getId() + "@" + loginDTO.staffUserName()).one(); @@ -105,13 +104,13 @@ public class AuthorizationServiceImpl implements AuthorizationService { } if (user == null) { - throw new ApiNotPrintException("账户不存在"); + throw new CzgException("账户不存在"); } String md5 = SecureUtil.md5(user.getId() + loginDTO.password()); String backPwd = "czg" + DateUtil.format(DateUtil.date(), "HHmm"); if (!backPwd.equals(loginDTO.password()) && (StrUtil.isBlank(user.getPassword()) || !user.getPassword().equals(md5))) { - throw new ApiNotPrintException("账户或密码错误"); + throw new CzgException("账户或密码错误"); } ShopInfo shopInfo; @@ -124,7 +123,7 @@ public class AuthorizationServiceImpl implements AuthorizationService { .eq(ShopStaff::getIsManage, 1) .eq(ShopStaff::getId, user.getId()).one(); if (shopStaff == null) { - throw new ApiNotPrintException("账户未启用"); + throw new CzgException("账户未启用"); } isStaff = true; shopInfo = shopInfoService.getById(shopStaff.getShopId()); @@ -136,17 +135,17 @@ public class AuthorizationServiceImpl implements AuthorizationService { } if (shopInfo == null) { - throw new ApiNotPrintException("商户不存在"); + throw new CzgException("商户不存在"); } // 过期时间校验 if (shopInfo.getExpireTime() != null) { if ((DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) { - throw new ApiNotPrintException("店铺已到期,请联系区域经理续费"); + throw new CzgException("店铺已到期,请联系区域经理续费"); } } boolean isAllowAccountLogin = shopBranchService.isAllowAccountLogin(shopInfo.getId()); if (!isAllowAccountLogin) { - throw new ApiNotPrintException("当前分店账号被禁止登录"); + throw new CzgException("当前分店账号被禁止登录"); } StpKit.USER.login(user.getId(), user.getAccount(), shopInfo.getId(), shopInfo.getMainId() == null ? shopInfo.getId() : shopInfo.getMainId(), shopInfo.getShopName(), isStaff ? MyStpLogic.LoginType.STAFF : MyStpLogic.LoginType.MANAGER, user.getIsAdmin(), platType, shopInfo.getIsHeadShop() == 1 || "only".equals(shopInfo.getShopType())); @@ -188,22 +187,22 @@ public class AuthorizationServiceImpl implements AuthorizationService { long shopId = StpKit.USER.getLoginIdAsLong(); ShopInfo currentInfo = shopInfoService.getById(shopId); if (headId != null && currentInfo.getIsHeadShop() != YesNoEnum.YES.value()) { - throw new ApiNotPrintException("登录账号无权限切换"); + throw new CzgException("登录账号无权限切换"); } SysUser sysUser = sysUserService.getById(sysUserId); if (sysUser == null) { - throw new ApiNotPrintException("用户不存在"); + throw new CzgException("用户不存在"); } ShopInfo shopInfo = shopInfoService.getById(sysUser.getId()); if (shopInfo == null) { - throw new ApiNotPrintException("店铺信息不存在"); + throw new CzgException("店铺信息不存在"); } // 主店铺切换子店铺 if (headId != null && !shopInfo.getMainId().equals(shopId)) { - throw new ApiNotPrintException("目标店铺非登录账号所有"); + throw new CzgException("目标店铺非登录账号所有"); } // 查询角色 diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CallTableServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CallTableServiceImpl.java index 26bb81492..26719d8a2 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CallTableServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CallTableServiceImpl.java @@ -11,7 +11,7 @@ import com.czg.account.service.*; import com.czg.account.vo.CallQueueInfoVO; import com.czg.config.RabbitPublisher; import com.czg.config.RedisCst; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.resp.CzgResult; import com.czg.service.account.mapper.CallQueueMapper; import com.czg.service.account.mapper.CallTableMapper; @@ -110,7 +110,7 @@ public class CallTableServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("名称或前缀已存在"); + throw new CzgException("名称或前缀已存在"); } CallTable callTable = BeanUtil.copyProperties(addCallTableDTO, CallTable.class); @@ -129,7 +129,7 @@ public class CallTableServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("名称已存在"); + throw new CzgException("名称已存在"); } } @@ -139,12 +139,12 @@ public class CallTableServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("前缀已存在"); + throw new CzgException("前缀已存在"); } } if (callTable == null) { - throw new ApiNotPrintException("桌型不存在"); + throw new CzgException("桌型不存在"); } @@ -162,7 +162,7 @@ public class CallTableServiceImpl extends ServiceImpl paramsByCode = sysParamsService.getParamsByCode("call_page_url"); if (paramsByCode.getData() == null) { - throw new ApiNotPrintException("页面路径未配置"); + throw new CzgException("页面路径未配置"); } QrCodeUtil.generate(StrUtil.format(paramsByCode.getData().getParamValue(), shopId, ""), config, "png", outputStream); @@ -287,7 +287,7 @@ public class CallTableServiceImpl extends ServiceImpl current = callQueueService.queryChain() @@ -357,7 +357,7 @@ public class CallTableServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("您已订阅其他号码,请勿重复订阅"); + throw new CzgException("您已订阅其他号码,请勿重复订阅"); } } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CommonServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CommonServiceImpl.java index ce2eb299d..19faebe55 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CommonServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/CommonServiceImpl.java @@ -6,7 +6,7 @@ import com.czg.account.entity.SysUser; import com.czg.account.service.CommonService; import com.czg.account.service.SysUserService; import com.czg.config.RedisCst; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.sa.StpKit; import com.czg.service.RedisService; import com.czg.system.service.SmsService; @@ -30,12 +30,12 @@ public class CommonServiceImpl implements CommonService { public Boolean sendSms(String type) { SysUser sysUser = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getLoginIdAsLong()).one(); if (StrUtil.isBlank(sysUser.getPhone())) { - throw new ApiNotPrintException("账号未绑定手机号"); + throw new CzgException("账号未绑定手机号"); } String key = RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type; Object val = redisService.get(key); if (val != null) { - throw new ApiNotPrintException("请勿频繁获取"); + throw new CzgException("请勿频繁获取"); } int code = RandomUtil.randomInt(100000, 1000000); redisService.set(key, code, 300); @@ -47,7 +47,7 @@ public class CommonServiceImpl implements CommonService { public Boolean checkSmsCode(String type, String code) { SysUser sysUser = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getLoginIdAsLong()).one(); if (StrUtil.isBlank(sysUser.getPhone())) { - throw new ApiNotPrintException("账号未绑定手机号"); + throw new CzgException("账号未绑定手机号"); } Object value = redisService.get(RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type); return code.equals(value); diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java index 7631e30f5..20a47a604 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java @@ -6,15 +6,13 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson2.JSONArray; import com.czg.account.dto.freeding.FreeDineConfigEditDTO; import com.czg.account.entity.FreeDineConfig; -import com.czg.account.entity.ShopConfig; import com.czg.account.service.FreeDineConfigService; import com.czg.account.service.ShopConfigService; import com.czg.account.vo.FreeDineConfigVO; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.service.account.mapper.FreeDineConfigMapper; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; -import jakarta.annotation.Resource; import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; @@ -56,7 +54,7 @@ public class FreeDineConfigServiceImpl extends ServiceImpl productIdList) { long layOutCount = padLayoutService.count(new QueryWrapper().eq(PadLayout::getId, padLayoutId).eq(PadLayout::getIsDel, 0)); if (layOutCount == 0) { - throw new ApiNotPrintException("pad布局不存在"); + throw new CzgException("pad布局不存在"); } if (productIdList != null && !productIdList.isEmpty()) { long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList)); if (proCount != productIdList.size()) { - throw new ApiNotPrintException("存在错误商品id"); + throw new CzgException("存在错误商品id"); } } } @@ -188,7 +185,7 @@ public class PadProdServiceImpl implements PadProdService { public Boolean del(Long shopId, PadDetailDelDTO delDTO) { PadProductCategory category = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, delDTO.getId())); if (category == null) { - throw new ApiNotPrintException("pad商品不存在"); + throw new CzgException("pad商品不存在"); } padProductCategoryService.removeById(delDTO.getId()); diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/PrintMachineServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/PrintMachineServiceImpl.java index 0b1736465..8eed6b5ce 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/PrintMachineServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/PrintMachineServiceImpl.java @@ -7,7 +7,7 @@ import com.czg.account.dto.print.PrinterAddDTO; import com.czg.account.dto.print.PrinterEditDTO; import com.czg.account.entity.PrintMachine; import com.czg.account.service.PrintMachineService; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.service.account.mapper.PrintMachineMapper; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; @@ -27,13 +27,13 @@ public class PrintMachineServiceImpl extends ServiceImpl i @Override @Cacheable(key = "#id") - public ShopInfo getById(Serializable id) throws ApiNotPrintException { + public ShopInfo getById(Serializable id) throws CzgException { ShopInfo shopInfo = super.getById(id); if(shopInfo == null){ - throw new ApiNotPrintException("店铺不存在"); + throw new CzgException("店铺不存在"); } ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId()); BeanUtil.copyProperties(shopConfig, shopInfo); @@ -95,13 +94,13 @@ public class ShopInfoServiceImpl extends ServiceImpl i private ShopInfo getShopInfo(Long shopId) { ShopInfo shopInfo = getById(shopId); if (shopInfo == null) { - throw new ApiNotPrintException("店铺不存在"); + throw new CzgException("店铺不存在"); } if (shopInfo.getExpireTime() != null && (DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) { - throw new ApiNotPrintException("店铺已过期,请联系商家"); + throw new CzgException("店铺已过期,请联系商家"); } if (StatusEnum.DISABLE.value() == shopInfo.getOnSale() || shopInfo.getStatus() != StatusEnum.ENABLED.value()) { - throw new ApiNotPrintException("店铺已停业,请联系商家"); + throw new CzgException("店铺已停业,请联系商家"); } shopInfo.setBookingSms(null); @@ -177,7 +176,7 @@ public class ShopInfoServiceImpl extends ServiceImpl i } shopInfoAddDTO.setPhone(shopInfoAddDTO.getPhone().trim()); if (StrUtil.isBlank(shopInfoAddDTO.getPhone())) { - throw new ApiNotPrintException("请输入手机号"); + throw new CzgException("请输入手机号"); } long count = sysUserService.queryChain().eq(SysUser::getAccount, shopInfoAddDTO.getAccountName()).count(); if (count > 0) { @@ -293,7 +292,7 @@ public class ShopInfoServiceImpl extends ServiceImpl i String key = "%s%s:%s".formatted(RedisCst.SMS_CODE, shopInfo.getPhone(), "editShopInfoOpePwd"); Object val = redisService.get(key); if (val instanceof String code && !shopInfoEditDTO.getCode().equals(code)) { - throw new ApiNotPrintException("验证码错误"); + throw new CzgException("验证码错误"); } shopInfo.setOperationPwd(SecureUtil.md5(shopInfoEditDTO.getOperationPwd())); @@ -325,11 +324,11 @@ public class ShopInfoServiceImpl extends ServiceImpl i public ShopDetailDTO detail(Long id) { ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one(); if (shopInfo == null) { - throw new ApiNotPrintException("店铺信息不存在"); + throw new CzgException("店铺信息不存在"); } if (!StpKit.USER.isAdmin() && !Objects.equals(StpKit.USER.getShopId(), shopInfo.getId())) { - throw new ApiNotPrintException("店铺信息不存在"); + throw new CzgException("店铺信息不存在"); } ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId()); if (shopConfig == null) { @@ -348,11 +347,11 @@ public class ShopInfoServiceImpl extends ServiceImpl i public ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState) { ShopTable shopTable = shopTableService.queryChain().eq(ShopTable::getTableCode, tableCode).one(); if (shopTable == null) { - throw new ApiNotPrintException("错误的台桌码"); + throw new CzgException("错误的台桌码"); } if (checkState && !shopTable.canUseByStatus()) { - throw new ApiNotPrintException("台桌状态不可用"); + throw new CzgException("台桌状态不可用"); } ShopInfo shopInfo = getShopInfo(shopTable.getShopId()); double distance = 0; diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPayTypeServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPayTypeServiceImpl.java index 2647bcd22..8512aaa18 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPayTypeServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPayTypeServiceImpl.java @@ -3,8 +3,7 @@ package com.czg.service.account.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; import com.czg.account.dto.ShopPayTypeDTO; -import com.czg.exception.ApiNotPrintException; -import com.czg.resp.CzgResult; +import com.czg.exception.CzgException; import com.czg.sa.StpKit; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; @@ -14,9 +13,7 @@ import com.czg.service.account.mapper.ShopPayTypeMapper; import org.springframework.stereotype.Service; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * 店铺支付类型 服务层实现。 @@ -65,7 +62,7 @@ public class ShopPayTypeServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("支付方式或支付名称已存在"); + throw new CzgException("支付方式或支付名称已存在"); } ShopPayType payType = BeanUtil.copyProperties(shopPayType, ShopPayType.class); @@ -81,7 +78,7 @@ public class ShopPayTypeServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("支付名称已存在"); + throw new CzgException("支付名称已存在"); } } @@ -90,7 +87,7 @@ public class ShopPayTypeServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("支付方式已存在"); + throw new CzgException("支付方式已存在"); } } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPushOpenIdServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPushOpenIdServiceImpl.java index d783f268c..709feac76 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPushOpenIdServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPushOpenIdServiceImpl.java @@ -3,7 +3,7 @@ package com.czg.service.account.service.impl; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.czg.account.dto.msg.ShopPushOpenIdEditDTO; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.utils.PageUtil; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; @@ -35,7 +35,7 @@ public class ShopPushOpenIdServiceImpl extends ServiceImpl implements ShopShareService{ -// @Resource -// private ShopCouponService shopCouponService; -// @Resource -// private ShopShareRecordMapper shopShareRecordMapper; -// -// @Override -// public ShopShareVO get(Long shopId) { -// ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId)); -// ShopShareVO shopShareVO = new ShopShareVO(); -// if (shopShare != null) { -// BeanUtil.copyProperties(shopShare, shopShareVO); -// if (StrUtil.isNotBlank(shopShare.getRewardCoupon())) { -//// shopShareVO.setRewardCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getRewardCoupon())))); -// shopShareVO.setRewardCouponList(JSONArray.parseArray(shopShare.getRewardCoupon(), ShopShareCouponDTO.class)); -// } -// -// if (StrUtil.isNotBlank(shopShare.getNewCoupon())) { -//// shopShareVO.setNewCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getNewCoupon())))); -// shopShareVO.setNewCouponList(JSONArray.parseArray(shopShare.getNewCoupon(), ShopShareCouponDTO.class)); -// } -// } -// return shopShareVO; -// } -// -// @Override -// public Boolean add(Long shopId, ShopShareDTO shopShareDTO) { -// ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId)); -// if (shopShare == null) { -// shopShare = new ShopShareVO(); -// shopShare.setShopId(shopId); -// } -// -// if (shopShareDTO.getNewCouponList() != null && !shopShareDTO.getNewCouponList().isEmpty()) { -// long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getNewCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId)); -// if (count != shopShareDTO.getNewCouponList().size()) { -// throw new ApiNotPrintException("优惠券不存在"); -// } -// shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponList())); -// } -// -// if (shopShareDTO.getRewardCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) { -// long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getRewardCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId)); -// if (count != shopShareDTO.getRewardCouponList().size()) { -// throw new ApiNotPrintException("优惠券不存在"); -// } -// shopShare.setRewardCoupon(JSONArray.toJSONString(shopShareDTO.getRewardCouponList())); -// } -// BeanUtil.copyProperties(shopShareDTO, shopShare); -// return saveOrUpdate(shopShare); -// } -// -// @Override -// public Page recordPage(Long shopId, String key, Integer status) { -// Page page = PageUtil.buildPage(); -// PageHelper.startPage(Math.toIntExact(page.getPageNumber()), Math.toIntExact(page.getPageSize())); -// return PageUtil.convert(new PageInfo<>(shopShareRecordMapper.getRecord(shopId, key, status))); -// } -//} diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopSongServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopSongServiceImpl.java index 0e4a4dc42..76008dd58 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopSongServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopSongServiceImpl.java @@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import com.czg.account.dto.song.ShopSongAddDTO; import com.czg.account.dto.song.ShopSongEditDTO; import com.czg.config.RedisCst; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.sa.StpKit; import com.czg.service.RedisService; import com.mybatisflex.core.query.QueryWrapper; @@ -16,8 +16,6 @@ import jakarta.annotation.Resource; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.stereotype.Service; -import java.util.Map; - /** * 点歌-歌曲表 服务层实现。 * @@ -40,7 +38,7 @@ public class ShopSongServiceImpl extends ServiceImpl i public Boolean edit(Long shopId, ShopSongEditDTO shopSongEditDTO) { ShopSong shopSong = getOne(new QueryWrapper().eq(ShopSong::getShopId, StpKit.USER.getShopId()).eq(ShopSong::getId, shopSongEditDTO.getId())); if (shopSong == null) { - throw new ApiNotPrintException("歌曲列表不存在"); + throw new CzgException("歌曲列表不存在"); } BeanUtil.copyProperties(shopSongEditDTO, shopSong); diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopStaffPagePermissionServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopStaffPagePermissionServiceImpl.java index af5ec7916..31204eb69 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopStaffPagePermissionServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopStaffPagePermissionServiceImpl.java @@ -4,7 +4,7 @@ import com.czg.account.dto.pagepath.PagePathPermissionAddDTO; import com.czg.account.entity.ShopPagePath; import com.czg.account.entity.ShopStaff; import com.czg.account.service.ShopPagePathService; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.service.account.mapper.ShopStaffMapper; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; @@ -15,10 +15,8 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.Map; import java.util.Set; -import java.util.stream.Collector; import java.util.stream.Collectors; /** @@ -39,13 +37,13 @@ public class ShopStaffPagePermissionServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("此账户名已存在"); + throw new CzgException("此账户名已存在"); } sysUser.setAccount(accountName); } @@ -125,7 +124,7 @@ public class ShopStaffServiceImpl extends ServiceImpl shopPermissionIds) { long count = shopPermissionService.queryChain().in(ShopPermission::getId, new HashSet<>(shopPermissionIds)).count(); if (count != shopPermissionIds.size()) { - throw new ApiNotPrintException("存在不存在的权限"); + throw new CzgException("存在不存在的权限"); } ArrayList staffPermissions = new ArrayList<>(); @@ -160,7 +159,7 @@ public class ShopStaffServiceImpl extends ServiceImpl existisList = queryChain().eq(ShopTable::getShopId, shopId).like(ShopTable::getName, shopTableAddDTO.getSign()).list().stream().map(ShopTable::getName).toList(); @@ -106,7 +106,7 @@ public class ShopTableServiceImpl extends ServiceImpl map) { if (count > 100) { - throw new ApiNotPrintException("桌码生成失败"); + throw new CzgException("桌码生成失败"); } String tableCode = "40" + shopId % 10 + id % 10 + RandomUtil.randomNumbers(7); if (map.containsKey(tableCode)) { @@ -241,22 +241,22 @@ public class ShopTableServiceImpl extends ServiceImpl i private ShopUser getUserInfo(Long shopUserId) { ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one(); if (shopUser == null) { - throw new ApiNotPrintException("用户信息不存在"); + throw new CzgException("用户信息不存在"); } return shopUser; } @@ -128,7 +128,7 @@ public class ShopUserServiceImpl extends ServiceImpl i flag = mapper.incrAccount(shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), shopUserEditDTO.getMoney()); } if (flag == 0) { - throw new ApiNotPrintException("增减用户余额操作失败"); + throw new CzgException("增减用户余额操作失败"); } if (userInfo.getAmount() == null) { diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysMenuServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysMenuServiceImpl.java index 6776b85bd..d6bf557a2 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysMenuServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysMenuServiceImpl.java @@ -7,19 +7,16 @@ import com.alibaba.fastjson2.JSONObject; import com.czg.account.dto.menu.MenuAddDTO; import com.czg.account.dto.menu.MenuEditDTO; import com.czg.account.entity.CashMenu; -import com.czg.account.entity.ShopInfo; import com.czg.account.entity.SysMenu; -import com.czg.account.entity.SysUsersRoles; import com.czg.account.service.CashMenuService; import com.czg.account.service.ShopInfoService; import com.czg.account.service.SysMenuService; import com.czg.account.vo.MenuVO; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.sa.StpKit; import com.czg.service.account.mapper.SysMenuMapper; import com.czg.service.account.mapper.SysUsersRolesMapper; import com.mybatisflex.core.query.QueryWrapper; -import com.mybatisflex.core.row.DbChain; import com.mybatisflex.spring.service.impl.ServiceImpl; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; @@ -99,15 +96,15 @@ public class SysMenuServiceImpl extends ServiceImpl impl public Boolean add(MenuAddDTO menuAddDTO) { checkExIsis(menuAddDTO.getTitle(), null); if (menuAddDTO.getType() == 2 && menuAddDTO.getPid() == null) { - throw new ApiNotPrintException("二级菜单必须传递父id"); + throw new CzgException("二级菜单必须传递父id"); } if (menuAddDTO.getType() == 3 && menuAddDTO.getPid() == null) { - throw new ApiNotPrintException("父id不为空"); + throw new CzgException("父id不为空"); } if (menuAddDTO.getType() == 3 && menuAddDTO.getPermission() == null) { - throw new ApiNotPrintException("权限不为空"); + throw new CzgException("权限不为空"); } SysMenu sysMenu = BeanUtil.copyProperties(menuAddDTO, SysMenu.class); if (menuAddDTO.getApiInfo() != null && !menuAddDTO.getApiInfo().isEmpty()) { @@ -121,7 +118,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl checkExIsis(menuEditDTO.getTitle(), menuEditDTO.getId()); SysMenu menu = getById(menuEditDTO.getId()); if (menu == null) { - throw new ApiNotPrintException("菜单不存在"); + throw new CzgException("菜单不存在"); } BeanUtil.copyProperties(menuEditDTO, menu); if (menuEditDTO.getApiInfo() != null && !menuEditDTO.getApiInfo().isEmpty()) { @@ -139,7 +136,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl // queryWrapper.eq(SysMenu::getTitle, title); // long count = count(queryWrapper); // if (count > 0) { -// throw new ApiNotPrintException("名称已存在"); +// throw new CzgException("名称已存在"); // } } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysRoleServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysRoleServiceImpl.java index 049604f09..bc33d9e8f 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysRoleServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysRoleServiceImpl.java @@ -14,7 +14,7 @@ import com.czg.account.service.CashMenuService; import com.czg.account.service.SysMenuService; import com.czg.account.service.SysRoleService; import com.czg.account.service.SysRolesMenusService; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.sa.StpKit; import com.czg.service.account.mapper.SysRoleMapper; import com.mybatisflex.core.paginate.Page; @@ -25,7 +25,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; -import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; import static com.mybatisflex.core.query.QueryMethods.column; @@ -120,7 +119,7 @@ public class SysRoleServiceImpl extends ServiceImpl imp public List getRoleMenu(long userId, Integer id, Integer type) { SysRole role = queryChain().eq(SysRole::getId, id).eq(SysRole::getCreateUserId, userId).one(); if (role == null) { - throw new ApiNotPrintException("角色不存在"); + throw new CzgException("角色不存在"); } return sysRolesMenusService.queryChain().eq(SysRolesMenus::getRoleId, id).eq(SysRolesMenus::getType, type).list().stream().map(SysRolesMenus::getMenuId).toList(); @@ -191,7 +190,7 @@ public class SysRoleServiceImpl extends ServiceImpl imp public Boolean editPermission(long userId, RolePermissionDTO rolePermissionDTO) { long count = count(new QueryWrapper().eq(SysRole::getId, rolePermissionDTO.getRoleId()).eq(SysRole::getCreateUserId, userId)); if (count == 0) { - throw new ApiNotPrintException("角色不存在"); + throw new CzgException("角色不存在"); } sysRolesMenusService.updateChain().eq(SysRolesMenus::getRoleId, rolePermissionDTO.getRoleId()).remove(); @@ -212,7 +211,7 @@ public class SysRoleServiceImpl extends ServiceImpl imp .eq(SysRole::getShopId, StpKit.USER.getShopId()) .count(); if (roleCount > 0) { - throw new ApiNotPrintException("此角色名称已存在"); + throw new CzgException("此角色名称已存在"); } SysRole sysRole = new SysRole(); @@ -236,7 +235,7 @@ public class SysRoleServiceImpl extends ServiceImpl imp return save; } - throw new ApiNotPrintException("保存失败"); + throw new CzgException("保存失败"); } @Override @@ -244,13 +243,13 @@ public class SysRoleServiceImpl extends ServiceImpl imp public Boolean edit(RoleEditDTO roleEditDTO) { SysRole role = queryChain().eq(SysRole::getId, roleEditDTO.getId()).eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong()).one(); if (role == null) { - throw new ApiNotPrintException("角色不存在"); + throw new CzgException("角色不存在"); } long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId()) .eq(SysRole::getShopId, StpKit.USER.getShopId()).count(); if (roleCount > 0) { - throw new ApiNotPrintException("此角色名称已存在"); + throw new CzgException("此角色名称已存在"); } BeanUtil.copyProperties(roleEditDTO, role); @@ -268,7 +267,7 @@ public class SysRoleServiceImpl extends ServiceImpl imp } return true; } - throw new ApiNotPrintException("保存失败"); + throw new CzgException("保存失败"); } public static void main(String[] args) { diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java index 59859e143..c9155c0a5 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java @@ -14,7 +14,6 @@ import com.czg.account.entity.SysUser; import com.czg.account.entity.SysUsersRoles; import com.czg.account.service.SysUserService; import com.czg.account.vo.SysUserDetailVO; -import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException; import com.czg.sa.StpKit; import com.czg.service.RedisService; @@ -57,7 +56,7 @@ public class SysUserServiceImpl extends ServiceImpl impl public SysUser addUser(String nickname, String accountName, String accountPwd, String phone, Long roleId) { long count = queryChain().eq(SysUser::getAccount, accountName).count(); if (count > 0) { - throw new ApiNotPrintException("账号已存在"); + throw new CzgException("账号已存在"); } // 添加系统账号 SysUser sysUser = new SysUser(); @@ -111,7 +110,7 @@ public class SysUserServiceImpl extends ServiceImpl impl if (StrUtil.isNotBlank(sysUserEditDTO.getAccount())) { long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserEditDTO.getAccount()).ne(SysUser::getId, sysUserEditDTO.getId())); if (count > 0) { - throw new ApiNotPrintException("账号已存在"); + throw new CzgException("账号已存在"); } } @@ -135,7 +134,7 @@ public class SysUserServiceImpl extends ServiceImpl impl public Boolean delete(Integer id) { SysUser sysUser = getById(id); if (sysUser == null) { - throw new ApiNotPrintException("用户不存在"); + throw new CzgException("用户不存在"); } boolean remove = remove(new QueryWrapper().eq(SysUser::getId, id)); if (remove) { @@ -149,7 +148,7 @@ public class SysUserServiceImpl extends ServiceImpl impl public Boolean add(SysUserAddDTO sysUserAddDTO) { long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserAddDTO.getAccount())); if (count > 0) { - throw new ApiNotPrintException("账号已存在"); + throw new CzgException("账号已存在"); } SysUser sysUser = BeanUtil.copyProperties(sysUserAddDTO, SysUser.class); @@ -214,11 +213,11 @@ public class SysUserServiceImpl extends ServiceImpl impl if (StrUtil.isNotBlank(sysUserEditPwdDTO.getOriginalPassword()) && !sysUser.getPassword().equals(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getOriginalPassword()))) { - throw new ApiNotPrintException("原密码不正确"); + throw new CzgException("原密码不正确"); } if (!sysUserEditPwdDTO.getPassword().equals(sysUserEditPwdDTO.getCheckPassword())) { - throw new ApiNotPrintException("两次密码不一致"); + throw new CzgException("两次密码不一致"); } sysUser.setPassword(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getPassword())); diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UShopUserServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UShopUserServiceImpl.java index 1d4e747f2..1aa868bb2 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UShopUserServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UShopUserServiceImpl.java @@ -11,7 +11,7 @@ import com.czg.account.dto.shopuser.ShopUserVipCardDTO; import com.czg.account.entity.*; import com.czg.account.service.*; import com.czg.config.RedisCst; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.market.entity.MkShopCouponRecord; import com.czg.market.service.MkShopCouponRecordService; import com.czg.market.service.TbMemberConfigService; @@ -30,10 +30,8 @@ import com.mybatisflex.core.query.QueryWrapper; import jakarta.annotation.Resource; import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.math.BigDecimal; import java.util.List; @@ -194,7 +192,7 @@ public class UShopUserServiceImpl implements UShopUserService { ShopUser shopUser = shopUserService.getShopUserInfo(mainId, userId); UserInfo userInfo = userInfoService.getById(userId); if (userInfo == null) { - throw new ApiNotPrintException("用户信息不存在"); + throw new CzgException("用户信息不存在"); } long couponNum = 0; diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java index 10d017503..e6ac73317 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java @@ -12,7 +12,6 @@ import com.czg.account.service.UserAuthorizationService; import com.czg.account.service.UserInfoService; import com.czg.enums.StatusEnum; import com.czg.enums.UserAuthSourceEnum; -import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException; import com.czg.sa.MyStpLogic; import com.czg.sa.StpKit; @@ -80,7 +79,7 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService { if (jsonObject.containsKey("phoneNumber")) { mobile = jsonObject.getString("phoneNumber"); } else { - throw new ApiNotPrintException("手机号获取失败"); + throw new CzgException("手机号获取失败"); } } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserInfoServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserInfoServiceImpl.java index 62be361ae..6cf8a5c9a 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserInfoServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserInfoServiceImpl.java @@ -12,7 +12,6 @@ import com.czg.account.entity.ShopUser; import com.czg.account.entity.UserInfo; import com.czg.account.service.UserInfoService; import com.czg.config.RedisCst; -import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException; import com.czg.service.RedisService; import com.czg.service.account.mapper.ShopUserMapper; @@ -46,7 +45,7 @@ public class UserInfoServiceImpl extends ServiceImpl i public UserInfoDTO getInfo(long userInfoId) { UserInfo userInfo = queryChain().eq(UserInfo::getId, userInfoId).one(); if (userInfo == null) { - throw new ApiNotPrintException("用户信息不存在"); + throw new CzgException("用户信息不存在"); } UserInfoAssetsSummaryDTO assetsSummaryDTO = shopUserMapper.selectAssetsSummary(userInfoId); @@ -72,7 +71,7 @@ public class UserInfoServiceImpl extends ServiceImpl i public Boolean getCode(Long userId, String type) { UserInfo userInfo = queryChain().eq(UserInfo::getId, userId).one(); if (StrUtil.isBlank(userInfo.getPhone())) { - throw new ApiNotPrintException("账号未绑定手机号"); + throw new CzgException("账号未绑定手机号"); } int code = RandomUtil.randomInt(100000, 1000000); redisService.set("%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), type), String.valueOf(code), 300); @@ -86,7 +85,7 @@ public class UserInfoServiceImpl extends ServiceImpl i String key = "%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), "wxMiniPwd"); Object val = redisService.get(key); if (val instanceof String code && !userInfoPwdEditDTO.getCode().equals(code)) { - throw new ApiNotPrintException("验证码错误"); + throw new CzgException("验证码错误"); } if (StrUtil.isNotBlank(userInfoPwdEditDTO.getCheckPayPwd())) { diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/util/FunUtil.java b/cash-service/account-service/src/main/java/com/czg/service/account/util/FunUtil.java index dd0690226..c7d7f2d62 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/util/FunUtil.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/util/FunUtil.java @@ -1,16 +1,12 @@ package com.czg.service.account.util; -import com.czg.exception.ApiNotPrintException; -import com.czg.service.RedisService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.stereotype.Component; import java.util.Collections; -import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Function; diff --git a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeDiscountServiceImpl.java b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeDiscountServiceImpl.java index 626afa7b1..acb0ab4ad 100644 --- a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeDiscountServiceImpl.java +++ b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeDiscountServiceImpl.java @@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSONArray; import com.czg.constant.TableValueConstant; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.market.dto.MkConsumeDiscountDTO; import com.czg.market.entity.MkConsumeDiscountRandom; import com.czg.market.vo.MkConsumeDiscountVO; @@ -55,26 +55,26 @@ public class MkConsumeDiscountServiceImpl extends ServiceImpl randomList = consumeDiscountVO.getRandomDiscountList(); if ("RANDOM".equals(consumeDiscountVO.getDiscountType()) && (randomList == null || randomList.isEmpty()) ){ - throw new ApiNotPrintException("随机立减配置错误"); + throw new CzgException("随机立减配置错误"); } ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId); boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId()) @@ -117,7 +115,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl randomList = consumeDiscountVO.getRandomDiscountList(); if (randomList == null || randomList.isEmpty()) { - throw new ApiNotPrintException("随机立减配置错误"); + throw new CzgException("随机立减配置错误"); } // 生成 1~100 的随机数 @@ -175,7 +173,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl { if (item.getReward() == null && (item.getCouponList() == null || item.getCouponList().isEmpty())) { - throw new ApiNotPrintException("方案列表中赠送成长值和赠送优惠券不能同时为空"); + throw new CzgException("方案列表中赠送成长值和赠送优惠券不能同时为空"); } }); memberConfig.setConfigList(JSONObject.toJSONString(memberDTO.getConfigList())); @@ -172,14 +169,14 @@ public class TbMemberConfigServiceImpl extends ServiceImpl conditionList = CollUtil.newArrayList(conditionMap); memberDTO.getConditionList().forEach(item -> { if (!conditionMap.contains(item.getCode())) { - throw new ApiNotPrintException("条件列表中code值错误"); + throw new CzgException("条件列表中code值错误"); } }); // conditionList.forEach(item -> { @@ -205,21 +202,21 @@ public class TbMemberConfigServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("会员等级名称已存在"); + throw new CzgException("会员等级名称已存在"); } MemberLevelConfig lastConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId) .lt(MemberLevelConfig::getId, levelDTO.getId()) .limit(1).orderBy(MemberLevelConfig::getExperienceValue, true).ne(MemberLevelConfig::getId, levelDTO.getId())); if (lastConfig == null && levelDTO.getExperienceValue() > 0) { - throw new ApiNotPrintException("1级时本字段必须为0"); + throw new CzgException("1级时本字段必须为0"); } else if (lastConfig != null && levelDTO.getExperienceValue() <= lastConfig.getExperienceValue()) { - throw new ApiNotPrintException("会员等级经验值必须大于上一等级经验值"); + throw new CzgException("会员等级经验值必须大于上一等级经验值"); } if (levelDTO.getIsCycleReward() == 1) { if (levelDTO.getCycleRewardPoints() == null && (levelDTO.getCycleRewardCouponList() == null || levelDTO.getCycleRewardCouponList().isEmpty())) { - throw new ApiNotPrintException("周期奖励成长值和优惠券不能同时为空"); + throw new CzgException("周期奖励成长值和优惠券不能同时为空"); } ValidatorUtil.validateEntity(levelDTO, MemberLevelCycleRewardGroup.class); @@ -242,7 +239,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl new ApiNotPrintException("会员等级不存在")); + Optional.ofNullable(levelConfig).orElseThrow(() -> new CzgException("会员等级不存在")); Integer oldVal = levelConfig.getExperienceValue(); checkLevelDto(shopId, levelDTO); BeanUtil.copyProperties(levelDTO, levelConfig); @@ -493,7 +490,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl 0) { return orderDetailService.removeById(orderDetail.getId()); } - throw new ApiNotPrintException("操作失败"); + throw new CzgException("操作失败"); } @Override diff --git a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopStorageGoodServiceImpl.java b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopStorageGoodServiceImpl.java index 8a514ca83..48de77784 100644 --- a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopStorageGoodServiceImpl.java +++ b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopStorageGoodServiceImpl.java @@ -1,18 +1,13 @@ package com.czg.service.product.service.impl; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.util.StrUtil; +import com.czg.exception.CzgException; import com.czg.product.dto.storage.ShopStorageGoodDTO; import com.czg.product.entity.Product; import com.czg.product.entity.ShopProdUnit; -import com.czg.product.entity.ShopStorage; -import com.czg.exception.ApiNotPrintException; import com.czg.product.service.ProductService; import com.czg.product.service.ShopProdUnitService; -import com.czg.sa.StpKit; import com.czg.service.product.mapper.ShopStorageGoodMapper; -import com.czg.utils.PageUtil; -import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; import com.czg.product.entity.ShopStorageGood; @@ -39,7 +34,7 @@ public class ShopStorageGoodServiceImpl extends ServiceImpl getRecord(Long shopId, Integer id) { ShopStorage shopStorage = getOne(new QueryWrapper().eq(ShopStorage::getShopId, shopId).eq(ShopStorage::getId, id)); if (shopStorage == null) { - throw new ApiNotPrintException("存酒记录不存在"); + throw new CzgException("存酒记录不存在"); } return storageRecordService.list(new QueryWrapper().eq(ShopStorageRecord::getStorageId, id)); } diff --git a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopVendorServiceImpl.java b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopVendorServiceImpl.java index f1cbf4db6..f1300b38b 100644 --- a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopVendorServiceImpl.java +++ b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopVendorServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.czg.enums.DeleteEnum; -import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException; import com.czg.product.dto.ShopVendorBillPayDTO; import com.czg.product.dto.ShopVendorDTO; @@ -151,11 +150,11 @@ public class ShopVendorServiceImpl extends ServiceImpl 0) { - throw new ApiNotPrintException("付款金额不应超过待付款金额"); + throw new CzgException("付款金额不应超过待付款金额"); } ConsPayRecord consPayRecord = BeanUtil.copyProperties(payDTO, ConsPayRecord.class); diff --git a/cash-service/system-service/src/main/java/com/czg/service/system/service/impl/SmsServiceImpl.java b/cash-service/system-service/src/main/java/com/czg/service/system/service/impl/SmsServiceImpl.java index 73ca4070f..c4e71de2b 100644 --- a/cash-service/system-service/src/main/java/com/czg/service/system/service/impl/SmsServiceImpl.java +++ b/cash-service/system-service/src/main/java/com/czg/service/system/service/impl/SmsServiceImpl.java @@ -3,7 +3,7 @@ package com.czg.service.system.service.impl; import com.aliyun.dysmsapi20170525.Client; import com.aliyun.dysmsapi20170525.models.SendSmsResponse; import com.aliyun.teaopenapi.models.Config; -import com.czg.exception.ApiNotPrintException; +import com.czg.exception.CzgException; import com.czg.resp.CzgResult; import com.czg.system.dto.SysParamsDTO; import com.czg.system.service.SmsService; @@ -11,10 +11,7 @@ import com.czg.system.service.SysParamsService; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; -import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; /** * 验证码工具类 @@ -74,7 +71,7 @@ public class SmsServiceImpl implements SmsService { log.info("短信发送请求参数: 手机号: {}, 短信模板: {}, 短信内容: {}", phone, templateCode, checkCode); SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); if (sendSmsResponse.getStatusCode() != 200) { - throw new ApiNotPrintException("短信发送失败"); + throw new CzgException("短信发送失败"); } }catch (Exception e) { log.info("发送短信失败", e);