package com.iailab.module.model.mcs.pre.controller;
|
|
import com.iailab.framework.common.exception.ErrorCode;
|
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.DmModuleEntity;
|
import com.iailab.module.model.mcs.pre.service.DmModuleService;
|
import com.iailab.module.model.mcs.pre.vo.DmModulePageReqVO;
|
import com.iailab.module.model.mcs.pre.vo.DmModuleRespVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import static com.iailab.framework.common.pojo.CommonResult.error;
|
import static com.iailab.framework.common.pojo.CommonResult.success;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年04月23日 9:05
|
*/
|
@RestController
|
@RequestMapping("/pre/module")
|
public class DmModuleController {
|
|
@Autowired
|
private DmModuleService dmModuleService;
|
|
/**
|
* 管网列表
|
*/
|
@GetMapping("/page")
|
public CommonResult<PageResult<DmModuleRespVO>> page(@Validated DmModulePageReqVO reqVO) {
|
PageResult<DmModuleEntity> page = dmModuleService.queryPage(reqVO);
|
|
return success(BeanUtils.toBean(page, DmModuleRespVO.class));
|
}
|
|
/**
|
* 管网列表
|
*/
|
@GetMapping("/list")
|
public CommonResult<List<DmModuleEntity>> list(@RequestParam Map<String, Object> params) {
|
List<DmModuleEntity> list = dmModuleService.list(params);
|
|
return success(list);
|
}
|
|
/**
|
* 管网信息
|
*/
|
@GetMapping("/get")
|
public CommonResult<DmModuleEntity> info(@RequestParam("id") String id){
|
DmModuleEntity module = dmModuleService.selectById(id);
|
|
return success(module);
|
}
|
|
/**
|
* 保存管网
|
*/
|
@PostMapping("/create")
|
public CommonResult<Boolean> save(@RequestBody DmModuleEntity module){
|
int count = dmModuleService.check(module);
|
if (count > 0) {
|
ErrorCode errorCode = new ErrorCode(999, "名称重复");
|
return error(errorCode);
|
}
|
dmModuleService.saveModule(module);
|
return success(true);
|
}
|
|
/**
|
* 修改管网
|
*/
|
@PutMapping("/update")
|
public CommonResult<Boolean> update(@RequestBody DmModuleEntity module){
|
dmModuleService.update(module);
|
return success(true);
|
}
|
|
/**
|
* 删除管网
|
*/
|
@DeleteMapping("/delete")
|
public CommonResult<Boolean> delete(@RequestParam("id") String id){
|
dmModuleService.deleteBatch(new String[]{id});
|
return success(true);
|
}
|
}
|