package com.iailab.module.model.mcs.pre.controller;
|
|
import com.iailab.framework.common.pojo.CommonResult;
|
import com.iailab.framework.common.pojo.PageResult;
|
import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO;
|
import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
|
import com.iailab.module.model.mcs.pre.vo.CountItemtypeVO;
|
import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
import static com.iailab.framework.common.pojo.CommonResult.error;
|
import static com.iailab.framework.common.pojo.CommonResult.success;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年04月26日 14:42
|
*/
|
@RestController
|
@RequestMapping("/pre/predict-item")
|
public class MmPredictItemController {
|
|
@Autowired
|
private MmPredictItemService mmPredictItemService;
|
|
/**
|
* 预测项列表
|
*/
|
@GetMapping("/page")
|
public CommonResult<PageResult<MmPredictItemRespVO>> page(@RequestParam Map<String, Object> params) {
|
PageResult<MmPredictItemRespVO> page = mmPredictItemService.getPageList(params);
|
return success(page);
|
}
|
|
/**
|
* 预测项信息
|
*/
|
@GetMapping("/info/{id}")
|
public CommonResult<MmPredictItemDTO> info(@PathVariable("id") String id, @RequestParam Map<String, Object> params){
|
MmPredictItemDTO predictItem = mmPredictItemService.getDetailById(id, params);
|
return success(predictItem);
|
}
|
|
/**
|
* 保存预测项
|
*/
|
@PostMapping
|
public CommonResult<Boolean> save(@RequestBody MmPredictItemDTO mmPredictItemDto){
|
int count = mmPredictItemService.check(mmPredictItemDto.getMmPredictItem());
|
if (count > 0) {
|
return error(999, "名称或编号重复");
|
}
|
mmPredictItemService.savePredictItem(mmPredictItemDto);
|
return success(true);
|
}
|
|
/**
|
* 修改预测项
|
*/
|
@PutMapping
|
public CommonResult<Boolean> update(@RequestBody MmPredictItemDTO mmPredictItemDto){
|
int count = mmPredictItemService.check(mmPredictItemDto.getMmPredictItem());
|
if (count > 0) {
|
return error(999, "名称或编号重复");
|
}
|
mmPredictItemService.update(mmPredictItemDto);
|
return success(true);
|
}
|
|
/**
|
* 删除预测项
|
*/
|
@DeleteMapping("{id}")
|
public CommonResult<Boolean> delete(@RequestBody String[] itemIds){
|
if (itemIds == null || itemIds.length == 0) {
|
return error(999, "参数不能为空");
|
}
|
mmPredictItemService.deleteBatch(itemIds);
|
return success(true);
|
}
|
|
/**
|
* 预测项列表
|
*/
|
@GetMapping("/count-itemtype")
|
public CommonResult<List<CountItemtypeVO>> countItemtype(@RequestParam Map<String, Object> params){
|
List<CountItemtypeVO> list = new ArrayList<>();
|
return success(list);
|
}
|
|
/**
|
* 数量
|
*/
|
@GetMapping("/count")
|
public CommonResult<Long> count() {
|
Long count = mmPredictItemService.count();
|
return success(count);
|
}
|
|
/**
|
* 上传模型
|
*/
|
@PostMapping("/uploadModel")
|
public CommonResult<Boolean> uploadModel(@RequestParam("file") MultipartFile file) throws Exception {
|
|
return success(true);
|
}
|
}
|