支付方式修改接口完善

This commit is contained in:
张松
2025-03-04 17:26:01 +08:00
parent 615f32d32d
commit 430a3825f5

View File

@@ -6,6 +6,7 @@ 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.mybatisflex.core.query.QueryWrapper;
@@ -49,6 +50,14 @@ public class ShopPayTypeController {
@PutMapping
public CzgResult<Boolean> edit(@RequestBody ShopPayTypeDTO shopPayTypeDTO) {
ShopPayType shopPayType = BeanUtil.copyProperties(shopPayTypeDTO, ShopPayType.class);
long count = shopPayTypeService.count(new QueryWrapper().eq(ShopPayType::getShopId, StpKit.USER.getShopId()).and(r -> {
r.eq(ShopPayType::getPayType, shopPayType.getPayType()).or(r1 -> {
r1.eq(ShopPayType::getPayName, shopPayType.getPayName());
});
}));
if (count > 0) {
throw new ApiNotPrintException("支付方式或支付名称已存在");
}
return CzgResult.success(shopPayTypeService.update(shopPayType, new QueryWrapper().eq(ShopPayType::getId, shopPayTypeDTO.getId()).eq(ShopPayType::getShopId, StpKit.USER.getShopId())));
}