支付方式接口完善

This commit is contained in:
张松
2025-03-04 17:38:09 +08:00
parent 7499cee35e
commit 97b145e0f6
5 changed files with 39 additions and 11 deletions

View File

@@ -10,8 +10,10 @@ 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;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -50,16 +52,7 @@ public class ShopPayTypeController {
@SaAdminCheckPermission(value = "shopPayType:edit", name = "支付方式编辑")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody ShopPayTypeDTO shopPayTypeDTO) {
ShopPayType shopPayType = BeanUtil.copyProperties(shopPayTypeDTO, ShopPayType.class);
if (StrUtil.isNotBlank(shopPayTypeDTO.getPayName())) {
long count = shopPayTypeService.count(new QueryWrapper().eq(ShopPayType::getShopId, StpKit.USER.getShopId())
.eq(ShopPayType::getPayName, shopPayTypeDTO.getPayName())
.ne(ShopPayType::getId, shopPayTypeDTO.getId()));
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())));
return CzgResult.success(shopPayTypeService.edit(StpKit.USER.getShopId(), shopPayTypeDTO));
}
/**
@@ -67,7 +60,7 @@ public class ShopPayTypeController {
*/
@SaAdminCheckPermission(value = "shopPayType:save", name = "支付方式添加")
@PostMapping
public CzgResult<Boolean> add(@RequestBody ShopPayTypeAddDTO shopPayTypeAddDTO) {
public CzgResult<Boolean> add(@RequestBody @Validated(InsertGroup.class) ShopPayTypeAddDTO shopPayTypeAddDTO) {
ShopPayType shopPayType = BeanUtil.copyProperties(shopPayTypeAddDTO, ShopPayType.class);
return CzgResult.success(shopPayTypeService.add(StpKit.USER.getShopId(),shopPayType));
}