Commit 128047ed authored by 王业雄's avatar 王业雄

fix

parent d758bbe7
package com.quantgroup.asset.distribution.controller.route.channelroute; package com.quantgroup.asset.distribution.controller.route.channelroute;
import com.quantgroup.asset.distribution.enums.route.SystemType;
import com.quantgroup.asset.distribution.enums.route.UserLevel; import com.quantgroup.asset.distribution.enums.route.UserLevel;
import com.quantgroup.asset.distribution.enums.route.UserTag; import com.quantgroup.asset.distribution.enums.route.UserTag;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelConfigInfoVo; import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteAddVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteQueryVo; import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteSaveVo; import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteSaveVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.FundProInfoVo; import com.quantgroup.asset.distribution.model.entity.route.channelroute.FundProInfoVo;
...@@ -135,16 +134,15 @@ public class ChannelRouteController { ...@@ -135,16 +134,15 @@ public class ChannelRouteController {
/** /**
* 新增渠道配置信息 * 新增渠道配置信息
* @param channelRouteSaveVoList * @param channelRouteAddVo
* @param type 0表示新增 1表示编辑
* @return * @return
*/ */
@RequestMapping("/addChannelConfig") @RequestMapping("/addChannelConfig")
public GlobalResponse addChannelConfig(@RequestBody@Valid@NotEmpty List<ChannelRouteSaveVo> channelRouteSaveVoList, @NotNull Integer type, BindingResult bindingResult){ public GlobalResponse addChannelConfig(@RequestBody@Valid ChannelRouteAddVo channelRouteAddVo, BindingResult bindingResult){
if (bindingResult.hasErrors()){ if (bindingResult.hasErrors()){
return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage()); return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage());
} }
channelRouteService.addChannelConfig(channelRouteSaveVoList,type); channelRouteService.addChannelConfig(channelRouteAddVo.getChannelRouteSaveVoList(),channelRouteAddVo.getType());
return GlobalResponse.success(); return GlobalResponse.success();
} }
......
...@@ -11,7 +11,7 @@ import java.sql.Timestamp; ...@@ -11,7 +11,7 @@ import java.sql.Timestamp;
public class ChannelConfigInfoVo { public class ChannelConfigInfoVo {
private Long fundId; private Long fundId;
private Long fundCorpId; private Long fundProId;
private String fundName; private String fundName;
private String fundType; private String fundType;
private String orgType; private String orgType;
......
package com.quantgroup.asset.distribution.model.entity.route.channelroute;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class ChannelRouteAddVo {
@Valid
@NotEmpty
private List<ChannelRouteSaveVo> channelRouteSaveVoList;
@NotNull
private Integer type;
}
package com.quantgroup.asset.distribution.service.jpa.entity; package com.quantgroup.asset.distribution.service.jpa.entity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Objects; import java.util.Objects;
...@@ -11,6 +14,8 @@ import java.util.Objects; ...@@ -11,6 +14,8 @@ import java.util.Objects;
*/ */
@Entity @Entity
@Table(name = "channel_rule", schema = "asset-distribution", catalog = "") @Table(name = "channel_rule", schema = "asset-distribution", catalog = "")
@DynamicInsert
@DynamicUpdate
public class ChannelRuleEntity { public class ChannelRuleEntity {
private long id; private long id;
private long fundProductId; private long fundProductId;
...@@ -32,6 +37,7 @@ public class ChannelRuleEntity { ...@@ -32,6 +37,7 @@ public class ChannelRuleEntity {
private Timestamp updatedAt; private Timestamp updatedAt;
@Id @Id
@GeneratedValue
@Column(name = "id", nullable = false) @Column(name = "id", nullable = false)
public long getId() { public long getId() {
return id; return id;
......
package com.quantgroup.asset.distribution.service.jpa.entity; package com.quantgroup.asset.distribution.service.jpa.entity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Objects; import java.util.Objects;
...@@ -11,6 +14,8 @@ import java.util.Objects; ...@@ -11,6 +14,8 @@ import java.util.Objects;
*/ */
@Entity @Entity
@Table(name = "fund_product", schema = "asset-distribution", catalog = "") @Table(name = "fund_product", schema = "asset-distribution", catalog = "")
@DynamicInsert
@DynamicUpdate
public class FundProductEntity { public class FundProductEntity {
private Long id; private Long id;
private Long fundId; private Long fundId;
......
...@@ -98,6 +98,12 @@ public class ChannelRouteServiceImpl implements IChannelRouteService { ...@@ -98,6 +98,12 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
allByChannelIdEqualsaAndEnableEquals.stream().forEach(channelRuleEntity -> { allByChannelIdEqualsaAndEnableEquals.stream().forEach(channelRuleEntity -> {
ChannelConfigInfoVo configInfoVo = new ChannelConfigInfoVo(); ChannelConfigInfoVo configInfoVo = new ChannelConfigInfoVo();
BeanUtils.copyProperties(channelRuleEntity, configInfoVo); BeanUtils.copyProperties(channelRuleEntity, configInfoVo);
String userLevel = configInfoVo.getUserLevel();
if (!StringUtils.isEmpty(userLevel)){
configInfoVo.setUserLevel(userLevel.substring(1, userLevel.length() - 1));
}
FundProductEntity one = fundProductRepository.findOne(channelRuleEntity.getFundProductId()); FundProductEntity one = fundProductRepository.findOne(channelRuleEntity.getFundProductId());
if (Objects.nonNull(one)){ if (Objects.nonNull(one)){
configInfoVo.setSystermType(one.getSystermType()); configInfoVo.setSystermType(one.getSystermType());
...@@ -148,10 +154,11 @@ public class ChannelRouteServiceImpl implements IChannelRouteService { ...@@ -148,10 +154,11 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
if ( 0 != type ){ if ( 0 != type ){
channelRuleRepository.deleteAllByChannelIdEqualsAndEnableEquals(channelRouteSaveVoList.get(0).getChannelId(),Byte.valueOf("0")); channelRuleRepository.deleteAllByChannelIdEqualsAndEnableEquals(channelRouteSaveVoList.get(0).getChannelId(),Byte.valueOf("0"));
} }
channelRouteSaveVoList.stream().forEach(channelRouteSaveVo -> {
ChannelRuleEntity channelRuleEntity = new ChannelRuleEntity(); List<ChannelRuleEntity> channelRuleEntityList = getChannelRuleEntityList(channelRouteSaveVoList);
BeanUtils.copyProperties(channelRouteSaveVo,channelRuleEntity);
FundProductEntity fundProductEntity = fundProductRepository.getByFundIdEqualsAndFundProIdEqualsAndEnableEquals(channelRouteSaveVo.getFundId(), channelRouteSaveVo.getFundProId(), Byte.valueOf("1")); channelRuleEntityList.stream().forEach(channelRuleEntity -> {
FundProductEntity fundProductEntity = fundProductRepository.getByFundIdEqualsAndFundProIdEqualsAndEnableEquals(channelRuleEntity.getFundId(), channelRuleEntity.getFundProId(), Byte.valueOf("1"));
if (Objects.nonNull(fundProductEntity)){ if (Objects.nonNull(fundProductEntity)){
channelRuleEntity.setFundProductId(fundProductEntity.getId()); channelRuleEntity.setFundProductId(fundProductEntity.getId());
channelRuleEntity.setPublishStatus(Byte.valueOf("0")); channelRuleEntity.setPublishStatus(Byte.valueOf("0"));
...@@ -165,6 +172,16 @@ public class ChannelRouteServiceImpl implements IChannelRouteService { ...@@ -165,6 +172,16 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
}); });
} }
private List<ChannelRuleEntity> getChannelRuleEntityList(List<ChannelRouteSaveVo> channelRouteSaveVoList){
List<ChannelRuleEntity> channelRuleEntityList = new ArrayList<>();
channelRouteSaveVoList.stream().forEach(channelRouteSaveVo -> {
ChannelRuleEntity channelRuleEntity = new ChannelRuleEntity();
BeanUtils.copyProperties(channelRouteSaveVo,channelRuleEntity);
channelRuleEntityList.add(channelRuleEntity);
});
return channelRuleEntityList;
}
@Override @Override
public void publishChannelConfig(Long channelId) { public void publishChannelConfig(Long channelId) {
List<ChannelRuleEntity> all = channelRuleRepository.getAllByChannelIdEqualsAndEnableEquals(channelId, Byte.valueOf("1")); List<ChannelRuleEntity> all = channelRuleRepository.getAllByChannelIdEqualsAndEnableEquals(channelId, Byte.valueOf("1"));
......
...@@ -71,18 +71,6 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -71,18 +71,6 @@ public class FundProductServiceImpl implements IFundProductService {
FundProductEntity byFundIdEqualsAndFundProIdEquals = fundProductRepository.getByFundIdEqualsAndFundProIdEquals(fundProductEntity.getFundId(), fundProductEntity.getFundProId()); FundProductEntity byFundIdEqualsAndFundProIdEquals = fundProductRepository.getByFundIdEqualsAndFundProIdEquals(fundProductEntity.getFundId(), fundProductEntity.getFundProId());
if (Objects.isNull(byFundIdEqualsAndFundProIdEquals)){ if (Objects.isNull(byFundIdEqualsAndFundProIdEquals)){
fundProductEntity.setEnable(Byte.valueOf("1")); fundProductEntity.setEnable(Byte.valueOf("1"));
fundProductEntity.setFundType("");
fundProductEntity.setOrgType("");
fundProductEntity.setBusinessType("");
fundProductEntity.setBasicRule("");
fundProductEntity.setAreaTerm(0);
fundProductEntity.setCardLimit(0);
fundProductEntity.setTelRule("");
fundProductEntity.setAreaRule("");
fundProductEntity.setRuleList("");
fundProductEntity.setCreatedAt(Timestamp.valueOf(LocalDateTime.now()));
fundProductEntity.setUpdatedAt(Timestamp.valueOf(LocalDateTime.now()));
fundProductRepository.save(fundProductEntity); fundProductRepository.save(fundProductEntity);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment