支付方式接口完善
This commit is contained in:
parent
7499cee35e
commit
97b145e0f6
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public class ShopPayTypeDTO implements Serializable {
|
|||
*/
|
||||
private Integer isShowShortcut;
|
||||
private String payName;
|
||||
private String payType;
|
||||
|
||||
/**
|
||||
* 0允许退款 1-不允许退款
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
package com.czg.account.dto.paytype;
|
||||
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
|
@ -24,10 +27,12 @@ public class ShopPayTypeAddDTO {
|
|||
/**
|
||||
* 支付类型 cash,alipay,weixin,deposit,arrears,virtual,member-account
|
||||
*/
|
||||
@NotEmpty(message = "支付方式不为空", groups = InsertGroup.class)
|
||||
private String payType;
|
||||
/**
|
||||
* 支付名称
|
||||
*/
|
||||
@NotEmpty(message = "支付名称不为空", groups = InsertGroup.class)
|
||||
private String payName;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.ShopPayTypeDTO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopPayType;
|
||||
|
||||
|
|
@ -17,4 +18,5 @@ public interface ShopPayTypeService extends IService<ShopPayType> {
|
|||
|
||||
Boolean add(Long shopId, ShopPayType shopPayType);
|
||||
|
||||
Boolean edit(Long shopId, ShopPayTypeDTO shopPayTypeDTO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
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.sa.StpKit;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
|
|
@ -58,4 +61,28 @@ public class ShopPayTypeServiceImpl extends ServiceImpl<ShopPayTypeMapper, ShopP
|
|||
payType.setShopId(shopId);
|
||||
return save(payType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean edit(Long shopId, ShopPayTypeDTO shopPayTypeDTO) {
|
||||
ShopPayType shopPayType = BeanUtil.copyProperties(shopPayTypeDTO, ShopPayType.class);
|
||||
if (StrUtil.isNotBlank(shopPayTypeDTO.getPayName())) {
|
||||
long count = count(new QueryWrapper().eq(ShopPayType::getShopId, shopId)
|
||||
.eq(ShopPayType::getPayName, shopPayTypeDTO.getPayName())
|
||||
.ne(ShopPayType::getId, shopPayTypeDTO.getId()));
|
||||
if (count > 0) {
|
||||
throw new ApiNotPrintException("支付名称已存在");
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(shopPayTypeDTO.getPayType())) {
|
||||
long count = count(new QueryWrapper().eq(ShopPayType::getShopId, shopId)
|
||||
.eq(ShopPayType::getPayType, shopPayTypeDTO.getPayType())
|
||||
.ne(ShopPayType::getId, shopPayTypeDTO.getId()));
|
||||
if (count > 0) {
|
||||
throw new ApiNotPrintException("支付方式已存在");
|
||||
}
|
||||
}
|
||||
|
||||
return update(shopPayType, new QueryWrapper().eq(ShopPayType::getId, shopPayTypeDTO.getId()).eq(ShopPayType::getShopId, shopId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue