code stringlengths 1 1.05M | repo_name stringlengths 6 83 | path stringlengths 3 242 | language stringclasses 222 values | license stringclasses 20 values | size int64 1 1.05M |
|---|---|---|---|---|---|
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.TenantEntity;
/**
* 表单设计器基本属性实体类
*
* @author BladeX
* @since 2021-07-02
*/
@Data
@TableName("design_desform_head")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "DesformHead对象", description = "表单设计器基本属性")
public class DesformHead extends TenantEntity {
private static final long serialVersionUID = 1L;
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@JsonSerialize(using = ToStringSerializer.class)
private Long createDept;
@ApiModelProperty(value = "online表名称")
@TableField(exist = false)
private String cgformCode;
/**
* 表单id
*/
@ApiModelProperty(value = "表单id")
private Long cgformHeadId;
/**
* 表单名称
*/
@ApiModelProperty(value = "表单名称")
private String formName;
/**
* 表单编码
*/
@ApiModelProperty(value = "表单编码")
private String formCode;
/**
* 表单图标
*/
@ApiModelProperty(value = "表单图标")
private String formIcon;
/**
* 表单json
*/
@ApiModelProperty(value = "表单json")
private String formDesignJson;
/**
* 类型:1=主表,2=子表
*/
@ApiModelProperty(value = "类型:1=主表,2=子表")
private Integer formType;
/**
* 父级id
*/
@ApiModelProperty(value = "父级id")
private Long parentId;
/**
* 父级编码
*/
@ApiModelProperty(value = "父级编码")
private String parentCode;
/**
* 手机模式:0=否 1=是
*/
@ApiModelProperty(value = "手机模式:0=否 1=是")
private Integer mobileView;
@ApiModelProperty(value = "不登录是否可以查询-0=否,1=是")
private String nologinSelect;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/entity/DesformHead.java | Java | apache-2.0 | 3,087 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.TenantEntity;
/**
* 表单设计器-路由实体类
*
* @author BladeX
* @since 2021-07-02
*/
@Data
@TableName("design_desform_route")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "表单设计器路由", description = "表单设计器路由")
public class DesformRoute extends TenantEntity {
private static final long serialVersionUID = 1L;
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@JsonSerialize(using = ToStringSerializer.class)
private Long createDept;
@ApiModelProperty(value = "表单设计id")
private Long desFormId;
@ApiModelProperty(value = "表单设计code")
private String desFormCode;
@ApiModelProperty(value = "'路由名称'")
private String routeName;
@ApiModelProperty(value = "路由地址")
private String routePath;
@ApiModelProperty(value = "路由跳转路径")
private String routeType;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/entity/DesformRoute.java | Java | apache-2.0 | 2,159 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springblade.core.mp.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 填值规则实体类
*
* @author BladeX
* @since 2021-07-03
*/
@Data
@TableName("sys_fill_rule")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "FillRule对象", description = "填值规则")
public class FillRule extends BaseEntity {
private static final long serialVersionUID = 1L;
private String id;
@JsonSerialize(using = ToStringSerializer.class)
private Long createDept;
/**
* 规则名称
*/
@ApiModelProperty(value = "规则名称")
private String ruleName;
/**
* 规则Code
*/
@ApiModelProperty(value = "规则Code")
private String ruleCode;
/**
* 规则实现类
*/
@ApiModelProperty(value = "规则实现类")
private String ruleClass;
/**
* 规则参数
*/
@ApiModelProperty(value = "规则参数")
private String ruleParams;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/entity/FillRule.java | Java | apache-2.0 | 2,062 |
package org.springblade.modules.mjkj.common.cgform.entity;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class MjkjBase implements Serializable {
/**
* 租户ID
*/
@ApiModelProperty(value = "租户ID")
private String tenantId;
/**
* 是否已删除
*/
@TableLogic
@ApiModelProperty(value = "是否已删除")
private Integer isDeleted;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/entity/MjkjBase.java | Java | apache-2.0 | 477 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springblade.core.mp.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 数据字典实体类
*
* @author BladeX
* @since 2021-05-27
*/
@Data
@TableName("sys_dict")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Dict对象", description = "数据字典")
public class SysDict extends BaseEntity {
private static final long serialVersionUID = 1L;
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@JsonSerialize(using = ToStringSerializer.class)
private String createDept;
/**
* 字典名称
*/
@ApiModelProperty(value = "字典名称")
private String dictName;
/**
* 字典编码
*/
@ApiModelProperty(value = "字典编码")
private String dictCode;
/**
* 描述
*/
@ApiModelProperty(value = "描述")
private String description;
/**
* 字典类型0为string,1为number
*/
@ApiModelProperty(value = "字典类型0为string,1为number")
private Integer type;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/entity/SysDict.java | Java | apache-2.0 | 2,126 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springblade.core.mp.base.TenantEntity;
/**
* 数据字典实体类
*
* @author BladeX
* @since 2021-05-27
*/
@Data
@TableName("sys_dict_item")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "DictItem对象", description = "数据字典")
public class SysDictItem extends TenantEntity {
private static final long serialVersionUID = 1L;
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@JsonSerialize(using = ToStringSerializer.class)
private Long createDept;
/**
* 字典id
*/
@ApiModelProperty(value = "字典id")
private String dictId;
/**
* 字典项文本
*/
@ApiModelProperty(value = "字典项文本")
private String itemText;
/**
* 字典项值
*/
@ApiModelProperty(value = "字典项值")
private String itemValue;
/**
* 描述
*/
@ApiModelProperty(value = "描述")
private String description;
/**
* 排序
*/
@ApiModelProperty(value = "排序")
private Integer sortOrder;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/entity/SysDictItem.java | Java | apache-2.0 | 2,184 |
package org.springblade.modules.mjkj.common.cgform.enums;
public interface CgformConstant {
//表类型: 1单表、2主表、3附表
Integer ONLINE_TABLE_TYPE_SUB = Integer.valueOf(3);
Integer ONLINE_TABLE_TYPE_ONE = Integer.valueOf(1);
Integer ONLINE_TABLE_TYPE_MAIN = Integer.valueOf(2);
String ONLINE_JS_CHANGE_FUNCTION_NAME = "onlChange";
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/enums/CgformConstant.java | Java | apache-2.0 | 368 |
package org.springblade.modules.mjkj.common.cgform.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* online表单枚举 代码生成器用到
*/
public enum CgformEnum {
/**
* 单表
*/
ONE(1, "one", "/mjkj/code-template-online", "default.one", "经典风格"),
/**
* 多表
*/
MANY(2, "many", "/mjkj/code-template-online", "default.onetomany", "经典风格"),
/**
* 多表
*/
ERP(2, "erp", "/mjkj/code-template-online", "erp.onetomany", "ERP风格"),
/**
* 多表(内嵌子表风格)
*/
INNER_TABLE(2, "innerTable", "/mjkj/code-template-online", "inner-table.onetomany", "内嵌子表风格"),
/**
* 树形列表
*/
TREE(3, "tree", "/mjkj/code-template-online", "default.tree", "树形列表");
/**
* 类型 1/单表 2/一对多 3/树
*/
int type;
/**
* 编码标识
*/
String code;
/**
* 代码生成器模板路径
*/
String templatePath;
/**
* 代码生成器模板路径
*/
String stylePath;
/**
* 模板风格名称
*/
String note;
/**
* 构造器
*
* @param type
* @param code
* @param templatePath
* @param note
*/
CgformEnum(int type, String code, String templatePath, String stylePath, String note) {
this.type = type;
this.code = code;
this.templatePath = templatePath;
this.stylePath = stylePath;
this.note = note;
}
/**
* 根据code获取模板路径
*
* @param code
* @return
*/
public static String getTemplatePathByConfig(String code) {
return getCgformEnumByConfig(code).templatePath;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getTemplatePath() {
return templatePath;
}
public void setTemplatePath(String templatePath) {
this.templatePath = templatePath;
}
public String getStylePath() {
return stylePath;
}
public void setStylePath(String stylePath) {
this.stylePath = stylePath;
}
/**
* 根据code找枚举
*
* @param code
* @return
*/
public static CgformEnum getCgformEnumByConfig(String code) {
for (CgformEnum e : CgformEnum.values()) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
/**
* 根据类型找所有
*
* @param type
* @return
*/
public static List<Map<String, Object>> getJspModelList(int type) {
List<Map<String, Object>> ls = new ArrayList<Map<String, Object>>();
for (CgformEnum e : CgformEnum.values()) {
if (e.type == type) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("code", e.code);
map.put("note", e.note);
ls.add(map);
}
}
return ls;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/enums/CgformEnum.java | Java | apache-2.0 | 3,130 |
package org.springblade.modules.mjkj.common.cgform.enums;
public enum CgformValidPatternEnum {
ONLY("only", "only", ""),
NUM6_16("n6-16", "^\\d{6,18}$", "请输入6-16位的数字"),
STRING6_16("*6-16", "^.{6,16}$", "请输入6-16位任意字符"),
LETTER6_18("s6-18", "^[a-z|A-Z]{6,18}$", "请输入6-18位字母"),
URL("url", "^((ht|f)tps?):\\/\\/[\\w\\-]+(\\.[\\w\\-]+)+([\\w\\-.,@?^=%&:\\/~+#]*[\\w\\-@?^=%&\\/~+#])?$", "请输入正规的网址"),
MOBILE("m", "^1[3456789]\\d{9}$", "请输入正规的手机号码"),
POSTAL("p", "^[1-9]\\d{5}$", "请输入正规的邮政编码"),
LETTER("s", "[A-Z|a-z]+$", "请输入字母"),
NUMBER("n", "^-?\\d+(\\.?\\d+|\\d?)$", "请输入数字"),
INTEGER("z", "z", "请输入整数"),
NOTNULL("*", "^.+$", "该字段不能为空"),
EMAIL("e", "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$", "请输入正确格式的邮箱地址"),
MONEY("money", "^(([1-9][0-9]*)|([0]\\.\\d{0,2}|[1-9][0-9]*\\.\\d{0,5}))$", "请输入正确的金额");
String type;
String pattern;
String msg;
private CgformValidPatternEnum(String type, String pattern, String msg) {
this.pattern = pattern;
this.msg = msg;
this.type = type;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getPattern() {
return this.pattern;
}
public void setPattern(String pattern) {
this.pattern = pattern;
}
public String getMsg() {
return this.msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public static CgformValidPatternEnum getPatternInfoByType(String type) {
CgformValidPatternEnum[] var1 = values();
int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) {
CgformValidPatternEnum var4 = var1[var3];
if (var4.type.equals(type)) {
return var4;
}
}
return null;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/enums/CgformValidPatternEnum.java | Java | apache-2.0 | 2,069 |
package org.springblade.modules.mjkj.common.cgform.enums;
public interface MjkjAeskey {
String key="O2BEeIv399qHQNhD6aGW8R8DEj4bqHXm";
//数据库key
String db_aes_key="O2BEeIv399qHQNhD6aGW8R8DEj4bqHXm";
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/enums/MjkjAeskey.java | Java | apache-2.0 | 213 |
package org.springblade.modules.mjkj.common.cgform.enums;
/**
* 日志按模块分类
*/
public enum ModuleType {
/**
* 普通
*/
COMMON,
/**
* online
*/
ONLINE;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/enums/ModuleType.java | Java | apache-2.0 | 205 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import org.springblade.modules.mjkj.common.cgform.model.KvModel;
import java.util.List;
import java.util.Map;
/**
* 公共sql
*/
public interface BaseSqlMapper {
int getProcessingProgressTotal(String tableName,String batchCode);
List<Long> getAdminIdList();
//查询公共接口
List<Map<String, Object>> baseSelectSqlList(Map<String, Object> map);
//公共新增接口
Long baseIntegerSql(Map<String, Object> map);
//公共修改接口
void baseUpdateSql(Map<String, Object> map);
//公共删除接口
void baseDeleteSql(Map<String, Object> map);
//查询一列
List<String> baseSelectByOneColumnSql(Map<String, Object> map);
//获取模型列表
List<KvModel> getKvModelList(Map<String, Object> map);
//查询数据字典
String getSysDictItem(Long sysDictId, Integer type);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/BaseSqlMapper.java | Java | apache-2.0 | 1,699 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.Category;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 分类字典 Mapper 接口
*
* @author BladeX
* @since 2021-05-27
*/
public interface CategoryMapper extends BaseMapper<Category> {
String queryCategoryIdByCode(@Param("code") String code);
List<Category> getAllSubList(Long id);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CategoryMapper.java | Java | apache-2.0 | 1,334 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformButton;
/**
* 自定义表单 Mapper 接口
*
* @author BladeX
* @since 2021-05-22
*/
public interface CgformButtonMapper extends BaseMapper<CgformButton> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformButtonMapper.java | Java | apache-2.0 | 1,176 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJava;
/**
* java增强 Mapper 接口
*
* @author BladeX
* @since 2021-05-22
*/
public interface CgformEnhanceJavaMapper extends BaseMapper<CgformEnhanceJava> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformEnhanceJavaMapper.java | Java | apache-2.0 | 1,185 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJs;
/**
* js增强 Mapper 接口
*
* @author BladeX
* @since 2021-05-22
*/
public interface CgformEnhanceJsMapper extends BaseMapper<CgformEnhanceJs> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformEnhanceJsMapper.java | Java | apache-2.0 | 1,178 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceSql;
import java.util.List;
import java.util.Map;
/**
* sql增强 Mapper 接口
*
* @author BladeX
* @since 2021-05-22
*/
public interface CgformEnhanceSqlMapper extends BaseMapper<CgformEnhanceSql> {
void executeDDL(@Param("sqlStr") String sqlStr);
//查询多条语句
List<Map<String,Object>> getListData(@Param("sqlStr") String sqlStr);
//查询多条语句
Page<Map<String, Object>> getListDataPage(@Param("page") Page<Map<String, Object>> page,Map<String, Object> params, @Param("sqlStr") String sqlStr);
//执行sql
Page<Map<String, Object>> executeSql(@Param("page") Page<Map<String, Object>> page,@Param("executeSql") String executeSql,@Param("params")Map<String, Object> params);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformEnhanceSqlMapper.java | Java | apache-2.0 | 1,843 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
/**
* Mapper 接口
*
* @author BladeX
* @since 2021-05-20
*/
public interface CgformFieldMapper extends BaseMapper<CgformField> {
Map<String, Object> queryOneByTableNameAndId(@Param("tbname") String tbname, @Param("dataId") Long dataId);
Integer getBlobCou(Long headId);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformFieldMapper.java | Java | apache-2.0 | 1,371 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* Mapper 接口
*
* @author BladeX
* @since 2021-05-20
*/
public interface CgformHeadMapper extends BaseMapper<CgformHead> {
List<Map<String, Object>> queryList(@Param("sqlStr") String var1);
void executeDDL(@Param("sqlStr") String var1);
Integer getMaxCopyVersion(Long physicId);
Map<String, Object> queryOneByTableNameAndId(@Param("tbname") String var1, @Param("dataId") String var2);
//逻辑删除
void deleteOne(@Param("sqlStr") String var1);
@Select({"select count(*) from ${tableName} where ${pidField} = #{pidValue}"})
Integer queryChildNode(@Param("tableName") String var1, @Param("pidField") String var2, @Param("pidValue") String var3);
@Select({"select physic_id from onl_cgform_head GROUP BY physic_id"})
List<String> queryCopyPhysicId();
@Select({"select table_name from onl_cgform_head where is_deleted=0"})
List<String> getAllTableName();
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformHeadMapper.java | Java | apache-2.0 | 2,065 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformIndex;
import org.apache.ibatis.annotations.Param;
/**
* Mapper 接口
*
* @author BladeX
* @since 2021-05-20
*/
public interface CgformIndexMapper extends BaseMapper<CgformIndex> {
int queryIndexCount(@Param("sqlStr") String var1);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformIndexMapper.java | Java | apache-2.0 | 1,256 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformValid;
/**
* 自定义表单字段校验规则表 Mapper 接口
*
* @author BladeX
* @since 2021-05-20
*/
public interface CgformValidMapper extends BaseMapper<CgformValid> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CgformValidMapper.java | Java | apache-2.0 | 1,194 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.CheckRule;
/**
* 编码校验规则 Mapper 接口
*
* @author BladeX
* @since 2021-07-03
*/
public interface CheckRuleMapper extends BaseMapper<CheckRule> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/CheckRuleMapper.java | Java | apache-2.0 | 1,169 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.DesformData;
/**
* 表单设计器-数据 Mapper 接口
*
* @author BladeX
* @since 2021-07-02
*/
public interface DesformDataMapper extends BaseMapper<DesformData> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/DesformDataMapper.java | Java | apache-2.0 | 1,180 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.DesformHead;
import java.util.List;
/**
* 表单设计器基本属性 Mapper 接口
*
* @author BladeX
* @since 2021-07-02
*/
public interface DesformHeadMapper extends BaseMapper<DesformHead> {
List<DesformHead> openList();
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/DesformHeadMapper.java | Java | apache-2.0 | 1,242 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.DesformRoute;
/**
* 表单设计器-路由 Mapper 接口
*
* @author BladeX
* @since 2021-07-02
*/
public interface DesformRouteMapper extends BaseMapper<DesformRoute> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/DesformRouteMapper.java | Java | apache-2.0 | 1,183 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.FillRule;
/**
* 填值规则 Mapper 接口
*
* @author BladeX
* @since 2021-07-03
*/
public interface FillRuleMapper extends BaseMapper<FillRule> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/FillRuleMapper.java | Java | apache-2.0 | 1,161 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.mjkj.common.cgform.model.KvModel;
import java.util.List;
import java.util.Map;
/**
* 魔晶公共定制
*/
public interface MjkjBaseSqlMapper {
List<Map<String, Object>> getDataByTable(String selectField,String tableName);
//根据id获取某一个表的一条数据
Map<String, Object> getTableById(String selectField,String tableName, String id);
Map<String, Object> getTableByIdL(String selectField,String tableName, Long id);
//根据id获取某一个表的一条数据 进行过滤
List<Map<String, Object>> getDataListByField(String selectField,String tableName, String whereFieldName, Object whereFieldValue);
//根据id获取某一个表的一条数据 进行删除过滤 排序
List<Map<String, Object>> getDataListByFieldOrderBy(String selectField,String tableName, String whereFieldName, Object whereFieldValue,String orderByField,String orderStr);
//根据id获取某一个表的一条数据 type=A:全部 L:左边模糊 R右模糊
List<Map<String, Object>> getDataListByLike(String selectField,String tableName, String whereFieldName, Object whereFieldValue,String type);
List<Map<String, Object>> getDataListByIn(String selectField,String tableName, String whereFieldName, List<Object> whereFieldValueList);
List<KvModel> getSysDictItemList(String dictCode);
//获取数字字典值
String getSysDictItemValue(String dictCode,String itemValue);
String getSysDictItemValueByText(String dictCode,String itemText);
//公共新增
Long baseInsertSql(Map<String, Object> map);
//公共更新
void baseUpdateSql(Map<String, Object> map);
//公共删除
Integer baseDeleteSqlStr(String tableName, String id);
Integer baseDeleteSql(String tableName, Long id);
//真实删除
Integer baseRealDeleteSql(String tableName, Long id);
//自定义公共删除
Integer baseZdyDeleteSql(String tableName, String whereFieldName, Long id);
//自定义公共删除 string
Integer baseZdyDeleteSql(String tableName, String whereFieldName, String id);
List<Long> getAdminIdList();
int getProcessingProgress(String tableName,String batchCode);
int getProcessingProgressTotal(String tableName,String batchCode);
List<Map<String,Object>> getBladeUserOauth(String uuid,String source);
//获取授权
List<Map<String,Object>> getBladeUserOauthByUserId(Long userId);
//解绑
void unBindBladeUserOauth(Long id);
// 根据表属性获取所有数据 多条件
<T> List<Map<String, T>> getDataListByWrapper(String tableName,@Param(Constants.WRAPPER) Wrapper<T> wrapper);
// 根据表属性获取所有数据 多条件 分页
<T> IPage<Map<String, T>> getDataListByWrapper(String tableName, IPage page, @Param(Constants.WRAPPER) Wrapper<T> wrapper);
//本次定制
//获取所有全仓借款用户
List<String> getAllBorrowMemberId();
//获取所有全仓用户
List<String> getAllContractMemberId();
//获取我的全仓交易对
List<String> getMyAllContractSymbolName(String memberId);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/MjkjBaseSqlMapper.java | Java | apache-2.0 | 4,085 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springblade.modules.mjkj.common.cgform.model.CommonEntity;
import org.springblade.modules.mjkj.common.cgform.model.TreeModel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 自定义查询sql,无租户id
*/
public interface SqlMapper {
/**
* 查询列表
* @param sqlStr
* @return
*/
List<Map<String, Object>> queryListBySqlList(@Param("sqlStr") String sqlStr);
/**
* 查询分页
* @param page
* @param sqlStr
* @return
*/
IPage<Map<String, Object>> selectPageBySqlList(Page<Map<String, Object>> page, @Param("sqlStr") String sqlStr);
/**
* 新增
* @param map
*/
void executeInsertSQL(Map<String, Object> map);
/**
* 批量新增
* @param map
*/
void executeInsertBatchSQL(String fieldStrList,List<Map<String, Object>> mapList);
/**
* 修改
* @param map
*/
void executeUpdatetSQL(Map<String, Object> map);
/**
* 保存数据
* @param sqlStr
*/
void saveFormData(@Param("sqlStr") String sqlStr);
/**
* 更新数据
* @param sqlStr
*/
void editFormData(@Param("sqlStr") String sqlStr);
/**
* 删除数据
* @param sqlStr
*/
void deleteAutoList(@Param("sqlStr") String sqlStr);
//真实删除
void deleteList(@Param("sqlStr") String sqlStr);
/**
* 查询单个数据
* @param sqlStr
* @return
*/
Map<String, Object> queryFormData(@Param("sqlStr") String sqlStr);
/**
* 查询数据总条数
* @param sqlStr
* @return
*/
Integer queryCountBySql(@Param("sqlStr") String sqlStr);
/**
* 查询数据列表
* @param sqlStr
* @return
*/
List<Map<String, Object>> queryListData(@Param("sqlStr") String sqlStr);
/**
*
* @param entity
* @return
*/
List<TreeModel> queryDataListByLinkDown(@Param("query") CommonEntity entity);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/SqlMapper.java | Java | apache-2.0 | 3,011 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.SysDictItem;
import org.springblade.modules.mjkj.common.cgform.model.DictModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 数据字典 Mapper 接口
*
* @author BladeX
* @since 2021-05-27
*/
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
List<DictModel> queryDictItemsByCode(@Param("code") String code);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/SysDictItemMapper.java | Java | apache-2.0 | 1,425 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.mjkj.common.cgform.entity.SysDict;
import org.springblade.modules.mjkj.common.cgform.model.DictModel;
import org.springblade.modules.mjkj.common.cgform.model.DuplicateCheckVo;
import org.springblade.modules.mjkj.common.cgform.model.TreeSelectModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* 数据字典 Mapper 接口
*
* @author BladeX
* @since 2021-05-27
*/
public interface SysDictMapper extends BaseMapper<SysDict> {
List<DictModel> queryTableDictItemsByCode(@Param("table") String table, @Param("text") String text, @Param("code") String code);
List<DictModel> queryDictItemsByCode(@Param("code") String code);
List<DictModel> queryTableDictItemsByCodeAndFilter(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
List<TreeSelectModel> queryTreeList(@Param("query") Map<String, String> query, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("pidField") String pidField, @Param("pid") String pid, @Param("hasChildField") String hasChildField);
List<DictModel> queryTableDictByKeys(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyArray") String[] keyArray);
Long getIdByCode(String code);
/**
* 通过关键字查询出字典表
* @param table
* @param text
* @param code
* @param keyword
* @return
*/
List<DictModel> queryTableDictItems(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyword") String keyword);
Long duplicateCheckCountSql(DuplicateCheckVo duplicateCheckVo);
Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo);
List<Map<String,Object>> getAllTenantList();
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/mapper/SysDictMapper.java | Java | apache-2.0 | 2,892 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.SqlMapper;
import org.springblade.modules.mjkj.common.cgform.service.ICgformEnhanceSqlService;
import java.util.List;
import java.util.Map;
@Data
public class AccumulatorRecursiveActionParam {
private ICgformEnhanceSqlService sqlService;
private CgformHead head;
private List<CgformField> cgformFieldList;
private List<Map<String, Object>> importList;
private String batchCode;
private SqlMapper sqlMapper;
private Map<String, Object> otherMap;
private org.springblade.modules.mjkj.common.cgform.model.CgformEnhanceJavaBatchInter java;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/AccumulatorRecursiveActionParam.java | Java | apache-2.0 | 826 |
package org.springblade.modules.mjkj.common.cgform.model;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import java.util.Map;
public interface CgformEnhanceJavaBatchInter {
Map<String,Object> getOtherParam(String batchCode);
/**
*
* @param head
* @param jsonobject
* @return 1=新增 2=更新 -1=不操作
* @throws BusinessException
*/
int execute(CgformHead head, JSONObject jsonobject, Map<String,Object> otherMap)
throws BusinessException;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/CgformEnhanceJavaBatchInter.java | Java | apache-2.0 | 621 |
package org.springblade.modules.mjkj.common.cgform.model;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
public interface CgformEnhanceJavaInter {
/**
*
* @param head
* @param jsonobject
* @return 1=新增 2=更新 -1=不操作
* @throws BusinessException
*/
int execute(CgformHead head, JSONObject jsonobject)
throws BusinessException;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/CgformEnhanceJavaInter.java | Java | apache-2.0 | 509 |
package org.springblade.modules.mjkj.common.cgform.model;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import java.util.List;
import java.util.Map;
/**
* java增强需要继承该接口
*/
public interface CgformEnhanceJavaListInter {
void execute(String tableName, String tenantId, List<Map<String, Object>> list, Map<String, Object> params)
throws BusinessException;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/CgformEnhanceJavaListInter.java | Java | apache-2.0 | 429 |
package org.springblade.modules.mjkj.common.cgform.model;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.entity.CgformIndex;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 表单新增实体
*/
@Data
public class CgformModel {
@ApiModelProperty(value = "基本内容")
private CgformHead head;
@ApiModelProperty(value = "属性列表")
private List<CgformField> fields;
@ApiModelProperty(value = "索引列表")
private List<CgformIndex> indexs;
@ApiModelProperty(value = "删除字段id")
private List<String> deleteFieldIds;
@ApiModelProperty(value = "删除字段索引")
private List<String> deleteIndexIds;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/CgformModel.java | Java | apache-2.0 | 855 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
@NoArgsConstructor
@Data
@EqualsAndHashCode
@ToString
public class CommonEntity {
private String table;
private String txt;
private String key;
private String linkField;
private String idField;
private String pidField;
private String pidValue;
private String condition;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/CommonEntity.java | Java | apache-2.0 | 474 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
import java.util.List;
@Data
public class DesformUpdateTimeModel {
List<String> idList;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/DesformUpdateTimeModel.java | Java | apache-2.0 | 172 |
package org.springblade.modules.mjkj.common.cgform.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DictModel implements Serializable{
private static final long serialVersionUID = 1L;
public DictModel() {
}
public DictModel(String value, String text) {
this.value = value;
this.text = text;
}
/**
* 字典value
*/
private String value;
/**
* 字典文本
*/
private String text;
private String label;
private String id;
private String key;
public void setText(String text) {
this.text = text;
this.label = text;
}
public void setValue(String value) {
this.value = value;
this.id =value;
this.key=value;
}
/**
* 特殊用途: JgEditableTable
* @return
*/
public String getTitle() {
return this.text;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/DictModel.java | Java | apache-2.0 | 1,034 |
package org.springblade.modules.mjkj.common.cgform.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value="重复校验数据模型",description="重复校验数据模型")
public class DuplicateCheckVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 表名
*/
@ApiModelProperty(value="表名",name="tableName",example="sys_log")
private String tableName;
/**
* 字段名
*/
@ApiModelProperty(value="字段名",name="fieldName",example="id")
private String fieldName;
/**
* 字段值
*/
@ApiModelProperty(value="字段值",name="fieldVal",example="1000")
private String fieldVal;
/**
* 数据ID
*/
@ApiModelProperty(value="数据ID",name="dataId",example="2000")
private String dataId;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/DuplicateCheckVo.java | Java | apache-2.0 | 868 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
@Data
public class FieldModel {
private String fieldName;
private String tableName;
private String codeField;
private String textField;
private String pidField;
private String pidValue;
private String hsaChildField;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/FieldModel.java | Java | apache-2.0 | 326 |
package org.springblade.modules.mjkj.common.cgform.model;
public class FieldSlotType
{
public static final String FILE = "file";
public static final String IMAGE = "image";
public static final String EDITOR = "editor";
public static final String DATE = "date";
public static final String PCA = "pca";
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/FieldSlotType.java | Java | apache-2.0 | 325 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
@Data
public class HrefSlots {
private String slotName;
private String href;
public HrefSlots(String slotName, String href) {
this.slotName = slotName;
this.href = href;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/HrefSlots.java | Java | apache-2.0 | 287 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
/**
*
* 图片大小
*/
@Data
public class ImageSizeModel {
private Integer width;
private Integer height;
private String proportion;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/ImageSizeModel.java | Java | apache-2.0 | 223 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
import java.io.Serializable;
@Data
public class KvModel implements Serializable {
private String k;
private String v;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/KvModel.java | Java | apache-2.0 | 209 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
@Data
public class OnlColumn {
private String title;
private String dataIndex;
private String align;
private String customRender;
private ScopedSlots scopedSlots;
private String hrefSlotName;
private ScopedSlots jsSlots;
private String jsEnhance;
private Integer width;
private boolean sorter = false;
public OnlColumn(String title, String dataIndex, Integer width) {
this.align = "center";
this.title = title;
this.dataIndex = dataIndex;
this.width = width;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/OnlColumn.java | Java | apache-2.0 | 624 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
@Data
public class OnlForeignKey {
private String field;
private String table;
private String key;
public OnlForeignKey(String field, String key) {
this.key = key;
this.field = field;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/OnlForeignKey.java | Java | apache-2.0 | 305 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
public class OnlGenerateModel implements Serializable {
/**
*
*/
private static final long serialVersionUID = 684098897071177558L;
private Long headId;
private String projectPath;
private String packageStyle;
private String ftlDescription;
private String jformType;
private String tableName;
private String entityPackage;
private String entityName;
private String jspMode;
private List<OnlGenerateModel> subList = new ArrayList<>();
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/OnlGenerateModel.java | Java | apache-2.0 | 651 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
import org.springblade.core.secure.BladeUser;
import org.springblade.modules.mjkj.common.cgform.entity.CgformButton;
import org.springblade.modules.system.entity.BladeDept;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
public class OnlineConfigModel {
private Long headId;
private String formTemplate;
private String description;
private String currentTableName;
private Integer tableType;
private String paginationFlag;
private String checkboxFlag;
private Integer scrollFlag;
private List<OnlColumn> columns;
private List<String> hideColumns;
private Map<String, List<DictModel>> dictOptions = new HashMap<>();
private Map<String, List<BladeDept>> deptOptions = new HashMap<>();
private Map<String, List<BladeUser>> userOptions = new HashMap<>();
private List<CgformButton> cgButtonList;
private List<HrefSlots> fieldHrefSlots;
private String enhanceJs;
private String enhanceJsApp;
private List<OnlForeignKey> foreignKeys;
private String pidField;
private String hasChildrenField;
private String textField;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/OnlineConfigModel.java | Java | apache-2.0 | 1,205 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
@Data
public class ScopedSlots {
private String customRender;
public ScopedSlots(String customRender) {
this.customRender = customRender;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/ScopedSlots.java | Java | apache-2.0 | 243 |
package org.springblade.modules.mjkj.common.cgform.model;
import java.util.Date;
/**
* <p>
* 菜单权限规则表
* </p>
*
* @Author huangzhilin
* @since 2019-03-29
*/
public class SysPermissionDataRuleModel {
/**
* id
*/
private String id;
/**
* 对应的菜单id
*/
private String permissionId;
/**
* 规则名称
*/
private String ruleName;
/**
* 字段
*/
private String ruleColumn;
/**
* 条件
*/
private String ruleConditions;
/**
* 规则值
*/
private String ruleValue;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private String createBy;
/**
* 修改时间
*/
private Date updateTime;
/**
* 修改人
*/
private String updateBy;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPermissionId() {
return permissionId;
}
public void setPermissionId(String permissionId) {
this.permissionId = permissionId;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getRuleColumn() {
return ruleColumn;
}
public void setRuleColumn(String ruleColumn) {
this.ruleColumn = ruleColumn;
}
public String getRuleConditions() {
return ruleConditions;
}
public void setRuleConditions(String ruleConditions) {
this.ruleConditions = ruleConditions;
}
public String getRuleValue() {
return ruleValue;
}
public void setRuleValue(String ruleValue) {
this.ruleValue = ruleValue;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/SysPermissionDataRuleModel.java | Java | apache-2.0 | 2,461 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
import org.springblade.core.tool.node.INode;
import java.util.ArrayList;
import java.util.List;
/**
* 树结构
*/
@Data
public class TreeDataModel implements INode<TreeDataModel> {
private Long id;
private Long pId;//父节点
private Long parentId;//父节点
private String title;//显示列
private Object data;
private List<TreeDataModel> children;
@Override
public List<TreeDataModel> getChildren() {
if (this.children == null) {
this.children = new ArrayList<>();
}
return this.children;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/TreeDataModel.java | Java | apache-2.0 | 657 |
package org.springblade.modules.mjkj.common.cgform.model;
import lombok.Data;
@Data
public class TreeModel {
private String label;
private String store;
private String id;
private String pid;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/TreeModel.java | Java | apache-2.0 | 212 |
package org.springblade.modules.mjkj.common.cgform.model;
import java.io.Serializable;
import java.util.List;
/**
* 树形下拉框
*/
public class TreeSelectModel implements Serializable {
private static final long serialVersionUID = 9016390975325574747L;
private String key;
private String title;
private boolean isLeaf;
private String icon;
private String parentId;
private String value;
private String code;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isLeaf() {
return isLeaf;
}
public void setLeaf(boolean isLeaf) {
this.isLeaf = isLeaf;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
private List<TreeSelectModel> children;
public List<TreeSelectModel> getChildren() {
return children;
}
public void setChildren(List<TreeSelectModel> children) {
this.children = children;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/TreeSelectModel.java | Java | apache-2.0 | 1,419 |
package org.springblade.modules.mjkj.common.cgform.model.database.util;
public interface DbConvertDef
{
String YES_DEF = "Y";
String NO_DEF = "N";
String MYSQL = "mysql";
String ORACLE = "oracle";
String SQLSERVER = "sqlserver";
String POSTGRESQL = "postgresql";
String MYSQL_COLUMNS_SQL = "select column_name,data_type,column_comment,numeric_precision,numeric_scale,character_maximum_length,is_nullable nullable from information_schema.columns where table_name = {0} and table_schema = {1} order by ORDINAL_POSITION";
String ORACLE_COLUMNS_SQL = " select colstable.column_name column_name, colstable.data_type data_type, commentstable.comments column_comment, colstable.Data_Precision column_precision, colstable.Data_Scale column_scale,colstable.Char_Length,colstable.nullable from user_tab_cols colstable inner join user_col_comments commentstable on colstable.column_name = commentstable.column_name where colstable.table_name = commentstable.table_name and colstable.table_name = {0}";
String SQLSERVER_COLUMNS_SQL = "select distinct cast(a.name as varchar(50)) column_name, cast(b.name as varchar(50)) data_type, cast(e.value as NVARCHAR(200)) comment, cast(ColumnProperty(a.object_id,a.Name,'''Precision''') as int) num_precision, cast(ColumnProperty(a.object_id,a.Name,'''Scale''') as int) num_scale, a.max_length, (case when a.is_nullable=1 then '''y''' else '''n''' end) nullable,column_id from sys.columns a left join sys.types b on a.user_type_id=b.user_type_id left join (select top 1 * from sys.objects where type = '''U''' and name ={0} order by name) c on a.object_id=c.object_id left join sys.extended_properties e on e.major_id=c.object_id and e.minor_id=a.column_id and e.class=1 where c.name={0} order by a.column_id";
String POSTGRESQL_COLUMNS_SQL = "select icm.column_name as field,icm.udt_name as type,fieldtxt.descript as comment, icm.numeric_precision_radix as column_precision ,icm.numeric_scale as column_scale ,icm.character_maximum_length as Char_Length,icm.is_nullable as attnotnull from information_schema.columns icm, (SELECT A.attnum,( SELECT description FROM pg_catalog.pg_description WHERE objoid = A.attrelid AND objsubid = A.attnum ) AS descript,A.attname FROM\tpg_catalog.pg_attribute A WHERE A.attrelid = ( SELECT oid FROM pg_class WHERE relname = {0} ) AND A.attnum > 0 AND NOT A.attisdropped ORDER BY\tA.attnum ) fieldtxt where icm.table_name={1} and fieldtxt.attname = icm.column_name";
String MYSQL_TABLES_SQL = "select distinct table_name from information_schema.columns where table_schema = {0}";
String ORACLE_TABLES_SQL = " select distinct colstable.table_name as table_name from user_tab_cols colstable order by colstable.table_name";
String SQLSERVER_TABLES_SQL = "select distinct c.name as table_name from sys.objects c where c.type = 'U' ";
String POSTGRESQL_TABLES_SQL = "select tablename from pg_tables where schemaname='public'";
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/database/util/DbConvertDef.java | Java | apache-2.0 | 2,959 |
package org.springblade.modules.mjkj.common.cgform.model.database.util;
import org.apache.commons.lang.StringUtils;
import java.util.List;
public class StringArrUtil
{
/**
* 字符数组处理:给字符串数组中的字符串加单引号和逗号
*
* @return
*/
public static String a(String[] array) {
final StringBuffer sb = new StringBuffer();
for (final String s : array) {
if (StringUtils.isNotBlank(s)) {
sb.append(",");
sb.append("'");
sb.append(s.trim());
sb.append("'");
}
}
return sb.toString().substring(1);
}
/**
* 首字母小写
*
* @param paramString
* @return
*/
public static String a(String string) {
if (StringUtils.isNotBlank(string)) {
string = string.substring(0, 1).toLowerCase() + string.substring(1);
}
return string;
}
/**
* 为数值添加默认值
*
* @param paramInteger
* @return
*/
public static Integer a(Integer n) {
if (n == null) {
return 0;
}
return n;
}
public static boolean isInclude(String s, String[] array) {
if (array == null || array.length == 0) {
return false;
}
for (int i = 0; i < array.length; ++i) {
if (array[i].equals(s)) {
return true;
}
}
return false;
}
public static boolean a(String s, List<String> list) {
String[] array = new String[0];
if (list != null) {
array = (String[])list.toArray();
}
if (array == null || array.length == 0) {
return false;
}
for (int i = 0; i < array.length; ++i) {
if (array[i].equals(s)) {
return true;
}
}
return false;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/database/util/StringArrUtil.java | Java | apache-2.0 | 1,912 |
package org.springblade.modules.mjkj.common.cgform.model.email;
import lombok.Data;
import java.util.List;
@Data
public class SendEmailModel {
private String sjr;//接收人
private String nr;//内容
private String yxzt;//主题
private String fsr;//发送人
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/email/SendEmailModel.java | Java | apache-2.0 | 271 |
package org.springblade.modules.mjkj.common.cgform.model.param;
import lombok.Data;
@Data
public class FormDataSaveModel {
String desformCode;
String desformDataJson;
String onlineFormCode;
String onlineFormDataId;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/param/FormDataSaveModel.java | Java | apache-2.0 | 223 |
package org.springblade.modules.mjkj.common.cgform.model.param;
import lombok.Data;
import java.io.Serializable;
@Data
public class InvitationCodeParam implements Serializable {
private Long activity_id;
private Long blade_user_id;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/param/InvitationCodeParam.java | Java | apache-2.0 | 245 |
package org.springblade.modules.mjkj.common.cgform.model.query;
import org.springblade.modules.mjkj.common.config.util.ConvertUtils;
/**
* 查询链接规则
*
* @Author Sunjianlei
*/
public enum MatchTypeEnum {
AND("AND"),
OR("OR");
private String value;
MatchTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static MatchTypeEnum getByValue(Object value) {
if (ConvertUtils.isEmpty(value)) {
return null;
}
return getByValue(value.toString());
}
public static MatchTypeEnum getByValue(String value) {
if (ConvertUtils.isEmpty(value)) {
return null;
}
for (MatchTypeEnum val : values()) {
if (val.getValue().toLowerCase().equals(value.toLowerCase())) {
return val;
}
}
return null;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/query/MatchTypeEnum.java | Java | apache-2.0 | 934 |
package org.springblade.modules.mjkj.common.cgform.model.query;
import java.io.Serializable;
public class QueryCondition implements Serializable {
private static final long serialVersionUID = 4740166316629191651L;
private String field;
private String type;
private String rule;
private String val;
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getRule() {
return rule;
}
public void setRule(String rule) {
this.rule = rule;
}
public String getVal() {
return val;
}
public void setVal(String val) {
this.val = val;
}
@Override
public String toString(){
StringBuffer sb =new StringBuffer();
if(field == null || "".equals(field)){
return "";
}
sb.append(this.field).append(" ").append(this.rule).append(" ").append(this.type).append(" ").append(this.val);
return sb.toString();
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/query/QueryCondition.java | Java | apache-2.0 | 1,011 |
package org.springblade.modules.mjkj.common.cgform.model.query;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springblade.modules.mjkj.common.config.constant.MjkjConstant;
import org.springblade.modules.mjkj.common.config.util.ConvertUtils;
import org.springblade.modules.mjkj.common.config.util.DateUtils;
import org.springblade.modules.mjkj.common.config.util.SqlInjectionUtil;
import org.springblade.modules.mjkj.common.cgform.model.SysPermissionDataRuleModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils;
import org.springblade.core.tool.utils.Func;
import org.springframework.util.NumberUtils;
import java.beans.PropertyDescriptor;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
public class QueryGenerator {
public static final String SQL_RULES_COLUMN = "SQL_RULES_COLUMN";
private static final String BEGIN = "_begin";
private static final String END = "_end";
/**
* 数字类型字段,拼接此后缀 接受多值参数
*/
private static final String MULTI = "_MultiString";
private static final String STAR = "*";
private static final String COMMA = ",";
private static final String NOT_EQUAL = "!";
/**页面带有规则值查询,空格作为分隔符*/
private static final String QUERY_SEPARATE_KEYWORD = " ";
/**高级查询前端传来的参数名*/
private static final String SUPER_QUERY_PARAMS = "superQueryParams";
/** 高级查询前端传来的拼接方式参数名 */
private static final String SUPER_QUERY_MATCH_TYPE = "superQueryMatchType";
/** 单引号 */
public static final String SQL_SQ = "'";
/**排序列*/
private static final String ORDER_COLUMN = "column";
/**排序方式*/
private static final String ORDER_TYPE = "order";
private static final String ORDER_TYPE_ASC = "ASC";
/**
* 获取sql中的#{key} 这个key组成的set
*/
public static Set<String> getSqlRuleParams(String sql) {
if (Func.isEmpty(sql)) {
return null;
}
Set<String> varParams = new HashSet<String>();
String regex = "\\#\\{\\w+\\}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(sql);
while (m.find()) {
String var = m.group();
varParams.add(var.substring(var.indexOf("{") + 1, var.indexOf("}")));
}
return varParams;
}
public static String converRuleValue(String ruleValue) {
String value = null;//todo JwtUtil.getUserSystemData(ruleValue,null);
return value != null ? value : ruleValue;
}
public static String getSqlRuleValue(String sqlRule) {
try {
Set<String> varParams = getSqlRuleParams(sqlRule);
for (String var : varParams) {
String tempValue = converRuleValue(var);
sqlRule = sqlRule.replace("#{" + var + "}", tempValue);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return sqlRule;
}
/**
* 获取查询条件
* @param field
* @param alias
* @param value
* @param isString
* @return
*/
public static String getSingleQueryConditionSql(String field,String alias,Object value,boolean isString) {
if (value == null) {
return "";
}
field = alias+ ConvertUtils.camelToUnderline(field);
QueryRuleEnum rule = QueryGenerator.convert2Rule(value);
return getSingleSqlByRule(rule, field, value, isString);
}
/**
* @author: scott
* @Description: 去掉值前后单引号
* @date: 2020/3/19 21:26
* @param ruleValue:
* @Return: java.lang.String
*/
public static String trimSingleQuote(String ruleValue) {
if (ConvertUtils.isEmpty(ruleValue)) {
return "";
}
if (ruleValue.startsWith(QueryGenerator.SQL_SQ)) {
ruleValue = ruleValue.substring(1);
}
if (ruleValue.endsWith(QueryGenerator.SQL_SQ)) {
ruleValue = ruleValue.substring(0, ruleValue.length() - 1);
}
return ruleValue;
}
/**
* 根据所传的值 转化成对应的比较方式
* 支持><= like in !
* @param value
* @return
*/
private static QueryRuleEnum convert2Rule(Object value) {
// 避免空数据
if (value == null) {
return null;
}
String val = (value + "").toString().trim();
if (val.length() == 0) {
return null;
}
QueryRuleEnum rule =null;
//update-begin--Author:scott Date:20190724 for:initQueryWrapper组装sql查询条件错误 #284-------------------
//TODO 此处规则,只适用于 le lt ge gt
// step 2 .>= =<
if (rule == null && val.length() >= 3) {
if(QUERY_SEPARATE_KEYWORD.equals(val.substring(2, 3))){
rule = QueryRuleEnum.getByValue(val.substring(0, 2));
}
}
// step 1 .> <
if (rule == null && val.length() >= 2) {
if(QUERY_SEPARATE_KEYWORD.equals(val.substring(1, 2))){
rule = QueryRuleEnum.getByValue(val.substring(0, 1));
}
}
//update-end--Author:scott Date:20190724 for:initQueryWrapper组装sql查询条件错误 #284---------------------
// step 3 like
if (rule == null && val.contains(STAR)) {
if (val.startsWith(STAR) && val.endsWith(STAR)) {
rule = QueryRuleEnum.LIKE;
} else if (val.startsWith(STAR)) {
rule = QueryRuleEnum.LEFT_LIKE;
} else if(val.endsWith(STAR)){
rule = QueryRuleEnum.RIGHT_LIKE;
}
}
// step 4 in
if (rule == null && val.contains(COMMA)) {
//TODO in 查询这里应该有个bug 如果一字段本身就是多选 此时用in查询 未必能查询出来
rule = QueryRuleEnum.IN;
}
// step 5 !=
if(rule == null && val.startsWith(NOT_EQUAL)){
rule = QueryRuleEnum.NE;
}
return rule != null ? rule : QueryRuleEnum.EQ;
}
public static String getSingleSqlByRule(QueryRuleEnum rule,String field,Object value,boolean isString) {
if(Func.isEmpty(rule)){
return "";
}
String res = "";
switch (rule) {
case GT:
res =field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case GE:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case LT:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case LE:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case EQ:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case NE:
res = field+" <> "+getFieldConditionValue(value, isString);
break;
case IN:
res = field + " in "+getInConditionValue(value, isString);
break;
case LIKE:
res = field + " like "+getLikeConditionValue(value);
break;
case LEFT_LIKE:
res = field + " like "+getLikeConditionValue(value);
break;
case RIGHT_LIKE:
res = field + " like "+getLikeConditionValue(value);
break;
default:
res = field+" = "+getFieldConditionValue(value, isString);
break;
}
return res;
}
private static String getFieldConditionValue(Object value,boolean isString) {
String str = value.toString().trim();
if(str.startsWith("!")) {
str = str.substring(1);
}else if(str.startsWith(">=")) {
str = str.substring(2);
}else if(str.startsWith("<=")) {
str = str.substring(2);
}else if(str.startsWith(">")) {
str = str.substring(1);
}else if(str.startsWith("<")) {
str = str.substring(1);
}
if(isString) {
if(MjkjConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return " N'"+str+"' ";
}else{
return " '"+str+"' ";
}
}else {
return value.toString();
}
}
private static String getLikeConditionValue(Object value) {
String str = value.toString().trim();
if(str.startsWith("*") && str.endsWith("*")) {
if(MjkjConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N'%"+str.substring(1,str.length()-1)+"%'";
}else{
return "'%"+str.substring(1,str.length()-1)+"%'";
}
}else if(str.startsWith("*")) {
if(MjkjConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N'%"+str.substring(1)+"'";
}else{
return "'%"+str.substring(1)+"'";
}
}else if(str.endsWith("*")) {
if(MjkjConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N'"+str.substring(0,str.length()-1)+"%'";
}else{
return "'"+str.substring(0,str.length()-1)+"%'";
}
}else {
if(str.indexOf("%")>=0) {
if(MjkjConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
if(str.startsWith("'") && str.endsWith("'")){
return "N"+str;
}else{
return "N"+"'"+str+"'";
}
}else{
if(str.startsWith("'") && str.endsWith("'")){
return str;
}else{
return "'"+str+"'";
}
}
}else {
if(MjkjConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N'%"+str+"%'";
}else{
return "'%"+str+"%'";
}
}
}
}
private static String getInConditionValue(Object value,boolean isString) {
if(isString) {
String temp[] = value.toString().split(",");
String res="";
for (String string : temp) {
if(MjkjConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
res+=",N'"+string+"'";
}else{
res+=",'"+string+"'";
}
}
return "("+res.substring(1)+")";
}else {
return "("+value.toString()+")";
}
}
/**
* 获取系统数据库类型
*/
private static String getDbType(){
return "MYSQL";
}
/**
* 获取查询条件构造器QueryWrapper实例 通用查询条件已被封装完成
* @param searchObj 查询实体
* @param parameterMap request.getParameterMap()
* @return QueryWrapper实例
*/
public static <T> QueryWrapper<T> initQueryWrapper(T searchObj, Map<String, String[]> parameterMap){
long start = System.currentTimeMillis();
QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
installMplus(queryWrapper, searchObj, parameterMap);
log.debug("---查询条件构造器初始化完成,耗时:"+(System.currentTimeMillis()-start)+"毫秒----");
return queryWrapper;
}
/**
* 组装Mybatis Plus 查询条件
* <p>使用此方法 需要有如下几点注意:
* <br>1.使用QueryWrapper 而非LambdaQueryWrapper;
* <br>2.实例化QueryWrapper时不可将实体传入参数
* <br>错误示例:如QueryWrapper<MjkjDemo> queryWrapper = new QueryWrapper<MjkjDemo>(mjkjDemo);
* <br>正确示例:QueryWrapper<MjkjDemo> queryWrapper = new QueryWrapper<MjkjDemo>();
* <br>3.也可以不使用这个方法直接调用 {@link #initQueryWrapper}直接获取实例
*/
public static void installMplus(QueryWrapper<?> queryWrapper,Object searchObj,Map<String, String[]> parameterMap) {
/*
* 注意:权限查询由前端配置数据规则 当一个人有多个所属部门时候 可以在规则配置包含条件 orgCode 包含 #{sys_org_code}
但是不支持在自定义SQL中写orgCode in #{sys_org_code}
当一个人只有一个部门 就直接配置等于条件: orgCode 等于 #{sys_org_code} 或者配置自定义SQL: orgCode = '#{sys_org_code}'
*/
//区间条件组装 模糊查询 高级查询组装 简单排序 权限查询
PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(searchObj);
Map<String, SysPermissionDataRuleModel> ruleMap = getRuleMap();
//权限规则自定义SQL表达式
for (String c : ruleMap.keySet()) {
if(Func.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){
queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue())));
}
}
String name, type;
for (int i = 0; i < origDescriptors.length; i++) {
//aliasName = origDescriptors[i].getName(); mybatis 不存在实体属性 不用处理别名的情况
name = origDescriptors[i].getName();
type = origDescriptors[i].getPropertyType().toString();
try {
if (judgedIsUselessField(name)|| !PropertyUtils.isReadable(searchObj, name)) {
continue;
}
Object value = PropertyUtils.getSimpleProperty(searchObj, name);
// update-begin--Author:taoyan Date:20200910 for:issues/1671 如果字段加注解了@TableField(exist = false),不走DB查询-------
//如果字段加注解了@TableField(exist = false),不走DB查询
//TODO 存在缺陷,这个写法 clazz.getDeclaredField(name) 获取不到继承的父实体字段
try {
if (Func.isNotEmpty(value)) {
Field field = searchObj.getClass().getDeclaredField(name);
if (field != null) {
TableField tableField = field.getAnnotation(TableField.class);
if (tableField != null && tableField.exist() == false) {
continue;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// update-end--Author:taoyan Date:20200910 for:issues/1671 如果字段加注解了@TableField(exist = false),不走DB查询 -------
//数据权限查询
if(ruleMap.containsKey(name)) {
addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper);
}
// 添加 判断是否有区间值
String endValue = null,beginValue = null;
if (parameterMap != null && parameterMap.containsKey(name + BEGIN)) {
beginValue = parameterMap.get(name + BEGIN)[0].trim();
addQueryByRule(queryWrapper, name, type, beginValue, QueryRuleEnum.GE);
}
if (parameterMap != null && parameterMap.containsKey(name + END)) {
endValue = parameterMap.get(name + END)[0].trim();
addQueryByRule(queryWrapper, name, type, endValue, QueryRuleEnum.LE);
}
//多值查询
if (parameterMap != null && parameterMap.containsKey(name + MULTI)) {
endValue = parameterMap.get(name + MULTI)[0].trim();
addQueryByRule(queryWrapper, name.replace(MULTI,""), type, endValue, QueryRuleEnum.IN);
}
//判断单值 参数带不同标识字符串 走不同的查询
//TODO 这种前后带逗号的支持分割后模糊查询需要否 使多选字段的查询生效
if (null != value && value.toString().startsWith(COMMA) && value.toString().endsWith(COMMA)) {
String multiLikeval = value.toString().replace(",,", COMMA);
String[] vals = multiLikeval.substring(1, multiLikeval.length()).split(COMMA);
final String field = ConvertUtils.camelToUnderline(name);
if(vals.length>1) {
queryWrapper.and(j -> {
j = j.like(field,vals[0]);
for (int k=1;k<vals.length;k++) {
j = j.or().like(field,vals[k]);
}
//return j;
});
}else {
queryWrapper.and(j -> j.like(field,vals[0]));
}
}else {
//根据参数值带什么关键字符串判断走什么类型的查询
QueryRuleEnum rule = convert2Rule(value);
value = replaceValue(rule,value);
// add -begin 添加判断为字符串时设为全模糊查询
//if( (rule==null || QueryRuleEnum.EQ.equals(rule)) && "class java.lang.String".equals(type)) {
// 可以设置左右模糊或全模糊,因人而异
//rule = QueryRuleEnum.LIKE;
//}
// add -end 添加判断为字符串时设为全模糊查询
addEasyQuery(queryWrapper, name, rule, value);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
// 排序逻辑 处理
doMultiFieldsOrder(queryWrapper, parameterMap);
//高级查询
doSuperQuery(queryWrapper, parameterMap);
}
/**
*
* @param name
* @return
*/
private static boolean judgedIsUselessField(String name) {
return "class".equals(name) || "ids".equals(name)
|| "page".equals(name) || "rows".equals(name)
|| "sort".equals(name) || "order".equals(name);
}
/**
* 获取请求对应的数据权限规则
* @return
*/
public static Map<String, SysPermissionDataRuleModel> getRuleMap() {
Map<String, SysPermissionDataRuleModel> ruleMap = new HashMap<String, SysPermissionDataRuleModel>();
return ruleMap;
}
@SuppressWarnings("unchecked")
private static void addRuleToQueryWrapper(SysPermissionDataRuleModel dataRule, String name, Class propertyType, QueryWrapper<?> queryWrapper) {
QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions());
if(rule.equals(QueryRuleEnum.IN) && ! propertyType.equals(String.class)) {
String[] values = dataRule.getRuleValue().split(",");
Object[] objs = new Object[values.length];
for (int i = 0; i < values.length; i++) {
objs[i] = NumberUtils.parseNumber(values[i], propertyType);
}
addEasyQuery(queryWrapper, name, rule, objs);
}else {
if (propertyType.equals(String.class)) {
addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue()));
}else if (propertyType.equals(Date.class)) {
String dateStr =converRuleValue(dataRule.getRuleValue());
if(dateStr.length()==10){
addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.date_sdf.get()));
}else{
addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.datetimeFormat.get()));
}
}else {
addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType));
}
}
}
/**
* 根据规则走不同的查询
* @param queryWrapper QueryWrapper
* @param name 字段名字
* @param rule 查询规则
* @param value 查询条件值
*/
private static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
if (value == null || rule == null || Func.isEmpty(value)) {
return;
}
name = ConvertUtils.camelToUnderline(name);
log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
switch (rule) {
case GT:
queryWrapper.gt(name, value);
break;
case GE:
queryWrapper.ge(name, value);
break;
case LT:
queryWrapper.lt(name, value);
break;
case LE:
queryWrapper.le(name, value);
break;
case EQ:
queryWrapper.eq(name, value);
break;
case NE:
queryWrapper.ne(name, value);
break;
case IN:
if(value instanceof String) {
queryWrapper.in(name, (Object[])value.toString().split(","));
}else if(value instanceof String[]) {
queryWrapper.in(name, (Object[]) value);
}
//update-begin-author:taoyan date:20200909 for:【bug】in 类型多值查询 不适配postgresql #1671
else if(value.getClass().isArray()) {
queryWrapper.in(name, (Object[])value);
}else {
queryWrapper.in(name, value);
}
//update-end-author:taoyan date:20200909 for:【bug】in 类型多值查询 不适配postgresql #1671
break;
case LIKE:
queryWrapper.like(name, value);
break;
case LEFT_LIKE:
queryWrapper.likeLeft(name, value);
break;
case RIGHT_LIKE:
queryWrapper.likeRight(name, value);
break;
default:
log.info("--查询规则未匹配到---");
break;
}
}
private static void addQueryByRule(QueryWrapper<?> queryWrapper,String name,String type,String value,QueryRuleEnum rule) throws ParseException {
if(Func.isNotEmpty(value)) {
Object temp;
// 针对数字类型字段,多值查询
if(value.indexOf(COMMA)!=-1){
temp = value;
addEasyQuery(queryWrapper, name, rule, temp);
return;
}
switch (type) {
case "class java.lang.Integer":
temp = Integer.parseInt(value);
break;
case "class java.math.BigDecimal":
temp = new BigDecimal(value);
break;
case "class java.lang.Short":
temp = Short.parseShort(value);
break;
case "class java.lang.Long":
temp = Long.parseLong(value);
break;
case "class java.lang.Float":
temp = Float.parseFloat(value);
break;
case "class java.lang.Double":
temp = Double.parseDouble(value);
break;
case "class java.util.Date":
temp = getDateQueryByRule(value, rule);
break;
default:
temp = value;
break;
}
addEasyQuery(queryWrapper, name, rule, temp);
}
}
/**
* 获取日期类型的值
* @param value
* @param rule
* @return
* @throws ParseException
*/
private static Date getDateQueryByRule(String value,QueryRuleEnum rule) throws ParseException {
Date date = null;
if(value.length()==10) {
if(rule==QueryRuleEnum.GE) {
//比较大于
date = getTime().parse(value + " 00:00:00");
}else if(rule==QueryRuleEnum.LE) {
//比较小于
date = getTime().parse(value + " 23:59:59");
}
//TODO 日期类型比较特殊 可能oracle下不一定好使
}
if(date==null) {
date = getTime().parse(value);
}
return date;
}
private static final ThreadLocal<SimpleDateFormat> local = new ThreadLocal<SimpleDateFormat>();
private static SimpleDateFormat getTime(){
SimpleDateFormat time = local.get();
if(time == null){
time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
local.set(time);
}
return time;
}
/**
* 替换掉关键字字符
*
* @param rule
* @param value
* @return
*/
private static Object replaceValue(QueryRuleEnum rule, Object value) {
if (rule == null) {
return null;
}
if (! (value instanceof String)){
return value;
}
String val = (value + "").toString().trim();
if (rule == QueryRuleEnum.LIKE) {
value = val.substring(1, val.length() - 1);
} else if (rule == QueryRuleEnum.LEFT_LIKE || rule == QueryRuleEnum.NE) {
value = val.substring(1);
} else if (rule == QueryRuleEnum.RIGHT_LIKE) {
value = val.substring(0, val.length() - 1);
} else if (rule == QueryRuleEnum.IN) {
value = val.split(",");
} else {
//update-begin--Author:scott Date:20190724 for:initQueryWrapper组装sql查询条件错误 #284-------------------
if(val.startsWith(rule.getValue())){
//TODO 此处逻辑应该注释掉-> 如果查询内容中带有查询匹配规则符号,就会被截取的(比如:>=您好)
value = val.replaceFirst(rule.getValue(),"");
}else if(val.startsWith(rule.getCondition()+QUERY_SEPARATE_KEYWORD)){
value = val.replaceFirst(rule.getCondition()+QUERY_SEPARATE_KEYWORD,"").trim();
}
//update-end--Author:scott Date:20190724 for:initQueryWrapper组装sql查询条件错误 #284-------------------
}
return value;
}
//多字段排序 TODO 需要修改前端
public static void doMultiFieldsOrder(QueryWrapper<?> queryWrapper,Map<String, String[]> parameterMap) {
String column=null,order=null;
if(parameterMap!=null&& parameterMap.containsKey(ORDER_COLUMN)) {
column = parameterMap.get(ORDER_COLUMN)[0];
}
if(parameterMap!=null&& parameterMap.containsKey(ORDER_TYPE)) {
order = parameterMap.get(ORDER_TYPE)[0];
}
log.debug("排序规则>>列:"+column+",排序方式:"+order);
if (ConvertUtils.isNotEmpty(column) && ConvertUtils.isNotEmpty(order)) {
//字典字段,去掉字典翻译文本后缀
if(column.endsWith(MjkjConstant.DICT_TEXT_SUFFIX)) {
column = column.substring(0, column.lastIndexOf(MjkjConstant.DICT_TEXT_SUFFIX));
}
//SQL注入check
SqlInjectionUtil.filterContent(column);
if (order.toUpperCase().indexOf(ORDER_TYPE_ASC)>=0) {
queryWrapper.orderByAsc(ConvertUtils.camelToUnderline(column));
} else {
queryWrapper.orderByDesc(ConvertUtils.camelToUnderline(column));
}
}
}
/**
* 高级查询
* @param queryWrapper
* @param parameterMap
*/
public static void doSuperQuery(QueryWrapper<?> queryWrapper,Map<String, String[]> parameterMap) {
if(parameterMap!=null&& parameterMap.containsKey(SUPER_QUERY_PARAMS)){
String superQueryParams = parameterMap.get(SUPER_QUERY_PARAMS)[0];
String superQueryMatchType = parameterMap.get(SUPER_QUERY_MATCH_TYPE) != null ? parameterMap.get(SUPER_QUERY_MATCH_TYPE)[0] : MatchTypeEnum.AND.getValue();
MatchTypeEnum matchType = MatchTypeEnum.getByValue(superQueryMatchType);
// update-begin--Author:sunjianlei Date:20200325 for:高级查询的条件要用括号括起来,防止和用户的其他条件冲突 -------
try {
superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
List<QueryCondition> conditions = JSON.parseArray(superQueryParams, QueryCondition.class);
if (conditions == null || conditions.size() == 0) {
return;
}
log.info("---高级查询参数-->" + conditions.toString());
queryWrapper.and(andWrapper -> {
for (int i = 0; i < conditions.size(); i++) {
QueryCondition rule = conditions.get(i);
if (Func.isNotEmpty(rule.getField())
&& Func.isNotEmpty(rule.getRule())
&& Func.isNotEmpty(rule.getVal())) {
log.debug("SuperQuery ==> " + rule.toString());
addEasyQuery(andWrapper, rule.getField(), QueryRuleEnum.getByValue(rule.getRule()), rule.getVal());
// 如果拼接方式是OR,就拼接OR
if (MatchTypeEnum.OR == matchType && i < (conditions.size() - 1)) {
andWrapper.or();
}
}
}
//return andWrapper;
});
} catch (UnsupportedEncodingException e) {
log.error("--高级查询参数转码失败:" + superQueryParams, e);
} catch (Exception e) {
log.error("--高级查询拼接失败:" + e.getMessage());
e.printStackTrace();
}
// update-end--Author:sunjianlei Date:20200325 for:高级查询的条件要用括号括起来,防止和用户的其他条件冲突 -------
}
//log.info(" superQuery getCustomSqlSegment: "+ queryWrapper.getCustomSqlSegment());
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/query/QueryGenerator.java | Java | apache-2.0 | 30,965 |
package org.springblade.modules.mjkj.common.cgform.model.query;
import org.springblade.modules.mjkj.common.config.util.ConvertUtils;
/**
* Query 规则 常量
* @Author Scott
* @Date 2019年02月14日
*/
public enum QueryRuleEnum {
GT(">","gt","大于"),
GE(">=","ge","大于等于"),
LT("<","lt","小于"),
LE("<=","le","小于等于"),
EQ("=","eq","等于"),
NE("!=","ne","不等于"),
IN("IN","in","包含"),
LIKE("LIKE","like","全模糊"),
LEFT_LIKE("LEFT_LIKE","left_like","左模糊"),
RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"),
SQL_RULES("USE_SQL_RULES","ext","自定义SQL片段");
private String value;
private String condition;
private String msg;
QueryRuleEnum(String value, String condition, String msg){
this.value = value;
this.condition = condition;
this.msg = msg;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
public static QueryRuleEnum getByValue(String value){
if(ConvertUtils.isEmpty(value)) {
return null;
}
for(QueryRuleEnum val :values()){
if (val.getValue().equals(value) || val.getCondition().equals(value)){
return val;
}
}
return null;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/model/query/QueryRuleEnum.java | Java | apache-2.0 | 1,618 |
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.SqlMapper;
import org.springblade.modules.mjkj.common.cgform.model.CgformEnhanceJavaBatchInter;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.List;
import java.util.Map;
public interface IAsyncPoolService {
//批量执行
void executeBatchSql(List<Map<String, Object>> dataList, CgformHead head, List<CgformField> fieldList, SqlMapper sqlMapper, String batchCode, Integer totalNum, Map<String, Object> otherMap, CgformEnhanceJavaBatchInter enhanceJava, ServletRequestAttributes sra) throws BusinessException;
/**
* 入库
* @param dataList
* @param batchCode
* @param tableName
*/
void addImportData(List<Map<String, Object>> dataList, String batchCode, String tableName, String key, Map<String,Object> params, ServletRequestAttributes sra);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/IAsyncPoolService.java | Java | apache-2.0 | 1,142 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.Category;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 分类字典 服务类
*
* @author BladeX
* @since 2021-05-27
*/
public interface ICategoryService extends BaseService<Category> {
void addSysCategory(Category category);
void updateSysCategory(Category category);
void batchDelete(List<Long> idList);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICategoryService.java | Java | apache-2.0 | 1,311 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.CgformButton;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 自定义表单 服务类
*
* @author BladeX
* @since 2021-05-22
*/
public interface ICgformButtonService extends BaseService<CgformButton> {
List<CgformButton> queryButtonList(Long headId, boolean isListButton);
List<CgformButton> queryButtonList(Long headId);
void executeCustomerButton(String buttonCode, Long headId, Long dataId) throws Exception;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformButtonService.java | Java | apache-2.0 | 1,420 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJava;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
import java.util.Map;
/**
* java增强 服务类
*
* @author BladeX
* @since 2021-05-22
*/
public interface ICgformEnhanceJavaService extends BaseService<CgformEnhanceJava> {
/**
* 校验
* @param onlcgformenhancejava
* @return
*/
boolean checkOnlyEnhance(CgformEnhanceJava onlcgformenhancejava);
CgformEnhanceJava getExecuteEnhanceJavaBatch(String buttonCode, String eventType, CgformHead onlcgformhead)
throws BusinessException;
/**
* 执行java增强对象
* @param buttonCode
* @param eventType
* @param onlcgformhead
* @param jsonobject
* @return
* @throws BusinessException
*/
int executeEnhanceJava(String buttonCode, String eventType, CgformHead onlcgformhead, JSONObject jsonobject)
throws BusinessException;
/**
* 执行java增强列表
* @param onlcgformhead
* @param buttonCode
* @param list
* @throws BusinessException
*/
void executeEnhanceList(CgformHead onlcgformhead, String buttonCode, List<Map<String, Object>> list, Map<String, Object> params)
throws BusinessException;
/**
* 执行java增强详情
* @param onlcgformhead
* @param buttonCode
* @param
* @throws BusinessException
*/
Map<String,Object> executeEnhanceDetail(CgformHead onlcgformhead, String buttonCode, Map<String, Object> data, Map<String, Object> params)
throws BusinessException;
Object getEnhanceJavaObj(CgformEnhanceJava enhanceJava);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformEnhanceJavaService.java | Java | apache-2.0 | 2,636 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJs;
import org.springblade.core.mp.base.BaseService;
/**
* js增强 服务类
*
* @author BladeX
* @since 2021-05-22
*/
public interface ICgformEnhanceJsService extends BaseService<CgformEnhanceJs> {
//获取js增强
CgformEnhanceJs queryEnhanceJs(Long headId, String cgJsType);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformEnhanceJsService.java | Java | apache-2.0 | 1,257 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceSql;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.SqlMapper;
import org.springblade.modules.mjkj.common.cgform.model.CgformEnhanceJavaBatchInter;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.core.mp.base.BaseService;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.List;
import java.util.Map;
/**
* sql增强 服务类
*
* @author BladeX
* @since 2021-05-22
*/
public interface ICgformEnhanceSqlService extends BaseService<CgformEnhanceSql> {
/**
* 执行sql增强
* @param buttonCode
* @param headId
* @param json
*/
void executeEnhanceSqlUpdate(String buttonCode, Long headId, JSONObject json);
void executeEnhanceSqlInsert(String buttonCode, Long headId, JSONObject json);
//sql增强详情
Map<String, Object> executeEnhanceSqlDetail(CgformHead head,String buttonCode, Map<String, Object> map, String id);
//sql增强 列表
void executeEnhanceSqlList(CgformHead head, String buttonCode, Map<String, Object> params);
void saveBatchOnlineTable(CgformHead onlcgformhead, List<CgformField> fieldList, List<Map<String, Object>> dataList);
void saveBatchCodeOnlineTable(CgformHead onlcgformhead, List<CgformField> fieldList, List<Map<String, Object>> dataList,String batchCode);
void saveBatchCodeOnlineTable(CgformHead onlcgformhead, List<CgformField> fieldList, List<Map<String, Object>> dataList, String batchCode, Integer totalNum, SqlMapper sqlMapper, Map<String, Object> otherMap, CgformEnhanceJavaBatchInter enhanceJava, ServletRequestAttributes sra) throws BusinessException;
void excutBacthData(CgformHead onlcgformhead, List<CgformField> fieldList, List<Map<String, Object>> dataList, String batchCode, ServletRequestAttributes sra) throws BusinessException;
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformEnhanceSqlService.java | Java | apache-2.0 | 2,982 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.model.CommonEntity;
import org.springblade.modules.mjkj.common.cgform.model.TreeModel;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
import java.util.Map;
/**
* 服务类
*
* @author BladeX
* @since 2021-05-20
*/
public interface ICgformFieldService extends BaseService<CgformField> {
//执行ddl
void executeInsertSQL(Map<String, Object> map);
/**
* 获取可用的字段
* @param headId
* @param tableName
* @param taskId
* @param isList
* @return
*/
public List<CgformField> queryAvailableFields(Long headId, String tableName, String taskId, boolean isList);
/**
* 查询可用字段
* @param tableName
* @param isList
* @param onlCgformFieldList
* @param needList
* @return
*/
public List<CgformField> queryAvailableFields(String tableName, boolean isList, List<CgformField> onlCgformFieldList, List<String> needList);
//获取查询条件
public List<Map<String, String>> getAutoListQueryInfo(Long headId);
List<CgformField> getByHeadId(Long headId);
/**
* 保存树形
* @param headId
* @param tableName
* @param json
* @param hasChildField
* @param pidField
*/
public String saveTreeFormData(Long headId, String tableName, JSONObject json, String hasChildField, String pidField);
/**
* 编辑树形
* @param headId
* @param tableName
* @param json
* @param hasChildField
* @param pidField
*/
public void editTreeFormData(Long headId, String tableName, JSONObject json, String hasChildField, String pidField);
/**
* 保存表单的数据
* @param headId
* @param tableName
* @param json
* @param isCrazy
*/
public String saveFormData(Long headId, String tableName, JSONObject json, boolean isCrazy);
/**
* 保存表单的数据
* @param fieldList
* @param tableName
* @param json
*/
public void saveFormDataList(List<CgformField> fieldList, String tableName, JSONObject json);
/**
* 编辑表单的数据
* @param headId
* @param tableName
* @param json
* @param isCrazy
*/
public void editFormData(Long headId, String tableName, JSONObject json, boolean isCrazy);
/**
* 查询表单的数据
* @param tableName 表名
* @param headId 表id
* @param params 查询条件
* @param needList
* @return
*/
Map<String, Object> queryAutolistPage(String tableName, Long headId, Map<String, Object> params, List<String> needList);
Map<String, Object> queryAutoTreeNoPage(String tbname, Long headId, Map<String, Object> params, List<String> needList, String pidField);
/**
* 通过表名获取字段
* @param tableName
* @return
*/
public List<CgformField> queryFormFieldsByTableName(String tableName);
/**
* 获取表单的字段
* @param code
* @param isForm
* @return
*/
public List<CgformField> queryFormFields(Long headId, boolean isForm);
/**
* 获取表单的数据
* @param fieldList
* @param tableName
* @param id
* @return
*/
public Map<String, Object> queryFormData(List<CgformField> fieldList, String tableName, String id);
/**
* 获取表单的数据-所有数据
* @param fieldList
* @param tableName
* @return
*/
public List<Map<String, Object>> queryFormAllData(List<CgformField> fieldList, String tableName);
/**
* 获取表单的数据
* @param fieldList
* @param tableName
* @param linkField
* @param value
* @return
*/
public List<Map<String, Object>> querySubFormData(List<CgformField> fieldList, String tableName, String linkField, String value);
public String queryTreeChildIds(CgformHead onlcgformhead, String dataIdStrs);
/**
* 删除表单
* @param tableName
* @param ids
*/
public void deleteAutoListById(String tableName, String ids);
/**
* 删除表单
* @param head
* @param ids
*/
public void deleteAutoListMainAndSub(CgformHead head, String ids);
/**
* 更新无孩子节点
* @param tableName
* @param filed
* @param id
*/
public void updateTreeNodeNoChild(String tableName, String filed, String id);
/**
* 通过linkDown获取树形数据
* @param entity
* @return
*/
public List<TreeModel> queryDataListByLinkDown(CommonEntity entity);
/**
* 删除表单
* @param tableName
* @param linkField
* @param linkValue
*/
public void deleteAutoList(String tableName, String linkField, String linkValue);
public void deleteList(String tableName, String linkField, String linkValue);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformFieldService.java | Java | apache-2.0 | 5,970 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.modules.mjkj.common.config.exception.DBException;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.model.CgformModel;
import org.springblade.modules.mjkj.common.cgform.model.OnlGenerateModel;
import org.springblade.modules.mjkj.common.cgform.model.TreeDataModel;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
import java.util.Map;
/**
* 服务类
*
* @author BladeX
* @since 2021-05-20
*/
public interface ICgformHeadService extends BaseService<CgformHead> {
//新增表数据
String saveManyFormData(CgformHead head, JSONObject jsonobject)
throws DBException, BusinessException;
//编辑表数据
void editManyFormData(CgformHead head, JSONObject jsonobject)
throws DBException, BusinessException;
//详情
Map<String, Object> queryManyFormData(Long headId, String id)
throws DBException;
//删除
void deleteOneTableInfo(Long headId, String s1)
throws BusinessException;
void initCopyState(List<CgformHead> list);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformHeadService.java | Java | apache-2.0 | 2,154 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.CgformIndex;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 服务类
*
* @author BladeX
* @since 2021-05-20
*/
public interface ICgformIndexService extends BaseService<CgformIndex> {
List<CgformIndex> getCgformIndexsByCgformId(Long cgformId);
//索引是否存在
boolean isExistIndex(String countSql);
//创建索引
void createIndex(Long headId, String databaseType, String tbname);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformIndexService.java | Java | apache-2.0 | 1,399 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.CgformValid;
import org.springblade.core.mp.base.BaseService;
/**
* 自定义表单字段校验规则表 服务类
*
* @author BladeX
* @since 2021-05-20
*/
public interface ICgformValidService extends BaseService<CgformValid> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICgformValidService.java | Java | apache-2.0 | 1,187 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.cgform.entity.CheckRule;
import org.springblade.core.mp.base.BaseService;
/**
* 编码校验规则 服务类
*
* @author BladeX
* @since 2021-07-03
*/
public interface ICheckRuleService extends BaseService<CheckRule> {
/**
* 通过用户设定的自定义校验规则校验传入的值
*
* @param checkRule
* @param value
* @return 返回 null代表通过校验,否则就是返回的错误提示文本
*/
JSONObject checkValue(CheckRule checkRule, String value);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ICheckRuleService.java | Java | apache-2.0 | 1,462 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.DesformData;
import org.springblade.core.mp.base.BaseService;
/**
* 表单设计器-数据 服务类
*
* @author BladeX
* @since 2021-07-02
*/
public interface IDesformDataService extends BaseService<DesformData> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/IDesformDataService.java | Java | apache-2.0 | 1,172 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.DesformHead;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 表单设计器基本属性 服务类
*
* @author BladeX
* @since 2021-07-02
*/
public interface IDesformHeadService extends BaseService<DesformHead> {
List<DesformHead> openList();
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/IDesformHeadService.java | Java | apache-2.0 | 1,236 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.DesformRoute;
import org.springblade.core.mp.base.BaseService;
/**
* 表单设计器-数据 服务类
*
* @author BladeX
* @since 2021-07-02
*/
public interface IDesformRouteService extends BaseService<DesformRoute> {
void formRouteEdit(DesformRoute route);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/IDesformRouteService.java | Java | apache-2.0 | 1,219 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.FillRule;
import org.springblade.core.mp.base.BaseService;
/**
* 填值规则 服务类
*
* @author BladeX
* @since 2021-07-03
*/
public interface IFillRuleService extends BaseService<FillRule> {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/IFillRuleService.java | Java | apache-2.0 | 1,153 |
package org.springblade.modules.mjkj.common.cgform.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.mjkj.common.cgform.model.KvModel;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.WebUtil;
import java.util.List;
import java.util.Map;
/**
* 魔晶公共定制
*/
public interface IMjkjBaseSqlService {
/*
* customFieldList 为自定义列
*
* */
//获取某个表的所有数据
List<Map<String, Object>> getDataByTable(String tableName);
List<Map<String, Object>> getDataByTable(String tableName,List<String> customFieldList);
List<Map<String, Object>> getDataByTableRedis(String tableName,Long time);//走缓存,秒
//根据id获取某一个表的一条数据
Map<String, Object> getTableById(String tableName, String id);
Map<String, Object> getTableByIdL(String tableName, Long id);
Map<String, Object> getTableById(String tableName, String id,List<String> customFieldList);//自定义列
Map<String, Object> getTableByIdRedis(String tableName, String id,Long time);//走缓存,秒
//根据id获取某一个表的数据
List<Map<String, Object>> getDataListByField(String tableName, String whereFieldName, Object whereFieldValue);
List<Map<String, Object>> getDataListByField(String tableName, String whereFieldName, Object whereFieldValue,List<String> customFieldList);
//根据id获取某一个表的数据 排序
List<Map<String, Object>> getDataListByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue,String orderByField,String orderStr);
List<Map<String, Object>> getDataListByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue,String orderByField,String orderStr,List<String> customFieldList);
//获取一条数据
Map<String, Object> getDataOneByField(String tableName, String whereFieldName, Object whereFieldValue);
Map<String, Object> getDataOneByField(String tableName, String whereFieldName, Object whereFieldValue,List<String> customFieldList);
Map<String, Object> getDataOneByFieldRedis(String tableName, String whereFieldName, Object whereFieldValue,Long time);
//获取一条数据 排序
Map<String, Object> getDataOneByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue,String orderByField,String orderStr);
Map<String, Object> getDataOneByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue,String orderByField,String orderStr,List<String> customFieldList);
//根据id获取某一个表的数据 type=A:全部 L:左边模糊 R右模糊
List<Map<String, Object>> getDataListByLike(String tableName, String whereFieldName, Object whereFieldValue,String type);
List<Map<String, Object>> getDataListByLike(String tableName, String whereFieldName, Object whereFieldValue,String type,List<String> customFieldList);
//根据id获取某一个表的数据
List<Map<String, Object>> getDataListByIn(String tableName, String whereFieldName, List<Object> whereFieldValue);
List<Map<String, Object>> getDataListByIn(String tableName, String whereFieldName, List<Object> whereFieldValue,List<String> customFieldList);
//获取数据字典 是否开启缓存 true=开启缓存 false = 不开启缓存
List<KvModel> getSysDictItemList(String dictCode,Boolean redisFlag);
//获取数字字段值
String getSysDictItemValue(String dictCode,String itemValue,Boolean redisFlag);
String getSysDictItemValueByText(String dictCode,String itemText,Boolean redisFlag);
//将表数据封装为map
Map<String,Map<String,Object>> getData2Map(String tableName,String key,Boolean redisFlag);
//------------------查询封装已完成---------------------------
//单个新增
Long baseInsertData(String tableName, Map<String, Object> dataMap);
//不对操作人进行封装
Long baseSimpleIntegerSql(String tableName, Map<String, Object> dataMap);
//单个修改
void baseUpdateData(String tableName,Map<String, Object> map,String id);
void baseUpdateDataLong(String tableName,Map<String, Object> map,Long id);
void baseUpdateDataWhere(String tableName,Map<String, Object> map,String whereCol, String whereVal);
void baseUpdateDataTenantIgnore(String tableName,Map<String, Object> map,String id);
//公共删除-逻辑
Integer baseDeleteSqlStr(String tableName, String id);
Integer baseDeleteSql(String tableName, Long id);
//真实删除
Integer baseRealDeleteSql(String tableName, Long id);
// 自定义公共删除-逻辑
Integer baseZdyDeleteSql(String tableName, String whereFieldName, Long id);
// 自定义公共删除-逻辑
Integer baseZdyDeleteSql(String tableName, String whereFieldName, String id);
//--------------其他--------------------
List<Long> getAdminIdList();
//获取处理进度
int getProcessingProgress(String tableName,String batchCode);
//获取总处理进度
int getProcessingProgressTotal(String tableName,String batchCode);
//获取授权
List<Map<String,Object>> getBladeUserOauth(String uuid,String source);
//获取授权
List<Map<String,Object>> getBladeUserOauthByUserId(Long userId);
//解绑
void unBindBladeUserOauth(Long id);
//根据表属性获取所有数据 多条件
<T> List<Map<String, T>> getDataListByFieldParams(String tableName, Wrapper<T> wrapper);
<T> Map<String, T> getDataOneByFieldParams(String tableName, Wrapper<T> wrapper);
//根据表属性获取所有数据 多条件 分页
<T> IPage<Map<String, T>> getDataIPageByFieldParams(String tableName, IPage page, Wrapper<T> wrapper);
//--------------本次定制---------------
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/IMjkjBaseSqlService.java | Java | apache-2.0 | 5,765 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJs;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.model.OnlineConfigModel;
/**
* @author BladeX
* @since 2021-05-22
*/
public interface IOnlineService {
//获取头部信息
OnlineConfigModel queryOnlineConfig(CgformHead head);
//获取字段内容
JSONObject queryOnlineFormObj(CgformHead onlcgformhead, CgformEnhanceJs onlcgformenhancejs);
JSONObject queryOnlineFormObj(CgformHead cgformhead);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/IOnlineService.java | Java | apache-2.0 | 1,499 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.SysDictItem;
import org.springblade.modules.mjkj.common.cgform.model.DictModel;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 数据字典 服务类
*
* @author BladeX
* @since 2021-05-27
*/
public interface ISysDictItemService extends BaseService<SysDictItem> {
List<DictModel> queryDictItemsByCode(String code);
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ISysDictItemService.java | Java | apache-2.0 | 1,308 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service;
import org.springblade.modules.mjkj.common.cgform.entity.SysDict;
import org.springblade.modules.mjkj.common.cgform.model.DictModel;
import org.springblade.modules.mjkj.common.cgform.model.DuplicateCheckVo;
import org.springblade.modules.mjkj.common.cgform.model.TreeSelectModel;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
import java.util.Map;
/**
* 数据字典 服务类
*
* @author BladeX
* @since 2021-05-27
*/
public interface ISysDictService extends BaseService<SysDict> {
/**
* 13获取表数据字典
* @param table
* @param text
* @param code
* @return
*/
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
/**
* 10获取数据字典
* @param code
* @return
*/
public List<DictModel> queryDictItemsByCode(String code);
/**
* 16查询表字典 支持过滤数据
* @param table
* @param text
* @param code
* @param filterSql
* @return
*/
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql);
List<TreeSelectModel> queryTreeList(Map<String, String> query, String table, String text, String code, String pidField, String pid, String hasChildField);
List<String> queryTableDictByKeys(String table, String text, String code, String keys);
Long getIdByCode(String code);
@Deprecated
List<DictModel> queryTableDictItemsByCodeAndFilter(String table, String text, String code, String filterSql);
/**
* 通过关键字查询字典表
* @param table
* @param text
* @param code
* @param keyword
* @return
*/
List<DictModel> queryTableDictItems(String table, String text, String code, String keyword);
Long duplicateCheckCountSql(DuplicateCheckVo duplicateCheckVo);
Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo);
List<Map<String,Object>> getAllTenantList();
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/ISysDictService.java | Java | apache-2.0 | 2,894 |
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.SqlMapper;
import org.springblade.modules.mjkj.common.cgform.model.CgformEnhanceJavaBatchInter;
import org.springblade.modules.mjkj.common.utils.MjkjUtils;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.modules.mjkj.common.config.util.SqlSymbolUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.RedisUtil;
import org.springblade.modules.mjkj.common.cgform.service.IAsyncPoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
异步调用
*/
@Service
public class AsyncPoolServiceImpl implements IAsyncPoolService {
@Autowired
private RedisUtil redisUtil;
//批量执行
@Override
@Async("asyncPoolTaskExecutor")
public void executeBatchSql(List<Map<String, Object>> dataList, CgformHead head, List<CgformField> fieldList, SqlMapper sqlMapper, String batchCode, Integer totalNum, Map<String, Object> otherMap, CgformEnhanceJavaBatchInter enhanceJava,ServletRequestAttributes sra) throws BusinessException {
RequestContextHolder.setRequestAttributes(sra, true);
//走增强
List<JSONObject> insertDataList = new ArrayList<>();
for (Map<String, Object> dataMap : dataList) {
String jsonStr = JSON.toJSONString(dataMap);
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
Integer result=0;
if(Func.isNotEmpty(enhanceJava)){
result = enhanceJava.execute(head, jsonObject, otherMap);
if(Func.isNotEmpty(result) && result==-1){
jsonObject.put("is_deleted",-1);
}
}
jsonObject.put("id", IdWorker.getId());
jsonObject.put("batch_code", batchCode);
jsonObject.put("total_num", totalNum);
insertDataList.add(jsonObject);
}
String tableName = head.getTableName();
Map<String, Object> batchSqlMap = SqlSymbolUtil.getInsertBatchSql(tableName, fieldList, insertDataList);
String ddl = MjkjUtils.getMap2Str(batchSqlMap, "ddl");
List<Map<String, Object>> insertList = (List<Map<String, Object>>) batchSqlMap.get("dataList");
sqlMapper.executeInsertBatchSQL(ddl, insertList);
String redisKey = "table_" + tableName + "_code_" + batchCode + ":" + IdWorker.getId();
String redisValue = insertDataList.size() + "_" + totalNum;
redisUtil.set(redisKey, redisValue, 3600*24L, TimeUnit.SECONDS);
}
/**
* 入库
*
* @param dataList
* @param batchCode
* @param tableName
*/
@Async("asyncPoolTaskExecutor")
public void addImportData(List<Map<String, Object>> dataList, String batchCode, String tableName, String redisKey, Map<String, Object> params, ServletRequestAttributes sra) {
RequestContextHolder.setRequestAttributes(sra, true);
try {
} catch (Exception e) {
e.printStackTrace();
}
}
//写redis
private void saveRedis(String tableName, String batchCode, String key, Integer val) {
String redisKey = "importData:" + tableName + ":" + batchCode + ":" + key + ":" + IdWorker.getId();
redisUtil.set(redisKey, val, 3600 * 24L,TimeUnit.SECONDS);
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/AsyncPoolServiceImpl.java | Java | apache-2.0 | 3,719 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import org.springblade.modules.mjkj.common.cgform.entity.Category;
import org.springblade.modules.mjkj.common.cgform.mapper.CategoryMapper;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.mjkj.common.cgform.service.ICategoryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 分类字典 服务实现类
*
* @author BladeX
* @since 2021-05-27
*/
@Service
public class CategoryServiceImpl extends BaseServiceImpl<CategoryMapper, Category> implements ICategoryService {
@Transactional(rollbackFor = Exception.class)
public void addSysCategory(Category category){
if(Func.isNotEmpty(category.getPid())){//有子集
Long pid = category.getPid();
if(pid!=0){
Category parent = baseMapper.selectById(pid);
if(!Func.equals(parent.getHasChild(),"0")){
parent.setHasChild("0");
baseMapper.updateById(parent);
}
if(Func.isEmpty(parent.getPstr())){
String pstr=parent.getId()+"#";
category.setPstr(pstr);
}else{
String pstr=parent.getPstr() + parent.getId()+"#";
category.setPstr(pstr);
}
}
}
this.save(category);
}
public void updateSysCategory(Category category){
Category old = baseMapper.selectById(category.getId());
if(Func.isNotEmpty(category.getPid())){
Long pid = category.getPid();
if(pid!=0){
Category parent = baseMapper.selectById(pid);
if(!Func.equals(parent.getHasChild(),"0")){
parent.setHasChild("0");
baseMapper.updateById(parent);
}
}
}
//设置自己
/* String pstr = category.getPstr();
pstr = pstr.replace(old.getPid()+"",category.getPid()+"");
category.setPstr(pstr);*/
this.updateById(category);
/* //获取下面所有子集
List<Category> allSubList = baseMapper.getAllSubList(category.getId());
if(Func.isNotEmpty(allSubList)){
for (Category sub:allSubList) {
pstr = sub.getPstr();
pstr = pstr.replace(old.getPid()+"",category.getPid()+"");
sub.setPstr(pstr);
baseMapper.updateById(sub);
}
}*/
}
@Transactional(rollbackFor = Exception.class)
@Override
public void batchDelete(List<Long> idList){
if(Func.isEmpty(idList)){
return;
}
for (Long id:idList) {
Category category = baseMapper.selectById(id);
Long pid = category.getPid();
List<Category> allSubList = baseMapper.getAllSubList(id);
if(Func.isNotEmpty(allSubList)){
for (Category sub:allSubList) {
baseMapper.deleteById(sub.getId());
}
}
baseMapper.deleteById(id);
//获取他的父级
if(Func.isNotEmpty(pid)){
allSubList = baseMapper.getAllSubList(pid);
if(Func.isEmpty(allSubList)){
Category parent = baseMapper.selectById(pid);
if(Func.isNotEmpty(parent)){
parent.setHasChild("1");
baseMapper.updateById(parent);
}
}
}
}
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CategoryServiceImpl.java | Java | apache-2.0 | 4,581 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springblade.modules.mjkj.common.config.util.SqlSymbolUtil;
import org.springblade.modules.mjkj.common.cgform.entity.CgformButton;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformButtonMapper;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformFieldMapper;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformHeadMapper;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.mjkj.common.cgform.service.ICgformButtonService;
import org.springblade.modules.mjkj.common.cgform.service.ICgformEnhanceJavaService;
import org.springblade.modules.mjkj.common.cgform.service.ICgformEnhanceSqlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 自定义表单 服务实现类
*
* @author BladeX
* @since 2021-05-22
*/
@Service
public class CgformButtonServiceImpl extends BaseServiceImpl<CgformButtonMapper, CgformButton> implements ICgformButtonService {
@Autowired
private CgformHeadMapper headMapperMapper;
@Autowired
private CgformFieldMapper fieldMapper;
@Autowired
private ICgformEnhanceSqlService sqlService;
@Autowired
private ICgformEnhanceJavaService javaService;
public List<CgformButton> queryButtonList(Long headId, boolean isListButton) {
LambdaQueryWrapper<CgformButton> qw = new LambdaQueryWrapper<>();
qw.eq(CgformButton::getButtonStatus, "1");
qw.eq(CgformButton::getCgformHeadId, headId);
if (isListButton) {
qw.in(CgformButton::getButtonStyle, new Object[]{"link", "button"});
} else {
qw.eq(CgformButton::getButtonStyle, "form");
}
qw.orderByAsc(CgformButton::getOrderNum);
return baseMapper.selectList(qw);
}
public List<CgformButton> queryButtonList(Long headId) {
LambdaQueryWrapper<CgformButton> qw = new LambdaQueryWrapper<>();
qw.eq(CgformButton::getButtonStatus, "1");
qw.eq(CgformButton::getCgformHeadId, headId);
qw.orderByAsc(CgformButton::getOrderNum);
return baseMapper.selectList(qw);
}
public void executeCustomerButton(String buttonCode,Long headId,Long dataId) throws Exception{
CgformHead head = headMapperMapper.selectById(headId);
if (head == null) {
throw new Exception("未找到表配置信息");
} else {
Map<String, Object> map = fieldMapper.queryOneByTableNameAndId(SqlSymbolUtil.getSubstring(head.getTableName()), dataId);
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(map));
javaService.executeEnhanceJava(buttonCode, "start", head, jsonObject);
sqlService.executeEnhanceSqlUpdate(buttonCode, headId, jsonObject);
javaService.executeEnhanceJava(buttonCode, "end", head, jsonObject);
}
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformButtonServiceImpl.java | Java | apache-2.0 | 4,062 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.modules.mjkj.common.config.util.ConvertUtils;
import org.springblade.modules.mjkj.common.config.util.MyClassLoader;
import org.springblade.modules.mjkj.common.config.util.SpringContextUtils;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJava;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformEnhanceJavaMapper;
import org.springblade.modules.mjkj.common.cgform.model.CgformEnhanceJavaInter;
import org.springblade.modules.mjkj.common.cgform.model.CgformEnhanceJavaListInter;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.mjkj.common.cgform.service.ICgformEnhanceJavaService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* java增强 服务实现类
*
* @author BladeX
* @since 2021-05-22
*/
@Service
public class CgformEnhanceJavaServiceImpl extends BaseServiceImpl<CgformEnhanceJavaMapper, CgformEnhanceJava> implements ICgformEnhanceJavaService {
@Override
public boolean checkOnlyEnhance(CgformEnhanceJava onlcgformenhancejava) {
LambdaQueryWrapper<CgformEnhanceJava> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceJava::getButtonCode, onlcgformenhancejava.getButtonCode());
wrapper.eq(CgformEnhanceJava::getCgformHeadId, onlcgformenhancejava.getCgformHeadId());
List<CgformEnhanceJava> enhanceJavaList = baseMapper.selectList(wrapper);
if (Func.isEmpty(enhanceJavaList)) {//没有增强
return true;
}
CgformEnhanceJava enhanceJava = enhanceJavaList.get(0);
if (Func.isEmpty(enhanceJava)) {
return true;
}
if (Func.isNotEmpty(enhanceJava) && Func.isEmpty(onlcgformenhancejava.getId())) {
return false;
}
return true;
}
//java增强 ok
@Override
public CgformEnhanceJava getExecuteEnhanceJavaBatch(String buttonCode, String eventType, CgformHead head) throws BusinessException {
LambdaQueryWrapper<CgformEnhanceJava> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceJava::getActiveStatus, "1");
wrapper.eq(CgformEnhanceJava::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceJava::getCgformHeadId, head.getId());
wrapper.eq(CgformEnhanceJava::getEvent, eventType);
List<CgformEnhanceJava> enhanceJavaList = baseMapper.selectList(wrapper);
if (Func.isEmpty(enhanceJavaList)) {//没有增强
return null;
}
CgformEnhanceJava enhanceJava = enhanceJavaList.get(0);
return enhanceJava;
}
//java增强 ok
@Override
public int executeEnhanceJava(String buttonCode, String eventType, CgformHead head, JSONObject json) throws BusinessException {
LambdaQueryWrapper<CgformEnhanceJava> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceJava::getActiveStatus, "1");
wrapper.eq(CgformEnhanceJava::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceJava::getCgformHeadId, head.getId());
wrapper.eq(CgformEnhanceJava::getEvent, eventType);
List<CgformEnhanceJava> enhanceJavaList = baseMapper.selectList(wrapper);
if (Func.isEmpty(enhanceJavaList)) {//没有增强
return 1;
}
CgformEnhanceJava enhanceJava = enhanceJavaList.get(0);
if (Func.isEmpty(enhanceJava)) {
return 1;
}
Object obj = this.getEnhanceJavaObj(enhanceJava);//获取要执行的对象
if (obj != null && obj instanceof CgformEnhanceJavaInter) {//参考
CgformEnhanceJavaInter enhanceJavaInter = (CgformEnhanceJavaInter) obj;
return enhanceJavaInter.execute(head, json);
} else {
return 1;
}
}
//ok
public void executeEnhanceList(CgformHead head, String buttonCode, List<Map<String, Object>> dataList, Map<String, Object> params) throws BusinessException {
LambdaQueryWrapper<CgformEnhanceJava> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceJava::getActiveStatus, "1");
wrapper.eq(CgformEnhanceJava::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceJava::getCgformHeadId, head.getId());
List<CgformEnhanceJava> enhanceJavaList = baseMapper.selectList(wrapper);
if (Func.isEmpty(enhanceJavaList)) {//没有增强
return;
}
CgformEnhanceJava enhanceJava = enhanceJavaList.get(0);
if (Func.isEmpty(enhanceJava)) {
return;
}
Object obj = this.getEnhanceJavaObj(enhanceJava);//获取要执行的对象
if (obj != null && obj instanceof CgformEnhanceJavaListInter) {
CgformEnhanceJavaListInter listInter = (CgformEnhanceJavaListInter) obj;
listInter.execute(head.getTableName(), head.getTenantId(), dataList, params);
}
}
/***
* 详情增强 ok
* @param head
* @param buttonCode
* @param data
* @throws BusinessException
*/
@Override
public Map<String, Object> executeEnhanceDetail(CgformHead head, String buttonCode, Map<String, Object> data, Map<String, Object> params) throws BusinessException {
LambdaQueryWrapper<CgformEnhanceJava> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceJava::getActiveStatus, "1");
wrapper.eq(CgformEnhanceJava::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceJava::getCgformHeadId, head.getId());
List<CgformEnhanceJava> enhanceJavaList = baseMapper.selectList(wrapper);
if (Func.isEmpty(enhanceJavaList)) {//没有增强
return data;
}
CgformEnhanceJava enhanceJava = enhanceJavaList.get(0);
if (Func.isEmpty(enhanceJava)) {
return data;
}
List<Map<String, Object>> dataList = new ArrayList<>();
dataList.add(data);
Object obj = this.getEnhanceJavaObj(enhanceJava);//获取要执行的对象
if (obj != null && obj instanceof CgformEnhanceJavaListInter) {
CgformEnhanceJavaListInter listInter = (CgformEnhanceJavaListInter) obj;
listInter.execute(head.getTableName(), head.getTenantId(), dataList, params);
}
if (Func.isNotEmpty(dataList)) {
return dataList.get(0);
}
return data;
}
/**
* 获取java增强对象
*
* @param enhanceJava
* @return
*/
@Override
public Object getEnhanceJavaObj(CgformEnhanceJava enhanceJava) {
if (Func.isEmpty(enhanceJava)) {
return null;
}
String javaType = enhanceJava.getCgJavaType();//类型
String javaValue = enhanceJava.getCgJavaValue();//内容
if (ConvertUtils.isNotEmpty(javaValue)) {
Object resultObject = null;
if ("class".equals(javaType)) {
try {
resultObject = MyClassLoader.getClassByScn(javaValue).newInstance();
} catch (InstantiationException e) {
log.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
log.error(e.getMessage(), e);
}
} else if ("spring".equals(javaType)) {
resultObject = SpringContextUtils.getBean(javaValue);
}
return resultObject;
}
return null;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformEnhanceJavaServiceImpl.java | Java | apache-2.0 | 7,842 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJs;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformEnhanceJsMapper;
import org.springblade.modules.mjkj.common.cgform.service.ICgformEnhanceJsService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* js增强 服务实现类
*
* @author BladeX
* @since 2021-05-22
*/
@Service
public class CgformEnhanceJsServiceImpl extends BaseServiceImpl<CgformEnhanceJsMapper, CgformEnhanceJs> implements ICgformEnhanceJsService {
@Override
public CgformEnhanceJs queryEnhanceJs(Long headId, String cgJsType) {
LambdaQueryWrapper<CgformEnhanceJs> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceJs::getCgformHeadId, headId);
wrapper.eq(CgformEnhanceJs::getCgJsType, cgJsType);
return baseMapper.selectOne(wrapper);
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformEnhanceJsServiceImpl.java | Java | apache-2.0 | 1,884 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJava;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceSql;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformEnhanceSqlMapper;
import org.springblade.modules.mjkj.common.cgform.mapper.SqlMapper;
import org.springblade.modules.mjkj.common.cgform.model.AccumulatorRecursiveActionParam;
import org.springblade.modules.mjkj.common.cgform.model.CgformEnhanceJavaBatchInter;
import org.springblade.modules.mjkj.common.cgform.model.query.QueryGenerator;
import org.springblade.modules.mjkj.common.cgform.service.IAsyncPoolService;
import org.springblade.modules.mjkj.common.cgform.service.ICgformEnhanceJavaService;
import org.springblade.modules.mjkj.common.cgform.service.ICgformEnhanceSqlService;
import org.springblade.modules.mjkj.common.cgform.service.ICgformFieldService;
import org.springblade.modules.mjkj.common.utils.MjkjUtils;
import org.springblade.modules.mjkj.common.config.constant.MjkjConstant;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.modules.mjkj.common.config.pool.AccumulatorRecursiveAction;
import org.springblade.modules.mjkj.common.config.util.ConvertUtils;
import org.springblade.modules.mjkj.common.config.util.SqlSymbolUtil;
import org.springblade.modules.mjkj.common.config.util.converter.ConverterUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.*;
import java.util.concurrent.ForkJoinPool;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* sql增强 服务实现类
*
* @author BladeX
* @since 2021-05-22
*/
@Service
@Slf4j
public class CgformEnhanceSqlServiceImpl extends BaseServiceImpl<CgformEnhanceSqlMapper, CgformEnhanceSql> implements ICgformEnhanceSqlService {
@Autowired
private SqlSessionTemplate sqlSessionTemplate;
@Autowired
private ICgformEnhanceJavaService javaService;
@Autowired
private SqlMapper sqlMapper;
@Autowired
private IAsyncPoolService asyncPoolService;
@Autowired
private ICgformFieldService cgformFieldService;
/**
* 执行sql增强 ok
*
* @param buttonCode
* @param headId
* @param json
*/
@Override
public void executeEnhanceSqlUpdate(String buttonCode, Long headId, JSONObject json) {
LambdaQueryWrapper<CgformEnhanceSql> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceSql::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceSql::getCgformHeadId, headId);
List<CgformEnhanceSql> cgformEnhanceSqlList = baseMapper.selectList(wrapper);
if(Func.isEmpty(cgformEnhanceSqlList)){
return;
}
CgformEnhanceSql enhanceSql =cgformEnhanceSqlList.get(0);
if (Func.isEmpty(enhanceSql) || Func.isEmpty(enhanceSql.getCgbSql())) {
return;
}
String cgbSql =enhanceSql.getCgbSql();
BladeUser user = AuthUtil.getUser();
if(Func.isNotEmpty(user)){
cgbSql = cgbSql.replace("#{default_update_user}", Func.toStr(user.getUserId()));
}
cgbSql = cgbSql.replace("#{default_update_time}", DateUtil.format(DateUtil.now(),DateUtil.PATTERN_DATETIME));
String enhanceSqlStr = SqlSymbolUtil.enhanceSql(cgbSql, json);
String[] enhanceSqls = enhanceSqlStr.split(";");
for (String ddl : enhanceSqls) {
if(Func.isEmpty(ddl) || ddl.toLowerCase().trim().equals("")){
continue;
}
baseMapper.executeDDL(ddl);
}
}
/**
* 新增 ok
* @param buttonCode
* @param headId
* @param json
*/
@Override
public void executeEnhanceSqlInsert(String buttonCode, Long headId, JSONObject json) {
LambdaQueryWrapper<CgformEnhanceSql> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceSql::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceSql::getCgformHeadId, headId);
List<CgformEnhanceSql> cgformEnhanceSqlList = baseMapper.selectList(wrapper);
if(Func.isEmpty(cgformEnhanceSqlList)){
return;
}
CgformEnhanceSql enhanceSql = cgformEnhanceSqlList.get(0);
if (Func.isEmpty(enhanceSql) || Func.isEmpty(enhanceSql.getCgbSql())) {
return;
}
String cgbSql =enhanceSql.getCgbSql();
cgbSql = cgbSql.replace("#{default_id}", IdWorker.getId()+"");//id 默认值
cgbSql = cgbSql.replace("#{default_pid}",json.getString("id"));
cgbSql = cgbSql.replace("#{default_uuid}",Func.randomUUID());
BladeUser user = AuthUtil.getUser();
if(Func.isNotEmpty(user)){
cgbSql = cgbSql.replace("#{default_tenant_id}", user.getTenantId());
cgbSql = cgbSql.replace("#{default_create_user}", Func.toStr(user.getUserId()));
cgbSql = cgbSql.replace("#{default_update_user}", Func.toStr(user.getUserId()));
String deptIdStr = user.getDeptId();
List<Long> deptIdList = Func.toLongList(deptIdStr);
cgbSql = cgbSql.replace("#{default_create_dept}", Func.toStr(deptIdList.get(0)));//替换值
}
cgbSql = cgbSql.replace("#{default_create_time}", DateUtil.format(DateUtil.now(),DateUtil.PATTERN_DATETIME));
cgbSql = cgbSql.replace("#{default_update_time}", DateUtil.format(DateUtil.now(),DateUtil.PATTERN_DATETIME));
cgbSql = cgbSql.replace("#{status}", "0");//替换值
cgbSql = cgbSql.replace("#{is_deleted}", "0");//替换值
String enhanceSqlStr = SqlSymbolUtil.enhanceSql(cgbSql, json);
String[] enhanceSqls = enhanceSqlStr.split(";");
for (String ddl : enhanceSqls) {
if(Func.isEmpty(ddl) || ddl.toLowerCase().trim().equals("")){
continue;
}
baseMapper.executeDDL(ddl);
}
}
/**
* sql增强详情 #{ID} ok
* @param head
* @param buttonCode
* @param resultMap
* @param id
*/
@Override
public Map<String, Object> executeEnhanceSqlDetail(CgformHead head,String buttonCode, Map<String, Object> resultMap, String id){
LambdaQueryWrapper<CgformEnhanceSql> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceSql::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceSql::getCgformHeadId, head.getId());
List<CgformEnhanceSql> cgformEnhanceSqlList = baseMapper.selectList(wrapper);
if(Func.isEmpty(cgformEnhanceSqlList)){
return resultMap;
}
CgformEnhanceSql enhanceSql = cgformEnhanceSqlList.get(0);
if (Func.isEmpty(enhanceSql) || Func.isEmpty(enhanceSql.getCgbSql())) {
return resultMap;
}
//存在增强
String cgbSql = enhanceSql.getCgbSql();
String enhanceSqlStr = cgbSql.replace("#{id}", "'"+id+"'");//替换值
String[] enhanceSqls = enhanceSqlStr.split(";");
String selectSql = enhanceSqls[0];
List<Map<String, Object>> listData = baseMapper.getListData(selectSql);
if(Func.isNotEmpty(listData)){
resultMap= listData.get(0);
}
return resultMap;
}
//sql增强 列表 ok
@Override
public void executeEnhanceSqlList(CgformHead head, String buttonCode, Map<String, Object> params){
LambdaQueryWrapper<CgformEnhanceSql> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformEnhanceSql::getButtonCode, buttonCode);
wrapper.eq(CgformEnhanceSql::getCgformHeadId, head.getId());
List<CgformEnhanceSql> cgformEnhanceSqlList = baseMapper.selectList(wrapper);
if(Func.isEmpty(cgformEnhanceSqlList)){
return;
}
CgformEnhanceSql enhanceSql = cgformEnhanceSqlList.get(0);
if (Func.isEmpty(enhanceSql) || Func.isEmpty(enhanceSql.getCgbSql())) {
return;
}
LambdaQueryWrapper<CgformField> fieldWrapper = new LambdaQueryWrapper<>();
fieldWrapper.eq(CgformField::getCgformHeadId, head.getId());
fieldWrapper.orderByAsc(CgformField::getOrderNum);
List<CgformField> fieldList = cgformFieldService.list(fieldWrapper);
// 根据数据库类型制造额外SQL
String cgbSql = enhanceSql.getCgbSql();
String sql = SqlSymbolUtil.getEnhanceByDataType(fieldList, params, null);
if(cgbSql.contains("#{online_user_id}")){
cgbSql = cgbSql.replace("#{online_user_id}", "'"+AuthUtil.getUserId()+"'");//id 默认值
}
String executeSql =cgbSql.replaceAll("\\$\\{mjkj_where}",sql);
//分页参数
Page page = MjkjUtils.getPage(params);
params.put("executeSql",executeSql);
Page pages = baseMapper.executeSql(page,executeSql,params);
MjkjUtils.setPageResult(params, pages);
}
@Override
public void saveBatchOnlineTable(CgformHead head, List<CgformField> fieldList, List<Map<String, Object>> dataList) {
SqlSession sqlSession = null;
try {
ConverterUtil.converter(2, dataList, fieldList);
sqlSession = this.sqlSessionTemplate.getSqlSessionFactory().openSession(ExecutorType.BATCH, false);
SqlMapper sqlMapper = (SqlMapper) sqlSession.getMapper(SqlMapper.class);
short len = 1000;
if (len >= dataList.size()) {//小于1000条
for (int i = 0; i < dataList.size(); ++i) {
String jsonStr = JSON.toJSONString(dataList.get(i));
this.executeSql(jsonStr, head, fieldList, sqlMapper);
}
} else {//大于等于1000条
for (int i = 0; i < dataList.size(); ++i) {
String jsonStr = JSON.toJSONString(dataList.get(i));
this.executeSql(jsonStr, head, fieldList, sqlMapper);
if (i % len == 0) {
sqlSession.commit();
sqlSession.clearCache();
}
}
}
sqlSession.commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
sqlSession.close();
}
}
@Override
public void saveBatchCodeOnlineTable(CgformHead head, List<CgformField> fieldList, List<Map<String, Object>> dataList,String batchCode) {
SqlSession sqlSession = null;
try {
ConverterUtil.converter(2, dataList, fieldList);
sqlSession = this.sqlSessionTemplate.getSqlSessionFactory().openSession(ExecutorType.BATCH, false);
SqlMapper sqlMapper = (SqlMapper) sqlSession.getMapper(SqlMapper.class);
short len = 1000;
if (len >= dataList.size()) {//小于1000条
for (int i = 0; i < dataList.size(); ++i) {
String jsonStr = JSON.toJSONString(dataList.get(i));
this.executeBatchSql(jsonStr, head, fieldList, sqlMapper,batchCode);
}
} else {//大于等于1000条
for (int i = 0; i < dataList.size(); ++i) {
String jsonStr = JSON.toJSONString(dataList.get(i));
this.executeBatchSql(jsonStr, head, fieldList, sqlMapper,batchCode);
if (i % len == 0) {
sqlSession.commit();
sqlSession.clearCache();
}
}
}
sqlSession.commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
sqlSession.close();
}
}
@Override
public void saveBatchCodeOnlineTable(CgformHead head, List<CgformField> fieldList, List<Map<String, Object>> dataList, String batchCode, Integer totalNum, SqlMapper sqlMapper, Map<String, Object> otherMap, CgformEnhanceJavaBatchInter enhanceJava, ServletRequestAttributes sra) throws BusinessException {
ConverterUtil.converter(2, dataList, fieldList);
asyncPoolService.executeBatchSql(dataList, head, fieldList, sqlMapper, batchCode, totalNum, otherMap,enhanceJava,sra);
}
@Override
public void excutBacthData(CgformHead head, List<CgformField> fieldList, List<Map<String, Object>> dataList, String batchCode, ServletRequestAttributes sra) throws BusinessException {
CgformEnhanceJava enhanceJava = javaService.getExecuteEnhanceJavaBatch(MjkjConstant.ENHANCE_IMPORT, MjkjConstant.ENHANCE_START, head);//获取sql增强
Object obj = javaService.getEnhanceJavaObj(enhanceJava);//获取要执行的对象
Map<String, Object> otherMap = null;
CgformEnhanceJavaBatchInter enhanceJavaInter=null;
if (obj != null && obj instanceof CgformEnhanceJavaBatchInter) {//参考
enhanceJavaInter = (CgformEnhanceJavaBatchInter) obj;
otherMap = enhanceJavaInter.getOtherParam(batchCode);
}
AccumulatorRecursiveActionParam param=new AccumulatorRecursiveActionParam();
param.setSqlService(this);
param.setHead(head);
param.setCgformFieldList(fieldList);
param.setImportList(dataList);
param.setBatchCode(Func.toStr(batchCode));
param.setSqlMapper(sqlMapper);
param.setOtherMap(otherMap);
param.setJava(enhanceJavaInter);
AccumulatorRecursiveAction action = new AccumulatorRecursiveAction(0, dataList.size(), param,sra);
ForkJoinPool forkJoinPool = new ForkJoinPool();
forkJoinPool.invoke(action);
}
private void executeSql(String jsonStr, CgformHead head, List<CgformField> fieldList, SqlMapper sqlMapper) throws BusinessException {
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
int cou = javaService.executeEnhanceJava(MjkjConstant.ENHANCE_IMPORT, MjkjConstant.ENHANCE_START, head, jsonObject);//获取sql增强
String tableName = head.getTableName();
if(!Func.equals(head.getFormCategory(),"view")) {//不是显示表
if (1 == cou) {
Map<String, Object> map = SqlSymbolUtil.getInsertSql(tableName, fieldList, jsonObject);
sqlMapper.executeInsertSQL(map);
} else if (2 == cou) {
Map<String, Object> map = SqlSymbolUtil.getUpdateSql(tableName, fieldList, jsonObject);
sqlMapper.executeUpdatetSQL(map);
}
}
}
//批量添加
private void executeBatchSql(String jsonStr, CgformHead head, List<CgformField> fieldList, SqlMapper sqlMapper,String batchCode) throws BusinessException {
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
int cou = javaService.executeEnhanceJava(MjkjConstant.ENHANCE_IMPORT, MjkjConstant.ENHANCE_START, head, jsonObject);//获取sql增强
String tableName = head.getTableName();
jsonObject.put("batch_code",batchCode);
if (1 == cou) {
Map<String, Object> map = SqlSymbolUtil.getInsertSql(tableName, fieldList, jsonObject);
sqlMapper.executeInsertSQL(map);
} else if (2 == cou) {
Map<String, Object> map = SqlSymbolUtil.getUpdateSql(tableName, fieldList, jsonObject);
sqlMapper.executeUpdatetSQL(map);
}
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformEnhanceSqlServiceImpl.java | Java | apache-2.0 | 15,404 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformFieldMapper;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformHeadMapper;
import org.springblade.modules.mjkj.common.cgform.mapper.SqlMapper;
import org.springblade.modules.mjkj.common.cgform.model.CommonEntity;
import org.springblade.modules.mjkj.common.cgform.model.TreeModel;
import org.springblade.modules.mjkj.common.cgform.service.ICgformFieldService;
import org.springblade.modules.mjkj.common.utils.MjkjUtils;
import org.springblade.modules.mjkj.common.config.util.ConvertUtils;
import org.springblade.modules.mjkj.common.config.util.SqlSymbolUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* 服务实现类
*
* @author BladeX
* @since 2021-05-20
*/
@Slf4j
@Service
public class CgformFieldServiceImpl extends BaseServiceImpl<CgformFieldMapper, CgformField> implements ICgformFieldService {
@Autowired
private CgformHeadMapper headMapper;
@Autowired
private SqlMapper sqlMapper;
@Autowired
private RedisUtil redisUtil;
public void executeInsertSQL(Map<String, Object> map) {
sqlMapper.executeInsertSQL(map);
}
//todo 流程和权限,有待优化
@Override
public List<CgformField> queryAvailableFields(Long headId, String tbname, String taskId, boolean isList) {
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
if (isList) {
wrapper.eq(CgformField::getIsShowList, 1);
} else {
wrapper.eq(CgformField::getIsShowForm, 1);
}
wrapper.orderByAsc(CgformField::getOrderNum);
List fieldList = this.list(wrapper);
return fieldList;
}
@Override
public List<CgformField> queryAvailableFields(String tbname, boolean isList, List List, List needList) {
List<CgformField> resultList = new ArrayList();
String str = "online:" + tbname + "%";
// LoginUser var7 = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//String var8 = var7.getId();
List hideList = new ArrayList(); //((OnlCgformFieldMapper)this.baseMapper).selectOnlineHideColumns(var8, var6);
boolean flag = true;
if (hideList == null || hideList.size() == 0 || hideList.get(0) == null) {
flag = false;
}
Iterator iterator = List.iterator();
while (iterator.hasNext()) {
CgformField field = (CgformField) iterator.next();
String dbFieldName = field.getDbFieldName();
if (needList != null && needList.contains(dbFieldName)) {
field.setIsQuery(1);
resultList.add(field);
} else {
if (isList) {
if (field.getIsShowList() != 1) {
if (Func.isNotEmpty(field.getMainTable()) && Func.isNotEmpty(field.getMainField())) {
resultList.add(field);
}
continue;
}
} else if (field.getIsShowForm() != 1) {
continue;
}
if (flag) {
/* if (this.b(var13, var9)) {todo
var5.add(var12);
}*/
} else {
resultList.add(field);
}
}
}
return resultList;
}
@Override
public List<Map<String, String>> getAutoListQueryInfo(Long headId) {
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
wrapper.eq(CgformField::getIsQuery, 1);
wrapper.orderByAsc(CgformField::getOrderNum);
List<CgformField> list = this.list(wrapper);
ArrayList resultList = new ArrayList();
int step = 0;
Iterator<CgformField> iterator = list.iterator();
while (iterator.hasNext()) {
HashMap map = new HashMap();
CgformField field = iterator.next();
map.put("label", field.getDbFieldTxt());
map.put("field", field.getDbFieldName());
map.put("mode", field.getQueryMode());
if ("1".equals(field.getQueryConfigFlag())) {
map.put("config", "1");
map.put("view", field.getQueryShowType());
map.put("defValue", field.getQueryDefVal());
if ("cat_tree".equals(field.getFieldShowType())) {
map.put("pcode", field.getQueryDictField());
} else if ("sel_tree".equals(field.getFieldShowType())) {
String[] queryDictTexts = field.getQueryDictText().split(",");
String dict = field.getQueryDictTable() + "," + queryDictTexts[2] + "," + queryDictTexts[0];
map.put("dict", dict);
map.put("pidField", queryDictTexts[1]);
map.put("hasChildField", queryDictTexts[3]);
map.put("pidValue", field.getQueryDictField());
} else {
map.put("dictTable", field.getQueryDictTable());
map.put("dictCode", field.getQueryDictField());
map.put("dictText", field.getQueryDictText());
}
} else {
map.put("view", field.getFieldShowType());
if ("cat_tree".equals(field.getFieldShowType())) {
map.put("pcode", field.getDictField());
} else if ("sel_tree".equals(field.getFieldShowType())) {
String[] queryDictTexts = field.getDictText().split(",");
String dict = field.getDictTable() + "," + queryDictTexts[2] + "," + queryDictTexts[0];
map.put("dict", dict);
map.put("pidField", queryDictTexts[1]);
map.put("hasChildField", queryDictTexts[3]);
map.put("pidValue", field.getDictField());
} else if ("popup".equals(field.getFieldShowType())) {
map.put("dictTable", field.getDictTable());
map.put("dictCode", field.getDictField());
map.put("dictText", field.getDictText());
}
map.put("mode", field.getQueryMode());
}
++step;
if (step > 2) {
map.put("hidden", "1");
}
resultList.add(map);
}
return resultList;
}
public List<CgformField> getByHeadId(Long headId){
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
return this.list(wrapper);
}
/**
* 保存树形结构
*
* @param headId
* @param tbname
* @param json
* @param hasChildField
* @param pidField
*/
@Override
public String saveTreeFormData(Long headId, String tbname, JSONObject json, String hasChildField, String pidField) {
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
List<CgformField> list = this.list(wrapper);
Iterator<CgformField> iterator = list.iterator();
while (iterator.hasNext()) {
CgformField field = iterator.next();
if (hasChildField.equals(field.getDbFieldName()) && field.getIsShowForm() != 1) {
field.setIsShowForm(1);
json.put(hasChildField, "1");
} else if (pidField.equals(field.getDbFieldName()) && Func.isEmpty(json.get(pidField))) {
field.setIsShowForm(1);
json.put(pidField, "0");
}
}
Map map = SqlSymbolUtil.getInsertSql(tbname, list, json);
sqlMapper.executeInsertSQL(map);
if (!"0".equals(json.getString(pidField))) {//树结构
sqlMapper.editFormData("update " + tbname + " set " + hasChildField + " = '0' where id = '" + json.getString(pidField) + "'");
}
return MjkjUtils.getMap2Str(map,"id");
}
/**
* 保存树形数据
*
* @param headId
* @param tbname
* @param json
* @param hasChildField
* @param pidField
*/
@Override
public void editTreeFormData(Long headId, String tbname, JSONObject json, String hasChildField, String pidField) {
String tableName = SqlSymbolUtil.getSubstring(tbname);
String sql = "select * from " + tableName + " where id = '" + json.getString("id") + "'";
Map map = sqlMapper.queryFormData(sql);
Map map2 = SqlSymbolUtil.getValueType(map);
String pidFieldStr = map2.get(pidField).toString();
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
List<CgformField> list = this.list(wrapper);
Iterator<CgformField> iterator = list.iterator();
while (iterator.hasNext()) {
CgformField field = iterator.next();
if (pidField.equals(field.getDbFieldName()) && Func.isEmpty(json.get(pidField))) {
field.setIsShowForm(1);
json.put(pidField, "0");
}
}
Map updateMap = SqlSymbolUtil.getUpdateSql(tbname, list, json);
sqlMapper.executeUpdatetSQL(updateMap);
if (!pidFieldStr.equals(json.getString(pidField))) {
if (!"0".equals(pidFieldStr)) {
String countSql = "select count(*) from " + tableName + " where " + pidField + " = '" + pidFieldStr + "'";
Integer cou = sqlMapper.queryCountBySql(countSql);
if (cou == null || cou == 0) {
sqlMapper.editFormData("update " + tableName + " set " + hasChildField + " = '0' where id = '" + pidFieldStr + "'");
}
}
if (!"0".equals(json.getString(pidField))) {
sqlMapper.editFormData("update " + tableName + " set " + hasChildField + " = '1' where id = '" + json.getString(pidField) + "'");
}
}
}
public String saveFormData(Long headId, String tbname, JSONObject json, boolean isCrazy) {
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
List<CgformField> list = this.list(wrapper);
Map<String, Object> map = SqlSymbolUtil.getInsertSql(tbname, list, json);
sqlMapper.executeInsertSQL(map);
return MjkjUtils.getMap2Str(map,"id");
}
public void saveFormDataList(List<CgformField> fieldList, String tableName, JSONObject json) {
Map map = SqlSymbolUtil.getInsertSql(tableName, fieldList, json);
sqlMapper.executeInsertSQL(map);
}
public void editFormData(Long headId, String tbname, JSONObject json, boolean isCrazy) {
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
List<CgformField> list = this.list(wrapper);
if (isCrazy) {
this.sqlMapper.executeUpdatetSQL(SqlSymbolUtil.getUpdateMap(tbname, list, json));
} else {
this.sqlMapper.executeUpdatetSQL(SqlSymbolUtil.getUpdateSql(tbname, list, json));
}
}
@Override
public Map<String, Object> queryAutolistPage(String tableName, Long headId, Map<String, Object> params, List<String> needList) {
HashMap<String, Object> resultMap = new HashMap<>();
String redisKey="mjkj_sql:tableName_"+tableName+":headId_"+headId+":md5_"+Func.md5Hex(JsonUtil.toJson(params));
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformField::getCgformHeadId, headId);
wrapper.orderByAsc(CgformField::getOrderNum);
//获取所以的字段
List<CgformField> fieldList = this.list(wrapper);
String sqlStr="";
/* if(bladeRedis.exists(redisKey)){
sqlStr =bladeRedis.get(redisKey);
}else{*///redis 不存在
StringBuffer sbf = new StringBuffer();
// 拼接查询这张表的数据的SQL语句:
SqlSymbolUtil.getSelect(tableName, fieldList, sbf);
// 根据数据库类型制造额外SQL
String sql = SqlSymbolUtil.getByDataType(fieldList, params, needList);
// 制造额外SQL(查询条件)
String sql1 = SqlSymbolUtil.getByParams(params);
// 拼接出完整的SQL查询语句
sbf.append(" where is_deleted =0 " + sql + sql1);
// 获取column字段属性
Object column = params.get("column");
// column != null, 制造获取排序规则:
if (column != null) {
String columnStr = column.toString();
// 获取排序字段 "asc" / "desc"
String orderStr = params.get("order").toString();
// column 等于转换成驼峰命名后的确是表额外属性集合内的某个字段,根据这个字段制造查询排序语句:
if (this.orderBy(columnStr, fieldList)) {
String orderBy = ConvertUtils.camelToUnderline(columnStr);
if(Func.equals(orderBy,"id")){
orderBy="("+orderBy+" +0 )";
}
// 拼接排序语句
sbf.append(" ORDER BY " + orderBy);
if ("asc".equals(orderStr)) {
sbf.append(" asc");
} else {
sbf.append(" desc");
}
}
}
if(params.containsKey("allIdFlag") && MjkjUtils.getMap2Integer(params,"allIdFlag")==1){//获取所有
sbf=new StringBuffer();
sbf.append("select id from "+tableName+" t where is_deleted =0 " + sql + sql1);
}
sqlStr=sbf.toString();
//写入redis 5分钟
redisUtil.set(redisKey,sqlStr,300L, TimeUnit.SECONDS);
//}
if(params.containsKey("allIdFlag") && MjkjUtils.getMap2Integer(params,"allIdFlag")==1){//获取所有
List<Map<String, Object>> dataList = sqlMapper.queryListBySqlList(sqlStr);
// 如果没有查到数据,封装
resultMap.put("total", 0);
resultMap.put("fieldList", new ArrayList<>());
resultMap.put("records",new ArrayList<>());
resultMap.put("idList",dataList);
return resultMap;
}
// pageSize是否为null?是的话,取10
Integer pageSzie = params.get("pageSize") == null ? 10 : Integer.parseInt(params.get("pageSize").toString());
// 如果pageSize = -521
if (pageSzie == -521) {
// 根据查询条件查询数据:
List<Map<String, Object>> dataList = sqlMapper.queryListBySqlList(sqlStr);
// 如果查询到了数据
if (dataList != null && dataList.size() != 0) {
resultMap.put("total", dataList.size());// 封装数据总条数
resultMap.put("fieldList", fieldList);// 封装表额外字段
//判断是否包含
Integer cou = baseMapper.getBlobCou(headId);
if(Func.isNotEmpty(cou) && cou>0){
resultMap.put("records", SqlSymbolUtil.handleClob(dataList)); // 封装数据
}else{
resultMap.put("records", dataList); // 封装数据
}
} else {
resultMap.put("total", 0);// 如果没有查到数据,封装
resultMap.put("fieldList", fieldList); // 封装字段集合
List<Map<String, Object>> list=new ArrayList<>();// 创建ArrayList
resultMap.put("records",list );// 封装数据为空的ArrayList
}
} else {
Integer pageNo = params.get("pageNo") == null ? 1 : Integer.parseInt(params.get("pageNo").toString());
Page<Map<String, Object>> page = new Page<>(pageNo, pageSzie);// 创建分页对象,封装参数
IPage<Map<String, Object>> ipage = sqlMapper.selectPageBySqlList(page, sqlStr); // 分页查询
resultMap.put("total", ipage.getTotal());// 封装总条数
Integer cou = baseMapper.getBlobCou(headId);
if(Func.isNotEmpty(cou) && cou>0){
resultMap.put("records", SqlSymbolUtil.handleClob(ipage.getRecords())); // 封装数据
}else{
resultMap.put("records", ipage.getRecords()); // 封装数据
}
}
return resultMap;
}
public Map<String, Object> queryAutoTreeNoPage(String tbname, Long headId, Map<String, Object> params, List<String> needList, String pidField) {
Map<String, Object> resultMap = new HashMap<>();
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformField::getCgformHeadId, headId);
wrapper.orderByAsc(CgformField::getOrderNum);
List<CgformField> cgformFieldList = this.list(wrapper);
List<CgformField> availableFieldsList = this.queryAvailableFields(tbname, true, cgformFieldList, needList);
StringBuffer sb = new StringBuffer();
SqlSymbolUtil.getSelect(tbname, availableFieldsList, sb);
String dataTypeStr = SqlSymbolUtil.getByDataType(cgformFieldList, params, needList);
String paramStr = SqlSymbolUtil.getByParams(params);
sb.append(" where is_deleted =0 " + dataTypeStr + paramStr);
Object obj = params.get("column");
if (obj != null) {
String column = obj.toString();
String order = params.get("order").toString();
if (this.orderBy(column, cgformFieldList)) {
String orderBy = ConvertUtils.camelToUnderline(column);
if(Func.equals(orderBy,"id")){
orderBy="("+orderBy+" +0 )";
}
sb.append(" ORDER BY " + orderBy);
if ("asc".equals(order)) {
sb.append(" asc");
} else {
sb.append(" desc");
}
}
}
Integer pageSize = params.get("pageSize") == null ? 10 : Integer.parseInt(params.get("pageSize").toString());
if (pageSize == -521) {
List<Map<String, Object>> mapList = sqlMapper.queryListBySqlList(sb.toString());
if ("true".equals(params.get("hasQuery"))) {
List<Map<String, Object>> newMapList = new ArrayList<>();
Iterator<Map<String, Object>> iterator = mapList.iterator();
while (true) {
while (iterator.hasNext()) {
Map<String, Object> map = iterator.next();
String pidFieldStr = map.get(pidField).toString();
if (pidFieldStr != null && !"0".equals(pidFieldStr)) {
Map<String, Object> var20 = this.a(pidFieldStr, tbname, headId, needList, pidField);
if (var20 != null && var20.size() > 0 && !newMapList.contains(var20)) {
newMapList.add(var20);
}
} else if (!newMapList.contains(map)) {
newMapList.add(map);
}
}
mapList = newMapList;
break;
}
}
log.info("---Online查询sql 不分页 :>>" + sb.toString());
if (mapList != null && mapList.size() != 0) {
resultMap.put("total", mapList.size());
resultMap.put("fieldList", availableFieldsList);
resultMap.put("records", SqlSymbolUtil.handleClob(mapList));
} else {
resultMap.put("total", 0);
resultMap.put("fieldList", availableFieldsList);
}
} else {
Integer pageNo = params.get("pageNo") == null ? 1 : Integer.parseInt(params.get("pageNo").toString());
Page page = new Page(pageNo, pageSize);
log.info("---Online查询sql:>>" + sb.toString());
IPage pageData = sqlMapper.selectPageBySqlList(page, sb.toString());
resultMap.put("total", pageData.getTotal());
resultMap.put("records", SqlSymbolUtil.handleClob(pageData.getRecords()));
}
List<Map<String, Object>> recordList =( List<Map<String, Object>> ) resultMap.get("records");
if(Func.isNotEmpty(recordList)){
for (Map<String, Object> recordMap:recordList) {
Long id = MjkjUtils.getMap2Long(recordMap,"id");
String haschildren = (String)recordMap.get("haschildren");
String sql="select * from "+tbname+" where is_deleted =0 and pid="+id;
List<Map<String, Object>> mapList = sqlMapper.queryListBySqlList(sql);
if(Func.isNotEmpty(mapList)){//有数据
if(id!=null && Func.equals(haschildren,"1")){//无数据,
String updateSql="update "+tbname+" set haschildren=0 where id="+id;
sqlMapper.editFormData(updateSql);
recordMap.put("haschildren","0");
}
}else{//没有数据
if(id!=null && Func.equals(haschildren,"0")){//有数据,
String updateSql="update "+tbname+" set haschildren=1 where id="+id;
sqlMapper.editFormData(updateSql);
recordMap.put("haschildren","1");
}
}
}
}
return resultMap;
}
public List<CgformField> queryFormFieldsByTableName(String tableName) {
CgformHead head = headMapper.selectOne((Wrapper) (new LambdaQueryWrapper<CgformHead>()).eq(CgformHead::getTableName, tableName));
if (Func.isEmpty(head)) {
return null;
}
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, head.getId());
return this.list(wrapper);
}
private Map<String, Object> a(String pidFieldStr, String tbname, Long headId, List<String> needList, String pidField) {
HashMap paramsMap = new HashMap();
paramsMap.put("id", pidFieldStr);
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
wrapper.orderByAsc(CgformField::getOrderNum);
List list = this.list(wrapper);
List availableFieldsList = this.queryAvailableFields(tbname, true, list, needList);
StringBuffer sb = new StringBuffer();
SqlSymbolUtil.getSelect(tbname, availableFieldsList, sb);
String dataType = SqlSymbolUtil.getByDataType(list, paramsMap, needList);
sb.append(" where is_deleted =0 " + dataType + "and id='" + pidFieldStr + "'");
List selectList = sqlMapper.queryListBySqlList(sb.toString());
if (Func.isEmpty(selectList)) {
return null;
}
Map map = (Map) selectList.get(0);
return map != null && map.get(pidField) != null && !"0".equals(map.get(pidField)) ? this.a(map.get(pidField).toString(), tbname, headId, needList, pidField) : map;
}
public List<CgformField> queryFormFields(Long headId, boolean isform) {
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
if (isform) {
wrapper.eq(CgformField::getIsShowForm, 1);
}
return this.list(wrapper);
}
public Map<String, Object> queryFormData(List fieldList, String tbname, String id) {
String sql = SqlSymbolUtil.getSelectSql(tbname, fieldList, id);
return sqlMapper.queryFormData(sql);
}
/**
* 获取表单的数据-所有数据
* @param fieldList
* @param tbname
* @return
*/
@Override
public List<Map<String, Object>> queryFormAllData(List fieldList, String tbname) {
String sql = SqlSymbolUtil.getSelectSqlAllData(tbname, fieldList);
return sqlMapper.queryListBySqlList(sql);
}
public List<Map<String, Object>> querySubFormData(List fieldList, String tbname, String linkField, String value) {
String sql = SqlSymbolUtil.getSelectSql(tbname, fieldList, linkField, value);
return sqlMapper.queryListData(sql);
}
@Override
public String queryTreeChildIds(CgformHead head, String dataIdStrs) {
String treeParentIdField = head.getTreeParentIdField();
String tableName = head.getTableName();
String[] dataIds = dataIdStrs.split(",");
StringBuffer sb = new StringBuffer();
for (String dataId : dataIds) {
if (Func.isEmpty(dataId) || sb.toString().contains(dataId)) {
continue;
}
if (sb.toString().length() > 0) {
sb.append(",");
}
sb.append(dataId);
this.getSelectSql(dataId, treeParentIdField, tableName, sb);
}
return sb.toString();
}
/**
* 删除主表和子表
*
* @param head
* @param idStrs
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAutoListMainAndSub(CgformHead head, String idStrs) {
// 不能删除单表和附表的数据
if (head.getTableType() != 2) {
return;
}
Long headId = head.getId();
String tableName = head.getTableName();
String tableNameStr = "tableName";
String linkField = "linkField";
String linkValueStr = "linkValueStr";
String mainField = "mainField";
ArrayList mapList = new ArrayList();
if (Func.isEmpty(head.getSubTableStr())) {
this.deleteAutoListById(head.getTableName(), idStrs);
return;
}
String[] subTableStrs = head.getSubTableStr().split(",");
for (String subTableStr : subTableStrs) {
CgformHead cgformHead = headMapper.selectOne((new LambdaQueryWrapper<CgformHead>()).eq(CgformHead::getTableName, subTableStr));
if (cgformHead == null) {
continue;
}
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformField::getCgformHeadId, cgformHead.getId());
wrapper.eq(CgformField::getMainTable, head.getTableName());
List<CgformField> cfList = this.list(wrapper);
if (Func.isEmpty(cfList)) {
continue;
}
CgformField cf = cfList.get(0);
HashMap map = new HashMap();
map.put(linkField, cf.getDbFieldName());
map.put(mainField, cf.getMainField());
map.put(tableNameStr, subTableStr);
map.put(linkValueStr, "");
mapList.add(map);
}
LambdaQueryWrapper<CgformField> wrapper = new LambdaQueryWrapper();
wrapper.eq(CgformField::getCgformHeadId, headId);
List<CgformField> cfList = this.list(wrapper);
String[] ids = idStrs.split(",");
int step = 0;
label52:
while (true) {
if (step >= ids.length) {
Iterator iterator = mapList.iterator();
while (true) {
if (!iterator.hasNext()) {
break label52;
}
Map map = (Map) iterator.next();
this.deleteAutoList((String) map.get(tableNameStr), (String) map.get(linkField), (String) map.get(linkValueStr));
}
}
String id = ids[step];
String sql = SqlSymbolUtil.getSelectSql(tableName, cfList, id);
Map map = sqlMapper.queryFormData(sql);
Iterator<Map> iterator = mapList.iterator();
while (iterator.hasNext()) {
Map m = iterator.next();
Object obj = map.get(((String) m.get(mainField)).toLowerCase());
if (obj == null) {
obj = map.get(((String) m.get(mainField)).toUpperCase());
}
if (obj != null) {
String var23 = (String) m.get(linkValueStr) + String.valueOf(obj) + ",";
m.put(linkValueStr, var23);
}
}
++step;
}
this.deleteAutoListById(head.getTableName(), idStrs);
}
public void updateTreeNodeNoChild(String tableName, String filed, String id) {
Map map = SqlSymbolUtil.getUpdateSqlMap(tableName, filed, id);
this.sqlMapper.executeUpdatetSQL(map);
}
@Override
public List<TreeModel> queryDataListByLinkDown(CommonEntity entity) {
return sqlMapper.queryDataListByLinkDown(entity);
}
public void deleteAutoListById(String tbname, String ids) {
this.deleteAutoList(tbname, "id", ids);
}
@Override
public void deleteAutoList(String tbname, String linkField, String linkValueStr) {
if (Func.isEmpty(linkValueStr)) {
return;
}
String[] linkValues = linkValueStr.split(",");
StringBuffer sb = new StringBuffer();
for (String linkValue : linkValues) {
if (Func.isEmpty(linkValue)) {
continue;
}
sb.append("'" + linkValue + "',");
}
String likeStr = sb.toString();
String sql = "UPDATE " + SqlSymbolUtil.getSubstring(tbname) + " SET is_deleted =-1 where " + linkField + " in(" + likeStr.substring(0, likeStr.length() - 1) + ")";
sqlMapper.deleteAutoList(sql);
}
@Override
public void deleteList(String tbname, String linkField, String linkValueStr) {
if (Func.isEmpty(linkValueStr)) {
return;
}
String[] linkValues = linkValueStr.split(",");
StringBuffer sb = new StringBuffer();
for (String linkValue : linkValues) {
if (Func.isEmpty(linkValue)) {
continue;
}
sb.append("'" + linkValue + "',");
}
String likeStr = sb.toString();
String sql = "DELETE FROM " + SqlSymbolUtil.getSubstring(tbname) + " where " + linkField + " in(" + likeStr.substring(0, likeStr.length() - 1) + ")";
sqlMapper.deleteList(sql);
}
public boolean orderBy(String str, List<CgformField> list) {
boolean flag = false;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
CgformField field = (CgformField) iterator.next();
if (ConvertUtils.camelToUnderline(str).equals(field.getDbFieldName())) {
flag = true;
break;
}
}
return flag;
}
private StringBuffer getSelectSql(String dataId, String treeParentIdField, String tableName, StringBuffer sb) {
String sql = "select * from " + SqlSymbolUtil.getSubstring(tableName) + " where is_deleted =0 AND " + treeParentIdField + "= '" + dataId + "'";
List list = sqlMapper.queryListBySqlList(sql);
if (Func.isEmpty(list)) {
return sb;
}
Iterator iterator = list.iterator();
if (iterator.hasNext()) {
Map map = (Map) iterator.next();
if (!sb.toString().contains(map.get("id").toString())) {
sb.append(",").append(map.get("id"));
}
this.getSelectSql(map.get("id").toString(), treeParentIdField, tableName, sb);
}
return sb;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformFieldServiceImpl.java | Java | apache-2.0 | 32,826 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.RedisUtil;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJava;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.entity.CgformIndex;
import org.springblade.modules.mjkj.common.cgform.enums.CgformEnum;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformHeadMapper;
import org.springblade.modules.mjkj.common.cgform.model.CgformModel;
import org.springblade.modules.mjkj.common.cgform.model.OnlGenerateModel;
import org.springblade.modules.mjkj.common.cgform.model.TreeDataModel;
import org.springblade.modules.mjkj.common.cgform.service.*;
import org.springblade.modules.mjkj.common.config.constant.MjkjConstant;
import org.springblade.modules.mjkj.common.config.db.DataBaseConfig;
import org.springblade.modules.mjkj.common.config.db.TableModel;
import org.springblade.modules.mjkj.common.config.exception.BusinessException;
import org.springblade.modules.mjkj.common.config.exception.DBException;
import org.springblade.modules.mjkj.common.config.service.DbTableHandleI;
import org.springblade.modules.mjkj.common.config.util.*;
import org.springblade.modules.mjkj.common.utils.MjkjUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.SQLException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* 服务实现类
*
* @author BladeX
* @since 2021-05-20
*/
@Slf4j
@Service
public class CgformHeadServiceImpl extends BaseServiceImpl<CgformHeadMapper, CgformHead> implements ICgformHeadService {
@Autowired
private ICgformFieldService fieldService;
@Autowired
private ICgformIndexService indexService;
@Autowired
private ICgformButtonService buttonService;
@Autowired
private ICgformEnhanceJsService jsService;
@Autowired
private ICgformEnhanceJavaService javaService;
@Autowired
private ICgformEnhanceSqlService sqlService;
@Autowired
private DataBaseConfig dataBaseConfig;
@Autowired
private RedisUtil redisUtil;
/**
* 保存自定义表单内容
*
* @param json
* @throws DBException
* @throws BusinessException
*/
@Transactional(rollbackFor = Exception.class)
@Override
public String saveManyFormData(CgformHead head, JSONObject json) throws DBException, BusinessException {
String resultId = "0";
int addFlag = javaService.executeEnhanceJava(MjkjConstant.ENHANCE_ADD, MjkjConstant.ENHANCE_START, head, json);//java - 开始 -增强
if (addFlag != 1) {
return resultId;
}
String tableName = SqlSymbolUtil.getSubstring(head.getTableName());//获取表明
if(!Func.equals(head.getFormCategory(),"view")) {//不是显示表
if (head.getTableType() == 2) {//表类型: 1单表、2主表、3附表
this.saveSubFormData(head, json);//保存附表信息
}
//先保存主表,再保存附表
if ("Y".equals(head.getIsTree())) {//树结构
resultId = fieldService.saveTreeFormData(head.getId(), tableName, json, head.getTreeIdField(), head.getTreeParentIdField());
} else {
resultId = fieldService.saveFormData(head.getId(), tableName, json, false);
}
}
sqlService.executeEnhanceSqlInsert(MjkjConstant.ENHANCE_ADD, head.getId(), json);//sql增强
javaService.executeEnhanceJava(MjkjConstant.ENHANCE_ADD, MjkjConstant.ENHANCE_END, head, json);//java增强
return resultId;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void editManyFormData(CgformHead head, JSONObject json) throws DBException, BusinessException {
javaService.executeEnhanceJava(MjkjConstant.ENHANCE_EDIT, MjkjConstant.ENHANCE_START, head, json);
String tableName = head.getTableName();
if(!Func.equals(head.getFormCategory(),"view")) {//不是显示表
if ("Y".equals(head.getIsTree())) {
this.fieldService.editTreeFormData(head.getId(), tableName, json, head.getTreeIdField(), head.getTreeParentIdField());
} else {
this.fieldService.editFormData(head.getId(), tableName, json, false);
}
if (head.getTableType() == 2) {//表类型: 1单表、2主表、3附表
editSubFormData(head, json);//处理编辑
}
}
javaService.executeEnhanceJava(MjkjConstant.ENHANCE_EDIT, MjkjConstant.ENHANCE_END, head, json);
sqlService.executeEnhanceSqlUpdate(MjkjConstant.ENHANCE_EDIT, head.getId(), json);
}
public Map<String, Object> queryManyFormData(Long headId, String id) throws DBException {
CgformHead head = this.getById(headId);
List<CgformField> fieldList = this.fieldService.queryFormFields(headId, false);
Map<String, Object> resultMap = this.fieldService.queryFormData(fieldList, head.getTableName(), id);
if (Func.isEmpty(resultMap)) {//判空操作
return resultMap;
}
String subTableStr = head.getSubTableStr();
if (head.getTableType() != 2 || Func.isEmpty(subTableStr)) {//表类型: 1单表、2主表、3附表
return resultMap;
}
String[] subTableStrs = subTableStr.split(",");
for (String table : subTableStrs) {
CgformHead subHead = baseMapper.selectOne((new LambdaQueryWrapper<CgformHead>()).eq(CgformHead::getTableName, table));
if (Func.isEmpty(subHead)) {
continue;
}
List<CgformField> subFieldList = this.fieldService.queryFormFields(subHead.getId(), false);
String dbFieldName = "";
String mainField = null;
Iterator<CgformField> subIterator = subFieldList.iterator();
while (subIterator.hasNext()) {
CgformField subField = subIterator.next();
if (Func.isEmpty(subField.getMainField())) {
continue;
}
dbFieldName = subField.getDbFieldName();
mainField = subField.getMainField();
if (null == resultMap.get(mainField)) {
mainField = resultMap.get(mainField.toUpperCase()).toString();
} else {
mainField = resultMap.get(mainField).toString();
}
}
List<Map<String, Object>> mapList = this.fieldService.querySubFormData(subFieldList, table, dbFieldName, mainField);
if (Func.isNotEmpty(mapList)) {
resultMap.put(table, SqlSymbolUtil.handleClob(mapList));
} else {
resultMap.put(table, new String[0]);
}
}
return resultMap;
}
@Transactional(
rollbackFor = {Exception.class}
)
public void deleteOneTableInfo(Long headId, String dataId) throws BusinessException {
CgformHead head = this.getById(headId);
if (Func.isEmpty(head)) {
throw new BusinessException("未找到表配置信息");
}
JSONObject jsonObject =new JSONObject();
jsonObject.put("id", dataId);
int i = javaService.executeEnhanceJava(MjkjConstant.ENHANCE_DELETE, MjkjConstant.ENHANCE_START, head, jsonObject);//java增强-开始
if (i == -1) {
return;
}
if(!Func.equals(head.getFormCategory(),"view")) {//不是显示表
this.updateParentNode(head, dataId);
if (head.getTableType() == 2) {
this.fieldService.deleteAutoListMainAndSub(head, dataId);
} else {
String deletesql = "update " + head.getTableName() + " set is_deleted = -1 where id = '" + dataId + "'";
baseMapper.deleteOne(deletesql);
}
}
sqlService.executeEnhanceSqlUpdate(MjkjConstant.ENHANCE_DELETE, headId, jsonObject);//sql增强-结束
javaService.executeEnhanceJava(MjkjConstant.ENHANCE_DELETE, MjkjConstant.ENHANCE_END, head, jsonObject);//java增强-结束
}
@Override
public void initCopyState(List<CgformHead> headList) {
List<String> copyPhysicIdList = this.baseMapper.queryCopyPhysicId();
Iterator<CgformHead> iterator = headList.iterator();
while (iterator.hasNext()) {
CgformHead head = iterator.next();
if (copyPhysicIdList.contains(head.getId())) {
head.setHascopy(1);
} else {
head.setHascopy(0);
}
}
}
/**
* 更新父级node
*
* @param head
* @param dataId
*/
private void updateParentNode(CgformHead head, String dataId) {
if (!Func.equals("Y", head.getIsTree())) {
return;
}
String tableName = SqlSymbolUtil.getSubstring(head.getTableName());
String treeParentIdField = head.getTreeParentIdField();
Map<String, Object> map = baseMapper.queryOneByTableNameAndId(tableName, dataId);
String treeParentIdFieldStr = null;
if (map.get(treeParentIdField) != null && !"0".equals(map.get(treeParentIdField))) {
treeParentIdFieldStr = map.get(treeParentIdField).toString();
} else if (map.get(treeParentIdField.toUpperCase()) != null && !"0".equals(map.get(treeParentIdField.toUpperCase()))) {
treeParentIdFieldStr = map.get(treeParentIdField.toUpperCase()).toString();
}
if (Func.isNotEmpty(treeParentIdFieldStr)) {
Integer cou = baseMapper.queryChildNode(tableName, treeParentIdField, treeParentIdFieldStr);
if (cou == 1) {
String treeIdField = head.getTreeIdField();
this.fieldService.updateTreeNodeNoChild(tableName, treeIdField, treeParentIdFieldStr);
}
}
}
/**
* 获取java增强实体
*
* @param java
* @return
*/
private Object a(CgformEnhanceJava java) {
if (Func.isEmpty(java)) {
return null;
}
String javaType = java.getCgJavaType();
String javaValue = java.getCgJavaValue();
if (Func.isEmpty(javaType) || Func.isEmpty(javaValue)) {
return null;
}
Object obj = null;
if ("class".equals(javaType)) {
try {
obj = MyClassLoader.getClassByScn(javaValue).newInstance();
} catch (InstantiationException e) {
log.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
log.error(e.getMessage(), e);
}
} else if ("spring".equals(javaType)) {
obj = SpringContextUtils.getBean(javaValue);
}
return obj;
}
//保存表单数据
private void saveFormData(List fieldList, String tbname, JSONObject json) {
Map map = SqlSymbolUtil.getInsertSql(tbname, fieldList, json);
fieldService.executeInsertSQL(map);
// 返回子表id,
json.put("id", MjkjUtils.getMap2Long(map, "id"));
}
/**
* 获取sql中的#{key} 这个key组成的set
*/
public static Set<String> getSqlRuleParams(String sql) {
if (ConvertUtils.isEmpty(sql)) {
return null;
}
Set<String> varParams = new HashSet<String>();
String regex = "\\#\\{\\w+\\}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(sql);
while (m.find()) {
String var = m.group();
varParams.add(var.substring(var.indexOf("{") + 1, var.indexOf("}")));
}
return varParams;
}
/**
* 保存附表数据
*/
private void saveSubFormData(CgformHead head, JSONObject json) {
String subTableStr = head.getSubTableStr();//-----以下处理附表-------
if (Func.isEmpty(subTableStr)) {
return;
}
String[] subTableStrs = subTableStr.split(",");
for (String subTable : subTableStrs) {
JSONArray jsonArray = json.getJSONArray(subTable);
if (jsonArray == null || jsonArray.size() == 0) {
continue;
}
//获取附表信息
CgformHead subHead = baseMapper.selectOne((new LambdaQueryWrapper<CgformHead>()).eq(CgformHead::getTableName, subTable));
if (Func.isEmpty(subHead)) {
continue;
}
//获取附表属性列表
List<CgformField> fieldList = this.fieldService.list((new LambdaQueryWrapper<CgformField>()).eq(CgformField::getCgformHeadId, subHead.getId()));
String dbFieldName = null;//字段名字
String mainFieldStr = null;//外键主键字段
Iterator<CgformField> iterator = fieldList.iterator();
while (iterator.hasNext()) {
CgformField field = iterator.next();
if (Func.isNotEmpty(field.getMainField())) {//外键主键字段不为空
dbFieldName = field.getDbFieldName();//字段名称
String mainField = field.getMainField();//外键主键
if (json.get(mainField.toLowerCase()) != null) {
mainFieldStr = json.getString(mainField.toLowerCase());
}
if (json.get(mainField.toUpperCase()) != null) {
mainFieldStr = json.getString(mainField.toUpperCase());
}
}
}
for (int j = 0; j < jsonArray.size(); ++j) {
JSONObject jsonObject = jsonArray.getJSONObject(j);
if (Func.isNotEmpty(mainFieldStr)) {
jsonObject.put(dbFieldName, mainFieldStr);
}
//保存附表数据
this.saveFormData(fieldList, subTable, jsonObject);
}
}
}
/**
* 编辑附表数据
*/
private void editSubFormData(CgformHead head, JSONObject json) {
String subTableStr = head.getSubTableStr();
if (Func.isEmpty(subTableStr)) {
return;
}
String[] subTableStrs = subTableStr.split(",");
for (String str : subTableStrs) {
JSONArray jsonArray = json.getJSONArray(str);
if (jsonArray == null) {
continue;
}
CgformHead subHead = baseMapper.selectOne((new LambdaQueryWrapper<CgformHead>()).eq(CgformHead::getTableName, str));
if (Func.isEmpty(subHead)) {
continue;
}
List<CgformField> list = this.fieldService.list((new LambdaQueryWrapper<CgformField>()).eq(CgformField::getCgformHeadId, subHead.getId()));
String dbFieldName = "";
String mainField = null;
Iterator<CgformField> iterator = list.iterator();
while (iterator.hasNext()) {
CgformField field = iterator.next();
if (!ConvertUtils.isEmpty(field.getMainField())) {
dbFieldName = field.getDbFieldName();
String mainFieldStr = field.getMainField();
if (json.get(mainFieldStr.toLowerCase()) != null) {
mainField = json.getString(mainFieldStr.toLowerCase());
}
if (json.get(mainFieldStr.toUpperCase()) != null) {
mainField = json.getString(mainFieldStr.toUpperCase());
}
}
}
if (Func.isNotEmpty(mainField)) {
this.fieldService.deleteList(str, dbFieldName, mainField);
JSONArray strJsonArray = json.getJSONArray(str);
if (Func.isNotEmpty(strJsonArray)) {
for (int i = 0; i < strJsonArray.size(); ++i) {
JSONObject jsonObject = strJsonArray.getJSONObject(i);
if (mainField != null) {
jsonObject.put(dbFieldName, mainField);
}
this.fieldService.saveFormDataList(list, str, jsonObject);
}
}
}
}
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformHeadServiceImpl.java | Java | apache-2.0 | 15,441 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springblade.modules.mjkj.common.cgform.entity.CgformIndex;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformHeadMapper;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformIndexMapper;
import org.springblade.modules.mjkj.common.cgform.service.ICgformIndexService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List;
/**
* 服务实现类
*
* @author BladeX
* @since 2021-05-20
*/
@Service
public class CgformIndexServiceImpl extends BaseServiceImpl<CgformIndexMapper, CgformIndex> implements ICgformIndexService {
@Autowired
private CgformHeadMapper headMapper;
@Override
public List<CgformIndex> getCgformIndexsByCgformId(Long cgformId) {
return this.baseMapper.selectList((new LambdaQueryWrapper<CgformIndex>()).in(CgformIndex::getCgformHeadId, new Object[]{cgformId}));
}
@Override
public boolean isExistIndex(String countSql) {
if (countSql == null) {
return true;
} else {
Integer count = baseMapper.queryIndexCount(countSql);
return count != null && count > 0;
}
}
@Override
public void createIndex(Long headId, String databaseType, String tbname) {
LambdaQueryWrapper<CgformIndex> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CgformIndex::getCgformHeadId, headId);
List<CgformIndex> list = this.list(wrapper);
if (Func.isEmpty(list)) {
return;
}
Iterator<CgformIndex> iterator = list.iterator();
while (iterator.hasNext()) {
CgformIndex index = iterator.next();
if ("N".equals(index.getIsDbSynch())) {
String ddlStr = "";
String indexName = index.getIndexName();
String indexField = index.getIndexField();
String var11 = "normal".equals(index.getIndexType()) ? " index " : index.getIndexType() + " index ";
byte type = -1;
switch (databaseType.hashCode()) {
case -1955532418:
if (databaseType.equals("ORACLE")) {
type = 1;
}
break;
case -1620389036:
if (databaseType.equals("POSTGRESQL")) {
type = 3;
}
break;
case 73844866:
if (databaseType.equals("MYSQL")) {
type = 0;
}
break;
case 912124529:
if (databaseType.equals("SQLSERVER")) {
type = 2;
}
}
switch (type) {
case 0:
ddlStr = "create " + var11 + indexName + " on " + tbname + "(" + indexField + ")";
break;
case 1:
ddlStr = "create " + var11 + indexName + " on " + tbname + "(" + indexField + ")";
break;
case 2:
ddlStr = "create " + var11 + indexName + " on " + tbname + "(" + indexField + ")";
break;
case 3:
ddlStr = "create " + var11 + indexName + " on " + tbname + "(" + indexField + ")";
break;
default:
ddlStr = "create " + var11 + indexName + " on " + tbname + "(" + indexField + ")";
}
headMapper.executeDDL(ddlStr);
index.setIsDbSynch("Y");
this.updateById(index);
}
}
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformIndexServiceImpl.java | Java | apache-2.0 | 4,967 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import org.springblade.modules.mjkj.common.cgform.entity.CgformValid;
import org.springblade.modules.mjkj.common.cgform.mapper.CgformValidMapper;
import org.springblade.modules.mjkj.common.cgform.service.ICgformValidService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 自定义表单字段校验规则表 服务实现类
*
* @author BladeX
* @since 2021-05-20
*/
@Service
public class CgformValidServiceImpl extends BaseServiceImpl<CgformValidMapper, CgformValid> implements ICgformValidService {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CgformValidServiceImpl.java | Java | apache-2.0 | 1,466 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springblade.modules.mjkj.common.cgform.entity.CheckRule;
import org.springblade.modules.mjkj.common.cgform.mapper.CheckRuleMapper;
import org.springblade.modules.mjkj.common.cgform.service.ICheckRuleService;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.regex.Pattern;
/**
* 编码校验规则 服务实现类
*
* @author BladeX
* @since 2021-07-03
*/
@Service
public class CheckRuleServiceImpl extends BaseServiceImpl<CheckRuleMapper, CheckRule> implements ICheckRuleService {
/**
* 通过用户设定的自定义校验规则校验传入的值
*
* @param checkRule
* @param value
* @return 返回 null代表通过校验,否则就是返回的错误提示文本
*/
@Override
public JSONObject checkValue(CheckRule checkRule, String value) {
if (checkRule != null && StringUtils.isNotBlank(value)) {
String ruleJson = checkRule.getRuleJson();
if (StringUtils.isNotBlank(ruleJson)) {
// 开始截取的下标,根据规则的顺序递增,但是 * 号不计入递增范围
int beginIndex = 0;
JSONArray rules = JSON.parseArray(ruleJson);
for (int i = 0; i < rules.size(); i++) {
JSONObject result = new JSONObject();
JSONObject rule = rules.getJSONObject(i);
// 位数
String digits = rule.getString("digits");
result.put("digits", digits);
// 验证规则
String pattern = rule.getString("pattern");
result.put("pattern", pattern);
// 未通过时的提示文本
String message = rule.getString("message");
result.put("message", message);
// 根据用户设定的区间,截取字符串进行验证
String checkValue;
// 是否检查整个值而不截取
if ("*".equals(digits)) {
checkValue = value;
} else {
int num = Integer.parseInt(digits);
int endIndex = beginIndex + num;
// 如果结束下标大于给定的值的长度,则取到最后一位
endIndex = endIndex > value.length() ? value.length() : endIndex;
// 如果开始下标大于结束下标,则说明用户还尚未输入到该位置,直接赋空值
if (beginIndex > endIndex) {
checkValue = "";
} else {
checkValue = value.substring(beginIndex, endIndex);
}
result.put("beginIndex", beginIndex);
result.put("endIndex", endIndex);
beginIndex += num;
}
result.put("checkValue", checkValue);
boolean passed = Pattern.matches(pattern, checkValue);
result.put("passed", passed);
// 如果没有通过校验就返回错误信息
if (!passed) {
return result;
}
}
}
}
return null;
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/CheckRuleServiceImpl.java | Java | apache-2.0 | 3,756 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import org.springblade.modules.mjkj.common.cgform.entity.DesformData;
import org.springblade.modules.mjkj.common.cgform.mapper.DesformDataMapper;
import org.springblade.modules.mjkj.common.cgform.service.IDesformDataService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 表单设计器-数据 服务实现类
*
* @author BladeX
* @since 2021-07-02
*/
@Service
public class DesformDataServiceImpl extends BaseServiceImpl<DesformDataMapper, DesformData> implements IDesformDataService {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/DesformDataServiceImpl.java | Java | apache-2.0 | 1,452 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import org.springblade.modules.mjkj.common.cgform.entity.DesformHead;
import org.springblade.modules.mjkj.common.cgform.mapper.DesformHeadMapper;
import org.springblade.modules.mjkj.common.cgform.service.IDesformHeadService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 表单设计器基本属性 服务实现类
*
* @author BladeX
* @since 2021-07-02
*/
@Service
public class DesformHeadServiceImpl extends BaseServiceImpl<DesformHeadMapper, DesformHead> implements IDesformHeadService {
@Autowired
private DesformHeadMapper desformHeadMapper;
public List<DesformHead> openList(){
return desformHeadMapper.openList();
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/DesformHeadServiceImpl.java | Java | apache-2.0 | 1,700 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springblade.modules.mjkj.common.cgform.entity.DesformRoute;
import org.springblade.modules.mjkj.common.cgform.mapper.DesformRouteMapper;
import org.springblade.modules.mjkj.common.cgform.service.IDesformRouteService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 表单设计器-数据 服务实现类
*
* @author BladeX
* @since 2021-07-02
*/
@Service
public class DesformRouteServiceImpl extends BaseServiceImpl<DesformRouteMapper, DesformRoute> implements IDesformRouteService {
@Transactional(rollbackFor = Exception.class)
@Override
public void formRouteEdit(DesformRoute route){
if(route.getStatus()==1){//当前开启,需要查出所有开启的进行关闭
LambdaQueryWrapper<DesformRoute> wrapper=new LambdaQueryWrapper<>();
wrapper.eq(DesformRoute::getStatus,1);
DesformRoute select = this.getOne(wrapper);
if(Func.isNotEmpty(select)){
select.setStatus(0);
this.updateById(select);
}
}
this.updateById(route);
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/DesformRouteServiceImpl.java | Java | apache-2.0 | 2,217 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import org.springblade.modules.mjkj.common.cgform.entity.FillRule;
import org.springblade.modules.mjkj.common.cgform.mapper.FillRuleMapper;
import org.springblade.modules.mjkj.common.cgform.service.IFillRuleService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 填值规则 服务实现类
*
* @author BladeX
* @since 2021-07-03
*/
@Service
public class FillRuleServiceImpl extends BaseServiceImpl<FillRuleMapper, FillRule> implements IFillRuleService {
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/FillRuleServiceImpl.java | Java | apache-2.0 | 1,420 |
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.springblade.modules.mjkj.common.cgform.mapper.MjkjBaseSqlMapper;
import org.springblade.modules.mjkj.common.cgform.model.KvModel;
import org.springblade.modules.mjkj.common.cgform.service.IMjkjBaseSqlService;
import org.springblade.modules.mjkj.common.utils.MjkjUtils;
import org.springblade.modules.mjkj.common.config.util.DataTypeUtil;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.RedisUtil;
import org.springblade.core.tool.utils.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 公共调用
*/
@Service
public class MjkjBaseSqlServiceImpl implements IMjkjBaseSqlService {
@Autowired
private MjkjBaseSqlMapper mjkjBaseSqlMapper;
@Autowired
private RedisUtil redisUtil;
private String getSelectField() {
return "*";
}
private String getSelectField(List<String> customFieldList) {
String selectField = "";
if (Func.isNotEmpty(customFieldList)) {
for (int i = 0; i < customFieldList.size(); i++) {
String field = customFieldList.get(i);
if (i == 0) {
selectField = field;
} else {
selectField += "," + field;
}
}
} else {
selectField = "*";
}
return selectField;
}
//获取某个表的所有数据
@Override
public List<Map<String, Object>> getDataByTable(String tableName) {
String selectField = this.getSelectField();
return mjkjBaseSqlMapper.getDataByTable(selectField, tableName);
}
//自定义字段
@Override
public List<Map<String, Object>> getDataByTable(String tableName, List<String> customFieldList) {
return mjkjBaseSqlMapper.getDataByTable(this.getSelectField(customFieldList), tableName);
}
@Override
public List<Map<String, Object>> getDataByTableRedis(String tableName, Long time) {
String redisKey = "MJKJBASE_TABLE_ALL:" + tableName;
if (redisUtil.hasKey(redisKey)) {//缓存存在
List<Map<String, Object>> list = (List<Map<String, Object>>) redisUtil.get(redisKey);
if (Func.isNotEmpty(list)) {
return list;
}
} //缓存不存在
if (Func.isEmpty(time)) {
time = 30L;//默认30秒
}
List<Map<String, Object>> dataList = mjkjBaseSqlMapper.getDataByTable(this.getSelectField(), tableName);
if (Func.isNotEmpty(dataList)) {
redisUtil.set(redisKey, dataList, time, TimeUnit.SECONDS);//写入缓存
}
return dataList;
}
//根据id获取某一个表的一条数据
@Override
public Map<String, Object> getTableById(String tableName, String id) {
return mjkjBaseSqlMapper.getTableById(this.getSelectField(), tableName, id);
}
@Override
public Map<String, Object> getTableByIdL(String tableName, Long id) {
return mjkjBaseSqlMapper.getTableByIdL(this.getSelectField(), tableName, id);
}
@Override
public Map<String, Object> getTableById(String tableName, String id, List<String> customFieldList) {
return mjkjBaseSqlMapper.getTableById(this.getSelectField(customFieldList), tableName, id);
}
@Override
public Map<String, Object> getTableByIdRedis(String tableName, String id, Long time) {
String redisKey = "MJKJBASE_TABLE_ID:" + tableName + ":id_" + id;
if (redisUtil.hasKey(redisKey)) {//缓存存在
String str = Func.toStr(redisUtil.get(redisKey));
Map<String, Object> resultMap = JsonUtil.parse(str, Map.class);
if (Func.isNotEmpty(resultMap)) {
return resultMap;
}
}//缓存不存在
if (Func.isEmpty(time)) {
time = 30L;//默认30秒
}
Map<String, Object> resultMap = mjkjBaseSqlMapper.getTableById(this.getSelectField(), tableName, id);
if (Func.isNotEmpty(resultMap)) {
redisUtil.set(redisKey, JsonUtil.toJson(resultMap), time);//写入缓存
}
return resultMap;
}
//根据id获取某一个表的一条数据 进行过滤
@Override
public List<Map<String, Object>> getDataListByField(String tableName, String whereFieldName, Object whereFieldValue) {
return mjkjBaseSqlMapper.getDataListByField(this.getSelectField(), tableName, whereFieldName, whereFieldValue);
}
@Override
public List<Map<String, Object>> getDataListByField(String tableName, String whereFieldName, Object whereFieldValue, List<String> customFieldList) {
return mjkjBaseSqlMapper.getDataListByField(this.getSelectField(customFieldList), tableName, whereFieldName, whereFieldValue);
}
//根据id获取某一个表的一条数据 进行删除过滤 排序
@Override
public List<Map<String, Object>> getDataListByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue, String orderByField, String orderStr) {
if (Func.isEmpty(orderStr)) {
orderStr = "DESC";
}
return mjkjBaseSqlMapper.getDataListByFieldOrderBy(this.getSelectField(), tableName, whereFieldName, whereFieldValue, orderByField, orderStr);
}
@Override
public List<Map<String, Object>> getDataListByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue, String orderByField, String orderStr, List<String> customFieldList) {
if (Func.isEmpty(orderStr)) {
orderStr = "DESC";
}
return mjkjBaseSqlMapper.getDataListByFieldOrderBy(this.getSelectField(customFieldList), tableName, whereFieldName, whereFieldValue, orderByField, orderStr);
}
//获取一条数据
@Override
public Map<String, Object> getDataOneByField(String tableName, String whereFieldName, Object whereFieldValue) {
List<Map<String, Object>> dataList = this.getDataListByField(tableName, whereFieldName, whereFieldValue);
if (Func.isEmpty(dataList)) {
return null;
}
return dataList.get(0);
}
@Override
public Map<String, Object> getDataOneByField(String tableName, String whereFieldName, Object whereFieldValue, List<String> customFieldList) {
List<Map<String, Object>> dataList = this.getDataListByField(tableName, whereFieldName, whereFieldValue, customFieldList);
if (Func.isEmpty(dataList)) {
return null;
}
return dataList.get(0);
}
@Override
public Map<String, Object> getDataOneByFieldRedis(String tableName, String whereFieldName, Object whereFieldValue, Long time) {
String redisKey = "MJKJBASE_TABLE_FIELD:" + tableName + ":whereFieldName_" + whereFieldName + ":whereFieldValue" + JsonUtil.toJson(whereFieldValue);
if (redisUtil.hasKey(redisKey)) {//缓存存在
String str = Func.toStr(redisUtil.get(redisKey));
Map<String, Object> resultMap = JsonUtil.parse(str, Map.class);
if (Func.isNotEmpty(resultMap)) {
return resultMap;
}
}//缓存不存在
if (Func.isEmpty(time)) {
time = 30L;//默认30秒
}
List<Map<String, Object>> dataList = this.getDataListByField(tableName, whereFieldName, whereFieldValue, null);
if (Func.isEmpty(dataList)) {
return null;
}
Map<String, Object> resultMap = dataList.get(0);
redisUtil.set(redisKey, JsonUtil.toJson(resultMap), time);//写入缓存
return resultMap;
}
//获取一条数据 排序
@Override
public Map<String, Object> getDataOneByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue, String orderByField, String orderStr) {
if (Func.isEmpty(orderStr)) {
orderStr = "DESC";
}
List<Map<String, Object>> dataList = this.getDataListByFieldOrderBy(tableName, whereFieldName, whereFieldValue, orderByField, orderStr);
if (Func.isEmpty(dataList)) {
return null;
}
return dataList.get(0);
}
//获取一条数据 排序
@Override
public Map<String, Object> getDataOneByFieldOrderBy(String tableName, String whereFieldName, Object whereFieldValue, String orderByField, String orderStr, List<String> customFieldList) {
if (Func.isEmpty(orderStr)) {
orderStr = "DESC";
}
List<Map<String, Object>> dataList = this.getDataListByFieldOrderBy(tableName, whereFieldName, whereFieldValue, orderByField, orderStr, customFieldList);
if (Func.isEmpty(dataList)) {
return null;
}
return dataList.get(0);
}
//根据id获取某一个表的一条数据 type=ALL:全部 L:左边模糊 R右模糊
@Override
public List<Map<String, Object>> getDataListByLike(String tableName, String whereFieldName, Object whereFieldValue, String type) {
if (Func.isEmpty(type)) {
type = "ALL";
}
return mjkjBaseSqlMapper.getDataListByLike(this.getSelectField(), tableName, whereFieldName, whereFieldValue, type);
}
@Override
public List<Map<String, Object>> getDataListByLike(String tableName, String whereFieldName, Object whereFieldValue, String type, List<String> customFieldList) {
if (Func.isEmpty(type)) {
type = "ALL";
}
return mjkjBaseSqlMapper.getDataListByLike(this.getSelectField(customFieldList), tableName, whereFieldName, whereFieldValue, type);
}
@Override
public List<Map<String, Object>> getDataListByIn(String tableName, String whereFieldName, List<Object> whereFieldValue) {
return mjkjBaseSqlMapper.getDataListByIn(this.getSelectField(), tableName, whereFieldName, whereFieldValue);
}
@Override
public List<Map<String, Object>> getDataListByIn(String tableName, String whereFieldName, List<Object> whereFieldValue, List<String> customFieldList) {
return mjkjBaseSqlMapper.getDataListByIn(this.getSelectField(customFieldList), tableName, whereFieldName, whereFieldValue);
}
//获取数据字典
@Transactional
@Override
public List<KvModel> getSysDictItemList(String dictCode, Boolean redisFlag) {
String redisKey = "MJKJBASE_DICTITEM_ALL:" + dictCode;
if (redisUtil.hasKey(redisKey) && redisFlag) {//开启缓存
List<KvModel> list = (List<KvModel>) redisUtil.get(redisKey);
if (Func.isNotEmpty(list)) {
return list;
}
}
List<KvModel> list = mjkjBaseSqlMapper.getSysDictItemList(dictCode);
if (Func.isNotEmpty(list) && redisFlag) {
redisUtil.set(redisKey, list, 30L);//30秒
}
return list;
}
//获取数字字段值
@Override
@Transactional
public String getSysDictItemValue(String dictCode, String itemValue, Boolean redisFlag) {
String redisKey = "MJKJBASE_DICTITEM_VALUE:CODE_" + dictCode + ":VALUE_" + itemValue;
if (redisUtil.hasKey(redisKey) && redisFlag) {//开启缓存
String str = (String) redisUtil.get(redisKey);
if (Func.isNotEmpty(str)) {
return str;
}
}
String itemText = mjkjBaseSqlMapper.getSysDictItemValue(dictCode, itemValue);
if (Func.isNotEmpty(itemText) && redisFlag) {
redisUtil.set(redisKey, itemText, 30L);//30秒
}
return itemText;
}
//获取数字字段值
@Override
@Transactional
public String getSysDictItemValueByText(String dictCode, String itemText, Boolean redisFlag) {
String redisKey = "MJKJBASE_DICTITEM_VALUE:CODE_" + dictCode + ":TEXT_" + itemText;
if (redisUtil.hasKey(redisKey) && redisFlag) {//开启缓存
String str = (String) redisUtil.get(redisKey);
if (Func.isNotEmpty(str)) {
return str;
}
}
String itemValue = mjkjBaseSqlMapper.getSysDictItemValueByText(dictCode, itemText);
if (Func.isNotEmpty(itemValue) && redisFlag) {
redisUtil.set(redisKey, itemValue, 30L);//30秒
}
return itemValue;
}
//将表数据封装为map
@Override
public Map<String, Map<String, Object>> getData2Map(String tableName, String key, Boolean redisFlag) {
String redisKey = "MJKJBASE_DATA2MAP:tableName_" + tableName + ":key_" + key;
if (redisUtil.hasKey(redisKey) && redisFlag) {//开启缓存
Map<String, Map<String, Object>> resultMap = (Map<String, Map<String, Object>>) redisUtil.get(redisKey);
if (Func.isNotEmpty(resultMap)) {
return resultMap;
}
}
List<Map<String, Object>> dataList = mjkjBaseSqlMapper.getDataByTable(this.getSelectField(), tableName);
Map<String, Map<String, Object>> resultMap = new HashMap<>();
if (Func.isNotEmpty(dataList)) {
dataList.forEach(map -> {
resultMap.put(Func.toStr(map.get(key)), map);
});
}
if (Func.isNotEmpty(resultMap) && redisFlag) {//写入缓存
redisUtil.set(redisKey, resultMap, 30L);//30秒
}
return resultMap;
}
//初始化默认值
private Map<String, Object> initMap(Map<String, Object> map) {
if (Func.isEmpty(map)) {
map = new LinkedHashMap<>();
}
Object id = map.get("id");
if (Func.isEmpty(id)) {
map.put("id", IdWorker.getId());
}
/*if (Func.isEmpty(MjkjUtils.getMap2Str(map, "status"))) {
map.put("status", 1);
}*/
String is_deleted = MjkjUtils.getMap2Str(map, "is_deleted");
if (Func.isEmpty(is_deleted)) {
map.put("is_deleted", "0");
}
map.put("create_time", DateUtil.now());
if (Func.isNotEmpty(map.get("tenant_id"))) {
map.put("tenant_id", MjkjUtils.getMap2Str(map, "tenant_id"));
}
BladeUser user = AuthUtil.getUser();
if (Func.isNotEmpty(user)) {
String tenantId = user.getTenantId();
Long userId = user.getUserId();
String deptId = Func.toStrList(user.getDeptId()).get(0);
if (Func.isEmpty(map.get("tenant_id"))) {
map.put("tenant_id", tenantId);
}
if (Func.isEmpty(map.get("create_user"))) {
map.put("create_user", userId);
}
if (Func.isEmpty(map.get("create_dept"))) {
map.put("create_dept", deptId);
}
} else {
if (Func.isNotEmpty(map.get("create_dept"))) {
String deptId = MjkjUtils.getMap2Str(map, "create_dept");
deptId = Func.toStrList(deptId).get(0);
map.put("create_dept", deptId);
}
}
return map;
}
//单个新增
@Override
public Long baseInsertData(String tableName, Map<String, Object> map) {
map = this.initMap(map);
String feildSql = "";
String dataSql = "";
for (Map.Entry<String, Object> entry : map.entrySet()) {
String field = entry.getKey();
Object value = entry.getValue();
feildSql += field + ",";
dataSql += DataTypeUtil.getSql(field, value) + ",";
}
if (feildSql.endsWith(",")) {
feildSql = feildSql.substring(0, feildSql.length() - 1);
dataSql = dataSql.substring(0, dataSql.length() - 1);
}
String sql = "insert into " + tableName + "(" + feildSql + ") values (" + dataSql + ")";
map.put("select_sql", sql);
System.out.println(map.get(sql));
Long result = mjkjBaseSqlMapper.baseInsertSql(map);
return result;
}
//不对操作人进行封装
@Override
public Long baseSimpleIntegerSql(String tableName, Map<String, Object> dataMap) {
String feildSql = "";
String dataSql = "";
for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
String field = entry.getKey();
Object value = entry.getValue();
feildSql += field + ",";
dataSql += DataTypeUtil.getSql(field, value) + ",";
}
if (feildSql.endsWith(",")) {
feildSql = feildSql.substring(0, feildSql.length() - 1);
dataSql = dataSql.substring(0, dataSql.length() - 1);
}
String sql = "insert into " + tableName + "(" + feildSql + ") values (" + dataSql + ")";
dataMap.put("select_sql", sql);
Long result = mjkjBaseSqlMapper.baseInsertSql(dataMap);
return result;
}
//单个修改
@Override
public void baseUpdateData(String tableName, Map<String, Object> map, String id) {
map.put("update_time", DateUtil.now());
BladeUser user = AuthUtil.getUser();
if (Func.isNotEmpty(user)) {
Long userId = user.getUserId();
map.put("update_user", userId);
}
String updateSql = "update " + tableName + " set ";
for (Map.Entry<String, Object> entry : map.entrySet()) {
String field = entry.getKey();
Object value = entry.getValue();
if (Func.equals("id", field)) {
continue;
}
updateSql += field + " = " + DataTypeUtil.getSql(field, value) + ",";
}
if (updateSql.endsWith(",")) {
updateSql = updateSql.substring(0, updateSql.length() - 1);
}
String sql = updateSql + " where id ='" + id + "'";
map.put("select_sql", sql);
mjkjBaseSqlMapper.baseUpdateSql(map);
}
//单个修改
@Override
public void baseUpdateDataLong(String tableName, Map<String, Object> map, Long id) {
map.put("update_time", DateUtil.now());
BladeUser user = AuthUtil.getUser();
if (Func.isNotEmpty(user)) {
Long userId = user.getUserId();
map.put("update_user", userId);
}
String updateSql = "update " + tableName + " set ";
for (Map.Entry<String, Object> entry : map.entrySet()) {
String field = entry.getKey();
Object value = entry.getValue();
if (Func.equals("id", field)) {
continue;
}
updateSql += field + " = " + DataTypeUtil.getSql(field, value) + ",";
}
if (updateSql.endsWith(",")) {
updateSql = updateSql.substring(0, updateSql.length() - 1);
}
String sql = updateSql + " where id =" + id;
map.put("select_sql", sql);
mjkjBaseSqlMapper.baseUpdateSql(map);
}
//单个修改
@Override
public void baseUpdateDataWhere(String tableName, Map<String, Object> map, String whereCol, String whereVal) {
map.put("update_time", DateUtil.now());
BladeUser user = AuthUtil.getUser();
if (Func.isNotEmpty(user)) {
Long userId = user.getUserId();
map.put("update_user", userId);
}
String updateSql = "update " + tableName + " set ";
for (Map.Entry<String, Object> entry : map.entrySet()) {
String field = entry.getKey();
Object value = entry.getValue();
if (Func.equals("id", field)) {
continue;
}
updateSql += field + " = " + DataTypeUtil.getSql(field, value) + ",";
}
if (updateSql.endsWith(",")) {
updateSql = updateSql.substring(0, updateSql.length() - 1);
}
String sql = updateSql + " where " + whereCol + " = '" + whereVal + "'";
map.put("select_sql", sql);
mjkjBaseSqlMapper.baseUpdateSql(map);
}
@Override
public void baseUpdateDataTenantIgnore(String tableName, Map<String, Object> map, String id) {
this.baseUpdateData(tableName, map, id);
}
//公共删除
@Override
public Integer baseDeleteSqlStr(String tableName, String id) {
return mjkjBaseSqlMapper.baseDeleteSqlStr(tableName, id);
}
@Override
public Integer baseDeleteSql(String tableName, Long id) {
return mjkjBaseSqlMapper.baseDeleteSql(tableName, id);
}
//真实删除
@Override
public Integer baseRealDeleteSql(String tableName, Long id) {
return mjkjBaseSqlMapper.baseRealDeleteSql(tableName, id);
}
// 自定义公共删除
@Override
public Integer baseZdyDeleteSql(String tableName, String whereFieldName, Long id) {
return mjkjBaseSqlMapper.baseZdyDeleteSql(tableName, whereFieldName, id);
}
// 自定义公共删除 string
@Override
public Integer baseZdyDeleteSql(String tableName, String whereFieldName, String id) {
return mjkjBaseSqlMapper.baseZdyDeleteSql(tableName, whereFieldName, id);
}
@Override
public List<Long> getAdminIdList() {
return mjkjBaseSqlMapper.getAdminIdList();
}
//获取处理进度
@Override
public int getProcessingProgress(String tableName, String batchCode) {
return mjkjBaseSqlMapper.getProcessingProgress(tableName, batchCode);
}
//获取总处理进度
@Override
public int getProcessingProgressTotal(String tableName, String batchCode) {
return mjkjBaseSqlMapper.getProcessingProgressTotal(tableName, batchCode);
}
//获取授权
@Override
public List<Map<String, Object>> getBladeUserOauth(String uuid, String source) {
return mjkjBaseSqlMapper.getBladeUserOauth(uuid, source);
}
//获取授权
@Override
public List<Map<String, Object>> getBladeUserOauthByUserId(Long userId) {
return mjkjBaseSqlMapper.getBladeUserOauthByUserId(userId);
}
//解绑
@Override
public void unBindBladeUserOauth(Long id) {
mjkjBaseSqlMapper.unBindBladeUserOauth(id);
}
// 根据表属性获取所有数据 多条件
@Override
public <T> List<Map<String, T>> getDataListByFieldParams(String tableName, Wrapper<T> wrapper) {
if (Func.isEmpty(tableName)) {
return null;
}
return mjkjBaseSqlMapper.getDataListByWrapper(tableName, wrapper);
}
// 根据表属性获取所有数据 多条件
@Override
public <T> Map<String, T> getDataOneByFieldParams(String tableName, Wrapper<T> wrapper) {
if (Func.isEmpty(tableName)) {
return new HashMap<>();
}
List<Map<String, T>> dataMapList = mjkjBaseSqlMapper.getDataListByWrapper(tableName, wrapper);
if (Func.isEmpty(dataMapList)) {
return new HashMap<>();
}
return dataMapList.get(0);
}
// 根据表属性获取所有数据 多条件 分页
@Override
public <T> IPage<Map<String, T>> getDataIPageByFieldParams(String tableName, IPage page, Wrapper<T> wrapper) {
if (Func.isEmpty(tableName)) {
return null;
}
return mjkjBaseSqlMapper.getDataListByWrapper(tableName, page, wrapper);
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/MjkjBaseSqlServiceImpl.java | Java | apache-2.0 | 20,808 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.mjkj.common.cgform.entity.CgformButton;
import org.springblade.modules.mjkj.common.cgform.entity.CgformEnhanceJs;
import org.springblade.modules.mjkj.common.cgform.entity.CgformField;
import org.springblade.modules.mjkj.common.cgform.entity.CgformHead;
import org.springblade.modules.mjkj.common.cgform.model.*;
import org.springblade.modules.mjkj.common.cgform.service.*;
import org.springblade.modules.mjkj.common.config.util.ConvertUtils;
import org.springblade.modules.mjkj.common.config.util.EnhanceJsUtil;
import org.springblade.modules.mjkj.common.config.util.SqlSymbolUtil;
import org.springblade.modules.system.entity.BladeDept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 服务实现类
*
* @author BladeX
* @since 2021-05-20
*/
@Slf4j
@Service
public class OnlineServiceImpl implements IOnlineService {
@Autowired
private ICgformFieldService fieldService;
@Autowired
private ICgformButtonService buttonService;
@Autowired
private ICgformEnhanceJsService jsService;
@Autowired
private ISysDictService dictService;
@Override
public OnlineConfigModel queryOnlineConfig(CgformHead head) {
Long headId = head.getId();
List<String> hideColumns = new ArrayList<>();//隐藏树形列表 todo
List<OnlColumn> columns = new ArrayList<>();//列属性
Map<String, List<DictModel>> dictOptions = new HashMap<>();//字典
Map<String, List<BladeDept>> deptOptions = new HashMap<>();//部门列表
Map<String, List<BladeUser>> userOptions = new HashMap<>();//用户列表
List<HrefSlots> fieldHrefSlots = new ArrayList<>();//跳转列表
List<OnlForeignKey> foreignKeys = new ArrayList<>();
List<String> dbFieldNameList = new ArrayList<>();//属性名称列表
// 根据表单基本属性id获取表单额外属性集合
//处理属性
List<CgformField> onlCgformFields = this.getFields(headId);//属性列表
// 迭代器遍历字段属性集合
Iterator<CgformField> iterator = onlCgformFields.iterator();
while (iterator.hasNext()) {
// 获取对象
CgformField onlCgformField = iterator.next();
String dbFieldName = onlCgformField.getDbFieldName();//字段名称
String mainTable = onlCgformField.getMainTable();//外键主表名
String mainField = onlCgformField.getMainField();//外键主键字段
if (Func.isNotEmpty(mainField) && Func.isNotEmpty(mainTable)) {
// 创建外部键对象,封装字段名称/外主键字段名
OnlForeignKey onlForeignKey = new OnlForeignKey(dbFieldName, mainField);
// 封装到集合内
foreignKeys.add(onlForeignKey);
}
//列表是否显示0否 1是
if (!"id".equals(dbFieldName)
&& !dbFieldNameList.contains(dbFieldName)) {
OnlColumn onlColumn = new OnlColumn(onlCgformField.getDbFieldTxt(), dbFieldName, onlCgformField.getFieldLength());
String dictField = onlCgformField.getDictField();
String fieldShowType = onlCgformField.getFieldShowType();//表单控件类型
// 表单控件类型存在,且不为"popup"
if (Func.isNotEmpty(dictField) && !"popup".equals(fieldShowType)) {//Popup弹框
// 创建字典集合
List<DictModel> dictModelList = new ArrayList<>();
// 判断字段数据的字典表数据是否存在
if (Func.isNotEmpty(onlCgformField.getDictTable())) {
// 存在,根据字典表数据,字典表text/字典code查询表数据的字典
dictModelList = dictService.queryTableDictItemsByCode(onlCgformField.getDictTable(), onlCgformField.getDictText(), dictField);
} else if (Func.isNotEmpty(onlCgformField.getDictField())) {
dictModelList = dictService.queryDictItemsByCode(dictField);
}
dictOptions.put(dbFieldName, dictModelList);
onlColumn.setCustomRender(dbFieldName);
}
if (Func.equals(fieldShowType, "switch")) {//开关
List<DictModel> sysDictOption = SqlSymbolUtil.getYNDict(onlCgformField);
dictOptions.put(dbFieldName, sysDictOption);
onlColumn.setCustomRender(dbFieldName);
}
if (Func.equals(fieldShowType, "link_down")) {//联动组件
String dictTable = onlCgformField.getDictTable();
if (Func.isNotEmpty(dictTable)) {
CommonEntity commonEntity = JSONObject.parseObject(dictTable, CommonEntity.class);
List<DictModel> tableDictOption = dictService.queryTableDictItemsByCode(commonEntity.getTable(), commonEntity.getTxt(), commonEntity.getKey());
dictOptions.put(dbFieldName, tableDictOption);
onlColumn.setCustomRender(dbFieldName);
columns.add(onlColumn);
String linkField = commonEntity.getLinkField();
this.linkFieldArr(onlCgformFields, dbFieldNameList, columns, dbFieldName, linkField);
}
}
if (Func.equals(fieldShowType, "sel_tree")) {//自定义树控件
String dictText = onlCgformField.getDictText();
if(Func.isNotEmpty(dictText)){
String[] dictTexts = onlCgformField.getDictText().split(",");
List<DictModel> tableDictItems = dictService.queryTableDictItemsByCode(onlCgformField.getDictTable(), dictTexts[2], dictTexts[0]);
dictOptions.put(dbFieldName, tableDictItems);
onlColumn.setCustomRender(dbFieldName);
}
}
if ("cat_tree".equals(fieldShowType)) {//分类字典树
String dictTable = onlCgformField.getDictText();
if (Func.isNotEmpty(dictTable)) {
String dictCode = onlCgformField.getDictField();
Long idByCode = dictService.getIdByCode(dictCode);
String filterSql = "(id ="+idByCode+" or pstr like '" + idByCode + "#%" + "')";
//String filterSql = SqlSymbolUtil.getFilterSql(onlCgformField.getDictField());
List<DictModel> tableDictOption = dictService.queryFilterTableDictInfo("sys_category", "name", "id", filterSql);
dictOptions.put(dbFieldName, tableDictOption);
onlColumn.setCustomRender(dbFieldName);
} else {
onlColumn.setCustomRender("_replace_text_" + dictTable);
}
}
if ("sel_depart".equals(fieldShowType)) {//部门选择
List<BladeDept> bladeDeptList = new ArrayList<>();
deptOptions.put(dbFieldName, bladeDeptList);
onlColumn.setCustomRender(dbFieldName);
}
if ("sel_user".equals(onlCgformField.getFieldShowType())) {//用户选择
List<BladeUser> userList = new ArrayList<>();
userOptions.put(dbFieldName, userList);
onlColumn.setCustomRender(dbFieldName);
}
if (fieldShowType.indexOf(FieldSlotType.FILE) >= 0) {
onlColumn.setScopedSlots(new ScopedSlots("fileSlot"));
} else if (fieldShowType.indexOf(FieldSlotType.IMAGE) >= 0) {
onlColumn.setScopedSlots(new ScopedSlots("imgSlot"));
} else if (fieldShowType.indexOf(FieldSlotType.EDITOR) >= 0) {
onlColumn.setScopedSlots(new ScopedSlots("htmlSlot"));
} else if (fieldShowType.equals(FieldSlotType.DATE)) {
onlColumn.setScopedSlots(new ScopedSlots("dateSlot"));
} else if (fieldShowType.equals(FieldSlotType.PCA)) {
onlColumn.setScopedSlots(new ScopedSlots("pcaSlot"));
} else {
onlColumn.setScopedSlots(new ScopedSlots("formatSlot"));
}
//js增强
String jsEnhance = onlCgformField.getJsEnhance();
if (!Func.isEmpty(jsEnhance)) {
onlColumn.setJsEnhance(onlCgformField.getJsEnhance());
}
if (Func.isNotBlank(onlCgformField.getFieldHref())) {
String dictTable = "fieldHref_" + dbFieldName;
onlColumn.setHrefSlotName(dictTable);
fieldHrefSlots.add(new HrefSlots(dictTable, onlCgformField.getFieldHref()));
}
if ("1".equals(onlCgformField.getSortFlag())) {//是否支持排序1是0否
onlColumn.setSorter(true);
}
if (!"link_down".equals(fieldShowType)) {
columns.add(onlColumn);
}
}
}
OnlineConfigModel onlineConfigModel = new OnlineConfigModel();
onlineConfigModel.setHeadId(headId);
onlineConfigModel.setTableType(head.getTableType());
onlineConfigModel.setFormTemplate(head.getFormTemplate());
onlineConfigModel.setDescription(head.getTableTxt());
onlineConfigModel.setCurrentTableName(head.getTableName());
onlineConfigModel.setPaginationFlag(head.getIsPage());
onlineConfigModel.setCheckboxFlag(head.getIsCheckbox());
onlineConfigModel.setScrollFlag(head.getScroll());
onlineConfigModel.setColumns(columns);
onlineConfigModel.setDictOptions(dictOptions);
onlineConfigModel.setDeptOptions(deptOptions);
onlineConfigModel.setUserOptions(userOptions);
onlineConfigModel.setFieldHrefSlots(fieldHrefSlots);
onlineConfigModel.setForeignKeys(foreignKeys);
onlineConfigModel.setHideColumns(hideColumns);
List<CgformButton> buttonList = buttonService.queryButtonList(headId, true);
List<CgformButton> showButtonList = new ArrayList<>();
Iterator<CgformButton> it = buttonList.iterator();
while (it.hasNext()) {
CgformButton button = it.next();
if (!hideColumns.contains(button.getButtonCode())) {
showButtonList.add(button);
}
}
onlineConfigModel.setCgButtonList(showButtonList);
CgformEnhanceJs enhanceJs = jsService.queryEnhanceJs(headId, "list");
if (enhanceJs != null && Func.isNotEmpty(enhanceJs.getCgJs())) {
String mainField = EnhanceJsUtil.getJsFunction(enhanceJs.getCgJs(), buttonList);
onlineConfigModel.setEnhanceJs(mainField);
}
CgformEnhanceJs enhanceJsApp = jsService.queryEnhanceJs(headId, "appList");
if (enhanceJsApp != null && Func.isNotEmpty(enhanceJsApp.getCgJs())) {
String mainField = EnhanceJsUtil.getJsFunction(enhanceJsApp.getCgJs(), buttonList);
onlineConfigModel.setEnhanceJsApp(mainField);
}
if ("Y".equals(head.getIsTree())) {//树结构
onlineConfigModel.setPidField(head.getTreeParentIdField());
onlineConfigModel.setHasChildrenField(head.getTreeIdField());
onlineConfigModel.setTextField(head.getTreeFieldname());
}
return onlineConfigModel;
}
@Override
public JSONObject queryOnlineFormObj(CgformHead head, CgformEnhanceJs onlCgformEnhanceJs) {
JSONObject result = new JSONObject();
//获取要显示的字段
List<CgformField> availableFields = fieldService.queryAvailableFields(head.getId(), head.getTableName(), (String) null, false);
List<String> disabledFields = new ArrayList<>();//获取要隐藏的字段 todo 权限 this.onlCgformFieldService.queryDisabledFields(head.getTableName());
EnhanceJsUtil.enhanceJs(onlCgformEnhanceJs, head.getTableName(), availableFields);//js增强
FieldModel fieldModel = null;
if ("Y".equals(head.getIsTree())) {//树形结构
fieldModel = new FieldModel();
fieldModel.setCodeField("id");
fieldModel.setFieldName(head.getTreeParentIdField());
fieldModel.setPidField(head.getTreeParentIdField());
fieldModel.setPidValue("0");
fieldModel.setHsaChildField(head.getTreeIdField());
fieldModel.setTableName(SqlSymbolUtil.getSubstring(head.getTableName()));
fieldModel.setTextField(head.getTreeFieldname());
}
JSONObject filedJson = SqlSymbolUtil.getFiledJson(availableFields, disabledFields, fieldModel);
filedJson.put("table", head.getTableName());
result.put("schema", filedJson);
result.put("head", head);
List<CgformButton> buttons = this.buttonService.queryButtonList(head.getId(), false);
if (buttons != null && buttons.size() > 0) {
result.put("cgButtonList", buttons);
}
if (onlCgformEnhanceJs != null && ConvertUtils.isNotEmpty(onlCgformEnhanceJs.getCgJs())) {
String cgJs = EnhanceJsUtil.getCgJs(onlCgformEnhanceJs.getCgJs(), buttons);
onlCgformEnhanceJs.setCgJs(cgJs);
result.put("enhanceJs", EnhanceJsUtil.getCgJs(onlCgformEnhanceJs.getCgJs()));
}
return result;
}
@Override
public JSONObject queryOnlineFormObj(CgformHead head) {
CgformEnhanceJs js = jsService.queryEnhanceJs(head.getId(), "form");
return this.queryOnlineFormObj(head, js);
}
private List<CgformField> getFields(Long headId) {
LambdaQueryWrapper<CgformField> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CgformField::getCgformHeadId, headId);
lambdaQueryWrapper.orderByAsc(CgformField::getOrderNum);
return fieldService.list(lambdaQueryWrapper);
}
private void linkFieldArr(List<CgformField> onlCgformFields, List<String> dbFieldNameList, List<OnlColumn> onlColumns, String render, String linkFields) {
if (ConvertUtils.isEmpty(linkFields)) {
return;
}
String[] linkFieldArr = linkFields.split(",");
for (int i = 0; i < linkFieldArr.length; ++i) {
String linkField = linkFieldArr[i];
Iterator<CgformField> iterator = onlCgformFields.iterator();
while (iterator.hasNext()) {
CgformField onlCgformField = iterator.next();
String dbFieldName = onlCgformField.getDbFieldName();
if (1 == onlCgformField.getIsShowList() && linkField.equals(dbFieldName)) {
dbFieldNameList.add(linkField);
OnlColumn onlColumn = new OnlColumn(onlCgformField.getDbFieldTxt(), dbFieldName, onlCgformField.getFieldLength());
onlColumn.setCustomRender(render);
onlColumns.add(onlColumn);
break;
}
}
}
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/OnlineServiceImpl.java | Java | apache-2.0 | 16,479 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import org.springblade.modules.mjkj.common.cgform.entity.SysDictItem;
import org.springblade.modules.mjkj.common.cgform.mapper.SysDictItemMapper;
import org.springblade.modules.mjkj.common.cgform.model.DictModel;
import org.springblade.modules.mjkj.common.cgform.service.ISysDictItemService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 数据字典 服务实现类
*
* @author BladeX
* @since 2021-05-27
*/
@Service
public class SysDictItemServiceImpl extends BaseServiceImpl<SysDictItemMapper, SysDictItem> implements ISysDictItemService {
/**
* 通过查询指定code 获取字典
* @param code
* @return
*/
@Override
public List<DictModel> queryDictItemsByCode(String code) {
return baseMapper.queryDictItemsByCode(code);
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/SysDictItemServiceImpl.java | Java | apache-2.0 | 1,764 |
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.mjkj.common.cgform.service.impl;
import org.springblade.modules.mjkj.common.cgform.entity.SysDict;
import org.springblade.modules.mjkj.common.cgform.mapper.SysDictMapper;
import org.springblade.modules.mjkj.common.cgform.model.DictModel;
import org.springblade.modules.mjkj.common.cgform.model.DuplicateCheckVo;
import org.springblade.modules.mjkj.common.cgform.model.TreeSelectModel;
import org.springblade.modules.mjkj.common.cgform.model.query.QueryGenerator;
import org.springblade.modules.mjkj.common.cgform.service.ISysDictService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 数据字典 服务实现类
*
* @author BladeX
* @since 2021-05-27
*/
@Service
public class SysDictServiceImpl extends BaseServiceImpl<SysDictMapper, SysDict> implements ISysDictService {
@Override
public List<DictModel> queryTableDictItemsByCode(String table, String text, String code) {
if(table.indexOf("#{")>=0){
table = QueryGenerator.getSqlRuleValue(table);
}
return baseMapper.queryTableDictItemsByCode(table, text, code);
}
@Override
public List<DictModel> queryDictItemsByCode(String code) {
return baseMapper.queryDictItemsByCode(code);
}
@Override
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql) {
return baseMapper.queryTableDictItemsByCodeAndFilter(table,text,code,filterSql);
}
@Override
public List<TreeSelectModel> queryTreeList(Map<String, String> query, String table, String text, String code, String pidField, String pid, String hasChildField) {
return baseMapper.queryTreeList(query,table, text, code, pidField, pid,hasChildField);
}
/**
* 通过查询指定table的 text code 获取字典,包含text和value
* dictTableCache采用redis缓存有效期10分钟
* @param table
* @param text
* @param code
* @param keys (逗号分隔)
* @return
*/
@Override
public List<String> queryTableDictByKeys(String table, String text, String code, String keys) {
if(Func.isEmpty(keys)){
return null;
}
String[] keyArray = keys.split(",");
List<DictModel> dictsList = baseMapper.queryTableDictByKeys(table, text, code, keyArray);
List<String> resultList = new ArrayList<>(dictsList.size());
// 查询出来的顺序可能是乱的,需要排个序
for (String key : keyArray) {
for (DictModel dict : dictsList) {
if (key.equals(dict.getValue())) {
resultList.add(dict.getText());
break;
}
}
}
return resultList;
}
@Override
public Long getIdByCode(String code){
return baseMapper.getIdByCode(code);
}
@Override
public List<DictModel> queryTableDictItemsByCodeAndFilter(String table, String text, String code, String filterSql) {
return baseMapper.queryTableDictItemsByCodeAndFilter(table,text,code,filterSql);
}
/**
* 通过关键字查询字典表
* @param table
* @param text
* @param code
* @param keyword
* @return
*/
@Deprecated
public List<DictModel> queryTableDictItems(String table, String text, String code,String keyword){
return baseMapper.queryTableDictItems(table,text,code,"%"+keyword+"%");
}
public Long duplicateCheckCountSql(DuplicateCheckVo duplicateCheckVo){
return baseMapper.duplicateCheckCountSql(duplicateCheckVo);
}
public Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo){
return baseMapper.duplicateCheckCountSqlNoDataId(duplicateCheckVo);
}
@Override
public List<Map<String,Object>> getAllTenantList(){
return baseMapper.getAllTenantList();
}
}
| 2301_78526554/springboot-openai-chatgpt | chatgpt-boot/src/main/java/org/springblade/modules/mjkj/common/cgform/service/impl/SysDictServiceImpl.java | Java | apache-2.0 | 4,890 |