package cn.besteam.modules.medical.controller;
|
|
import cn.besteam.common.api.vo.Result;
|
import cn.besteam.common.aspect.annotation.AutoLog;
|
import cn.besteam.common.constant.ErrorCode;
|
import cn.besteam.common.exception.BusinessException;
|
import cn.besteam.modules.medical.entity.MwWarningConfig;
|
import cn.besteam.modules.medical.entity.MwWarningConfigPlatform;
|
import cn.besteam.modules.medical.service.IMwWarningConfigPlatformService;
|
import cn.besteam.modules.medical.service.IMwWarningConfigService;
|
import cn.besteam.modules.medical.vo.MwWarningConfigVO;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* @Title: Controller
|
* @Description: 预警-配置-平台
|
* @author: besteam
|
* @date: 2020-07-17
|
* @version: V1.0
|
*/
|
@RestController
|
@RequestMapping("/medical/mwWarningConfigPlatform")
|
@Slf4j
|
@Api(description = "预警-配置-平台")
|
public class MwWarningConfigPlatformController {
|
|
@Autowired
|
private IMwWarningConfigPlatformService mwWarningConfigService;
|
|
/**
|
* 编辑
|
*
|
* @param mwWarningConfigVO
|
* @return
|
*/
|
@PostMapping(value = "/editByType")
|
@AutoLog(value = "编辑预警配置平台(新)")
|
@ApiOperation(value = "编辑预警配置平台(新)", notes = "编辑预警配置", produces = "application/json")
|
public Result<Boolean> editByType(@RequestBody MwWarningConfigVO mwWarningConfigVO) {
|
|
MwWarningConfigPlatform warningConfig = mwWarningConfigService.getOne(new QueryWrapper<MwWarningConfigPlatform>().lambda().eq(MwWarningConfigPlatform::getType, mwWarningConfigVO.getType()).last("limit 1"));
|
if (warningConfig == null) {
|
throw new BusinessException(ErrorCode.ERR_500, "预警配置不存在");
|
}
|
warningConfig.setDefaultValue(mwWarningConfigVO.getDefaultValue());
|
warningConfig.setWasteTypes(mwWarningConfigVO.getWasteTypes());
|
return Result.ok(mwWarningConfigService.updateById(warningConfig));
|
}
|
|
@GetMapping(value = "/getByType")
|
@ApiOperation(value = "按类型获取预警配置平台(新)", notes = "按类型获取预警配置", produces = "application/json")
|
public Result<MwWarningConfigVO> getByType(@RequestParam Integer type) {
|
|
MwWarningConfigPlatform warningConfig = mwWarningConfigService.getOne(new QueryWrapper<MwWarningConfigPlatform>().lambda().eq(MwWarningConfigPlatform::getType, type).last("limit 1"));
|
if (warningConfig == null) {
|
throw new BusinessException(ErrorCode.ERR_500, "预警配置不存在");
|
}
|
MwWarningConfigVO vo = new MwWarningConfigVO();
|
BeanUtils.copyProperties(warningConfig, vo);
|
return Result.ok(vo);
|
}
|
|
}
|