package com.hz.employmentsite.controller.baseSettings; import com.github.pagehelper.PageInfo; import com.hz.employmentsite.filter.exception.BaseResponse; import com.hz.employmentsite.filter.exception.RespGenerstor; import com.hz.employmentsite.model.SelectProps; import com.hz.employmentsite.util.ExcelHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.hz.employmentsite.services.service.baseSettings.InstitutionService; import com.hz.employmentsite.services.service.baseSettings.SiteInfoService; import com.hz.employmentsite.services.service.AccountService; import com.hz.employmentsite.vo.baseSettings.InstitutionVo; import javax.servlet.http.HttpServletResponse; import java.util.*; @RestController @RequestMapping("/api/institution/") public class InstitutionController { @Autowired private AccountService accountService; @Autowired private InstitutionService institutionService; @Autowired private SiteInfoService siteInfoService; @Autowired private ExcelHelper excelHelper; @ResponseBody @GetMapping("/getList") public BaseResponse> getList(@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize, @RequestParam(required = false) String primaryKey, @RequestParam(required = false) String companyName, @RequestParam(required = false) String companyAddress, @RequestParam(required = false) String dutyUserName) { PageInfo result = institutionService.getList(pageIndex,pageSize,primaryKey,companyName,companyAddress,dutyUserName); return RespGenerstor.success(result); } @GetMapping("get") public BaseResponse get(@RequestParam(required = false) String institutionID) { InstitutionVo dataModel = new InstitutionVo(); if (institutionID == null || institutionID == ""){ dataModel.institutionID = UUID.randomUUID().toString(); }else{ dataModel = institutionService.get(institutionID); } dataModel.manageSites = null; return RespGenerstor.success(dataModel); } @ResponseBody @GetMapping("/getDataList") public BaseResponse> getDataList() { return RespGenerstor.success(institutionService.getDataList()); } @PostMapping("save") public BaseResponse save(@RequestBody InstitutionVo data) { return RespGenerstor.success(institutionService.save(data,accountService.getLoginUserID())); } @GetMapping("export") public BaseResponse export(HttpServletResponse response, @RequestParam(required = false) Boolean isExport, @RequestParam("page") int page, @RequestParam("rows") int rows, @RequestParam(required = false) String szkey, @RequestParam(required = false) String companyName, @RequestParam(required = false) String companyAddress,@RequestParam(required = false) String dutyUserName) throws Exception{ PageInfo result = institutionService.getList(page,rows,szkey,companyName,companyAddress,dutyUserName); if (isExport == null || !isExport) { return RespGenerstor.success(result); } else { ExcelHelper.ExcelData data = excelHelper.new ExcelData(); data.setTitles(Arrays.asList(new String[]{"序号","年级","问题反馈日期", "学院", "问题描述","问题特性", "解决方案", "是否解决", "解决时间", "登记人"})); int i = 0; List> rowDatas = new ArrayList(); for (InstitutionVo item : result.getList()) { List row = new ArrayList(); ++i; row.add(i); row.add(item.companyCode); row.add(item.companyCode); row.add(item.fzrName); row.add(item.fzrMobile); row.add(item.frName); row.add(item.frMobile); row.add(item.companyAddress); row.add(item.companyDesc); row.add(item.createUserID); row.add(item.createTime); row.add(item.modifyUserID); row.add(item.modifyTime); rowDatas.add(row); } data.setRows(rowDatas); excelHelper.exportExcel(response, data); return null; } } @ResponseBody @PostMapping("/delete") public BaseResponse delete(@RequestBody List idList){ return RespGenerstor.success(institutionService.delete(idList)); } }