@@ -1,5 +1,6 @@ | |||
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.core.entity.basic.QtkAgencyMap; | |||
@@ -38,7 +39,7 @@ public class CenterAgencyController extends MyValidController{ | |||
@ApiOperation(value = "新增修改") | |||
@PostMapping(value = "/addOrUpDate") | |||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterAgencyAddOrUpdateReqDTO reqDto) { | |||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterAgencyAddOrUpdateReqDTO reqDto) throws ManagerException { | |||
manager.addOrUpdate(reqDto); | |||
return ApiResponse.success().setMessage("成功"); | |||
} |
@@ -1,5 +1,6 @@ | |||
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.core.entity.basic.QtkServicehallMap; | |||
@@ -36,7 +37,7 @@ public class CenterServiceHallController extends MyValidController{ | |||
@ApiOperation(value = "新增修改") | |||
@PostMapping(value = "/addOrUpDate") | |||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterHallAddOrUpdateReqDTO reqDto) { | |||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterHallAddOrUpdateReqDTO reqDto) throws ManagerException { | |||
manager.addOrUpdate(reqDto); | |||
return ApiResponse.success().setMessage("成功"); | |||
} |
@@ -1,10 +1,14 @@ | |||
package cn.com.taiji.userw.dto.centerHallAndAgency; | |||
import cn.com.taiji.common.valid.ViolationValidator; | |||
import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.IntegerConstant; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/20 13:11 | |||
@@ -20,4 +24,23 @@ public class CenterAgencyAddOrUpdateReqDTO extends AbstractStaffBizRequestDTO { | |||
@ApiModelProperty(value = "中心渠道名称") | |||
private String centerAgencyName; | |||
@ApiModelProperty(value = "ID") | |||
private String id; | |||
@ApiModelProperty(value = "操作类型 1新增 2修改") | |||
@IntegerConstant(values = "1,2", message = "操作类型错误") | |||
@NotNull | |||
private Integer optType; | |||
@Override | |||
protected void validate(ViolationValidator validator) { | |||
if (optType == 1){ | |||
validator.validFieldNotBlank("centerAgencyName",centerAgencyName); | |||
validator.validFieldNotBlank("centerAgencyId",centerAgencyId); | |||
}else { | |||
validator.validFieldNotBlank("id",id); | |||
validator.validFieldNotBlank("centerAgencyName",centerAgencyName); | |||
} | |||
} | |||
} |
@@ -1,10 +1,14 @@ | |||
package cn.com.taiji.userw.dto.centerHallAndAgency; | |||
import cn.com.taiji.common.valid.ViolationValidator; | |||
import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.FixedLength; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.IntegerConstant; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @Author:ChenChao | |||
@@ -14,9 +18,28 @@ import javax.validation.constraints.NotBlank; | |||
*/ | |||
@Data | |||
public class CenterHallAddOrUpdateReqDTO extends AbstractStaffBizRequestDTO { | |||
@NotBlank(message = "中心网点编号不能为空") | |||
@FixedLength(length = 19, message = "中心网点编号必须是19位") | |||
private String centerServiceHallId; | |||
@NotBlank(message = "网点名称不能为空") | |||
private String centerServicehallName; | |||
@ApiModelProperty(value = "ID") | |||
private String id; | |||
@ApiModelProperty(value = "操作类型 1新增 2修改") | |||
@IntegerConstant(values = "1,2", message = "操作类型错误") | |||
@NotNull | |||
private Integer optType; | |||
@Override | |||
protected void validate(ViolationValidator validator) { | |||
if (optType == 1){ | |||
validator.validFieldNotBlank("centerServiceHallId",centerServiceHallId); | |||
validator.validFieldNotBlank("centerServicehallName",centerServicehallName); | |||
}else { | |||
validator.validFieldNotBlank("id",id); | |||
validator.validFieldNotBlank("centerServicehallName",centerServicehallName); | |||
} | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package cn.com.taiji.userw.manager.centerHallAndAgency; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.basic.QtkAgencyMap; | |||
import cn.com.taiji.userw.dto.centerHallAndAgency.CenterAgencyAddOrUpdateReqDTO; | |||
@@ -18,7 +19,7 @@ public interface CenterAgencyManager { | |||
List<QtkAgencyMap> getCenterAgencyId(); | |||
void addOrUpdate(CenterAgencyAddOrUpdateReqDTO reqDto); | |||
void addOrUpdate(CenterAgencyAddOrUpdateReqDTO reqDto) throws ManagerException; | |||
void delete(CenterHallOrAgencyDeleteRequestDTO reqDto); | |||
@@ -1,6 +1,7 @@ | |||
package cn.com.taiji.userw.manager.centerHallAndAgency; | |||
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.QtkAgencyMap; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkAgencyMapRepo; | |||
@@ -29,14 +30,18 @@ public class CenterAgencyManagerImpl extends AbstractManager implements CenterAg | |||
} | |||
@Override | |||
public void addOrUpdate(CenterAgencyAddOrUpdateReqDTO reqDto) { | |||
QtkAgencyMap agencyMap = qtkAgencyMapRepo.findByCenterAgencyId(reqDto.getCenterAgencyId()); | |||
if (agencyMap != null) { | |||
agencyMap.setCenterAgencyName(reqDto.getCenterAgencyName()); | |||
qtkAgencyMapRepo.merge(agencyMap); | |||
public void addOrUpdate(CenterAgencyAddOrUpdateReqDTO reqDto) throws ManagerException { | |||
reqDto.validate(); | |||
if (reqDto.getOptType() == 1){ | |||
QtkAgencyMap agencyMap = qtkAgencyMapRepo.findByCenterAgencyId(reqDto.getCenterAgencyId()); | |||
if (agencyMap != null) throw new ManagerException("此中心渠道编号也存在"); | |||
agencyMap = copyProperties(reqDto, new QtkAgencyMap()); | |||
qtkAgencyMapRepo.persist(agencyMap); | |||
}else { | |||
QtkAgencyMap qtkAgencyMap = copyProperties(reqDto, new QtkAgencyMap()); | |||
qtkAgencyMapRepo.persist(qtkAgencyMap); | |||
QtkAgencyMap qtkAgencyMap = qtkAgencyMapRepo.findById(reqDto.getId()).orElse(null); | |||
if (qtkAgencyMap == null) throw new ManagerException("此中心渠道不存在"); | |||
copyProperties(reqDto,qtkAgencyMap,"id","centerAgencyName"); | |||
qtkAgencyMapRepo.merge(qtkAgencyMap); | |||
} | |||
} | |||
@@ -1,5 +1,6 @@ | |||
package cn.com.taiji.userw.manager.centerHallAndAgency; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
import cn.com.taiji.userw.dto.centerHallAndAgency.CenterHallOrAgencyDeleteRequestDTO; | |||
@@ -18,7 +19,7 @@ public interface CenterServiceHallManager { | |||
List<QtkServicehallMap> getCenterServiceHall(); | |||
void addOrUpdate(CenterHallAddOrUpdateReqDTO reqDto); | |||
void addOrUpdate(CenterHallAddOrUpdateReqDTO reqDto) throws ManagerException; | |||
void delete(CenterHallOrAgencyDeleteRequestDTO reqDto); | |||
@@ -1,6 +1,7 @@ | |||
package cn.com.taiji.userw.manager.centerHallAndAgency; | |||
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.QtkServicehallMap; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallMapRepo; | |||
@@ -32,14 +33,18 @@ public class CenterServiceHallManagerImpl extends AbstractManager implements Cen | |||
} | |||
@Override | |||
public void addOrUpdate(CenterHallAddOrUpdateReqDTO reqDto){ | |||
QtkServicehallMap serviceHallId = qtkServicehallMapRepo.findByCenterServiceHallId(reqDto.getCenterServiceHallId()); | |||
if (serviceHallId != null) { | |||
serviceHallId.setCenterServicehallName(reqDto.getCenterServicehallName()); | |||
qtkServicehallMapRepo.merge(serviceHallId); | |||
}else { | |||
public void addOrUpdate(CenterHallAddOrUpdateReqDTO reqDto) throws ManagerException { | |||
reqDto.validate(); | |||
if (reqDto.getOptType() == 1){ | |||
QtkServicehallMap serviceHallId = qtkServicehallMapRepo.findByCenterServiceHallId(reqDto.getCenterServiceHallId()); | |||
if (serviceHallId != null) throw new ManagerException("此中心网点已存在"); | |||
QtkServicehallMap servicehallMap = copyProperties(reqDto, new QtkServicehallMap()); | |||
qtkServicehallMapRepo.persist(servicehallMap); | |||
}else { | |||
QtkServicehallMap servicehallMap = qtkServicehallMapRepo.findById(reqDto.getId()).orElse(null); | |||
if (servicehallMap == null) throw new ManagerException("此中心网点不存在"); | |||
copyProperties(reqDto, servicehallMap,"id","centerServiceHallId"); | |||
qtkServicehallMapRepo.merge(servicehallMap); | |||
} | |||
} | |||