|
|
@@ -0,0 +1,156 @@
|
|
|
+package com.jpsoft.enterprise.modules.mobile.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.ActivityInfoListDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.CooperationInfoDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.CooperationInfoListDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.ActivityInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.CooperationInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.PersonInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.CooperationInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.PersonInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.enterprise.modules.sys.entity.DataDictionary;
|
|
|
+import com.jpsoft.enterprise.modules.sys.service.DataDictionaryService;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+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 java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 墨鱼_mo
|
|
|
+ * @date 2021-1-13 14:52
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mobile/cooperationInfoApi")
|
|
|
+@Slf4j
|
|
|
+public class CooperationInfoApiController {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CooperationInfoService cooperationInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyInfoService companyInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @PostMapping("cooperationInfoList")
|
|
|
+ @ApiOperation(value = "互助信息列表(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type", value = "type", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(cooperationInfo.getCompanyId());
|
|
|
+ if (companyInfo != null){
|
|
|
+ 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("cooperationInfoDetail")
|
|
|
+ @ApiOperation(value = "互助信息详情(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<CooperationInfoDTO> cooperationInfoDetail(String id) {
|
|
|
+ MessageResult<CooperationInfoDTO> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ CooperationInfo cooperationInfo = cooperationInfoService.get(id);
|
|
|
+ CooperationInfoDTO cooperationInfoDTO = new CooperationInfoDTO();
|
|
|
+ if (cooperationInfo != null){
|
|
|
+ BeanUtils.copyProperties(cooperationInfo,cooperationInfoDTO);
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(cooperationInfo.getCompanyId());
|
|
|
+ if (companyInfo != null){
|
|
|
+ cooperationInfoDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
+ cooperationInfoDTO.setCompanyLogo(companyInfo.getLogoUrl());
|
|
|
+ }
|
|
|
+ PersonInfo personInfo = personInfoService.get(cooperationInfo.getCreateBy());
|
|
|
+ if (personInfo != null){
|
|
|
+ cooperationInfoDTO.setPersonName(personInfo.getPersonName());
|
|
|
+ }
|
|
|
+
|
|
|
+ cooperationInfoDTO.setCreateTime(DateUtil.format(cooperationInfo.getCreateTime(),"yyyy-MM-dd"));
|
|
|
+ String typeName = dataDictionaryService.findNameByCatalogNameAndValue("互助类型",cooperationInfo.getType());
|
|
|
+ cooperationInfoDTO.setTypeName(typeName);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(cooperationInfoDTO);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|