|
@@ -71,6 +71,54 @@ public class PersonCompanyController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value="批量添加信息")
|
|
|
+ @PostMapping("batchAdd")
|
|
|
+ public MessageResult<Integer> batchAdd(@RequestBody String personId,
|
|
|
+ @RequestBody List<String> companyIds,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ int affectCount = 0;
|
|
|
+
|
|
|
+ MessageResult<List<PersonCompany>> list = list(personId,null,subject);
|
|
|
+ for(PersonCompany personCompany : list.getData()){
|
|
|
+ personCompanyService.delete(personCompany.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String companyId : companyIds) {
|
|
|
+ PersonCompany personCompany = new PersonCompany();
|
|
|
+
|
|
|
+ personCompany.setId(UUID.randomUUID().toString());
|
|
|
+ personCompany.setPersonId(Long.valueOf(personId));
|
|
|
+ personCompany.setCompanyId(companyId);
|
|
|
+ personCompany.setDelFlag(false);
|
|
|
+ personCompany.setCreateBy(subject);
|
|
|
+ personCompany.setCreateTime(new Date());
|
|
|
+
|
|
|
+ personCompanyService.insert(personCompany);
|
|
|
+
|
|
|
+ affectCount++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(affectCount);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value="获取信息")
|
|
|
@GetMapping("edit/{id}")
|
|
|
public MessageResult<PersonCompany> edit(@PathVariable("id") String id){
|
|
@@ -193,7 +241,7 @@ public class PersonCompanyController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
+ @ApiOperation(value="分页列表")
|
|
|
@RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
|
String id,
|
|
@@ -222,4 +270,34 @@ public class PersonCompanyController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value="列表")
|
|
|
+ @RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
+ public MessageResult<List<PersonCompany>> list(
|
|
|
+ @RequestParam(value="personId",defaultValue="") String personId,
|
|
|
+ @RequestParam(value="companyId",defaultValue="") String companyId,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<List<PersonCompany>> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(personId)) {
|
|
|
+ searchParams.put("personId", personId);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(companyId)) {
|
|
|
+ searchParams.put("companyId", companyId);
|
|
|
+ }
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("id_","asc"));
|
|
|
+
|
|
|
+ Page<PersonCompany> page = personCompanyService.pageSearch(searchParams,1,1000,false,sortList);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(page.getResult());
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
}
|