New file |
| | |
| | | package com.cl.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.cl.common.result.Result; |
| | | import com.cl.pojo.dto.AddInstitutionDTO; |
| | | import com.cl.pojo.dto.DataPageDTO; |
| | | import com.cl.pojo.dto.EditInstitutionDTO; |
| | | import com.cl.pojo.dto.InstitutionPageDTO; |
| | | import com.cl.pojo.entity.Institution; |
| | | import com.cl.pojo.vo.InstitutionVO; |
| | | import com.cl.service.InstitutionService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/institution") |
| | | @Slf4j |
| | | @Api(tags = "机构") |
| | | @Validated |
| | | public class InstitutionController { |
| | | @Autowired |
| | | private InstitutionService institutionService; |
| | | |
| | | /** |
| | | * 添加 |
| | | */ |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加机构") |
| | | public Result<String> add(@RequestBody @Valid AddInstitutionDTO addDTO) { |
| | | institutionService.add(addDTO); |
| | | return Result.success("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | @PostMapping("/pageList") |
| | | @ApiOperation("机构分页") |
| | | public Result<IPage<InstitutionVO> > pageList(@RequestBody @Valid InstitutionPageDTO dataPageDTO) { |
| | | IPage<Institution> page = new Page<>(dataPageDTO.getPageNum(), dataPageDTO.getPageSize()); |
| | | return Result.success(institutionService.pageList(page,dataPageDTO.getCountyList(),dataPageDTO.getName())); |
| | | } |
| | | /** |
| | | * 编辑回显 |
| | | */ |
| | | @GetMapping("/read/{id}") |
| | | @ApiOperation("详情(回显)") |
| | | public Result<InstitutionVO> read(@PathVariable("id")Integer id) { |
| | | return Result.success(institutionService.read(id)); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | */ |
| | | @PutMapping("/edit") |
| | | @ApiOperation("修改机构") |
| | | public Result<String> edit(@RequestBody @Valid EditInstitutionDTO editDTO) { |
| | | institutionService.edit(editDTO); |
| | | return Result.success("修改成功"); |
| | | } |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @DeleteMapping("/delete/{id}") |
| | | @ApiOperation("删除机构") |
| | | public Result<String> delete(@PathVariable("id")Integer id) { |
| | | institutionService.delete(id); |
| | | return Result.success("删除成功"); |
| | | } |
| | | /** |
| | | * 大屏数据 |
| | | */ |
| | | @GetMapping("/getAll/{county}") |
| | | @ApiOperation("大屏滚动数据") |
| | | public Result<List<InstitutionVO>> getAll(@PathVariable("county") Integer county) { |
| | | return Result.success(institutionService.getAll(county)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |