Browse Source

[招商]adjust

release_toaliyun_real
Burce 6 years ago
parent
commit
b5aa692078
6 changed files with 124 additions and 5 deletions
  1. +34
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java
  2. +24
    -3
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java
  3. +1
    -2
      mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java
  4. +37
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java
  5. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestPageQuery.java
  6. +26
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java

+ 34
- 0
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java View File

@@ -5,14 +5,27 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.InvestResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.vo.invest.InvestUserContext;
import com.iformall.enums.EnumCustomerType;
import com.iformall.exception.MallinkException;
import com.iformall.service.invest.InvestHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.beans.PropertyEditor;
import java.beans.PropertyEditorSupport;
import java.util.function.Function;


@Slf4j
public class InvestBaseController extends BaseController {

@InitBinder
public void InitBinder(WebDataBinder dataBinder) {
super.InitBinder(dataBinder);
registerEnumEditor(dataBinder, EnumCustomerType.class, "customerType") ;
}

public <R, T> InvestResultData<R> execute(T params, Function<T, R> function) {
try {
log.debug("[" + getIpAddr() + "] request , params : {}", JSON.toJSONString(params));
@@ -30,4 +43,25 @@ public class InvestBaseController extends BaseController {
}
}

public <R, T> R convert(T params, Function<T, R> function) {
InvestHelper.notNull(params);
return function.apply(params);
}

private <T extends Enum<T>> void registerEnumEditor(WebDataBinder binder, Class<T> clz, String propertyName) {
binder.registerCustomEditor(clz, propertyName, newEnumEditor(clz));
}

private <T extends Enum<T>> PropertyEditor newEnumEditor(Class<T> clz) {
return new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
try {
setValue(InvestHelper.codeOf(clz, Integer.parseInt(text)));
} catch (Exception NumberFormatException) {
setValue(InvestHelper.valueOf(clz, text));
}
}
};
}
}

+ 24
- 3
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java View File

@@ -3,6 +3,9 @@ package com.iformall.controller.invest;
import com.iformall.annotation.SystemServiceLog;
import com.iformall.common.InvestResultData;
import com.iformall.domain.dto.InvestDemandDto;
import com.iformall.domain.po.invest.InvestCustomerEntity;
import com.iformall.domain.po.invest.InvestDemandEntity;
import com.iformall.domain.vo.invest.InvestDemandQuery;
import com.iformall.domain.vo.invest.InvestDemandVo;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult;
@@ -11,6 +14,7 @@ import com.iformall.service.invest.InvestDemandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@@ -42,11 +46,10 @@ public class InvestDemandController extends InvestBaseController {
@SystemServiceLog
@ApiOperation(value = "分页列表接口")
@GetMapping("/list")
public InvestResultData<InvestPageResult<InvestDemandVo>> list(InvestPageQuery<InvestDemandDto> params) {
return execute(params, p -> investBizService.queryPageDemand(p));
public InvestResultData<InvestPageResult<InvestDemandVo>> list(InvestDemandQuery params) {
return execute(convert(params, this::doConvert), p -> investBizService.queryPageDemand(p));
}


/**
* 信息
*/
@@ -82,4 +85,22 @@ public class InvestDemandController extends InvestBaseController {
return execute(ids, p -> investDemandService.removeByIds(Arrays.asList(p)));
}

private InvestPageQuery<InvestDemandDto> doConvert(InvestDemandQuery params) {
InvestCustomerEntity customerEntity = new InvestCustomerEntity();
customerEntity.setId(params.getCustomerId());
customerEntity.setType(params.getCustomerType());
customerEntity.setBusinessId(params.getBusinessId());

InvestDemandEntity demandEntity = new InvestDemandEntity();
demandEntity.setOwner(params.getOwner());

InvestDemandDto demandDto = new InvestDemandDto();
demandDto.setCustomer(customerEntity);
demandDto.setDemand(demandEntity);
InvestPageQuery<InvestDemandDto> pageQuery = new InvestPageQuery<>();
BeanUtils.copyProperties(params, pageQuery);
pageQuery.setQueryData(demandDto);
return pageQuery;
}

}

+ 1
- 2
mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java View File

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.iformall.common.LogColumn;
import com.iformall.domain.po.invest.InvestBaseEntity;
import com.iformall.enums.EnumCustomerRatingType;
import com.iformall.enums.EnumCustomerType;
import com.iformall.enums.EnumInvestChannel;
@@ -69,7 +68,7 @@ public class InvestCustomerEntity extends InvestBaseEntity {
*/
@io.swagger.annotations.ApiModelProperty(value = "招商渠道:0-无;1-电视;2-广播;3-报纸;4-刊物;5-物联网;6-招商活动;7-中介机构;8-自定义渠道", name = "investChannel")
@LogColumn
private EnumInvestChannel investChannel = EnumInvestChannel.NONE;
private EnumInvestChannel investChannel ;

/**
* 更新时间


+ 37
- 0
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java View File

@@ -0,0 +1,37 @@
package com.iformall.domain.vo.invest;

import com.iformall.common.LogColumn;
import com.iformall.enums.EnumCustomerType;
import lombok.Data;

@Data
public class InvestDemandQuery extends InvestPageQuery {

/**
* 主键ID
*/
@io.swagger.annotations.ApiModelProperty(value = "客户编号", name = "customerId")
private Long customerId;

/**
* 客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败
*/
@io.swagger.annotations.ApiModelProperty(value = "客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败", name = "customerType")
@LogColumn
private EnumCustomerType customerType;

/**
* 经营业态
*/
@LogColumn
@io.swagger.annotations.ApiModelProperty(value = "经营业态", name = "businessId")
private Integer businessId;

/**
* 负责人
*/
@io.swagger.annotations.ApiModelProperty(value = "负责人", name = "owner")
@LogColumn
private Long owner;

}

+ 2
- 0
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestPageQuery.java View File

@@ -1,10 +1,12 @@
package com.iformall.domain.vo.invest;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class InvestPageQuery<T> {
public InvestPageQuery(T queryData) {
this.queryData = queryData;


+ 26
- 0
mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java View File

@@ -8,6 +8,7 @@ import com.iformall.exception.MallinkException;
import org.apache.commons.compress.utils.Lists;
import org.springframework.util.CollectionUtils;

import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.List;
import java.util.Objects;
@@ -105,4 +106,29 @@ public class InvestHelper {
throwException(ErrorCode.INVEST_RESULT_NOT_FOUND, message);
}
}

public static <T extends Enum<T>> int code(T t) {
try {
Method code = t.getClass().getDeclaredMethod("code");
Object rs = code.invoke(t);
return (int) rs;
} catch (ReflectiveOperationException e) {
throw new IllegalArgumentException(e);
}
}

@SuppressWarnings("unchecked")
public static <T extends Enum<T>> T codeOf(Class<T> enumType, int code) {
try {
Method method = enumType.getDeclaredMethod("getEnum", Integer.class);
Object rs = method.invoke(null, code);
return (T) rs;
} catch (ReflectiveOperationException e) {
throw new IllegalArgumentException(e);
}
}

public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) {
return T.valueOf(enumType, name);
}
}

Loading…
Cancel
Save