组态图元功能调整
This commit is contained in:
@@ -10,11 +10,13 @@ import com.njcn.cssystem.pojo.po.CsElement;
|
||||
import com.njcn.cssystem.service.IElementService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -36,7 +38,7 @@ public class ElementController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("组态图元新增")
|
||||
@ApiOperation("新增图元")
|
||||
public HttpResult<CsElement> add(@Validated ElementParam param){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
CsElement csElement = csElementService.addElement(param);
|
||||
@@ -45,11 +47,21 @@ public class ElementController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/find")
|
||||
@ApiOperation("查询组态图元数据")
|
||||
@ApiOperation("查询图元")
|
||||
public HttpResult<List<CsElement>> find(){
|
||||
String methodDescribe = getMethodDescribe("find");
|
||||
List<CsElement> list = csElementService.findElement();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除图元")
|
||||
@ApiImplicitParam(name = "id", value = "图元Id", required = true)
|
||||
public HttpResult<String> deleteById(@RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("deleteById");
|
||||
csElementService.deleteById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,4 +27,9 @@ public interface IElementService extends IService<CsElement> {
|
||||
*/
|
||||
List<CsElement> findElement();
|
||||
|
||||
/**
|
||||
* 组态图元数据查询
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.njcn.cssystem.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.cssystem.enums.CsSystemResponseEnum;
|
||||
import com.njcn.cssystem.mapper.CsElementMapper;
|
||||
import com.njcn.cssystem.pojo.param.ElementParam;
|
||||
import com.njcn.cssystem.pojo.po.CsElement;
|
||||
@@ -12,6 +14,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -29,6 +32,13 @@ public class CsElementServiceImpl extends ServiceImpl<CsElementMapper, CsElement
|
||||
|
||||
@Override
|
||||
public CsElement addElement(ElementParam param) {
|
||||
CsElement po = this.lambdaQuery().eq(CsElement::getStatus,1)
|
||||
.eq(CsElement::getElementCode,param.getElementCode())
|
||||
.eq(CsElement::getElementName,param.getElementName())
|
||||
.eq(CsElement::getElementMark,param.getElementMark()).one();
|
||||
if (!Objects.isNull(po)){
|
||||
throw new BusinessException(CsSystemResponseEnum.SAME_DATA_ERROR);
|
||||
}
|
||||
CsElement csElement = new CsElement();
|
||||
BeanUtils.copyProperties(param,csElement);
|
||||
String path = fileStorageUtil.uploadMultipart(param.getMultipartFile(), OssPath.ELEMENT);
|
||||
@@ -47,4 +57,11 @@ public class CsElementServiceImpl extends ServiceImpl<CsElementMapper, CsElement
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
CsElement csElement = this.lambdaQuery().eq(CsElement::getId,id).one();
|
||||
csElement.setStatus(0);
|
||||
this.updateById(csElement);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user