package com.sooka.sponest.mobile.comprehensive.comprehensiveconflictdefuseController; import com.ruoyi.common.core.constant.HttpStatus; import com.ruoyi.common.core.domain.DictKeys; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.PageDomain; import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableSupport; import com.ruoyi.common.security.utils.DictUtils; import com.sooka.sponest.comprehensive.api.comprehensiveOrganizationAndInstitution.domain.ComprehensiveRfhGridLeader; import com.sooka.sponest.comprehensive.api.comprehensiveOrganizationAndInstitution.service.RemoteRfhGridLeaderService; import org.apache.commons.collections4.MapUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; import java.util.Map; import static com.ruoyi.common.security.utils.DictUtils.getComprehensiveDictCacheToMap; /** * 网格长管理App * * @author hanfucheng * @date 2023/9/6 14:57 */ @RestController @RequestMapping("/AppGridLeaderController") public class AppGridLeaderController extends BaseController { @Resource RemoteRfhGridLeaderService remoteRfhGridLeaderService; /** * 查询网格长管理列表 */ @GetMapping("/leader/list") public AjaxResult list(ComprehensiveRfhGridLeader comprehensiveRfhGridLeader) { PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); TableDataInfo tableDataInfo = remoteRfhGridLeaderService.selectComprehensiveRfhGridLeaderList(pageNum, pageSize, comprehensiveRfhGridLeader.getUserName(), comprehensiveRfhGridLeader.getMemberName()); if(HttpStatus.SUCCESS == tableDataInfo.getCode()){ List> rows = (List>) tableDataInfo.getRows(); Map map = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_SEX);//性别 Map map1 = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_NATION);//民族 Map map2 = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_POLITICAL_STATUS);//政治面貌 Map map3 = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_EDUCATIONAL_BACKGROUND);//学历 for (Map row : rows) { row.put("genderLabel",map.get(MapUtils.getString(row,"gender"))); row.put("nationLabel",map1.get(MapUtils.getString(row,"nation"))); row.put("politicalOutlookLabel",map2.get(MapUtils.getString(row,"politicalOutlook"))); row.put("educationLabel",map3.get(MapUtils.getString(row,"education"))); } return AjaxResult.success(tableDataInfo.getRows()); }else{ return AjaxResult.error(tableDataInfo.getCode(),tableDataInfo.getMsg()); } } @GetMapping("/leader/listAll") public AjaxResult listAll(ComprehensiveRfhGridLeader comprehensiveRfhGridLeader) { AjaxResult ajaxResult = remoteRfhGridLeaderService.listAll(); if ("200".equals(ajaxResult.get("code").toString())){ Map map = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_SEX);//性别 Map map1 = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_NATION);//民族 Map map2 = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_POLITICAL_STATUS);//政治面貌 Map map3 = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_EDUCATIONAL_BACKGROUND);//学历 List> data = (List>) ajaxResult.get("data"); for (Map row : data) { row.put("genderLabel",map.get(MapUtils.getString(row,"gender"))); row.put("nationLabel",map1.get(MapUtils.getString(row,"nation"))); row.put("politicalOutlookLabel",map2.get(MapUtils.getString(row,"politicalOutlook"))); row.put("educationLabel",map3.get(MapUtils.getString(row,"education"))); } } return ajaxResult; } /** * 获取网格长管理详细信息 */ @GetMapping("/leader/edit") public AjaxResult getInfo(String id) { AjaxResult ajaxResult = remoteRfhGridLeaderService.selectComprehensiveRfhGridLeaderById(id); if ("200".equals(ajaxResult.get("code").toString())){ Map data = (Map) ajaxResult.get("data"); data.put("genderLabel",DictUtils.getDictDataByValue(DictKeys.COMPREHENSIVE_SEX, MapUtils.getString(data,"gender"))); data.put("nationLabel",DictUtils.getDictDataByValue(DictKeys.COMPREHENSIVE_NATION, MapUtils.getString(data,"nation"))); data.put("politicalOutlookLabel",DictUtils.getDictDataByValue(DictKeys.COMPREHENSIVE_POLITICAL_STATUS, MapUtils.getString(data,"politicalOutlook"))); data.put("educationLabel",DictUtils.getDictDataByValue(DictKeys.COMPREHENSIVE_EDUCATIONAL_BACKGROUND, MapUtils.getString(data,"education"))); } return ajaxResult; } /** * 新增网格长管理 */ @PostMapping("/leader") public AjaxResult add(@RequestBody String json) { return remoteRfhGridLeaderService.insertComprehensiveRfhGridLeader(json); } /** * 修改网格长管理 */ @PostMapping("/leader/put") public AjaxResult edit(@RequestBody String json) { return remoteRfhGridLeaderService.updateComprehensiveRfhGridLeader(json); } /** * 删除网格长管理 */ @GetMapping("/leader/del") public AjaxResult remove(@RequestParam("id") List id) { return remoteRfhGridLeaderService.deleteComprehensiveRfhGridLeaderByIds(id.toArray(new String[0])); } }