New file |
| | |
| | | package com.panzhihua.community_backstage.api; |
| | | |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.listen.ComEldersAuthElderlyExcelListen; |
| | | import com.panzhihua.common.model.dtos.community.EldersAuthElderlyDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageEldersAuthElderlyDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComEldersAuthElderlyVO; |
| | | import com.panzhihua.common.model.vos.community.EldersAuthElderlyExcelVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * |
| | | * @author cedoo email:cedoo(a)qq.com |
| | | * @version 1.0 |
| | | * @since 1.0 |
| | | * */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/eldersauthelderly") |
| | | @Api(tags = {"高龄老人"}) |
| | | public class EldersAuthElderlyApi extends BaseController { |
| | | |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | /** |
| | | * 高领老人列表 |
| | | * @param pageEldersAuthElderlyDTO |
| | | * @return |
| | | */ |
| | | @PostMapping("/page") |
| | | @ApiOperation(value = "高领老人列表", response = ComEldersAuthElderlyVO.class) |
| | | R query(@Validated @RequestBody PageEldersAuthElderlyDTO pageEldersAuthElderlyDTO){ |
| | | // ClazzUtils.setIfStringIsEmpty(pageEldersAuthElderlyDTO); |
| | | // pageEldersAuthElderlyDTO.setUserId(getUserId()); |
| | | return communityService.pageQueryEldersAuthElderly(pageEldersAuthElderlyDTO); |
| | | } |
| | | |
| | | /** |
| | | * 高领老人导入 |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @PostMapping("/import") |
| | | @ApiOperation(value = "高领老人导入", response = R.class) |
| | | R batchSave(@RequestParam MultipartFile file){ |
| | | InputStream inputStream; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | EasyExcel.read(inputStream, EldersAuthElderlyExcelVO.class, new ComEldersAuthElderlyExcelListen(communityService, getCommunityId(),getUserId())).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
| | | } |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 查看高龄老人详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "高领老人详情", response = ComEldersAuthElderlyVO.class) |
| | | R details(@PathVariable("id") Long id){ |
| | | return communityService.getEldersAuthElderlyById(id); |
| | | } |
| | | |
| | | /** |
| | | * 修改高龄老人 |
| | | * @param eldersAuthElderlyDTO |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperation(value = "更新高龄老人信息", response = R.class) |
| | | R update(@RequestBody EldersAuthElderlyDTO eldersAuthElderlyDTO){ |
| | | return communityService.updateEldersAuthElderly(eldersAuthElderlyDTO); |
| | | } |
| | | |
| | | /** |
| | | * 删除高龄老人 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | @ApiOperation(value = "更新高龄老人信息", response = R.class) |
| | | R delete(@RequestParam("id") Long id){ |
| | | return communityService.deleteEldersAuthElderly(id); |
| | | } |
| | | |
| | | |
| | | } |