Browse Source

流水线参数增删查改接口初步实现

pull/7/head
西大锐 1 year ago
parent
commit
cca20ef3d2
9 changed files with 714 additions and 1 deletions
  1. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/icon/AssetIconController.java
  2. +90
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowParamController.java
  3. +165
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/WorkflowParam.java
  4. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java
  5. +83
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowParamDao.java
  6. +58
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowParamService.java
  7. +122
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowParamServiceImpl.java
  8. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java
  9. +191
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowParamDaoMapper.xml

+ 2
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/icon/AssetIconController.java View File

@@ -66,6 +66,8 @@ public class AssetIconController {
@ApiOperation("根据图标类别id查询") @ApiOperation("根据图标类别id查询")
public AjaxResult queryByCategoryId(@PathVariable("id") Integer categoryId) { public AjaxResult queryByCategoryId(@PathVariable("id") Integer categoryId) {
return AjaxResult.success(this.assetIconService.queryByCategoryId(categoryId)); return AjaxResult.success(this.assetIconService.queryByCategoryId(categoryId));


} }


/** /**


+ 90
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowParamController.java View File

@@ -0,0 +1,90 @@
package com.ruoyi.platform.controller.workflow;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.platform.domain.WorkflowParam;
import com.ruoyi.platform.service.WorkflowParamService;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
* (WorkflowParam)表控制层
*
* @author Xidaray
* @since 2024-03-18 14:12:07
*/
@RestController
@RequestMapping("workflowParam")
public class WorkflowParamController {
/**
* 服务对象
*/
@Resource
private WorkflowParamService workflowParamService;

/**
* 分页查询
*
* @param workflowParam 筛选条件
* @return 查询结果
*/
@GetMapping
@ApiOperation("分页查询")
public AjaxResult queryByPage(WorkflowParam workflowParam, int page, int size) {
PageRequest pageRequest = PageRequest.of(page,size);
return AjaxResult.success(this.workflowParamService.queryByPage(workflowParam, pageRequest));
}

/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("{id}")
@ApiOperation("根据id查询单条数据")
public AjaxResult queryById(@PathVariable("id") Integer id) {
return AjaxResult.success(this.workflowParamService.queryById(id));
}
/**
* 新增数据
*
* @param workflowParam 实体
* @return 新增结果
*/
@PostMapping
@ApiOperation("新增流水线参数")
public AjaxResult add(WorkflowParam workflowParam) {
return AjaxResult.success(this.workflowParamService.insert(workflowParam));
}

/**
* 编辑数据
*
* @param workflowParam 实体
* @return 编辑结果
*/
@PutMapping
@ApiOperation("编辑流水线参数")
public AjaxResult edit(WorkflowParam workflowParam) {
return AjaxResult.success(this.workflowParamService.update(workflowParam));
}

/**
* 删除数据
*
* @param id 主键
* @return 删除是否成功
*/
@DeleteMapping
@ApiOperation("删除流水线参数")
public AjaxResult deleteById(Integer id) {
return AjaxResult.success(this.workflowParamService.removeById(id));
}

}


+ 165
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/WorkflowParam.java View File

@@ -0,0 +1,165 @@
package com.ruoyi.platform.domain;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import java.util.Date;
import java.io.Serializable;

/**
* (WorkflowParam)实体类
*
* @author Xidaray
* @since 2024-03-18 15:48:42
*/
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class WorkflowParam implements Serializable {
private static final long serialVersionUID = -96152285866099549L;
/**
* 主键
*/
private Integer id;
/**
* 流水线id
*/
private Long workflowId;
/**
* 参数名称
*/
private String paramName;
/**
* 参数描述
*/
private String description;
/**
* 参数类型,1字符串,2整形,3布尔型
*/
private Integer paramType;
/**
* 参数的值
*/
private String paramValue;
/**
* 0失效,1生效
*/
private Integer isSensitive;
/**
* 创建者
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新者
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 0失效,1生效
*/
private Integer state;


public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Long getWorkflowId() {
return workflowId;
}

public void setWorkflowId(Long workflowId) {
this.workflowId = workflowId;
}

public String getParamName() {
return paramName;
}

public void setParamName(String paramName) {
this.paramName = paramName;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Integer getParamType() {
return paramType;
}

public void setParamType(Integer paramType) {
this.paramType = paramType;
}

public String getParamValue() {
return paramValue;
}

public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}

public Integer getIsSensitive() {
return isSensitive;
}

public void setIsSensitive(Integer isSensitive) {
this.isSensitive = isSensitive;
}

public String getCreateBy() {
return createBy;
}

public void setCreateBy(String createBy) {
this.createBy = createBy;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public String getUpdateBy() {
return updateBy;
}

public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}

public Date getUpdateTime() {
return updateTime;
}

public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}

public Integer getState() {
return state;
}

public void setState(Integer state) {
this.state = state;
}

}


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java View File

@@ -29,7 +29,7 @@ public interface WorkflowDao {
* @param pageable 分页对象 * @param pageable 分页对象
* @return 对象列表 * @return 对象列表
*/ */
List<Workflow> queryAllByLimit(@Param("workflow")Workflow workflow, @Param("pageable") Pageable pageable);
List<Workflow> queryAllByLimit(@Param("workflow") Workflow workflow, @Param("pageable") Pageable pageable);


/** /**
* 统计总行数 * 统计总行数


+ 83
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowParamDao.java View File

@@ -0,0 +1,83 @@
package com.ruoyi.platform.mapper;

import com.ruoyi.platform.domain.WorkflowParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;

/**
* (WorkflowParam)表数据库访问层
*
* @author Xidaray
* @since 2024-03-18 14:12:07
*/
public interface WorkflowParamDao {

/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
WorkflowParam queryById(Integer id);

/**
* 查询指定行数据
*
* @param workflowParam 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<WorkflowParam> queryAllByLimit(WorkflowParam workflowParam, @Param("pageable") Pageable pageable);

/**
* 统计总行数
*
* @param workflowParam 查询条件
* @return 总行数
*/
long count(WorkflowParam workflowParam);

/**
* 新增数据
*
* @param workflowParam 实例对象
* @return 影响行数
*/
int insert(WorkflowParam workflowParam);

/**
* 批量新增数据(MyBatis原生foreach方法)
*
* @param entities List<WorkflowParam> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<WorkflowParam> entities);

/**
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
*
* @param entities List<WorkflowParam> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<WorkflowParam> entities);

/**
* 修改数据
*
* @param workflowParam 实例对象
* @return 影响行数
*/
int update(WorkflowParam workflowParam);

/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);

}


+ 58
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowParamService.java View File

@@ -0,0 +1,58 @@
package com.ruoyi.platform.service;

import com.ruoyi.platform.domain.WorkflowParam;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

/**
* (WorkflowParam)表服务接口
*
* @author Xidaray
* @since 2024-03-18 14:12:07
*/
public interface WorkflowParamService {

/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
WorkflowParam queryById(Integer id);

/**
* 分页查询
*
* @param workflowParam 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
Page<WorkflowParam> queryByPage(WorkflowParam workflowParam, PageRequest pageRequest);

/**
* 新增数据
*
* @param workflowParam 实例对象
* @return 实例对象
*/
WorkflowParam insert(WorkflowParam workflowParam) throws Exception;

/**
* 修改数据
*
* @param workflowParam 实例对象
* @return 实例对象
*/
WorkflowParam update(WorkflowParam workflowParam);

String removeById(Integer id);

/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Integer id);

}

+ 122
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowParamServiceImpl.java View File

@@ -0,0 +1,122 @@
package com.ruoyi.platform.service.impl;

import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.domain.AssetIcon;
import com.ruoyi.platform.domain.DatasetVersion;
import com.ruoyi.platform.domain.WorkflowParam;
import com.ruoyi.platform.mapper.WorkflowParamDao;
import com.ruoyi.platform.service.WorkflowParamService;
import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.Date;

/**
* (WorkflowParam)表服务实现类
*
* @author Xidaray
* @since 2024-03-18 14:12:07
*/
@Service("workflowParamService")
public class WorkflowParamServiceImpl implements WorkflowParamService {
@Resource
private WorkflowParamDao workflowParamDao;

/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public WorkflowParam queryById(Integer id) {
return this.workflowParamDao.queryById(id);
}

/**
* 分页查询
*
* @param workflowParam 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<WorkflowParam> queryByPage(WorkflowParam workflowParam, PageRequest pageRequest) {
long total = this.workflowParamDao.count(workflowParam);
return new PageImpl<>(this.workflowParamDao.queryAllByLimit(workflowParam, pageRequest), pageRequest, total);
}

/**
* 新增数据
*
* @param workflowParam 实例对象
* @return 实例对象
*/
@Override
public WorkflowParam insert(WorkflowParam workflowParam) throws Exception {
insertPrepare(workflowParam);
this.workflowParamDao.insert(workflowParam);
return workflowParam;
}

/**
* 修改数据
*
* @param workflowParam 实例对象
* @return 实例对象
*/
@Override
public WorkflowParam update(WorkflowParam workflowParam) {
LoginUser loginUser = SecurityUtils.getLoginUser();
workflowParam.setUpdateBy(loginUser.getUsername());
workflowParam.setUpdateTime(new Date());
this.workflowParamDao.update(workflowParam);
return this.queryById(workflowParam.getId());
}

@Override
public String removeById(Integer id) {
WorkflowParam workflowParam = this.workflowParamDao.queryById(id);
if (workflowParam == null){
return "图标不存在";
}

//判断权限,只有admin和创建者本身可以删除
LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername();


String createdBy = workflowParam.getCreateBy();
if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){
return "无权限删除该流水线参数";
}

workflowParam.setState(0);
return this.workflowParamDao.update(workflowParam)>0?"删除成功":"删除失败";
}

/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Integer id) {
return this.workflowParamDao.deleteById(id) > 0;
}

private void insertPrepare(WorkflowParam workflowParam) throws Exception {
LoginUser loginUser = SecurityUtils.getLoginUser();
workflowParam.setCreateBy(loginUser.getUsername());
workflowParam.setUpdateBy(loginUser.getUsername());
workflowParam.setUpdateTime(new Date());
workflowParam.setCreateTime(new Date());
workflowParam.setState(1);
}
}

+ 2
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java View File

@@ -151,6 +151,8 @@ public class WorkflowServiceImpl implements WorkflowService {
return null; return null;
} }




// @Override // @Override
// public Workflow saveWorkflow(Long id) { // public Workflow saveWorkflow(Long id) {
// Workflow workflow = this.queryById(id); // Workflow workflow = this.queryById(id);


+ 191
- 0
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowParamDaoMapper.xml View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.platform.mapper.WorkflowParamDao">

<resultMap type="com.ruoyi.platform.domain.WorkflowParam" id="WorkflowParamMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="workflowId" column="workflow_id" jdbcType="INTEGER"/>
<result property="paramName" column="param_name" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="paramType" column="param_type" jdbcType="INTEGER"/>
<result property="paramValue" column="param_value" jdbcType="VARCHAR"/>
<result property="isSensitive" column="is_sensitive" jdbcType="INTEGER"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="state" column="state" jdbcType="INTEGER"/>
</resultMap>

<!--查询单个-->
<select id="queryById" resultMap="WorkflowParamMap">
select
id,workflow_id,param_name,description,param_type,param_value,is_sensitive,create_by,create_time,update_by,update_time,state
from workflow_param
where id = #{id} and state = 1
</select>

<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="WorkflowParamMap">
select
id,workflow_id,param_name,description,param_type,param_value,is_sensitive,create_by,create_time,update_by,update_time,state
from workflow_param
<where>
state = 1
<if test="id != null">
and id = #{id}
</if>
<if test="workflowId != null">
and workflow_id = #{workflowId}
</if>
<if test="paramName != null and paramName != ''">
and param_name = #{paramName}
</if>
<if test="description != null and description != ''">
and description = #{description}
</if>
<if test="paramType != null">
and param_type = #{paramType}
</if>
<if test="paramValue != null and paramValue != ''">
and param_value = #{paramValue}
</if>
<if test="isSensitive != null">
and is_sensitive = #{isSensitive}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="state != null">
and state = #{state}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>

<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from workflow_param
<where>
state = 1
<if test="id != null">
and id = #{id}
</if>
<if test="workflowId != null">
and workflow_id = #{workflowId}
</if>
<if test="paramName != null and paramName != ''">
and param_name = #{paramName}
</if>
<if test="description != null and description != ''">
and description = #{description}
</if>
<if test="paramType != null">
and param_type = #{paramType}
</if>
<if test="paramValue != null and paramValue != ''">
and param_value = #{paramValue}
</if>
<if test="isSensitive != null">
and is_sensitive = #{isSensitive}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="state != null">
and state = #{state}
</if>
</where>
</select>

<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into workflow_param(workflow_id,param_name,description,param_type,param_value,is_sensitive,create_by,create_time,update_by,update_time,state)
values (#{workflowId}#{paramName}#{description}#{paramType}#{paramValue}#{isSensitive}#{createBy}#{createTime}#{updateBy}#{updateTime}#{state})
</insert>

<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into workflow_param(workflow_id,param_name,description,param_type,param_value,is_sensitive,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.workflowId}#{entity.paramName}#{entity.description}#{entity.paramType}#{entity.paramValue}#{entity.isSensitive}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state})
</foreach>
</insert>

<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into workflow_param(workflow_id,param_name,description,param_type,param_value,is_sensitive,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.workflowId}#{entity.paramName}#{entity.description}#{entity.paramType}#{entity.paramValue}#{entity.isSensitive}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state})
</foreach>
on duplicate key update
workflow_id = values(workflow_id)param_name = values(param_name)description = values(description)param_type = values(param_type)param_value = values(param_value)is_sensitive = values(is_sensitive)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)
</insert>

<!--通过主键修改数据-->
<update id="update">
update workflow_param
<set>
<if test="workflowId != null">
workflow_id = #{workflowId},
</if>
<if test="paramName != null and paramName != ''">
param_name = #{paramName},
</if>
<if test="description != null and description != ''">
description = #{description},
</if>
<if test="paramType != null">
param_type = #{paramType},
</if>
<if test="paramValue != null and paramValue != ''">
param_value = #{paramValue},
</if>
<if test="isSensitive != null">
is_sensitive = #{isSensitive},
</if>
<if test="createBy != null and createBy != ''">
create_by = #{createBy},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="state != null">
state = #{state},
</if>
</set>
where id = #{id}
</update>

<!--通过主键删除-->
<delete id="deleteById">
delete from workflow_param where id = #{id}
</delete>

</mapper>


Loading…
Cancel
Save