101 lines
2.6 KiB
Java
101 lines
2.6 KiB
Java
package com.whdc.controller;
|
|
|
|
|
|
import com.whdc.model.entity.AbUdR;
|
|
import com.whdc.model.group.Insert;
|
|
import com.whdc.model.group.Update;
|
|
import com.whdc.service.IAbUdRService;
|
|
import com.whdc.utils.ResultJson;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* @author xusan
|
|
* @date 2024-05-11
|
|
*/
|
|
@Slf4j
|
|
@Api(tags = "用户单位字典关联表 - Controller")
|
|
@RestController
|
|
@RequestMapping("/abudr")
|
|
public class AbUdRController {
|
|
|
|
@Autowired
|
|
private IAbUdRService service;
|
|
|
|
|
|
|
|
@ApiOperation(value = "查询所有")
|
|
@PostMapping(value = "find")
|
|
public ResultJson<AbUdR> find(@RequestBody AbUdR dto) {
|
|
|
|
return ResultJson.ok(service.find(dto));
|
|
|
|
}
|
|
|
|
@ApiOperation(value = "分页查询")
|
|
@PostMapping(value = "page")
|
|
public ResultJson<AbUdR> page(@RequestBody AbUdR dto) {
|
|
|
|
return ResultJson.ok(service.page(dto));
|
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "添加")
|
|
@PostMapping(value = "save")
|
|
public ResultJson insert(@RequestBody @Validated(Insert.class) AbUdR model) {
|
|
|
|
if (CollectionUtils.isNotEmpty(
|
|
service.lambdaQuery()
|
|
.eq(AbUdR::getAdId,String.valueOf(model.getAdId()).trim())
|
|
.eq(AbUdR::getDictId,String.valueOf(model.getDictId() ).trim())
|
|
.list())
|
|
){
|
|
return ResultJson.error("重复新增");
|
|
}
|
|
|
|
return ResultJson.ok(service.save(model));
|
|
|
|
}
|
|
|
|
@ApiOperation(value = "修改")
|
|
@PostMapping(value = "edit")
|
|
public ResultJson update(@RequestBody @Validated(Update.class) AbUdR model) {
|
|
|
|
if (CollectionUtils.isNotEmpty(
|
|
service.lambdaQuery()
|
|
.eq(AbUdR::getAdId,String.valueOf(model.getAdId()).trim())
|
|
.eq(AbUdR::getDictId,String.valueOf(model.getDictId() ).trim())
|
|
.list())
|
|
){
|
|
return ResultJson.error("重复修改");
|
|
}
|
|
|
|
return ResultJson.ok(service.updateById(model));
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除")
|
|
@GetMapping(value = "del/{id}")
|
|
public ResultJson delete(@PathVariable("id") Integer id) {
|
|
|
|
|
|
if (Objects.isNull(service.getById(id))) {
|
|
|
|
return ResultJson.error("当前数据不存在");
|
|
|
|
}
|
|
|
|
return ResultJson.ok(service.removeById(id));
|
|
|
|
}
|
|
|
|
}
|