package com.iailab.module.model.mcs.pre.controller.admin; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO; import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity; 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.MmPredictItemPageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; 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 java.util.UUID; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao * @date 2021年04月26日 14:42 */ @RestController @RequestMapping("/model/pre/predict-item") public class MmPredictItemController { @Autowired private MmPredictItemService mmPredictItemService; /** * 预测项列表 */ @GetMapping("/page") @PreAuthorize("@ss.hasPermission('model:pre-predict:query')") public CommonResult> page(@Validated MmPredictItemPageReqVO reqVO) { PageResult page = mmPredictItemService.queryPage(reqVO); return success(BeanUtils.toBean(page, MmPredictItemRespVO.class)); } @GetMapping("/list") @PreAuthorize("@ss.hasPermission('model:pre-predict:query')") public CommonResult> list(@RequestParam Map params) { List list = mmPredictItemService.list(params); return success(list); } /** * 预测项信息 */ @GetMapping("/get/{id}") @PreAuthorize("@ss.hasPermission('model:pre-predict:query')") public CommonResult info(@PathVariable("id") String id){ MmPredictItemDTO predictItem = mmPredictItemService.info(id); return success(predictItem); } /** * 保存预测项 */ @PostMapping("/create") @PreAuthorize("@ss.hasPermission('model:pre-predict:create')") @DSTransactional(rollbackFor= Exception.class) public CommonResult save(@RequestBody MmPredictItemDTO mmPredictItemDto){ mmPredictItemService.add(mmPredictItemDto); return success(true); } /** * 修改预测项 */ @PutMapping("/update") @PreAuthorize("@ss.hasPermission('model:pre-predict:update')") @DSTransactional(rollbackFor= Exception.class) public CommonResult update(@RequestBody MmPredictItemDTO mmPredictItemDTO){ mmPredictItemService.update(mmPredictItemDTO); return success(true); } /** * 删除预测项 */ @DeleteMapping("/delete") @PreAuthorize("@ss.hasPermission('model:pre-predict:delete')") @DSTransactional(rollbackFor= Exception.class) public CommonResult delete(@RequestParam("id") String id) { mmPredictItemService.deleteBatch(new String[]{id}); return success(true); } /** * 预测项列表 */ @GetMapping("/count-itemtype") public CommonResult> countItemtype(@RequestParam Map params){ List list = new ArrayList<>(); return success(list); } // /** // * 数量 // */ // @GetMapping("/count") // public CommonResult count() { // Long count = mmPredictItemService.count(); // return success(count); // } /** * 上传模型 */ @PostMapping("/uploadModel") public CommonResult uploadModel(@RequestParam("file") MultipartFile file) throws Exception { return success(true); } }