Merge remote-tracking branch 'origin/master'

This commit is contained in:
wangw 2025-03-05 09:21:48 +08:00
commit 004059fd16
12 changed files with 142 additions and 11 deletions

View File

@ -1,15 +1,19 @@
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;
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;
@ -48,8 +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);
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));
}
/**
@ -57,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));
}

View File

@ -84,8 +84,15 @@ public class ShopTableController {
*/
@SaAdminCheckPermission("shopTable:detail")
@GetMapping("/detail")
public CzgResult<ShopTable> detail(@RequestParam Long id) {
return CzgResult.success(shopTableService.getOne(new QueryWrapper().eq(ShopTable::getId, id).eq(ShopTable::getShopId, StpKit.USER.getShopId())));
public CzgResult<ShopTable> detail(Long id, String tableCode) {
if (id == null && StrUtil.isBlank(tableCode)) {
return CzgResult.failure("id和桌码不能同时为空");
}
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopTable::getId, id).eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, id);
if (StrUtil.isNotBlank(tableCode)) {
queryWrapper.eq(ShopTable::getTableCode, tableCode);
}
return CzgResult.success(shopTableService.getOne(queryWrapper));
}

View File

@ -28,15 +28,15 @@ dubbo:
application:
name: account-server
qos-port: 22221
# qos-enable: true
qos-enable: true
registry:
address: nacos://121.40.109.122:8848 # Nacos 服务地址
group: server-dev
namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
# namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
protocol:
port: 9101
threads: 20
threadpool: fixed
# threadpool: fixed
seata:

View File

@ -34,11 +34,11 @@ dubbo:
registry:
address: nacos://121.40.109.122:8848 # Nacos 服务地址
group: server-dev
namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
# namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
protocol:
port: 9401
threads: 20
threadpool: fixed
# threadpool: fixed
seata:
application-id: system-server

View File

@ -60,6 +60,12 @@
<version>1.10.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-common</artifactId>
<version>3.3.3</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -0,0 +1,61 @@
package com.czg.config;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @author GYJoker
*/
@Component
public class CzgDubboBean {
private ApplicationConfig applicationConfig;
private ProtocolConfig protocolConfig;
@Value("${dubbo.application.name}")
private String applicationName;
@Value("${dubbo.application.qos-port}")
private Integer qosPort;
@Value("${dubbo.application.qos-enable}")
private Boolean qosEnable;
@Value("${dubbo.registry.address}")
private String registryAddress;
@Value("${dubbo.registry.group}")
private String registryGroup;
@Value("${dubbo.protocol.port}")
private Integer port;
@Value("${dubbo.protocol.threads}")
private Integer threads;
public CzgDubboBean() {
applicationConfig = new ApplicationConfig();
applicationConfig.setName(applicationName);
applicationConfig.setQosPort(qosPort);
applicationConfig.setQosEnable(qosEnable);
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress(registryAddress);
registryConfig.setGroup(registryGroup);
protocolConfig = new ProtocolConfig();
protocolConfig.setPort(port);
protocolConfig.setThreads(threads);
}
public ApplicationConfig getApplicationConfig() {
return applicationConfig;
}
public ProtocolConfig getProtocolConfig() {
return protocolConfig;
}
}

View File

@ -0,0 +1,18 @@
package com.czg.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
/**
* @author GYJoker
*/
@Configuration
@DependsOn("nacosConfigProperties") // 这里假设 Nacos 的配置属性 Bean 名为 nacosConfigProperties
public class DubboConfig {
// 这里可以添加 Dubbo 相关的配置 Bean
@Bean
public CzgDubboBean czgDubboBean() {
return new CzgDubboBean();
}
}

View File

@ -33,6 +33,8 @@ public class ShopPayTypeDTO implements Serializable {
* 是否快捷展示1是0否
*/
private Integer isShowShortcut;
private String payName;
private String payType;
/**
* 0允许退款 1-不允许退款

View File

@ -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;
/**

View File

@ -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);
}

View File

@ -23,7 +23,7 @@ import java.time.LocalDateTime;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("mq_log")
@Table("tb_mq_log")
@Accessors(chain = true)
public class MqLog implements Serializable {

View File

@ -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));
}
}