crud接口调整

This commit is contained in:
xiang2lin 2025-05-07 14:28:48 +08:00
parent 4c40538ae1
commit 6e3a47706a
9 changed files with 248 additions and 65 deletions

View File

@ -104,32 +104,34 @@
<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.sys.flow.entity.SysFlowClassEntity" keyProperty="id" useGeneratedKeys="true">
insert into sys_flow_class(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> id , </if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
<if test="create_time != null"> create_time , </if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
<if test="modify_time != null"> modify_time , </if>
<if test="sts != null and sts != ''"> sts , </if>
<if test="name != null and name != ''"> name , </if>
<if test="parentId != null and parentId != ''"> parent_id , </if>
<if test="sorts == null ">sorts,</if>
<if test="sts == null ">sts,</if>
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> #{id} ,</if>
<if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
<if test="create_time != null"> #{create_time} ,</if>
<if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
<if test="modify_time != null"> #{modify_time} ,</if>
<if test="sts != null and sts != ''"> #{sts} ,</if>
<if test="name != null and name != ''"> #{name} ,</if>
<if test="parentId != null and parentId != ''"> #{parentId} ,</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_class a WHERE a.sts = 'Y' ),1),</if>
<if test="sts == null ">'Y',</if>
</trim>
)
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''">id ,</if>
<if test="create_user_id != null and create_user_id != ''">create_user_id ,</if>
<if test="create_time != null">create_time ,</if>
<if test="modify_user_id != null and modify_user_id != ''">modify_user_id ,</if>
<if test="modify_time != null">modify_time ,</if>
<if test="sts != null and sts != ''">sts ,</if>
<if test="name != null and name != ''">name ,</if>
<if test="parentId != null and parentId != ''">parent_id ,</if>
<if test="sorts == null ">sorts,</if>
<if test="sts == null ">sts,</if>
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''">#{id} ,</if>
<if test="create_user_id != null and create_user_id != ''">#{create_user_id} ,</if>
<if test="create_time != null">#{create_time} ,</if>
<if test="modify_user_id != null and modify_user_id != ''">#{modify_user_id} ,</if>
<if test="modify_time != null">#{modify_time} ,</if>
<if test="sts != null and sts != ''">#{sts} ,</if>
<if test="name != null and name != ''">#{name} ,</if>
<if test="parentId != null and parentId != ''">#{parentId} ,</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_class a WHERE
a.sts = 'Y' ),1),
</if>
<if test="sts == null ">'Y',</if>
</trim>
)
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">

View File

@ -128,39 +128,41 @@
<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.sys.flow.entity.SysFlowEntity" keyProperty="id" useGeneratedKeys="true">
insert into sys_flow(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> id , </if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
<if test="create_time != null"> create_time , </if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
<if test="modify_time != null"> modify_time , </if>
<if test="sts != null and sts != ''"> sts , </if>
<if test="name != null and name != ''"> name , </if>
<if test="status != null and status != ''"> status , </if>
<if test="classId != null and classId != ''"> class_id , </if>
<if test="triggerModeId != null and triggerModeId != ''"> trigger_mode_id , </if>
<if test="nifiGroupId != null and nifiGroupId != ''"> nifi_group_id , </if>
<if test="description != null and description != ''"> description , </if>
<if test="sorts == null ">sorts,</if>
<if test="sts == null ">sts,</if>
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> #{id} ,</if>
<if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
<if test="create_time != null"> #{create_time} ,</if>
<if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
<if test="modify_time != null"> #{modify_time} ,</if>
<if test="sts != null and sts != ''"> #{sts} ,</if>
<if test="name != null and name != ''"> #{name} ,</if>
<if test="classId != null and classId != ''"> #{classId} ,</if>
<if test="triggerModeId != null and triggerModeId != ''"> #{triggerModeId} ,</if>
<if test="nifiGroupId != null and nifiGroupId != ''"> #{nifiGroupId} ,</if>
<if test="description != null and description != ''"> #{description} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow a WHERE a.sts = 'Y' ),</if>
<if test="sts == null ">'Y',</if>
</trim>
)
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''">id ,</if>
<if test="create_user_id != null and create_user_id != ''">create_user_id ,</if>
<if test="create_time != null">create_time ,</if>
<if test="modify_user_id != null and modify_user_id != ''">modify_user_id ,</if>
<if test="modify_time != null">modify_time ,</if>
<if test="sts != null and sts != ''">sts ,</if>
<if test="name != null and name != ''">name ,</if>
<if test="status != null and status != ''">status ,</if>
<if test="classId != null and classId != ''">class_id ,</if>
<if test="triggerModeId != null and triggerModeId != ''">trigger_mode_id ,</if>
<if test="nifiGroupId != null and nifiGroupId != ''">nifi_group_id ,</if>
<if test="description != null and description != ''">description ,</if>
<if test="sorts == null ">sorts,</if>
<if test="sts == null ">sts,</if>
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''">#{id} ,</if>
<if test="create_user_id != null and create_user_id != ''">#{create_user_id} ,</if>
<if test="create_time != null">#{create_time} ,</if>
<if test="modify_user_id != null and modify_user_id != ''">#{modify_user_id} ,</if>
<if test="modify_time != null">#{modify_time} ,</if>
<if test="sts != null and sts != ''">#{sts} ,</if>
<if test="name != null and name != ''">#{name} ,</if>
<if test="status != null and status != ''">#{status} ,</if>
<if test="classId != null and classId != ''">#{classId} ,</if>
<if test="triggerModeId != null and triggerModeId != ''">#{triggerModeId} ,</if>
<if test="nifiGroupId != null and nifiGroupId != ''">#{nifiGroupId} ,</if>
<if test="description != null and description != ''">#{description} ,</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow a WHERE a.sts = 'Y' ),1),
</if>
<if test="sts == null ">'Y',</if>
</trim>
)
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">

View File

@ -198,7 +198,7 @@
<if test="appSecret != null and appSecret != ''"> #{appSecret} ,</if>
<if test="corpid != null and corpid != ''"> #{corpid} ,</if>
<if test="agentid != null and agentid != ''"> #{agentid} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_account a WHERE a.sts = 'Y' ),</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_account a WHERE a.sts = 'Y' ),1),</if>
<if test="sts == null ">'Y',</if>
</trim>
)

View File

@ -198,7 +198,7 @@
<if test="sourceFieldName != null and sourceFieldName != ''"> #{sourceFieldName} ,</if>
<if test="sourceFieldType != null and sourceFieldType != ''"> #{sourceFieldType} ,</if>
<if test="sourceFieldDescription != null and sourceFieldDescription != ''"> #{sourceFieldDescription} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_config_b a WHERE a.sts = 'Y' ),</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_config_b a WHERE a.sts = 'Y' ),1),</if>
<if test="sts == null ">'Y',</if>
</trim>
)

View File

@ -206,7 +206,7 @@
<if test="createTableFlag != null and createTableFlag != ''"> #{createTableFlag} ,</if>
<if test="writeType != null and writeType != ''"> #{writeType} ,</if>
<if test="sqlStatement != null and sqlStatement != ''"> #{sqlStatement} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_config a WHERE a.sts = 'Y' ),</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_config a WHERE a.sts = 'Y' ),1),</if>
<if test="sts == null ">'Y',</if>
</trim>
)

View File

@ -190,7 +190,7 @@
<if test="nifiAppId != null and nifiAppId != ''"> #{nifiAppId} ,</if>
<if test="nifiApiId != null and nifiApiId != ''"> #{nifiApiId} ,</if>
<if test="sortMode != null and sortMode != ''"> #{sortMode} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step a WHERE a.sts = 'Y' ),</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step a WHERE a.sts = 'Y' ),1),</if>
<if test="sts == null ">'Y',</if>
</trim>
)

View File

@ -158,7 +158,7 @@
<if test="outputNifiAppId != null and outputNifiAppId != ''"> #{outputNifiAppId} ,</if>
<if test="inputNifiApiId != null and inputNifiApiId != ''"> #{inputNifiApiId} ,</if>
<if test="outputNifiApiId != null and outputNifiApiId != ''"> #{outputNifiApiId} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_relation a WHERE a.sts = 'Y' ),</if>
<if test="sorts == null ">COALESCE((select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_flow_step_relation a WHERE a.sts = 'Y' ),1),</if>
<if test="sts == null ">'Y',</if>
</trim>
)

View File

@ -1,7 +1,10 @@
package com.hzya.frame.sys.flow.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.sys.flow.entity.SysFlowEntity;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.web.entity.JsonResultEntity;
/**
* 流程主表;流程就是数环通的Linkup(SysFlow)表服务接口
*
@ -9,4 +12,38 @@ import com.hzya.frame.basedao.service.IBaseService;
* @since 2025-04-29 10:16:24
*/
public interface ISysFlowService extends IBaseService<SysFlowEntity, String>{
/**
* 保存流程主表
* @param object
* @return
*/
JsonResultEntity saveFlow(JSONObject object);
/**
* 更新流程主表
* @param object
* @return
*/
JsonResultEntity updateFlow(JSONObject object);
/**
* 删除流程主表
* @param object
* @return
*/
JsonResultEntity deleteFlow(JSONObject object);
/**
* 列表查询
* @param object
* @return
*/
JsonResultEntity queryFlowList(JSONObject object);
/**
* 分页查询
* @param object
* @return
*/
JsonResultEntity queryFlowPagedInfo(JSONObject object);
}

View File

@ -1,12 +1,23 @@
package com.hzya.frame.sys.flow.service.impl;
import cn.hutool.core.lang.Assert;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.sys.flow.entity.SysFlowEntity;
import com.hzya.frame.sys.flow.dao.ISysFlowDao;
import com.hzya.frame.sys.flow.service.ISysFlowService;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.util.List;
/**
* 流程主表;流程就是数环通的Linkup(SysFlow)表服务实现类
*
@ -23,4 +34,135 @@ public class SysFlowServiceImpl extends BaseService<SysFlowEntity, String> imple
this.sysFlowDao = dao;
this.dao = dao;
}
/**
* 保存流程主表
*
* @param object
* @return
*/
@Override
public JsonResultEntity saveFlow(JSONObject object) {
SysFlowEntity flowEntity = getData("jsonStr",object,SysFlowEntity.class);
try {
checkParams(flowEntity,"save");
} catch (Exception e) {
return BaseResult.getFailureMessageEntity(e.getMessage());
}
sysFlowDao.save(flowEntity);
return BaseResult.getSuccessMessageEntity("保存成功");
}
/**
* 更新流程主表
*
* @param object
* @return
*/
@Override
public JsonResultEntity updateFlow(JSONObject object) {
SysFlowEntity flowEntity = getData("jsonStr",object,SysFlowEntity.class);
try {
checkParams(flowEntity,"update");
} catch (Exception e) {
return BaseResult.getFailureMessageEntity(e.getMessage());
}
sysFlowDao.update(flowEntity);
return BaseResult.getSuccessMessageEntity("更新成功");
}
/**
* 删除流程主表
*
* @param object
* @return
*/
@Override
public JsonResultEntity deleteFlow(JSONObject object) {
SysFlowEntity flowEntity = getData("jsonStr",object,SysFlowEntity.class);
try {
checkParams(flowEntity,"delete");
} catch (Exception e) {
return BaseResult.getFailureMessageEntity(e.getMessage());
}
//删除主表
sysFlowDao.logicRemove(flowEntity);
//删除子表
return BaseResult.getSuccessMessageEntity("删除成功");
}
/**
* 列表查询
*
* @param object
* @return
*/
@Override
public JsonResultEntity queryFlowList(JSONObject object) {
SysFlowEntity flowEntity = getData("jsonStr",object,SysFlowEntity.class);
try {
checkParams(flowEntity,"queryList");
} catch (Exception e) {
return BaseResult.getFailureMessageEntity(e.getMessage());
}
List<SysFlowEntity> list = sysFlowDao.query(flowEntity);
return BaseResult.getSuccessMessageEntity("查询数据成功",list);
}
/**
* 分页查询
*
* @param object
* @return
*/
@Override
public JsonResultEntity queryFlowPagedInfo(JSONObject object) {
SysFlowEntity flowEntity = getData("jsonStr",object,SysFlowEntity.class);
try {
checkParams(flowEntity,"queryPaged");
} catch (Exception e) {
return BaseResult.getFailureMessageEntity(e.getMessage());
}
PageHelper.startPage(flowEntity.getPageNum(),flowEntity.getPageSize());
List<SysFlowEntity> queryByLike = sysFlowDao.queryByLike(flowEntity);
PageInfo pageInfo = new PageInfo(queryByLike);
return BaseResult.getSuccessMessageEntity("pageInfo",pageInfo);
}
/**
* 参数检查
* @param entity
* @param type
*/
private void checkParams(SysFlowEntity entity,String type){
Assert.notNull(entity,"请求参数不能为空");
if ("save".equals(type)){
Assert.notEmpty(entity.getClassId(),"classId不能为空");
Assert.notEmpty(entity.getName(),"name不能为空");
SysFlowEntity flow = new SysFlowEntity();
flow.setName(entity.getName());
List<SysFlowEntity> flowList = sysFlowDao.query(flow);
if (CollectionUtils.isNotEmpty(flowList)){
throw new BaseSystemException(entity.getName()+"重复");
}
}else if("update".equals(type)){
Assert.notEmpty(entity.getId(),"Id不能为空");
SysFlowEntity flow = new SysFlowEntity();
flow.setName(entity.getName());
List<SysFlowEntity> flowList = sysFlowDao.query(flow);
if (CollectionUtils.isNotEmpty(flowList)){
for (SysFlowEntity sysFlowEntity : flowList) {
if (!sysFlowEntity.getId().equals(entity.getId())){
throw new BaseSystemException(entity.getName()+"重复");
}
}
}
}else if ("delete".equals(type)){
Assert.notEmpty(entity.getId(),"Id不能为空");
}else if ("queryPaged".equals(type)){
Assert.notNull(entity.getPageNum(),"pageNum不能为空");
Assert.notNull(entity.getPageSize(),"pageSize不能为空");
}
}
}