Преглед изворни кода

canal集成、数据权限

4.0
yaoq пре 2 година
родитељ
комит
3bbcdf6522
19 измењених фајлова са 452 додато и 48 уклоњено
  1. +22
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/canal/FilePathConfig.java
  2. +5
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/common/BpmConst.java
  3. +47
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/common/BpmEnum.java
  4. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageTreeHandler.java
  5. +5
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginHelper.java
  6. +44
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/DataRightGroupHandler.java
  7. +43
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/IDataRightTreeFactory.java
  8. +21
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/IDataRightTreeWorker.java
  9. +56
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/impl/DeptDataRightTreeWork.java
  10. +55
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/impl/PartyDataRightTreeWork.java
  11. +2
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java
  12. +6
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java
  13. +6
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleHandler.java
  14. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java
  15. +1
    -0
      smtweb-framework/canal/client/src/main/java/cc/smtweb/system/canal/example/ClientInstance.java
  16. +10
    -0
      smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/common/AbstractFileWork.java
  17. +125
    -1
      smtweb-framework/canal/file/src/main/resources/config/field-mapping.json
  18. +0
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java
  19. +0
    -30
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java

+ 22
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/canal/FilePathConfig.java Прегледај датотеку

@@ -0,0 +1,22 @@
package cc.smtweb.system.bpm.web.canal;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
* @Author yaoq
* @Date 2022年07月20日 10:38
* @Description
*/
@Configuration
public class FilePathConfig {

@Value("${canal.file.path}")
private String path;

public String getPath() {
return path;
}
}



+ 5
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/common/BpmConst.java Прегледај датотеку

@@ -6,10 +6,11 @@ package cc.smtweb.system.bpm.web.common;
* @Desc: bpm模块的常量
*/
public interface BpmConst {

String DEF_PWD = "abc@123456"; //初始密码

interface DataRight {
public final static String CUR_VALUE = "_CURRENT";//本区划、本机构、本部门
public final static String ALL_DEPT = "_ALL_DEPT";//全部门权限
public final static int V_SELF = 0;//不含下级
public final static int V_INCLUDE_CHILDREN = 1;//含下级
public final static Long CUR_VALUE = 999L;//本机构,本部门
public final static Long ALL_DEPT = 998L;//全部门权限
}
}

+ 47
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/common/BpmEnum.java Прегледај датотеку

@@ -0,0 +1,47 @@
package cc.smtweb.system.bpm.web.common;

import cc.smtweb.framework.core.common.IntEnum;
import cc.smtweb.framework.core.common.StrEnum;

/**
* Created by Akmm at 2022/3/23 9:39
* 系统的一些枚举变量
*/
public interface BpmEnum {

// 权限类型
class MenuRightType extends StrEnum {
public static MenuFuncRight instance = new MenuFuncRight();
public static StrEnumBean DATA = instance.addEnum("data", "数据权限");
public static StrEnumBean FUNC = instance.addEnum("func", "功能权限");
public static StrEnumBean FIELD = instance.addEnum("field", "字段权限");
}

class MenuType extends IntEnum {
public static MenuType instance = new MenuType();
public static IntEnumBean DESIGN = instance.addEnum(0, "设计器页面");
public static IntEnumBean CUSTOM = instance.addEnum(1, "自定义页面");
public static IntEnumBean LINK = instance.addEnum(2, "外部链接");
}

// 功能权限枚举
class MenuFuncRight extends StrEnum {
public static MenuFuncRight instance = new MenuFuncRight();
public static StrEnumBean READ = instance.addEnum("read", "查看");
public static StrEnumBean WRITE = instance.addEnum("write", "修改");
}

class UserStatu extends IntEnum {
public static UserStatu instance = new UserStatu();
public static IntEnumBean NOACT = instance.addEnum(0, "未激活");
public static IntEnumBean NORMAL = instance.addEnum(1, "已激活");
public static IntEnumBean LOCK = instance.addEnum(2, "已锁定");
public static IntEnumBean STOP = instance.addEnum(9, "已停用");
}

class DataRightType extends StrEnum {
public static DataRightType instance = new DataRightType();
public static StrEnumBean PARTY = instance.addEnum("party", "机构权限");
public static StrEnumBean DEPT = instance.addEnum("dept", "部门权限");
}
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageTreeHandler.java Прегледај датотеку

@@ -21,7 +21,7 @@ import java.util.List;
public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> {
protected long pageId;
//过滤条件
private SwMap filter;
protected SwMap filter;
//对应的数据集定义
private PageDataset pageDataSet;



+ 5
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginHelper.java Прегледај датотеку

@@ -6,6 +6,8 @@ import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.common.BpmConst;
import cc.smtweb.system.bpm.web.common.BpmEnum;
import cc.smtweb.system.bpm.web.sys.user.user.User;
import cc.smtweb.system.bpm.web.sys.user.user.UserCache;
import cc.smtweb.system.bpm.web.sys.user.user.UserParty;
@@ -63,7 +65,7 @@ public class LoginHelper {
throw new BizException("账号或者密码出错");
}

if (SwEnum.UserStatu.NORMAL.value != user.getStatu()) {
if (BpmEnum.UserStatu.NORMAL.value != user.getStatu()) {
throw new BizException("账户状态异常");
}
}
@@ -130,7 +132,7 @@ public class LoginHelper {
// throw new BizException("账号或者密码出错");
// }
//
// if (SwEnum.UserStatu.NORMAL.value != user.getStatu()) {
// if (BpmEnum.UserStatu.NORMAL.value != user.getStatu()) {
// throw new BizException("账户状态异常");
// }
//
@@ -154,7 +156,7 @@ public class LoginHelper {
* @throws Exception
*/
public static void checkPwdLevel(String pwd) throws Exception {
if (SwConsts.DEF_PWD.equals(pwd)) return;
if (BpmConst.DEF_PWD.equals(pwd)) return;

}



+ 44
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/DataRightGroupHandler.java Прегледај датотеку

@@ -2,11 +2,16 @@ package cc.smtweb.system.bpm.web.sys.user.dataRightGroup;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageLoadHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageSaveHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageTreeHandler;
import cc.smtweb.system.bpm.web.sys.user.dataRight.DataRightDefine;
import cc.smtweb.system.bpm.web.sys.user.dataRight.DataRightDefineCache;

import java.util.List;
import java.util.Map;

/**
@@ -15,6 +20,7 @@ import java.util.Map;
* @Desc:
*/
public class DataRightGroupHandler {
private final static String drgValueTree = "drgValueTree";

static class DrgSaveHandler extends DynPageSaveHandler {

@@ -29,9 +35,47 @@ public class DataRightGroupHandler {
static class DrgLoadHandle extends DynPageLoadHandler {

@Override
public DynPageTreeHandler getTreeWorker(SwMap filter, PageDataset pageDataSet) {
if (pageDataSet.name.equals("drgValueTree")) {
return new DrgValueTreeHandler(form.getId(), filter, pageDataSet);
}
return super.getTreeWorker(filter, pageDataSet);
}

@Override
protected void afterLoadBean(PageDataset dataset, SwMap bean) {
super.afterLoadBean(dataset, bean);
bean.put("sdrg_content", JsonUtil.parseList(bean.readString("sdrg_content"), Map.class));
}
}

static class DrgValueTreeHandler extends DynPageTreeHandler {

public DrgValueTreeHandler(long pageId, SwMap filter, PageDataset pageDataSet) {
super(pageId, filter, pageDataSet);
}

@Override
protected List<SwMap> getChildren(long id) {
DataRightDefine define = DataRightDefineCache.getInstance().get(filter.readLong("type"));
if (define == null) return null;
IDataRightTreeWorker worker;
try {
worker = IDataRightTreeFactory.getInstance().getWork(define.getCode());
} catch (Exception e) {
throw new SwException(e);
}
return worker.getChildren(id);
}

@Override
protected long getId(SwMap bean) {
return bean.readLong("id");
}

@Override
protected String getText(SwMap bean) {
return bean.readString("text");
}
}
}

+ 43
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/IDataRightTreeFactory.java Прегледај датотеку

@@ -0,0 +1,43 @@
package cc.smtweb.system.bpm.web.sys.user.dataRightGroup;

import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.system.bpm.web.common.BpmEnum;
import cc.smtweb.system.bpm.web.sys.user.dataRightGroup.impl.DeptDataRightTreeWork;
import cc.smtweb.system.bpm.web.sys.user.dataRightGroup.impl.PartyDataRightTreeWork;

import java.util.HashMap;
import java.util.Map;

/**
* @Author yaoq
* @Date 2022年09月20日 9:26
* @Description
*/
public class IDataRightTreeFactory {

private volatile static IDataRightTreeFactory instance = null;

public static IDataRightTreeFactory getInstance() {
if (instance == null) {
synchronized (IDataRightTreeFactory.class) {
if (instance == null) instance = new IDataRightTreeFactory();
}
}
return instance;
}

private Map<String, Class<? extends IDataRightTreeWorker>> mapWorks;


private IDataRightTreeFactory() {
mapWorks = new HashMap<>();
mapWorks.put(BpmEnum.DataRightType.PARTY.value, PartyDataRightTreeWork.class);
mapWorks.put(BpmEnum.DataRightType.DEPT.value, DeptDataRightTreeWork.class);
}

public IDataRightTreeWorker getWork(String key) throws Exception {
Class<? extends IDataRightTreeWorker> cls = mapWorks.get(key);
if (cls == null) throw new SwException("暂不支持[" + key + "]类型权限!");
return cls.newInstance();
}
}

+ 21
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/IDataRightTreeWorker.java Прегледај датотеку

@@ -0,0 +1,21 @@
package cc.smtweb.system.bpm.web.sys.user.dataRightGroup;

import cc.smtweb.framework.core.common.SwMap;

import java.util.List;

/**
* Created by Akmm at 2016/9/13 11:52
* 数据权限类定义
*/
public interface IDataRightTreeWorker {

List<SwMap> getExtraValues();

SwMap buildExtraValue(long key, String value);

List<SwMap> getChildren(long id);

//获取值的显示文本
String getText(long value);
}

+ 56
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/impl/DeptDataRightTreeWork.java Прегледај датотеку

@@ -0,0 +1,56 @@
package cc.smtweb.system.bpm.web.sys.user.dataRightGroup.impl;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.web.common.BpmConst;
import cc.smtweb.system.bpm.web.sys.user.dataRightGroup.IDataRightTreeWorker;
import cc.smtweb.system.bpm.web.sys.user.dept.Dept;
import cc.smtweb.system.bpm.web.sys.user.dept.DeptCache;
import cc.smtweb.system.bpm.web.sys.user.party.PartyCache;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
* @Author yaoq
* @Date 2022年09月22日 15:48
* @Description
*/
public class DeptDataRightTreeWork implements IDataRightTreeWorker {

@Override
public SwMap buildExtraValue(long key, String value) {
SwMap swMap = new SwMap();
swMap.put("id", key);
swMap.put("text", value);
return swMap;
}

@Override
public List<SwMap> getExtraValues() {
List<SwMap> list = new ArrayList<>();
list.add(buildExtraValue(BpmConst.DataRight.ALL_DEPT, "所有部门"));
list.add(buildExtraValue(BpmConst.DataRight.CUR_VALUE, "所属部门"));
return list;
}

@Override
public List<SwMap> getChildren(long id) {
List<SwMap> list = new ArrayList<>();
list.addAll(getExtraValues());
Collection<Dept> depts = DeptCache.getInstance().getAll();
if (CommUtil.isEmpty(depts)) return list;
depts.forEach(dept -> {
list.add(buildExtraValue(dept.getId(), dept.getName()));
});
return list;
}

@Override
public String getText(long value) {
if (BpmConst.DataRight.CUR_VALUE == value) return "所属部门";
if (BpmConst.DataRight.ALL_DEPT == value) return "所有部门";
return PartyCache.getInstance().getNameById(value);
}
}

+ 55
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/dataRightGroup/impl/PartyDataRightTreeWork.java Прегледај датотеку

@@ -0,0 +1,55 @@
package cc.smtweb.system.bpm.web.sys.user.dataRightGroup.impl;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.web.common.BpmConst;
import cc.smtweb.system.bpm.web.sys.user.dataRightGroup.IDataRightTreeWorker;
import cc.smtweb.system.bpm.web.sys.user.party.Party;
import cc.smtweb.system.bpm.web.sys.user.party.PartyCache;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
* @Author yaoq
* @Date 2022年09月22日 15:48
* @Description
*/
public class PartyDataRightTreeWork implements IDataRightTreeWorker {

@Override
public SwMap buildExtraValue(long key, String value) {
SwMap swMap = new SwMap();
swMap.put("id", key);
swMap.put("text", value);
return swMap;
}

@Override
public List<SwMap> getExtraValues() {
List<SwMap> list = new ArrayList<>();
list.add(buildExtraValue(BpmConst.DataRight.CUR_VALUE, "所属机构"));
return list;
}

@Override
public List<SwMap> getChildren(long id) {
long key = id;
if (key <= 0) key = -1;
Set<Party> partys = PartyCache.getInstance().getChildren(key);
List<SwMap> list = new ArrayList<>();
list.addAll(getExtraValues());
if (CommUtil.isEmpty(partys)) return list;
partys.forEach(party -> {
list.add(buildExtraValue(party.getId(), party.getName()));
});
return list;
}

@Override
public String getText(long value) {
if (BpmConst.DataRight.CUR_VALUE == value) return "所属机构";
return PartyCache.getInstance().getNameById(value);
}
}

+ 2
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java Прегледај датотеку

@@ -8,6 +8,7 @@ import cc.smtweb.framework.core.db.vo.ModelProject;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.common.BpmEnum;
import cc.smtweb.system.bpm.web.design.db.ModelCatalogTreeHelper;
import cc.smtweb.system.bpm.web.design.db.ModelProjectCache;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
@@ -223,7 +224,7 @@ public class MenuHandler {
protected void afterQuery(List<SwMap> listData) {
super.afterQuery(listData);
listData.forEach(row -> {
row.put("sm_type_text", SwEnum.MenuType.instance.getName(row.readInt("sm_type")));
row.put("sm_type_text", BpmEnum.MenuType.instance.getName(row.readInt("sm_type")));
});
}
}


+ 6
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java Прегледај датотеку

@@ -48,4 +48,10 @@ public class PartyCache extends AbstractEntityCache<Party> {
Set<Party> children = getChildren(key);
return CommUtil.isEmpty(children);
}

public final String getNameById(Long id) {
Party party = get(id);
if (party == null) return "";
return party.getName();
}
}

+ 6
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleHandler.java Прегледај датотеку

@@ -7,6 +7,7 @@ import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.common.BpmEnum;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormCache;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
@@ -83,7 +84,7 @@ public class RoleHandler {
right.setFunc(formData.readStringSet("func"));
right.setData(formData.readListMap("data"));
if (item.getMenu() > 0L)
right.setField(MenuCache.getInstance().get(item.getMenu()).getRightSet(SwEnum.MenuRightType.FIELD.value), formData.readStringSet("write"), formData.readStringSet("read"));
right.setField(MenuCache.getInstance().get(item.getMenu()).getRightSet(BpmEnum.MenuRightType.FIELD.value), formData.readStringSet("write"), formData.readStringSet("read"));
rc.saveItem(right);
}
role.setPrivilege(rc.toContentStr());
@@ -168,7 +169,7 @@ public class RoleHandler {
Menu menu = MenuCache.getInstance().get(item.getMenu());
if (menu == null) return SwListData.create(list, 0);
ModelForm mf = ModelFormCache.getInstance().get(menu.getPageId());
for (String f : menu.getRightSet(SwEnum.MenuRightType.FIELD.value)) {
for (String f : menu.getRightSet(BpmEnum.MenuRightType.FIELD.value)) {
String name = getFieldName(mf, f);
if (name == null) continue;
SwMap row = new SwMap();
@@ -202,11 +203,11 @@ public class RoleHandler {
if (item == null) return SwListData.create(list, 0);
Menu menu = MenuCache.getInstance().get(item.getMenu());
if (menu == null) return SwListData.create(list, 0);
for (String f : menu.getRightSet(SwEnum.MenuRightType.FUNC.value)) {
for (String f : menu.getRightSet(BpmEnum.MenuRightType.FUNC.value)) {
if (StringUtil.isEmpty(f)) continue;
SwMap row = new SwMap();
row.put("f_id", f);
row.put("f_name", SwEnum.MenuFuncRight.instance.getName(f));
row.put("f_name", BpmEnum.MenuFuncRight.instance.getName(f));
list.add(row);
}
return SwListData.create(list, 0);
@@ -238,7 +239,7 @@ public class RoleHandler {
RoleRightContent rc = new RoleRightContent(role.getPrivilege());
Map<String, Object> data = rc.getDataRight(item.getId());

for (String f : menu.getRightSet(SwEnum.MenuRightType.DATA.value)) {
for (String f : menu.getRightSet(BpmEnum.MenuRightType.DATA.value)) {
if (StringUtil.isEmpty(f)) continue;
SwMap row = new SwMap();
row.put("key", f);


+ 3
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java Прегледај датотеку

@@ -13,6 +13,7 @@ import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.common.BpmConst;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageDelHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler;
@@ -100,7 +101,7 @@ public class UserHandler {
}
if (bean.isNew()) {
((User) bean).setCreate(DateUtil.nowDateTimeLong());
((User) bean).setPwd(LoginHelper.encodePwd(bean.getEntityId(), SwConsts.DEF_PWD));
((User) bean).setPwd(LoginHelper.encodePwd(bean.getEntityId(), BpmConst.DEF_PWD));
}

Set<Long> up = UserPartyCache.getInstance().getIdByUser(bean.getEntityId());
@@ -224,7 +225,7 @@ public class UserHandler {
Set<Long> idList = params.readLongSet("ids");
Set<User> userList = UserCache.getInstance().getUserList(idList);
userList.forEach(user -> {
user.setPwd(LoginHelper.encodePwd(user.getId(), SwConsts.DEF_PWD));
user.setPwd(LoginHelper.encodePwd(user.getId(), BpmConst.DEF_PWD));
});
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override


+ 1
- 0
smtweb-framework/canal/client/src/main/java/cc/smtweb/system/canal/example/ClientInstance.java Прегледај датотеку

@@ -308,6 +308,7 @@ public class ClientInstance {
if (!path.endsWith("/")) {
path = path + "/";
}
path = path + "increment/";
File file = new File(path + "/" + DateUtil.toLongDateTimeString(null) + ".cf");
if (!file.getParentFile().exists()) { // 如果父目录不存在,创建父目录
file.getParentFile().mkdirs();


+ 10
- 0
smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/common/AbstractFileWork.java Прегледај датотеку

@@ -46,6 +46,7 @@ public abstract class AbstractFileWork {
if (!path.endsWith("/")) {
path = path + "/";
}
path = path + "increment/";
log.debug("[解析canal文件] path:" + path);
File dir = new File(path);
File[] fs = dir.listFiles(new FileFilter() {
@@ -175,11 +176,20 @@ public abstract class AbstractFileWork {
getDbEngine().update("delete from " + canalVO.getTableName() + " where " + canalVO.getIdField() + " = ? ", canalVO.getId());
}

/**
* @Author yaoq
* @Date j 9:55
* @Params sql
* @Return java.util.Map<java.lang.String, java.lang.String>
* @Description 解析mysql create 语句, 转换成 {filed,type} 格式
*/
protected Map<String, String> decodeCreateSql(String sql) {
Map<String, String> map = new HashMap<>();
String data = sql.substring(sql.indexOf("(") + 1, sql.lastIndexOf(")")).trim().replaceAll("`", "");
String[] rows = data.split(",");
for (String row : rows) {
//索引不管
if (row.contains("INDEX")) continue;
if (row.contains("PRIMARY KEY")) {
map.put(idField, row.substring(row.indexOf("(") + 1, row.lastIndexOf(")")));
continue;


+ 125
- 1
smtweb-framework/canal/file/src/main/resources/config/field-mapping.json Прегледај датотеку

@@ -1 +1,125 @@
[{"type":"kbsql","fields":[{"INT":"INT"},{"BIGINT":"BIGINT"},{"INTEGER":"INTEGER"},{"NUMERIC":"NUMERIC"},{"TINYINT":"TINYINT"},{"SMALLINT":"SMALLINT"},{"CHAR":"CHAR"},{"TEXT":"TEXT"},{"BLOB":"BLOB"},{"CLOB":"CLOB"},{"VARCHAR":"VARCHAR2"}]},{"type":"dmsql","fields":[{"INT":"INT"},{"BIGINT":"BIGINT"},{"INTEGER":"INTEGER"},{"NUMERIC":"NUMERIC"},{"TINYINT":"TINYINT"},{"SMALLINT":"SMALLINT"},{"CHAR":"CHAR"},{"TEXT":"TEXT"},{"BLOB":"BLOB"},{"CLOB":"CLOB"},{"VARCHAR":"VARCHAR2"}]},{"type":"oracle","fields":[{"INT":"INT"},{"BIGINT":"BIGINT"},{"INTEGER":"INTEGER"},{"NUMERIC":"NUMERIC"},{"TINYINT":"TINYINT"},{"SMALLINT":"SMALLINT"},{"CHAR":"CHAR"},{"TEXT":"VARCHAR2"},{"BLOB":"BLOB"},{"CLOB":"CLOB"},{"VARCHAR":"VARCHAR2"}]}]
[
{
"type": "kbsql",
"fields": [
{
"INT": "INT"
},
{
"BIGINT": "BIGINT"
},
{
"INTEGER": "INTEGER"
},
{
"NUMERIC": "NUMERIC"
},
{
"TINYINT": "TINYINT"
},
{
"SMALLINT": "SMALLINT"
},
{
"CHAR": "CHAR"
},
{
"TEXT": "TEXT"
},
{
"MEDIUMTEXT": "TEXT"
},
{
"BLOB": "BLOB"
},
{
"CLOB": "CLOB"
},
{
"VARCHAR": "VARCHAR2"
}
]
},
{
"type": "dmsql",
"fields": [
{
"INT": "INT"
},
{
"BIGINT": "BIGINT"
},
{
"INTEGER": "INTEGER"
},
{
"NUMERIC": "NUMERIC"
},
{
"TINYINT": "TINYINT"
},
{
"SMALLINT": "SMALLINT"
},
{
"CHAR": "CHAR"
},
{
"TEXT": "TEXT"
},
{
"MEDIUMTEXT": "TEXT"
},
{
"BLOB": "BLOB"
},
{
"CLOB": "CLOB"
},
{
"VARCHAR": "VARCHAR2"
}
]
},
{
"type": "oracle",
"fields": [
{
"INT": "INT"
},
{
"BIGINT": "BIGINT"
},
{
"INTEGER": "INTEGER"
},
{
"NUMERIC": "NUMERIC"
},
{
"TINYINT": "TINYINT"
},
{
"SMALLINT": "SMALLINT"
},
{
"CHAR": "CHAR"
},
{
"TEXT": "VARCHAR2"
},
{
"MEDIUMTEXT": "VARCHAR2"
},
{
"BLOB": "BLOB"
},
{
"CLOB": "CLOB"
},
{
"VARCHAR": "VARCHAR2"
}
]
}
]

+ 0
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java Прегледај датотеку

@@ -57,7 +57,6 @@ public interface SwConsts {
String TEXT_SUFFIX = "_text";
String NAME_ID = "id";

String DEF_PWD = "abc@123456"; //初始密码
String LOGIN_VERIFY_CODE = "_VERIFY_CODE";
String _LOGIN_USER_ID_IN_SESSION = "_LOGIN_USER_ID_IN_SESSION";



+ 0
- 30
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java Прегледај датотеку

@@ -355,36 +355,6 @@ public interface SwEnum {
public static StrEnumBean FLOW_LT_MS = instance.addEnum("FLOW_LT_MS", "左树-主子列表(含编辑卡片、工作流)");
}

// 权限类型
class MenuRightType extends StrEnum {
public static MenuFuncRight instance = new MenuFuncRight();
public static StrEnumBean DATA = instance.addEnum("data", "数据权限");
public static StrEnumBean FUNC = instance.addEnum("func", "功能权限");
public static StrEnumBean FIELD = instance.addEnum("field", "字段权限");
}

class MenuType extends IntEnum {
public static MenuType instance = new MenuType();
public static IntEnumBean DESIGN = instance.addEnum(0, "设计器页面");
public static IntEnumBean CUSTOM = instance.addEnum(1, "自定义页面");
public static IntEnumBean LINK = instance.addEnum(2, "外部链接");
}

// 功能权限枚举
class MenuFuncRight extends StrEnum {
public static MenuFuncRight instance = new MenuFuncRight();
public static StrEnumBean READ = instance.addEnum("read", "查看");
public static StrEnumBean WRITE = instance.addEnum("write", "修改");
}

class UserStatu extends IntEnum {
public static UserStatu instance = new UserStatu();
public static IntEnumBean NOACT = instance.addEnum(0, "未激活");
public static IntEnumBean NORMAL = instance.addEnum(1, "已激活");
public static IntEnumBean LOCK = instance.addEnum(2, "已锁定");
public static IntEnumBean STOP = instance.addEnum(9, "已停用");
}

// 用户等级
class UserLevel extends IntEnum {
public static UserLevel instance = new UserLevel();


Loading…
Откажи
Сачувај