| @@ -1,9 +1,13 @@ | |||||
| package com.iformall.controller.invest; | package com.iformall.controller.invest; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.List; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.InvestResultData; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.InvestFollowRecordEntity; | import com.iformall.domain.po.InvestFollowRecordEntity; | ||||
| import com.iformall.domain.vo.invest.InvestPage; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.invest.InvestFollowRecordService; | import com.iformall.service.invest.InvestFollowRecordService; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -33,17 +37,24 @@ public class InvestFollowRecordController { | |||||
| */ | */ | ||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("/list") | @GetMapping("/list") | ||||
| public ResultData list(@RequestBody InvestFollowRecordEntity params){ | |||||
| List page = investFollowRecordService.queryPage(params); | |||||
| return new ResultData(page); | |||||
| public InvestResultData<InvestPage<InvestFollowRecordEntity>> list(InvestFollowRecordEntity params) { | |||||
| try { | |||||
| InvestPage<InvestFollowRecordEntity> page = investFollowRecordService.queryPage(params); | |||||
| return new InvestResultData(page); | |||||
| } catch (MallinkException e) { | |||||
| log.error("list error", e); | |||||
| return new InvestResultData(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| log.error("list error", e); | |||||
| return new InvestResultData(ErrorCode.SYS_BEAN_EMPTY_PROPERTY_ERROR); | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| * 信息 | * 信息 | ||||
| */ | */ | ||||
| @GetMapping("/info/{id}") | |||||
| //@GetMapping("/info/{id}") | |||||
| public ResultData info(@PathVariable("id") Long id){ | public ResultData info(@PathVariable("id") Long id){ | ||||
| InvestFollowRecordEntity investFollowRecord = investFollowRecordService.getById(id); | InvestFollowRecordEntity investFollowRecord = investFollowRecordService.getById(id); | ||||
| @@ -63,7 +74,7 @@ public class InvestFollowRecordController { | |||||
| /** | /** | ||||
| * 修改 | * 修改 | ||||
| */ | */ | ||||
| @PostMapping("/update") | |||||
| //@PostMapping("/update") | |||||
| public ResultData update(@RequestBody InvestFollowRecordEntity investFollowRecord){ | public ResultData update(@RequestBody InvestFollowRecordEntity investFollowRecord){ | ||||
| investFollowRecordService.updateById(investFollowRecord); | investFollowRecordService.updateById(investFollowRecord); | ||||
| @@ -73,7 +84,7 @@ public class InvestFollowRecordController { | |||||
| /** | /** | ||||
| * 删除 | * 删除 | ||||
| */ | */ | ||||
| @GetMapping("/delete") | |||||
| //@GetMapping("/delete") | |||||
| public ResultData delete(@RequestBody Long[] ids){ | public ResultData delete(@RequestBody Long[] ids){ | ||||
| investFollowRecordService.removeByIds(Arrays.asList(ids)); | investFollowRecordService.removeByIds(Arrays.asList(ids)); | ||||
| @@ -282,7 +282,7 @@ public class InvestTests { | |||||
| @Test | @Test | ||||
| public void pager() throws Exception { | public void pager() throws Exception { | ||||
| InvestDemandEntity demandQuery = new InvestDemandEntity(); | InvestDemandEntity demandQuery = new InvestDemandEntity(); | ||||
| demandQuery.setPageIndex(1); | |||||
| demandQuery.setPageNum(1); | |||||
| demandQuery.setPageSize(10); | demandQuery.setPageSize(10); | ||||
| InvestPage page = demandService.queryPage(demandQuery); | InvestPage page = demandService.queryPage(demandQuery); | ||||
| log.debug("page : {}", objectMapper().writeValueAsString(page)); | log.debug("page : {}", objectMapper().writeValueAsString(page)); | ||||
| @@ -523,8 +523,11 @@ public enum ErrorCode{ | |||||
| // 业态 52999 end | // 业态 52999 end | ||||
| // 招商管理 53000 begin | // 招商管理 53000 begin | ||||
| CUSTOMER_NOT_FOUND(53000, "客户信息不存在"), | |||||
| INVEST_CUSTOMER_NOT_FOUND(53000, "客户信息不存在"), | |||||
| INVEST_UNKNOW_ERRROR(53000, "客户信息不存在"), | |||||
| // 招商管理 53999 end | // 招商管理 53999 end | ||||
| /** | /** | ||||
| * 首页浮屠广告 | * 首页浮屠广告 | ||||
| */ | */ | ||||
| @@ -63,10 +63,10 @@ public class BaseInvestEntity implements Serializable { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<String> ascs; | private List<String> ascs; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "当前页", name = "pageIndex",example = "1") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "当前页", name = "pageNum",example = "1") | |||||
| @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) | @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Integer pageIndex; | |||||
| private Integer pageNum; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "每页数据", name = "pageSize",example = "10") | @io.swagger.annotations.ApiModelProperty(value = "每页数据", name = "pageSize",example = "10") | ||||
| @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) | @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) | ||||
| @@ -2,9 +2,7 @@ package com.iformall.service.invest; | |||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import com.iformall.domain.po.InvestFollowRecordEntity; | import com.iformall.domain.po.InvestFollowRecordEntity; | ||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import com.iformall.domain.vo.invest.InvestPage; | |||||
| /** | /** | ||||
| * 跟踪记录 | * 跟踪记录 | ||||
| @@ -15,6 +13,6 @@ import java.util.Map; | |||||
| */ | */ | ||||
| public interface InvestFollowRecordService extends IService<InvestFollowRecordEntity> { | public interface InvestFollowRecordService extends IService<InvestFollowRecordEntity> { | ||||
| List queryPage(InvestFollowRecordEntity params); | |||||
| InvestPage<InvestFollowRecordEntity> queryPage(InvestFollowRecordEntity params); | |||||
| } | } | ||||
| @@ -12,10 +12,7 @@ import com.iformall.service.WxShopService; | |||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| import org.apache.commons.lang3.ObjectUtils; | import org.apache.commons.lang3.ObjectUtils; | ||||
| import java.lang.reflect.Field; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.Objects; | import java.util.Objects; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -91,7 +88,7 @@ public class InvestHelper { | |||||
| public static void checkCustomerExit(InvestCustomerService customerService, Long id) { | public static void checkCustomerExit(InvestCustomerService customerService, Long id) { | ||||
| InvestCustomerEntity customerEntity = customerService.getById(id); | InvestCustomerEntity customerEntity = customerService.getById(id); | ||||
| if (Objects.isNull(customerEntity)) { | if (Objects.isNull(customerEntity)) { | ||||
| throw new MallinkException(ErrorCode.CUSTOMER_NOT_FOUND.getCode(), id + ErrorCode.CUSTOMER_NOT_FOUND.getMessage()); | |||||
| throw new MallinkException(ErrorCode.INVEST_CUSTOMER_NOT_FOUND.getCode(), id + ErrorCode.INVEST_CUSTOMER_NOT_FOUND.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -108,7 +105,7 @@ public class InvestHelper { | |||||
| public static Page buildQueryPage(BaseInvestEntity entity) { | public static Page buildQueryPage(BaseInvestEntity entity) { | ||||
| Page page = new Page(); | Page page = new Page(); | ||||
| page.setCurrent(entity.getPageIndex()); | |||||
| page.setCurrent(entity.getPageNum()); | |||||
| page.setSize(entity.getPageSize()); | page.setSize(entity.getPageSize()); | ||||
| page.setAscs(entity.getAscs()); | page.setAscs(entity.getAscs()); | ||||
| page.setDescs(entity.getDescs()); | page.setDescs(entity.getDescs()); | ||||
| @@ -63,14 +63,14 @@ public class InvestDemandServiceImpl extends ServiceImpl<InvestDemandDao, Invest | |||||
| Map<Long, WxBrand> brandMap = brands.stream().collect(Collectors.toMap(WxBrand::getId, brand -> brand)); | Map<Long, WxBrand> brandMap = brands.stream().collect(Collectors.toMap(WxBrand::getId, brand -> brand)); | ||||
| List<InvestDemandVo> resultList = new ArrayList<>(); | List<InvestDemandVo> resultList = new ArrayList<>(); | ||||
| for (InvestDemandEntity demandEntity : demandList) { | |||||
| InvestCustomerEntity customer = customersMap.get(demandEntity.getCustomerId()); | |||||
| WxShop shop = shopsMap.get(demandEntity.getTargetId()); | |||||
| for (InvestDemandEntity item : demandList) { | |||||
| InvestCustomerEntity customer = customersMap.get(item.getCustomerId()); | |||||
| WxShop shop = shopsMap.get(item.getTargetId()); | |||||
| WxBrand brand = null; | WxBrand brand = null; | ||||
| if (Objects.nonNull(customer)) { | if (Objects.nonNull(customer)) { | ||||
| brand = brandMap.get(customer.getBrandId()); | brand = brandMap.get(customer.getBrandId()); | ||||
| } | } | ||||
| resultList.add(buildCustomerDemandVo(demandEntity, customer, brand, shop)); | |||||
| resultList.add(buildResultItem(item, customer, brand, shop)); | |||||
| } | } | ||||
| BeanUtils.copyProperties(demandPage, investPage); | BeanUtils.copyProperties(demandPage, investPage); | ||||
| @@ -112,18 +112,18 @@ public class InvestDemandServiceImpl extends ServiceImpl<InvestDemandDao, Invest | |||||
| InvestHelper.checkAllNotNull(customerEntity); | InvestHelper.checkAllNotNull(customerEntity); | ||||
| WxBrand brand = brandService.getById(customerEntity.getBrandId()); | WxBrand brand = brandService.getById(customerEntity.getBrandId()); | ||||
| WxShop shop = shopService.getById(demandEntity.getTargetId()); | WxShop shop = shopService.getById(demandEntity.getTargetId()); | ||||
| InvestDemandVo customerDemandVo = buildCustomerDemandVo(demandEntity, customerEntity, brand, shop); | |||||
| InvestDemandVo customerDemandVo = buildResultItem(demandEntity, customerEntity, brand, shop); | |||||
| return customerDemandVo; | return customerDemandVo; | ||||
| } | } | ||||
| private InvestDemandVo buildCustomerDemandVo(InvestDemandEntity demandEntity, InvestCustomerEntity customer, WxBrand brand, WxShop shop) { | |||||
| InvestDemandVo customerDemandVo = InvestDemandVo.builder() | |||||
| private InvestDemandVo buildResultItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop) { | |||||
| InvestDemandVo resultItemVo = InvestDemandVo.builder() | |||||
| .brand(brand) | .brand(brand) | ||||
| .customer(customer) | .customer(customer) | ||||
| .targetInfo(shop) | .targetInfo(shop) | ||||
| .build(); | .build(); | ||||
| BeanUtils.copyProperties(demandEntity, customerDemandVo); | |||||
| return customerDemandVo; | |||||
| BeanUtils.copyProperties(item, resultItemVo); | |||||
| return resultItemVo; | |||||
| } | } | ||||
| @TableLog | @TableLog | ||||
| @@ -1,22 +1,44 @@ | |||||
| package com.iformall.service.invest.impl; | package com.iformall.service.invest.impl; | ||||
| import com.baomidou.mybatisplus.core.conditions.Wrapper; | import com.baomidou.mybatisplus.core.conditions.Wrapper; | ||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | |||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.TableLog; | import com.iformall.common.TableLog; | ||||
| import com.iformall.domain.po.InvestFollowRecordEntity; | import com.iformall.domain.po.InvestFollowRecordEntity; | ||||
| import com.iformall.domain.po.InvestTaskEntity; | |||||
| import com.iformall.domain.vo.invest.InvestPage; | |||||
| import com.iformall.enums.EnumFollowType; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.InvestFollowRecordDao; | import com.iformall.mapper.InvestFollowRecordDao; | ||||
| import com.iformall.service.invest.InvestDemandService; | |||||
| import com.iformall.service.invest.InvestFollowRecordService; | import com.iformall.service.invest.InvestFollowRecordService; | ||||
| import com.iformall.service.invest.InvestHelper; | |||||
| import com.iformall.service.invest.InvestTaskService; | |||||
| import org.springframework.beans.BeanUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.List; | |||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import java.util.Objects; | |||||
| @Service | @Service | ||||
| public class InvestFollowRecordServiceImpl extends ServiceImpl<InvestFollowRecordDao, InvestFollowRecordEntity> implements InvestFollowRecordService { | public class InvestFollowRecordServiceImpl extends ServiceImpl<InvestFollowRecordDao, InvestFollowRecordEntity> implements InvestFollowRecordService { | ||||
| @Autowired | |||||
| private InvestDemandService demandService ; | |||||
| @Autowired | |||||
| private InvestTaskService taskService ; | |||||
| @Override | @Override | ||||
| public List queryPage(InvestFollowRecordEntity params) { | |||||
| return this.list() ; | |||||
| public InvestPage<InvestFollowRecordEntity> queryPage(InvestFollowRecordEntity params) { | |||||
| InvestHelper.checkAllNotNull(params); | |||||
| Page page = InvestHelper.buildQueryPage(params); | |||||
| InvestPage<InvestFollowRecordEntity> investPage = new InvestPage<>(); | |||||
| IPage<InvestFollowRecordEntity> records = this.page(page) ; | |||||
| BeanUtils.copyProperties(records, investPage); | |||||
| return investPage; | |||||
| } | } | ||||
| @TableLog | @TableLog | ||||
| @@ -42,4 +64,15 @@ public class InvestFollowRecordServiceImpl extends ServiceImpl<InvestFollowRecor | |||||
| public boolean updateById(InvestFollowRecordEntity entity) { | public boolean updateById(InvestFollowRecordEntity entity) { | ||||
| return super.updateById(entity); | return super.updateById(entity); | ||||
| } | } | ||||
| private void checkBeforeSaveOrUpdate(InvestFollowRecordEntity entity) { | |||||
| InvestHelper.checkAllNotNull(entity); | |||||
| if(Objects.equals(entity.getType(), EnumFollowType.DEMAND)) { | |||||
| } else if(Objects.equals(entity.getType(), EnumFollowType.TASK)) { | |||||
| } else { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL) ; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | |||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import com.iformall.common.TableLog; | import com.iformall.common.TableLog; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.invest.InvestDemandVo; | |||||
| import com.iformall.domain.vo.invest.InvestPage; | import com.iformall.domain.vo.invest.InvestPage; | ||||
| import com.iformall.domain.vo.invest.InvestTaskVo; | import com.iformall.domain.vo.invest.InvestTaskVo; | ||||
| import com.iformall.mapper.InvestTaskDao; | import com.iformall.mapper.InvestTaskDao; | ||||
| @@ -49,9 +50,9 @@ public class InvestTaskServiceImpl extends ServiceImpl<InvestTaskDao, InvestTask | |||||
| Map<Long, WxShop> shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); | Map<Long, WxShop> shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); | ||||
| List<InvestTaskVo> resultList = new ArrayList<>(); | List<InvestTaskVo> resultList = new ArrayList<>(); | ||||
| for (InvestTaskEntity demandEntity : taskList) { | |||||
| WxShop shop = shopsMap.get(demandEntity.getTargetId()); | |||||
| resultList.add(InvestTaskVo.builder().targetInfo(shop).build()); | |||||
| for (InvestTaskEntity item : taskList) { | |||||
| WxShop shop = shopsMap.get(item.getTargetId()); | |||||
| resultList.add(buildResultItem(item, shop)); | |||||
| } | } | ||||
| BeanUtils.copyProperties(taskPage, investPage); | BeanUtils.copyProperties(taskPage, investPage); | ||||
| @@ -60,6 +61,14 @@ public class InvestTaskServiceImpl extends ServiceImpl<InvestTaskDao, InvestTask | |||||
| return investPage; | return investPage; | ||||
| } | } | ||||
| private InvestTaskVo buildResultItem(InvestTaskEntity item, WxShop shop) { | |||||
| InvestTaskVo resultItemVo = InvestTaskVo.builder() | |||||
| .targetInfo(shop) | |||||
| .build(); | |||||
| BeanUtils.copyProperties(item, resultItemVo); | |||||
| return resultItemVo; | |||||
| } | |||||
| @TableLog | @TableLog | ||||
| @Override | @Override | ||||
| public boolean save(InvestTaskEntity entity) { | public boolean save(InvestTaskEntity entity) { | ||||
| @@ -94,6 +103,7 @@ public class InvestTaskServiceImpl extends ServiceImpl<InvestTaskDao, InvestTask | |||||
| private void checkBeforeSaveOrUpdate(InvestTaskEntity entity) { | private void checkBeforeSaveOrUpdate(InvestTaskEntity entity) { | ||||
| InvestHelper.checkAllNotNull(entity); | |||||
| // 1 check shop 状态 | // 1 check shop 状态 | ||||
| InvestHelper.checkShop(shopService, entity); | InvestHelper.checkShop(shopService, entity); | ||||
| // 2 check user | // 2 check user | ||||