package com.kidgrow.oprationcenter.controller;
|
|
import com.kidgrow.common.controller.BaseController;
|
import com.kidgrow.common.model.PageResult;
|
import com.kidgrow.common.model.ResultBody;
|
import com.kidgrow.common.utils.ExcelUtil;
|
import com.kidgrow.oprationcenter.model.DataNeed;
|
import com.kidgrow.oprationcenter.service.IDataNeedService;
|
import com.kidgrow.oprationcenter.vo.DataNeedExcel;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.BindingResult;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import javax.validation.Valid;
|
import java.io.IOException;
|
import java.util.List;
|
import java.util.Map;
|
|
|
/**
|
* 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
|
* @Description: 医生的数据需求
|
* @Project: 用户中心
|
* @CreateDate: Created in 2020-04-01 09:37:04 <br>
|
* @Author: <a href="4345453@kidgrow.com">liuke</a>
|
* @version: 1.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/dataneed")
|
@Api(tags = "医生的数据需求")
|
public class DataNeedController extends BaseController{
|
@Autowired
|
private IDataNeedService dataNeedService;
|
|
/**
|
* 列表
|
*/
|
@ApiOperation(value = "查询列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
|
@ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer")
|
})
|
@GetMapping
|
public PageResult list(@RequestParam Map<String, Object> params) {
|
if(params.size()==0){
|
params.put("page",1);
|
params.put("limit",10);
|
}
|
return dataNeedService.findList(params);
|
}
|
|
/**
|
* 查询
|
*/
|
@ApiOperation(value = "查询")
|
@GetMapping("/{id}")
|
public ResultBody findById(@PathVariable Long id) {
|
DataNeed model = dataNeedService.getById(id);
|
return ResultBody.ok().data(model).msg("查询成功");
|
}
|
|
/**
|
* 根据DataNeed当做查询条件进行查询
|
*/
|
@ApiOperation(value = "根据DataNeed当做查询条件进行查询")
|
@PostMapping("/query")
|
public ResultBody findByObject(@RequestBody DataNeed dataNeed) {
|
DataNeed model = dataNeedService.findByObject(dataNeed);
|
return ResultBody.ok().data(model).msg("查询成功");
|
}
|
|
/**
|
* 新增or更新
|
*/
|
@ApiOperation(value = "保存")
|
@PostMapping
|
public ResultBody save(@Valid @RequestBody DataNeed dataNeed, BindingResult bindingResult) {
|
if (bindingResult.hasErrors()) {
|
return ResultBody.failed().msg(bindingResult.getFieldError().getDefaultMessage());
|
} else {
|
dataNeedService.saveOrUpdate(dataNeed);
|
return ResultBody.ok().data(dataNeed).msg("保存成功");
|
}
|
}
|
|
/**
|
* 删除
|
*/
|
@ApiOperation(value = "删除")
|
@DeleteMapping("/{id}")
|
public ResultBody delete(@PathVariable Long id) {
|
dataNeedService.removeById(id);
|
return ResultBody.ok().msg("删除成功");
|
}
|
/**
|
* 导出excel
|
*
|
* @return
|
*/
|
@PostMapping("/export")
|
public ResultBody exportUser(@RequestParam Map<String, Object> params, HttpServletResponse response) throws IOException {
|
List<DataNeedExcel> result = dataNeedService.findListExportByParam(params);
|
//导出操作
|
ExcelUtil.exportExcel(result, null, "数据需求", DataNeedExcel.class, "DataNeed", response);
|
return ResultBody.ok().msg("导出数据成功");
|
}
|
}
|