|
|
@@ -22,15 +22,9 @@ 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.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author 墨鱼_mo
|
|
|
@@ -57,51 +51,50 @@ public class CooperationInfoApiController {
|
|
|
@PostMapping("cooperationInfoList")
|
|
|
@ApiOperation(value = "互助信息列表(公开接口)")
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "type", value = "type", required = true, paramType = "form")
|
|
|
+ @ApiImplicitParam(name = "type", value = "type(1:闲置资源,2:企业需求)", required = true, paramType = "form")
|
|
|
})
|
|
|
- public MessageResult<Map> cooperationInfoList(String type,@RequestParam(value="pageIndex",defaultValue="1") int pageIndex, @RequestParam(value="pageSize",defaultValue="10") int pageSize) {
|
|
|
+ public MessageResult<Map> cooperationInfoList(String type, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
List<CooperationInfoListDTO> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
-
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
- searchParams.put("type",type);
|
|
|
- searchParams.put("status",1);
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("type", type);
|
|
|
+ searchParams.put("status", 1);
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("create_time","desc"));
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
|
|
|
- Page<CooperationInfo> page = cooperationInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+ Page<CooperationInfo> page = cooperationInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
List<CooperationInfo> cooperationInfoList = page.getResult();
|
|
|
- if (cooperationInfoList.size()>0){
|
|
|
- for (CooperationInfo cooperationInfo : cooperationInfoList){
|
|
|
+ if (cooperationInfoList.size() > 0) {
|
|
|
+ for (CooperationInfo cooperationInfo : cooperationInfoList) {
|
|
|
CooperationInfoListDTO cooperationInfoListDTO = new CooperationInfoListDTO();
|
|
|
- BeanUtils.copyProperties(cooperationInfo,cooperationInfoListDTO);
|
|
|
+ BeanUtils.copyProperties(cooperationInfo, cooperationInfoListDTO);
|
|
|
CompanyInfo companyInfo = companyInfoService.get(cooperationInfo.getCompanyId());
|
|
|
- if (companyInfo != null){
|
|
|
+ if (companyInfo != null) {
|
|
|
cooperationInfoListDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
- cooperationInfoListDTO.setCreateTime(DateUtil.format(cooperationInfo.getCreateTime(),"yyyy-MM-dd HH:mm"));
|
|
|
+ cooperationInfoListDTO.setCreateTime(DateUtil.format(cooperationInfo.getCreateTime(), "yyyy-MM-dd HH:mm"));
|
|
|
list.add(cooperationInfoListDTO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Map<String,Object> pageMap = new HashMap<>();
|
|
|
+ Map<String, Object> pageMap = new HashMap<>();
|
|
|
|
|
|
- pageMap.put("recordsTotal",page.getTotal());
|
|
|
- pageMap.put("recordsFiltered",page.getTotal());
|
|
|
- pageMap.put("totalPage",page.getPages());
|
|
|
- pageMap.put("pageNumber",page.getPageNum());
|
|
|
- pageMap.put("pageSize",page.getPageSize());
|
|
|
+ pageMap.put("recordsTotal", page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered", page.getTotal());
|
|
|
+ pageMap.put("totalPage", page.getPages());
|
|
|
+ pageMap.put("pageNumber", page.getPageNum());
|
|
|
+ pageMap.put("pageSize", page.getPageSize());
|
|
|
pageMap.put("data", list);
|
|
|
|
|
|
messageResult.setData(pageMap);
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
- log.error(ex.getMessage(),ex);
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
messageResult.setCode(400);
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|
|
|
@@ -122,20 +115,20 @@ public class CooperationInfoApiController {
|
|
|
|
|
|
CooperationInfo cooperationInfo = cooperationInfoService.get(id);
|
|
|
CooperationInfoDTO cooperationInfoDTO = new CooperationInfoDTO();
|
|
|
- if (cooperationInfo != null){
|
|
|
- BeanUtils.copyProperties(cooperationInfo,cooperationInfoDTO);
|
|
|
+ if (cooperationInfo != null) {
|
|
|
+ BeanUtils.copyProperties(cooperationInfo, cooperationInfoDTO);
|
|
|
CompanyInfo companyInfo = companyInfoService.get(cooperationInfo.getCompanyId());
|
|
|
- if (companyInfo != null){
|
|
|
+ if (companyInfo != null) {
|
|
|
cooperationInfoDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
cooperationInfoDTO.setCompanyLogo(companyInfo.getLogoUrl());
|
|
|
}
|
|
|
PersonInfo personInfo = personInfoService.get(cooperationInfo.getCreateBy());
|
|
|
- if (personInfo != null){
|
|
|
+ if (personInfo != null) {
|
|
|
cooperationInfoDTO.setPersonName(personInfo.getPersonName());
|
|
|
}
|
|
|
|
|
|
- cooperationInfoDTO.setCreateTime(DateUtil.format(cooperationInfo.getCreateTime(),"yyyy-MM-dd"));
|
|
|
- String typeName = dataDictionaryService.findNameByCatalogNameAndValue("互助类型",cooperationInfo.getType());
|
|
|
+ cooperationInfoDTO.setCreateTime(DateUtil.format(cooperationInfo.getCreateTime(), "yyyy-MM-dd"));
|
|
|
+ String typeName = dataDictionaryService.findNameByCatalogNameAndValue("互助类型", cooperationInfo.getType());
|
|
|
cooperationInfoDTO.setTypeName(typeName);
|
|
|
}
|
|
|
|
|
|
@@ -144,7 +137,156 @@ public class CooperationInfoApiController {
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
- log.error(ex.getMessage(),ex);
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("cooperationInfoListForOwn")
|
|
|
+ @ApiOperation(value = "个人互助信息列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type", value = "type(1:闲置资源,2:企业需求)", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> cooperationInfoListForOwn(String type, String token, @RequestAttribute String subject, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<CooperationInfoListDTO> list = new ArrayList<>();
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
+ if (personInfo == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if (companyInfo == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("type", type);
|
|
|
+ searchParams.put("status", 1);
|
|
|
+ searchParams.put("companyId", companyInfo.getId());
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
+
|
|
|
+ Page<CooperationInfo> page = cooperationInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+ List<CooperationInfo> cooperationInfoList = page.getResult();
|
|
|
+ if (cooperationInfoList.size() > 0) {
|
|
|
+ for (CooperationInfo cooperationInfo : cooperationInfoList) {
|
|
|
+ CooperationInfoListDTO cooperationInfoListDTO = new CooperationInfoListDTO();
|
|
|
+ BeanUtils.copyProperties(cooperationInfo, cooperationInfoListDTO);
|
|
|
+
|
|
|
+ cooperationInfoListDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
+ cooperationInfoListDTO.setCreateTime(DateUtil.format(cooperationInfo.getCreateTime(), "yyyy-MM-dd HH:mm"));
|
|
|
+ list.add(cooperationInfoListDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> pageMap = new HashMap<>();
|
|
|
+
|
|
|
+ pageMap.put("recordsTotal", page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered", page.getTotal());
|
|
|
+ pageMap.put("totalPage", page.getPages());
|
|
|
+ pageMap.put("pageNumber", page.getPageNum());
|
|
|
+ pageMap.put("pageSize", page.getPageSize());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("submitCooperationInfo")
|
|
|
+ @ApiOperation(value = "个人互助信息提交")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type", value = "type(1:闲置资源,2:企业需求)", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "content", value = "内容", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> submitCooperationInfo(String type, String token, @RequestAttribute String subject,String content) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
+ if (personInfo == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if (companyInfo == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+ CooperationInfo cooperationInfo = new CooperationInfo();
|
|
|
+ cooperationInfo.setId(UUID.randomUUID().toString());
|
|
|
+ cooperationInfo.setCompanyId(companyInfo.getId());
|
|
|
+ cooperationInfo.setType(type);
|
|
|
+ cooperationInfo.setContent(content);
|
|
|
+ cooperationInfo.setCreateBy(personInfo.getId());
|
|
|
+ cooperationInfo.setCreateTime(new Date());
|
|
|
+ cooperationInfo.setDelFlag(false);
|
|
|
+ cooperationInfo.setStatus(true);
|
|
|
+ cooperationInfoService.insert(cooperationInfo);
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("deleteCooperationInfo")
|
|
|
+ @ApiOperation(value = "个人互助信息删除")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> deleteCooperationInfo(String id, String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
+ if (personInfo == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if (companyInfo == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+ CooperationInfo cooperationInfo = cooperationInfoService.get(id);
|
|
|
+ if (cooperationInfo != null){
|
|
|
+ cooperationInfo.setDelFlag(true);
|
|
|
+ cooperationInfo.setUpdateBy(personInfo.getId());
|
|
|
+ cooperationInfo.setUpdateTime(new Date());
|
|
|
+ cooperationInfoService.update(cooperationInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
messageResult.setCode(400);
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|