53 lines
1.7 KiB
Java
53 lines
1.7 KiB
Java
|
|
package com.whdc.controller;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||
|
|
import com.whdc.model.entity.WarnMsgFB;
|
||
|
|
import com.whdc.service.IWarnMsgFBService;
|
||
|
|
import com.whdc.utils.ResultJson;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.validation.annotation.Validated;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
@Slf4j
|
||
|
|
@Api(tags = "预警叫应 - Controller")
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/warnmsgfb")
|
||
|
|
public class WarnMsgFBController {
|
||
|
|
@Autowired
|
||
|
|
private IWarnMsgFBService service;
|
||
|
|
//增
|
||
|
|
@ApiOperation(value = "新增")
|
||
|
|
@PostMapping(value = "/add")
|
||
|
|
public ResultJson<String> insert(@RequestBody @Validated WarnMsgFB dto) {
|
||
|
|
|
||
|
|
//根据warnid和phone判断是否重复
|
||
|
|
if (CollectionUtils.isNotEmpty(
|
||
|
|
service.lambdaQuery()
|
||
|
|
.eq(WarnMsgFB::getWarnid,dto.getWarnid())
|
||
|
|
.eq(WarnMsgFB::getCalledPhone,String.valueOf(dto.getCalledPhone())).list()
|
||
|
|
)
|
||
|
|
){
|
||
|
|
return ResultJson.error("该名称或编码重复");
|
||
|
|
}
|
||
|
|
|
||
|
|
boolean save = service.save(dto);
|
||
|
|
return ResultJson.ok(save);
|
||
|
|
}
|
||
|
|
//删
|
||
|
|
//改
|
||
|
|
//查
|
||
|
|
@ApiOperation(value = "查询所有")
|
||
|
|
@PostMapping(value = "/find")
|
||
|
|
public ResultJson<WarnMsgFB> find(@RequestBody WarnMsgFB dto) {
|
||
|
|
|
||
|
|
return ResultJson.ok(service.find(dto));
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|