| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.export.THelpNeedsExport; |
| | | import com.ruoyi.system.export.TMicroWishExport; |
| | | import com.ruoyi.system.model.TAppUser; |
| | | import com.ruoyi.system.model.THelpNeeds; |
| | | import com.ruoyi.system.model.THelpNeeds; |
| | | import com.ruoyi.system.query.AssistedDiningListQuery; |
| | | import com.ruoyi.system.query.HelpNeedsListQuery; |
| | | import com.ruoyi.system.query.TCourseOrderQuery; |
| | | import com.ruoyi.system.service.THelpNeedsService; |
| | | import com.ruoyi.system.service.THelpNeedsService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | public class THelpNeedsController { |
| | | @Autowired |
| | | private THelpNeedsService helpNeedsService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @ApiOperation(value = "助需管理分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<THelpNeeds>> pageList(@RequestBody HelpNeedsListQuery query) { |
| | |
| | | @Log(title = "助需管理-添加", businessType = BusinessType.INSERT) |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> save(@RequestBody THelpNeeds dto) { |
| | | String nickName = tokenService.getLoginUser().getUser().getNickName(); |
| | | dto.setNickName(nickName); |
| | | helpNeedsService.save(dto); |
| | | return R.ok(); |
| | | } |
| | |
| | | } |
| | | @ApiOperation(value = "查看详情") |
| | | @GetMapping(value = "/detail") |
| | | public R<THelpNeeds> detail(Integer id) { |
| | | public R<THelpNeeds> detail(String id) { |
| | | return R.ok(helpNeedsService.getById( id)); |
| | | } |
| | | |
| | | @Log(title = "助需管理-助需记录导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "助需记录导出") |
| | | @PostMapping("/exportHelpNeeds") |
| | | public void exportHelpNeeds(@RequestBody HelpNeedsListQuery query){ |
| | | List<THelpNeedsExport> helpNeedsExports = helpNeedsService.exportHelpNeeds(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), THelpNeedsExport.class, helpNeedsExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("助需记录导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |