委托工程开发
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
package com.dc.dc_project.controller.record;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.dc.dc_project.common.ResponseResult;
|
||||||
|
import com.dc.dc_project.model.pojo.RecordEngineering;
|
||||||
|
import com.dc.dc_project.model.pojo.RecordResult;
|
||||||
|
import com.dc.dc_project.service.RecordEngineeringService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/record/engineering")
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
public class RecordEngineeringController {
|
||||||
|
|
||||||
|
private final RecordEngineeringService recordEngineeringService;
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseResult add(RecordEngineering recordResult) {
|
||||||
|
Long userId = StpUtil.getLoginIdAsLong();
|
||||||
|
return recordEngineeringService.add(recordResult, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
public ResponseResult list(RecordEngineering recordResult) {
|
||||||
|
return recordEngineeringService.getList(recordResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseResult delete(RecordEngineering recordResult) {
|
||||||
|
return recordEngineeringService.delete(recordResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ResponseResult update(RecordEngineering recordResult) {
|
||||||
|
return recordEngineeringService.update(recordResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.dc.dc_project.service;
|
package com.dc.dc_project.service;
|
||||||
|
|
||||||
|
import com.dc.dc_project.common.ResponseResult;
|
||||||
import com.dc.dc_project.model.pojo.RecordEngineering;
|
import com.dc.dc_project.model.pojo.RecordEngineering;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.dc.dc_project.model.pojo.RecordResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ADMIN
|
* @author ADMIN
|
||||||
@@ -10,4 +12,25 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface RecordEngineeringService extends IService<RecordEngineering> {
|
public interface RecordEngineeringService extends IService<RecordEngineering> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加检测工程信息
|
||||||
|
* @param recordResult 检测工程信息
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 添加结果
|
||||||
|
*/
|
||||||
|
ResponseResult add(RecordEngineering recordResult, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取检测工程信息列表
|
||||||
|
* @param recordResult 检测工程信息
|
||||||
|
* @return 检测工程信息列表
|
||||||
|
*/
|
||||||
|
ResponseResult getList(RecordEngineering recordResult);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除检测工程信息
|
||||||
|
* @param recordResult 检测工程信息
|
||||||
|
* @return 删除结果
|
||||||
|
*/
|
||||||
|
ResponseResult delete(RecordEngineering recordResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.dc.dc_project.service.impl;
|
package com.dc.dc_project.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.dc.dc_project.common.ResponseResult;
|
||||||
|
import com.dc.dc_project.model.pojo.Laboratory;
|
||||||
import com.dc.dc_project.model.pojo.RecordEngineering;
|
import com.dc.dc_project.model.pojo.RecordEngineering;
|
||||||
|
import com.dc.dc_project.model.pojo.RecordResult;
|
||||||
import com.dc.dc_project.service.RecordEngineeringService;
|
import com.dc.dc_project.service.RecordEngineeringService;
|
||||||
import com.dc.dc_project.mapper.RecordEngineeringMapper;
|
import com.dc.dc_project.mapper.RecordEngineeringMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -15,6 +19,33 @@ import org.springframework.stereotype.Service;
|
|||||||
public class RecordEngineeringServiceImpl extends ServiceImpl<RecordEngineeringMapper, RecordEngineering>
|
public class RecordEngineeringServiceImpl extends ServiceImpl<RecordEngineeringMapper, RecordEngineering>
|
||||||
implements RecordEngineeringService{
|
implements RecordEngineeringService{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseResult add(RecordEngineering recordEngineering, Long userId) {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<RecordEngineering> queryWrapper = new LambdaQueryWrapper<RecordEngineering>()
|
||||||
|
.eq(RecordEngineering::getEngineeringName, recordEngineering.getEngineeringName());
|
||||||
|
|
||||||
|
if (this.count(queryWrapper) > 0) {
|
||||||
|
return ResponseResult.error("检测工程已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.save(recordEngineering) ? ResponseResult.success("添加成功") : ResponseResult.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseResult getList(RecordEngineering recordEngineering) {
|
||||||
|
LambdaQueryWrapper<RecordEngineering> queryWrapper = new LambdaQueryWrapper<RecordEngineering>()
|
||||||
|
.eq(recordEngineering.getEngineeringName() != null,RecordEngineering::getEngineeringName, recordEngineering.getEngineeringName())
|
||||||
|
.eq(recordEngineering.getId() != null,RecordEngineering::getId, recordEngineering.getId());
|
||||||
|
return ResponseResult.success(this.list(queryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseResult delete(RecordEngineering recordResult) {
|
||||||
|
if(recordResult.getId() == null)
|
||||||
|
return ResponseResult.error("请选择要删除的检测工程");
|
||||||
|
return this.removeById(recordResult.getId()) ? ResponseResult.success("删除成功") : ResponseResult.error("删除失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user