2024-07-30 17:24:38 +08:00
|
|
|
package com.whdc.controller;
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.whdc.exception.MyException;
|
2024-07-31 13:26:01 +08:00
|
|
|
import com.whdc.model.dto.ShCallWordDto;
|
2024-07-30 17:24:38 +08:00
|
|
|
import com.whdc.model.entity.ShCallWord;
|
|
|
|
|
import com.whdc.model.group.Insert;
|
|
|
|
|
import com.whdc.model.group.Update;
|
|
|
|
|
import com.whdc.service.ShCallWordService;
|
2024-07-31 13:26:01 +08:00
|
|
|
import com.whdc.service.ShPeriodService;
|
2024-07-30 17:24:38 +08:00
|
|
|
import com.whdc.utils.ResultJson;
|
2024-07-31 17:55:05 +08:00
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
2024-07-30 17:24:38 +08:00
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
2024-07-31 13:26:01 +08:00
|
|
|
import java.util.Date;
|
2024-08-02 17:13:58 +08:00
|
|
|
import java.util.List;
|
2024-07-31 13:26:01 +08:00
|
|
|
import java.util.Objects;
|
|
|
|
|
|
2024-07-30 17:24:38 +08:00
|
|
|
/**
|
|
|
|
|
* 描述: 备注
|
|
|
|
|
* author: xusan
|
|
|
|
|
* date: 2024-07-29 17:27:25
|
|
|
|
|
*/
|
2024-07-31 17:55:05 +08:00
|
|
|
@Api(tags = "备注")
|
2024-07-30 17:24:38 +08:00
|
|
|
@RestController
|
|
|
|
|
@RequestMapping(value="/shCallWord")
|
|
|
|
|
public class ShCallWordController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShCallWordService service;
|
|
|
|
|
|
2024-07-31 13:26:01 +08:00
|
|
|
@Autowired
|
|
|
|
|
private ShPeriodService shPeriodService;
|
|
|
|
|
|
2024-07-30 17:24:38 +08:00
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
@ApiOperation(value = "新增")
|
2024-07-30 17:24:38 +08:00
|
|
|
@PostMapping("/insert")
|
|
|
|
|
public ResultJson<ShCallWord> insert(@Validated(Insert.class) @RequestBody ShCallWord dto) {
|
2024-07-31 13:26:01 +08:00
|
|
|
if (Objects.nonNull(dto.getShPeriodId()) && Objects.isNull(shPeriodService.getById(dto.getShPeriodId()))){
|
2024-07-31 17:55:05 +08:00
|
|
|
throw new MyException("当前防汛周期不存在");
|
2024-07-31 13:26:01 +08:00
|
|
|
}
|
2024-08-01 17:41:07 +08:00
|
|
|
dto.setId(null);
|
2024-07-31 13:26:01 +08:00
|
|
|
dto.setCreateTime(new Date());
|
2024-07-30 17:24:38 +08:00
|
|
|
boolean result = service.save(dto);
|
|
|
|
|
return ResultJson.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
@ApiOperation(value = "修改")
|
2024-07-30 17:24:38 +08:00
|
|
|
@PostMapping("/update")
|
|
|
|
|
public ResultJson<ShCallWord> update(@Validated(Update.class) @RequestBody ShCallWord dto) {
|
2024-07-31 13:26:01 +08:00
|
|
|
if (Objects.isNull(service.getById(dto.getId()))){
|
2024-07-31 17:55:05 +08:00
|
|
|
throw new MyException("当前数据不存在");
|
2024-07-31 13:26:01 +08:00
|
|
|
}
|
|
|
|
|
if (Objects.nonNull(dto.getShPeriodId()) && Objects.isNull(shPeriodService.getById(dto.getShPeriodId()))){
|
2024-07-31 17:55:05 +08:00
|
|
|
throw new MyException("当前防汛周期不存在");
|
2024-07-31 13:26:01 +08:00
|
|
|
}
|
2024-08-01 17:41:07 +08:00
|
|
|
dto.setCreateTime(null);
|
2024-07-30 17:24:38 +08:00
|
|
|
boolean result = service.updateById(dto);
|
|
|
|
|
return ResultJson.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
@ApiOperation(value = "删除")
|
2024-07-30 17:24:38 +08:00
|
|
|
@GetMapping("/del/{id}")
|
|
|
|
|
public ResultJson<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
|
|
|
|
return ResultJson.ok(service.removeById(id));
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 17:13:58 +08:00
|
|
|
@ApiOperation(value = "列表")
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
public ResultJson<List<ShCallWord>> list(@RequestBody ShCallWordDto dto) {
|
|
|
|
|
return ResultJson.ok(service.list(dto));
|
|
|
|
|
}
|
2024-07-31 13:26:01 +08:00
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
@ApiOperation(value = "分页")
|
2024-07-31 13:26:01 +08:00
|
|
|
@PostMapping("/page")
|
2024-07-31 17:55:05 +08:00
|
|
|
public ResultJson<IPage<ShCallWord>> page(@RequestBody ShCallWordDto dto) {
|
|
|
|
|
// LambdaQueryChainWrapper<ShCallWord> query = service.lambdaQuery();
|
|
|
|
|
// if (Objects.nonNull(dto.getStm()) && Objects.nonNull(dto.getEtm())){
|
|
|
|
|
// query.between(ShCallWord::getCreateTime,dto.getStm(),dto.getEtm());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (StringUtils.isNotBlank(dto.getShAbType1())){
|
|
|
|
|
// query.eq(ShCallWord::getShAbType1,dto.getShAbType1());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// query.orderByDesc(ShCallWord::getCreateTime);
|
|
|
|
|
//
|
|
|
|
|
// return ResultJson.ok(service.page(dto.getPage(),query));
|
|
|
|
|
return ResultJson.ok(service.page(dto));
|
2024-07-30 17:24:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|