组态新增图元功能
This commit is contained in:
@@ -32,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
@RequestMapping("/csElement")
|
@RequestMapping("/csElement")
|
||||||
@Api(tags = "组态图元")
|
@Api(tags = "组态图元")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Deprecated
|
||||||
public class CsElementController extends BaseController {
|
public class CsElementController extends BaseController {
|
||||||
|
|
||||||
private final ICsElementService csElementService;
|
private final ICsElementService csElementService;
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.njcn.cssystem.pojo.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/7/12 16:23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ElementParam {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件分类")
|
||||||
|
@NotBlank(message="组件分类不能为空!")
|
||||||
|
private String elementType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件子类型")
|
||||||
|
@NotBlank(message="组件子类型不能为空!")
|
||||||
|
private String elementSonType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件编码")
|
||||||
|
private String elementCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件名称")
|
||||||
|
private String elementName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件标识")
|
||||||
|
private String elementMark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图元文件")
|
||||||
|
@NotNull(message="图元文件不能为空!")
|
||||||
|
private MultipartFile multipartFile;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.njcn.cssystem.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cs_element")
|
||||||
|
public class CsElement extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图元文件路径
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件分类
|
||||||
|
*/
|
||||||
|
private String elementType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件子类型
|
||||||
|
*/
|
||||||
|
private String elementSonType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件编码
|
||||||
|
*/
|
||||||
|
private String elementCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件名称
|
||||||
|
*/
|
||||||
|
private String elementName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件标识
|
||||||
|
*/
|
||||||
|
private String elementMark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.njcn.cssystem.controller.zutai;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.cssystem.pojo.param.ElementParam;
|
||||||
|
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.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.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/7/12 16:07
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/csElement")
|
||||||
|
@Api(tags = "组态图元")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ElementController extends BaseController {
|
||||||
|
|
||||||
|
private final IElementService csElementService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("组态图元新增")
|
||||||
|
public HttpResult<CsElement> add(@Validated ElementParam param){
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
CsElement csElement = csElementService.addElement(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csElement, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/find")
|
||||||
|
@ApiOperation("查询组态图元数据")
|
||||||
|
public HttpResult<List<CsElement>> find(){
|
||||||
|
String methodDescribe = getMethodDescribe("find");
|
||||||
|
List<CsElement> list = csElementService.findElement();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.cssystem.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.cssystem.pojo.po.CsElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-12
|
||||||
|
*/
|
||||||
|
public interface CsElementMapper extends BaseMapper<CsElement> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.njcn.cssystem.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.cssystem.pojo.param.ElementParam;
|
||||||
|
import com.njcn.cssystem.pojo.po.CsElement;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-06-14
|
||||||
|
*/
|
||||||
|
public interface IElementService extends IService<CsElement> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增组态图元
|
||||||
|
* @param param 图元参数
|
||||||
|
*/
|
||||||
|
CsElement addElement(ElementParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组态图元数据查询
|
||||||
|
*/
|
||||||
|
List<CsElement> findElement();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.njcn.cssystem.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.cssystem.mapper.CsElementMapper;
|
||||||
|
import com.njcn.cssystem.pojo.param.ElementParam;
|
||||||
|
import com.njcn.cssystem.pojo.po.CsElement;
|
||||||
|
import com.njcn.cssystem.service.IElementService;
|
||||||
|
import com.njcn.oss.constant.OssPath;
|
||||||
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-12
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CsElementServiceImpl extends ServiceImpl<CsElementMapper, CsElement> implements IElementService {
|
||||||
|
|
||||||
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CsElement addElement(ElementParam param) {
|
||||||
|
CsElement csElement = new CsElement();
|
||||||
|
BeanUtils.copyProperties(param,csElement);
|
||||||
|
String path = fileStorageUtil.uploadMultipart(param.getMultipartFile(), OssPath.ELEMENT);
|
||||||
|
csElement.setPath(path);
|
||||||
|
csElement.setStatus(1);
|
||||||
|
this.saveOrUpdate(csElement);
|
||||||
|
csElement.setPath(fileStorageUtil.getFileUrl(path));
|
||||||
|
return csElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsElement> findElement() {
|
||||||
|
List<CsElement> list = this.lambdaQuery().eq(CsElement::getStatus,1).list();
|
||||||
|
list.forEach(item->{
|
||||||
|
item.setPath(fileStorageUtil.getFileUrl(item.getPath()));
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user