package cn.com.taiji.core.entity.basic; | |||||
import javax.persistence.*; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.Size; | |||||
import cn.com.taiji.common.entity.StringPropertyUUIDEntity; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* | |||||
* | |||||
*/ | |||||
@Getter | |||||
@Setter | |||||
@Entity | |||||
@Table(name = "WX_SIGN_CHANNEL_CONFIG") | |||||
public class WxSignChannelConfig extends StringPropertyUUIDEntity { | |||||
@NotBlank | |||||
@Size(max = 11) | |||||
@Column(name = "AGENCY_ID") | |||||
private String agencyId;//渠道编号 | |||||
@NotBlank | |||||
@Size(max = 30) | |||||
@Column(name = "MCH_ID") | |||||
private String mchId;//商户号 | |||||
@NotBlank | |||||
@Size(max = 50) | |||||
@Column(name = "APP_ID") | |||||
private String appId; | |||||
@NotBlank | |||||
@Size(max = 50) | |||||
@Column(name = "SUB_APP_ID") | |||||
private String subAppId; | |||||
@NotBlank | |||||
@Size(max = 30) | |||||
@Column(name = "SUB_MCH_ID") | |||||
private String subMchId;//子商户号 | |||||
@NotBlank | |||||
@Size(max = 255) | |||||
@Column(name = "SIGN_KEY") | |||||
private String signKey;//签名密钥 | |||||
@NotBlank | |||||
@Size(max = 255) | |||||
@Column(name = "DESC") | |||||
private String desc;//描述 | |||||
@Column(name = "INSERT_TIME") | |||||
private LocalDateTime localDateTime = LocalDateTime.now(); | |||||
@Column(name = "UPDATE_TIME") | |||||
private LocalDateTime updateTime = LocalDateTime.now(); | |||||
} |
package cn.com.taiji.core.repo.jpa.basic; | |||||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||||
import cn.com.taiji.core.entity.basic.WxSignChannelConfig; | |||||
public interface WxSignChannelConfigRepo extends AbstractJpaRepo<WxSignChannelConfig, String>{ | |||||
WxSignChannelConfig findByAgencyId(String agnecyId); | |||||
} |
*/ | */ | ||||
@Api(tags = {"中心渠道管理"}) | @Api(tags = {"中心渠道管理"}) | ||||
@RestController | @RestController | ||||
@RequestMapping("/centerServiceHall") | |||||
@RequestMapping("/centerAgency") | |||||
public class CenterAgencyController extends MyValidController{ | public class CenterAgencyController extends MyValidController{ | ||||
@Autowired | @Autowired | ||||
@GetMapping(value = "/addOrUpDate") | @GetMapping(value = "/addOrUpDate") | ||||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterAgencyAddOrUpdateReqDTO reqDto) { | public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterAgencyAddOrUpdateReqDTO reqDto) { | ||||
manager.addOrUpdate(reqDto); | manager.addOrUpdate(reqDto); | ||||
return ApiResponse.success().setMessage("新增成功"); | |||||
return ApiResponse.success().setMessage("成功"); | |||||
} | } | ||||
@ApiOperation(value = "删除") | @ApiOperation(value = "删除") |
@GetMapping(value = "/addOrUpDate") | @GetMapping(value = "/addOrUpDate") | ||||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterHallAddOrUpdateReqDTO reqDto) { | public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterHallAddOrUpdateReqDTO reqDto) { | ||||
manager.addOrUpdate(reqDto); | manager.addOrUpdate(reqDto); | ||||
return ApiResponse.success().setMessage("新增成功"); | |||||
return ApiResponse.success().setMessage("成功"); | |||||
} | } | ||||
@ApiOperation(value = "删除") | @ApiOperation(value = "删除") |
package cn.com.taiji.userw.api; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.model.dao.Pagination; | |||||
import cn.com.taiji.common.web.ApiResponse; | |||||
import cn.com.taiji.userw.dto.wx.WxCarAddReqDTO; | |||||
import cn.com.taiji.userw.dto.wx.WxCarPageRequestDTO; | |||||
import cn.com.taiji.userw.dto.wx.WxCarUpdateReqDTO; | |||||
import cn.com.taiji.userw.manager.wx.WxSignChannelConfigManager; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.validation.annotation.Validated; | |||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.RequestBody; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/20 14:46 | |||||
* @Filename:WxSignConfigController | |||||
* @description: 微信车主签约配置管理 | |||||
*/ | |||||
@Api(tags = {"微信车主签约配置管理"}) | |||||
@RestController | |||||
@RequestMapping("/wxCar") | |||||
public class WxSignConfigController extends MyValidController{ | |||||
@Autowired | |||||
private WxSignChannelConfigManager manager; | |||||
@ApiOperation(value = "分页查询") | |||||
@GetMapping(value = "/page") | |||||
public ApiResponse<Pagination> page(@Validated @RequestBody WxCarPageRequestDTO reqDto) { | |||||
Pagination page = manager.page(reqDto); | |||||
return ApiResponse.of(page); | |||||
} | |||||
@ApiOperation(value = "新增") | |||||
@GetMapping(value = "/add") | |||||
public ApiResponse<?> add(@Validated @RequestBody WxCarAddReqDTO reqDto) throws ManagerException { | |||||
manager.add(reqDto); | |||||
return ApiResponse.success().setMessage("新增成功"); | |||||
} | |||||
@ApiOperation(value = "修改") | |||||
@GetMapping(value = "/update") | |||||
public ApiResponse<?> update(@Validated @RequestBody WxCarUpdateReqDTO reqDto) throws ManagerException { | |||||
manager.update(reqDto); | |||||
return ApiResponse.success().setMessage("修改成功"); | |||||
} | |||||
// @ApiOperation(value = "删除") | |||||
// @GetMapping(value = "/delete") | |||||
// public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterHallOrAgencyDeleteRequestDTO reqDto) { | |||||
// manager.delete(reqDto); | |||||
// return ApiResponse.success().setMessage("删除成功"); | |||||
// } | |||||
} |
package cn.com.taiji.userw.dto.wx; | |||||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import javax.validation.constraints.NotBlank; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/20 15:03 | |||||
* @Filename:WxCarAddOrUpdateReqDTO | |||||
* @description: 车主签约新增修改 | |||||
*/ | |||||
@Data | |||||
@ApiModel(description = "车主签约新增") | |||||
public class WxCarAddReqDTO extends AbstractBizRequestDTO { | |||||
@NotBlank | |||||
@ApiModelProperty(value = "渠道编号") | |||||
private String agencyId;//渠道编号 | |||||
@NotBlank | |||||
@ApiModelProperty(value = "商户编号") | |||||
private String mchId;//商户号 | |||||
@NotBlank | |||||
@ApiModelProperty(value = "appId") | |||||
private String appId; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "appId") | |||||
private String subAppId; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "子商户号") | |||||
private String subMchId; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "签名密钥") | |||||
private String signKey; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "描述") | |||||
private String desc;//描述 | |||||
} |
package cn.com.taiji.userw.dto.wx; | |||||
import cn.com.taiji.common.model.finals.SysFinals; | |||||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||||
import lombok.Data; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/20 14:52 | |||||
* @Filename:WxConfigPageRequestDTO | |||||
* @description: | |||||
*/ | |||||
@Data | |||||
public class WxCarPageRequestDTO extends AbstractBizRequestDTO { | |||||
private Integer pageNo = SysFinals.DEFAULT_PAGE_NUM; | |||||
private Integer pageSize = SysFinals.DEFAULT_PAGE_SIZE; | |||||
} |
package cn.com.taiji.userw.dto.wx; | |||||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import javax.validation.constraints.NotBlank; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/20 15:03 | |||||
* @Filename:WxCarAddOrUpdateReqDTO | |||||
* @description: 车主签约新增修改 | |||||
*/ | |||||
@Data | |||||
@ApiModel(description = "车主签约修改") | |||||
public class WxCarUpdateReqDTO extends AbstractBizRequestDTO { | |||||
@NotBlank | |||||
@ApiModelProperty(value = "主键Id") | |||||
private String id; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "渠道编号") | |||||
private String agencyId;//渠道编号 | |||||
@NotBlank | |||||
@ApiModelProperty(value = "商户编号") | |||||
private String mchId;//商户号 | |||||
@NotBlank | |||||
@ApiModelProperty(value = "appId") | |||||
private String appId; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "appId") | |||||
private String subAppId; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "子商户号") | |||||
private String subMchId; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "签名密钥") | |||||
private String signKey; | |||||
@NotBlank | |||||
@ApiModelProperty(value = "描述") | |||||
private String desc;//描述 | |||||
} |
package cn.com.taiji.userw.manager.wx; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.model.dao.Pagination; | |||||
import cn.com.taiji.userw.dto.wx.WxCarAddReqDTO; | |||||
import cn.com.taiji.userw.dto.wx.WxCarPageRequestDTO; | |||||
import cn.com.taiji.userw.dto.wx.WxCarUpdateReqDTO; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/20 14:47 | |||||
* @Filename:WxSignChannelConfigManager | |||||
* @description: | |||||
*/ | |||||
public interface WxSignChannelConfigManager { | |||||
Pagination page(WxCarPageRequestDTO reqDto); | |||||
void add(WxCarAddReqDTO reqDto) throws ManagerException; | |||||
void update(WxCarUpdateReqDTO reqDto) throws ManagerException; | |||||
} |
package cn.com.taiji.userw.manager.wx; | |||||
import cn.com.taiji.common.manager.AbstractManager; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.model.dao.Pagination; | |||||
import cn.com.taiji.core.entity.basic.WxSignChannelConfig; | |||||
import cn.com.taiji.core.repo.jpa.basic.WxSignChannelConfigRepo; | |||||
import cn.com.taiji.userw.dto.wx.WxCarAddReqDTO; | |||||
import cn.com.taiji.userw.dto.wx.WxCarPageRequestDTO; | |||||
import cn.com.taiji.userw.dto.wx.WxCarUpdateReqDTO; | |||||
import cn.com.taiji.userw.repo.jpa.request.WxSignChannelConfigPageRequest; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/20 14:48 | |||||
* @Filename:WxSignChannelConfigManagerImpl | |||||
* @description:微信车主签约配置管理 | |||||
*/ | |||||
@Service | |||||
public class WxSignChannelConfigManagerImpl extends AbstractManager implements WxSignChannelConfigManager{ | |||||
@Autowired | |||||
private WxSignChannelConfigRepo wxSignChannelConfigRepo; | |||||
@Override | |||||
public Pagination page(WxCarPageRequestDTO reqDto) { | |||||
WxSignChannelConfigPageRequest request = copyProperties(reqDto, new WxSignChannelConfigPageRequest()); | |||||
return wxSignChannelConfigRepo.page(request); | |||||
} | |||||
@Override | |||||
public void add(WxCarAddReqDTO reqDto) throws ManagerException { | |||||
WxSignChannelConfig byAgencyId = wxSignChannelConfigRepo.findByAgencyId(reqDto.getAgencyId()); | |||||
if(byAgencyId != null){ | |||||
throw new ManagerException("该渠道已配置"); | |||||
} | |||||
WxSignChannelConfig config = copyProperties(reqDto, new WxSignChannelConfig()); | |||||
wxSignChannelConfigRepo.persist(config); | |||||
} | |||||
@Override | |||||
public void update(WxCarUpdateReqDTO reqDto) throws ManagerException { | |||||
WxSignChannelConfig config = wxSignChannelConfigRepo.findById(reqDto.getId()).orElse(null); | |||||
if(config == null) throw new ManagerException("该配置不存在"); | |||||
if (!config.getAgencyId().equals(reqDto.getAgencyId())){ | |||||
//渠道编号被修改,要验证数据库是否已存在此编号 | |||||
WxSignChannelConfig byAgencyId = wxSignChannelConfigRepo.findByAgencyId(reqDto.getAgencyId()); | |||||
if (byAgencyId != null) throw new ManagerException("该渠道编号已配置,请更换渠道"); | |||||
} | |||||
config.setUpdateTime(LocalDateTime.now()); | |||||
wxSignChannelConfigRepo.merge(copyProperties(reqDto, config)); | |||||
} | |||||
} |
package cn.com.taiji.userw.repo.jpa.request; | |||||
import cn.com.taiji.common.pub.dao.HqlBuilder; | |||||
import cn.com.taiji.common.repo.request.jpa.JpaDateTimePageableDataRequest; | |||||
import cn.com.taiji.core.entity.basic.WxSignChannelConfig; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
@Getter | |||||
@Setter | |||||
public class WxSignChannelConfigPageRequest extends JpaDateTimePageableDataRequest<WxSignChannelConfig> { | |||||
public WxSignChannelConfigPageRequest() { | |||||
this.orderBy="id"; | |||||
this.desc=true; | |||||
} | |||||
@Override | |||||
public HqlBuilder toSelectHql(){ | |||||
HqlBuilder hql = new HqlBuilder("from WxSignChannelConfig where 1=1 "); | |||||
return hql; | |||||
} | |||||
} |