diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java index 47531af6b..c9cf2a5bc 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java @@ -1,5 +1,6 @@ package com.iformall.controller.invest; +import com.alibaba.fastjson.JSON; import com.iformall.common.ErrorCode; import com.iformall.common.InvestResultData; import com.iformall.controller.base.BaseController; @@ -7,18 +8,17 @@ import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.exception.MallinkException; import lombok.extern.slf4j.Slf4j; +import java.util.function.Function; + @Slf4j public class InvestBaseController extends BaseController { - interface ExecuteFunction { - E execute(T t); - } - - public InvestResultData execute(T params, ExecuteFunction function) { + public InvestResultData execute(T params, Function function) { try { + log.debug("[" + getIpAddr() + "] request , params : {}", JSON.toJSONString(params)); InvestUserContext.setUser(getUser()); - E e = function.execute(params); - return new InvestResultData(e); + R r = function.apply(params); + return new InvestResultData(r); } catch (MallinkException e) { log.error("execute error", e); return new InvestResultData(e.getErrorCode(), e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index af024bfa6..4806eebb6 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -1,5 +1,7 @@ package com.iformall.common; +import org.springframework.util.ObjectUtils; + import java.text.MessageFormat; /** @@ -524,7 +526,8 @@ public enum ErrorCode{ // 招商管理 53000 begin INVEST_CUSTOMER_NOT_FOUND(53000, "客户信息不存在"), - INVEST_UNKNOW_ERRROR(53000, "客户信息不存在"), + INVEST_UNKNOW_ERRROR(53001, "客户信息不存在"), + INVEST_DATA_NOT_FOUND(53002, "信息不存在"), // 招商管理 53999 end @@ -552,7 +555,8 @@ public enum ErrorCode{ if (param.length == 0) { return message; } - return MessageFormat.format(message, param); + //return MessageFormat.format(message, param); + return MessageFormat.format("{0}, {1}", ObjectUtils.nullSafeToString(param), message); } public static ErrorCode getByCode(int code) { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/InvestCustomerEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/InvestCustomerEntity.java index 87e4829b0..5b51c4e95 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/InvestCustomerEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/InvestCustomerEntity.java @@ -66,7 +66,6 @@ public class InvestCustomerEntity extends InvestBaseEntity { */ @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate", example = "2018-10-01 12:18:48",readOnly = true) @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Version private Date updateDate; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/InvestDemandEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/InvestDemandEntity.java index 4ff692910..d8e9d3507 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/InvestDemandEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/InvestDemandEntity.java @@ -54,7 +54,6 @@ public class InvestDemandEntity extends InvestBaseEntity { */ @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate", example = "2018-10-01 12:18:48",readOnly = true) @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Version private Date updateDate; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/InvestOperateRecordEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/InvestOperateRecordEntity.java index 6cd91db34..2cc6728f9 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/InvestOperateRecordEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/InvestOperateRecordEntity.java @@ -57,7 +57,6 @@ public class InvestOperateRecordEntity extends InvestBaseEntity { * 创建时间 */ @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate", example = "2018-10-01 12:18:48") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createDate; @JsonIgnore diff --git a/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java index 0817e6e8a..9a2bd0a21 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java @@ -53,7 +53,6 @@ public class InvestTaskEntity extends InvestBaseEntity { */ @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate", example = "2018-10-01 12:18:48",readOnly = true) @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Version private Date updateDate; diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java deleted file mode 100644 index 447949081..000000000 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.iformall.service.invest; - -import com.alibaba.fastjson.JSONArray; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.iformall.common.ErrorCode; -import com.iformall.domain.po.*; -import com.iformall.domain.vo.invest.InvestPageQuery; -import com.iformall.enums.EnumInvestType; -import com.iformall.enums.EnumShopStatus; -import com.iformall.exception.MallinkException; -import com.iformall.service.MallUserInfoService; -import com.iformall.service.WxShopService; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.ObjectUtils; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -public class InvestHelper { - - /** - * 校验商铺 - * - * @param shopService - * @param inputEntity - */ - public static void checkShop(WxShopService shopService, InvestBaseEntity inputEntity) { - Long targetId = null; - EnumInvestType investType = null; - if (inputEntity instanceof InvestDemandEntity) { - InvestDemandEntity entity = (InvestDemandEntity) inputEntity; - targetId = entity.getTargetId(); - investType = entity.getTargetType(); - } else if (inputEntity instanceof InvestTaskEntity) { - InvestTaskEntity entity = (InvestTaskEntity) inputEntity; - targetId = entity.getTargetId(); - investType = entity.getTargetType(); - } - if (EnumInvestType.SHOP.equals(investType)) { - WxShop shop = shopService.getById(targetId); - checkShopNotNull(shop); - } - } - - - /** - * 校验参数是否为空 - * - * @param shop - */ - public static void checkShopNotNull(WxShop shop) { - if (Objects.isNull(shop)) { - throw new MallinkException(ErrorCode.SHOP_IS_NOT_FOUND); - } - - if (Objects.equals(shop.getStatus(), EnumShopStatus.RENT.getCode())) { - throw new MallinkException(ErrorCode.SHOP_IS_RENT); - } - } - - /** - * 校验用户是否存在 - * - * @param userInfoService - * @param userIdJson - */ - public static void checkUserExit(MallUserInfoService userInfoService, String userIdJson) { - if (Objects.nonNull(userIdJson)) { - List ids = JSONArray.parseArray(userIdJson, Long.class); - if (CollectionUtils.isNotEmpty(ids)) { - List usersFromDb = userInfoService.getByIds(ids).stream().map(MallUserInfo::getId).collect(Collectors.toList()); - List notExsitIds = ids.stream().filter(uid -> !usersFromDb.contains(uid)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(notExsitIds)) { - throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), notExsitIds + ErrorCode.USER_IS_EMPTY.getMessage()); - } - } - } - } - - public static void checkUserExit(MallUserInfoService userInfoService, Long id) { - if (Objects.nonNull(id)) { - MallUserInfo userInfo = userInfoService.getById(id); - if (Objects.isNull(userInfo)) - throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), id + ErrorCode.USER_IS_EMPTY.getMessage()); - } - } - - public static void checkCustomerExit(InvestCustomerService customerService, Long id) { - InvestCustomerEntity customerEntity = customerService.getById(id); - if (Objects.isNull(customerEntity)) { - throw new MallinkException(ErrorCode.INVEST_CUSTOMER_NOT_FOUND.getCode(), id + ErrorCode.INVEST_CUSTOMER_NOT_FOUND.getMessage()); - } - } - - /** - * 校验参数是否为空 - * - * @param values - */ - public static void checkAllNotNull(final Object... values) { - if (!ObjectUtils.allNotNull(values)) { - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL); - } - } - - public static Page buildQueryPage(InvestPageQuery pageQuery) { - Page page = new Page(); - page.setCurrent(pageQuery.getPageNum()); - page.setSize(pageQuery.getPageSize()); - page.setAscs(pageQuery.getAscs()); - page.setDescs(pageQuery.getDescs()); - page.setOptimizeCountSql(true); - page.setSearchCount(true); - return page; - } - - - public static void notSupport() { - throw new MallinkException(ErrorCode.SYS_METHOD_NOT_SUPPORT); - } -} diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java index 30e82274e..63218d384 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java @@ -1,7 +1,6 @@ package com.iformall.service.invest.impl; import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iformall.common.ErrorCode; import com.iformall.common.TableLog; import com.iformall.domain.po.InvestCustomerEntity; @@ -13,7 +12,6 @@ import com.iformall.mapper.InvestCustomerDao; import com.iformall.service.WxBrandService; import com.iformall.service.WxBusinessService; import com.iformall.service.invest.InvestCustomerService; -import com.iformall.service.invest.InvestHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -21,7 +19,7 @@ import java.util.List; import java.util.Objects; @Service -public class InvestCustomerServiceImpl extends ServiceImpl implements InvestCustomerService { +public class InvestCustomerServiceImpl extends InvestBaseService implements InvestCustomerService { @Autowired private WxBrandService brandService; @@ -54,11 +52,7 @@ public class InvestCustomerServiceImpl extends ServiceImpl implements InvestDemandService { +public class InvestDemandServiceImpl extends InvestBaseService implements InvestDemandService { @Autowired private WxShopService shopService; @@ -43,8 +41,8 @@ public class InvestDemandServiceImpl extends ServiceImpl queryPage(InvestPageQuery params) { - InvestHelper.checkAllNotNull(params); - Page page = InvestHelper.buildQueryPage(params); + checkAllNotNull(params); + Page page = buildQueryPage(params); InvestPageResult investPage = new InvestPageResult<>(); //1、客户需求 InvestDemandEntity queryTask = params.getQueryData(); @@ -54,6 +52,14 @@ public class InvestDemandServiceImpl extends ServiceImpl resultList = getITargeInfoList(demandPage); + + BeanUtils.copyProperties(demandPage, investPage); + investPage.setRecords(resultList); + return investPage; + } + + private List getITargeInfoList(IPage demandPage) { List demandList = demandPage.getRecords(); //2、客户信息 Collection customers = customerService.listByIds(demandList @@ -78,11 +84,7 @@ public class InvestDemandServiceImpl extends ServiceImpl implements InvestFollowRecordService { +public class InvestFollowRecordServiceImpl extends InvestBaseService implements InvestFollowRecordService { @Autowired private InvestDemandService demandService ; @Autowired private InvestTaskService taskService ; - @Autowired - private MallUserInfoService userInfoService; @Override public InvestPageResult queryPage(InvestPageQuery params) { - InvestHelper.checkAllNotNull(params); - Page page = InvestHelper.buildQueryPage(params); + checkAllNotNull(params); + Page page = buildQueryPage(params); InvestFollowRecordEntity queryTask = params.getQueryData(); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(queryTask); IPage records = this.page(page, queryWrapper); @@ -62,32 +58,27 @@ public class InvestFollowRecordServiceImpl extends ServiceImpl updateWrapper) { - //checkBeforeSaveOrUpdate(entity); - //return super.update(entity, updateWrapper); - InvestHelper.notSupport(); + notSupport(); return false; } @Deprecated @Override public boolean saveOrUpdate(InvestFollowRecordEntity entity) { - //checkBeforeSaveOrUpdate(entity); - //return super.saveOrUpdate(entity); - InvestHelper.notSupport(); + notSupport(); return false; } @Deprecated @Override public boolean updateById(InvestFollowRecordEntity entity) { - //checkBeforeSaveOrUpdate(entity); - //return super.updateById(entity); - InvestHelper.notSupport(); + notSupport(); return false; } private void checkBeforeSaveOrUpdate(InvestFollowRecordEntity entity) { - InvestHelper.checkAllNotNull(entity); + checkAllNotNull(entity); + checkAllNotNull(InvestUserContext.getUserId()); InvestBaseEntity baseInvestEntity; if(Objects.equals(entity.getType(), EnumFollowType.DEMAND)) { baseInvestEntity = demandService.getById(entity.getFollowId()); @@ -96,8 +87,7 @@ public class InvestFollowRecordServiceImpl extends ServiceImpl implements InvestOperateRecordService { +public class InvestOperateRecordServiceImpl extends InvestBaseService implements InvestOperateRecordService { @Override public InvestPageResult queryPage(InvestPageQuery params) { - InvestHelper.checkAllNotNull(params); + checkAllNotNull(params); //1、分页信息 - Page queryPage = InvestHelper.buildQueryPage(params); + Page queryPage = buildQueryPage(params); //2、查询数据 InvestOperateRecordEntity queryParams = params.getQueryData(); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(queryParams); diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestRemindServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestRemindServiceImpl.java index bd8120693..bc932e5f9 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestRemindServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestRemindServiceImpl.java @@ -11,29 +11,27 @@ import com.iformall.domain.vo.invest.InvestPageResult; import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.mapper.InvestRemindDao; import com.iformall.service.MallUserInfoService; -import com.iformall.service.invest.InvestHelper; import com.iformall.service.invest.InvestRemindService; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @Service -public class InvestRemindServiceImpl extends ServiceImpl implements InvestRemindService { +public class InvestRemindServiceImpl extends InvestBaseService implements InvestRemindService { @Autowired private MallUserInfoService userInfoService; @Override public InvestPageResult queryPage(InvestPageQuery params) { - InvestHelper.checkAllNotNull(params); + checkAllNotNull(params); //1、分页信息 - Page queryPage = InvestHelper.buildQueryPage(params); + Page queryPage = buildQueryPage(params); //2、查询数据 InvestRemindEntity queryParams = params.getQueryData(); - InvestHelper.checkUserExit(userInfoService, InvestUserContext.getUserId()); + checkUserExit(userInfoService, InvestUserContext.getUserId()); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(queryParams); IPage taskPage = this.page(queryPage, queryWrapper); @@ -74,9 +72,8 @@ public class InvestRemindServiceImpl extends ServiceImpl implements InvestTaskService { +public class InvestTaskServiceImpl extends InvestBaseService implements InvestTaskService { @Autowired private WxShopService shopService; @@ -38,8 +36,8 @@ public class InvestTaskServiceImpl extends ServiceImpl queryPage(InvestPageQuery params) { - InvestHelper.checkAllNotNull(params); - Page queryPage = InvestHelper.buildQueryPage(params); + checkAllNotNull(params); + Page queryPage = buildQueryPage(params); //1、任务信息 InvestTaskEntity queryTask = params.getQueryData(); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(queryTask); @@ -94,9 +92,7 @@ public class InvestTaskServiceImpl extends ServiceImpl