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.framework.common.util.object.BeanUtils; import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; import com.iailab.module.model.mcs.pre.service.MmItemTypeService; import com.iailab.module.model.mcs.pre.vo.MmItemTypePageReqVO; import com.iailab.module.model.mcs.pre.vo.MmItemTypeRespVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import static com.iailab.framework.common.pojo.CommonResult.error; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao * @date 2021年04月22日 9:57 */ @RestController @RequestMapping("/pre/item-type") public class MmItemTypeController { @Autowired private MmItemTypeService mmItemTypeService; /** * 预测项类型列表 */ @GetMapping("/page") public CommonResult> page(@Validated MmItemTypePageReqVO reqVO) { PageResult page = mmItemTypeService.page(reqVO); return success(BeanUtils.toBean(page, MmItemTypeRespVO.class)); } /** * 预测项类型信息 */ @GetMapping("/info/{id}") public CommonResult info(@PathVariable("id") String id) { MmItemTypeEntity itemType = mmItemTypeService.selectById(id); return success(itemType); } /** * 保存预测项类型 */ @PostMapping("/create") public CommonResult save(@RequestBody MmItemTypeEntity itemType) { int count = mmItemTypeService.check(itemType); if (count > 0) { return error(999,"名称重复"); } mmItemTypeService.saveItemType(itemType); return success(true); } /** * 修改预测项类型 */ @PutMapping("/update") public CommonResult update(@RequestBody MmItemTypeEntity itemType) { int count = mmItemTypeService.check(itemType); if (count > 0) { return error(999,"名称重复"); } mmItemTypeService.update(itemType); return success(true); } /** * 删除预测项类型 */ @DeleteMapping("/delete") public CommonResult delete(@RequestParam("id") String id) { mmItemTypeService.deleteBatch(new String[]{id}); return success(true); } }