diff --git a/dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java b/dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java index 13d1d446..633801ae 100644 --- a/dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java +++ b/dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java @@ -18,5 +18,5 @@ public interface EmployeeControllerApi { * 根据id查询员工的基本信息和部门信息 */ @ApiOperation(value = "根据id查询员工的基本信息和部门信息", notes = "根据id查询员工的基本信息和部门信息") - ResponseResult getEmployeeAndDeptById(List ids); + ResponseResult getEmployeeAndDeptById(Long[] ids); } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java index df7c7fb2..9c8cd15d 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java @@ -40,48 +40,4 @@ public class CustomerController implements CustomerControllerApi { } - /** - * 信息 - */ - @GetMapping("/info/{id}") - //@RequiresPermissions("crms:customer:info") - public ResponseResult info(@PathVariable("id") Long id) { - CustomerEntity customer = customerService.getById(id); - - return new ResponseResult().SUCCESS(customer); - } - - /** - * 保存 - */ - @PostMapping("/save") - //@RequiresPermissions("crms:customer:save") - public ResponseResult save(@RequestBody CustomerEntity customer) { - customerService.save(customer); - - return ResponseResult.SUCCESS(); - } - - /** - * 修改 - */ - @PutMapping("/update") - //@RequiresPermissions("crms:customer:update") - public ResponseResult update(@RequestBody CustomerEntity customer) { - customerService.updateById(customer); - - return ResponseResult.SUCCESS(); - } - - /** - * 删除 - */ - @DeleteMapping("/delete") - //@RequiresPermissions("crms:customer:delete") - public ResponseResult delete(@RequestBody Long[] ids) { - customerService.removeByIds(Arrays.asList(ids)); - - return ResponseResult.SUCCESS(); - } - } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/feign/HrmsFeignService.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/feign/HrmsFeignService.java index 69504248..c0403738 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/feign/HrmsFeignService.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/feign/HrmsFeignService.java @@ -4,10 +4,7 @@ import com.daqing.framework.domain.hrms.ext.EmployeeTO; import com.daqing.framework.model.response.ResponseResult; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @@ -21,6 +18,6 @@ public interface HrmsFeignService { @GetMapping("/hrms/dept/list") ResponseResult list(@RequestParam Map params); - @GetMapping("/hrms/employee/getEmployeeAndDeptById/{ids}") - ResponseResult> getEmployeeAndDeptById(@PathVariable("ids") List ids); + @GetMapping("/hrms/employee/getEmployeeAndDeptById/{ids}") // 远程调用传递集合类型的参数必须以数组封装,不然会导致数据接收不完整 + ResponseResult> getEmployeeAndDeptById(@PathVariable("ids") Long[] ids); } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java index 7a1e8c60..92d5a19b 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java @@ -1,6 +1,5 @@ package com.daqing.financial.crms.service.impl; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -20,6 +19,7 @@ import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service("customerService") @@ -43,7 +43,7 @@ public class CustomerServiceImpl extends ServiceImpl customers = customerEntityIPage.getRecords(); // 获取所有的客户经理id - List ids = customers.stream().map(CustomerEntity::getId).collect(Collectors.toList()); + Long[] ids = customers.stream().map(CustomerEntity::getId).toArray(Long[]::new); // 用于拼装客户信息和员工及部门信息的集合 List customerTOS = new ArrayList<>(); - CustomerTO customerTO = new CustomerTO(); + CustomerTO customerTO; //TODO 远程调用查询客户经理信息的接口 - ResponseResult result = hrmsFeignService.getEmployeeAndDeptById(ids); - List employeeTO = (List) result.getData(); - - /*String data = (String) responseResult.getData(); - List employeeTO = JSON.parseArray(data, EmployeeTO.class);*/ + ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids); + List employeeTO = (List) responseResult.getData(); // 将客户信息和客户经理及部门信息拼装起来 for (CustomerEntity customer : customers) { + // 每一个客户对应一个不同的对象 + customerTO = new CustomerTO(); for (EmployeeTO anEmployeeTO : employeeTO) { if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) { customerTO.setId(customer.getId()); @@ -91,7 +91,7 @@ public class CustomerServiceImpl extends ServiceImpl list1 = (List) list.getList(); list1.forEach(customerEntity -> System.out.println(customerEntity)); diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java index aa777d96..58192a71 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java @@ -82,8 +82,8 @@ public class EmployeeController implements EmployeeControllerApi{ */ @GetMapping("/getEmployeeAndDeptById/{ids}") @Override - public ResponseResult getEmployeeAndDeptById(@PathVariable("ids") List ids) { - List byId = employeeService.getEmployeeAndDeptById(ids); - return new ResponseResult>().SUCCESS(byId); + public ResponseResult getEmployeeAndDeptById(@RequestBody @PathVariable("ids") Long[] ids) { + List employeeTO = employeeService.getEmployeeAndDeptById(Arrays.asList(ids)); + return new ResponseResult>().SUCCESS(employeeTO); } } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java index a5b6588e..43190108 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java @@ -1,7 +1,5 @@ package com.daqing.financial.hrms.dao; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.daqing.framework.domain.hrms.EmployeeEntity; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.daqing.framework.domain.hrms.ext.EmployeeTO; diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java index 538c55a6..767c0ca4 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java @@ -14,7 +14,7 @@ public class EmployeeServiceImpl extends ServiceImpl +