Browse Source

open

master
pioneer 2 years ago
commit
2421153370
  1. 6
      README.md
  2. BIN
      lib/finekit-10.0-20220427.jar
  3. 33
      plugin.xml
  4. 53
      src/main/java/com/fr/plugin/cpic/config/CpicCustomConfig.java
  5. 18
      src/main/java/com/fr/plugin/cpic/config/CpicLifeCycleMonitor.java
  6. 31
      src/main/java/com/fr/plugin/cpic/db/CpicDBAccessProvider.java
  7. 74
      src/main/java/com/fr/plugin/cpic/db/bean/CpicEntryBean.java
  8. 96
      src/main/java/com/fr/plugin/cpic/db/bean/CpicHomeBean.java
  9. 84
      src/main/java/com/fr/plugin/cpic/db/bean/CpicUserBean.java
  10. 84
      src/main/java/com/fr/plugin/cpic/db/dao/CpicEntryDao.java
  11. 100
      src/main/java/com/fr/plugin/cpic/db/dao/CpicHomeDao.java
  12. 96
      src/main/java/com/fr/plugin/cpic/db/dao/CpicUserDao.java
  13. 71
      src/main/java/com/fr/plugin/cpic/db/entity/CpicEntryEntity.java
  14. 94
      src/main/java/com/fr/plugin/cpic/db/entity/CpicHomeEntity.java
  15. 82
      src/main/java/com/fr/plugin/cpic/db/entity/CpicUserEntity.java
  16. 116
      src/main/java/com/fr/plugin/cpic/db/service/CpicEntryService.java
  17. 177
      src/main/java/com/fr/plugin/cpic/db/service/CpicHomeService.java
  18. 135
      src/main/java/com/fr/plugin/cpic/db/service/CpicUserService.java
  19. 148
      src/main/java/com/fr/plugin/cpic/filter/EntryFilter.java
  20. 96
      src/main/java/com/fr/plugin/cpic/filter/LogoutFilter.java
  21. 83
      src/main/java/com/fr/plugin/cpic/filter/ResponseWrapper.java
  22. 13
      src/main/java/com/fr/plugin/cpic/recorder/FunctionRecoder.java
  23. 295
      src/main/java/com/fr/plugin/cpic/utils/ConvertUtil.java
  24. 88
      src/main/java/com/fr/plugin/cpic/utils/DateUtils.java
  25. 373
      src/main/java/com/fr/plugin/cpic/utils/IPWhiteListUtil.java
  26. 48
      src/main/java/com/fr/plugin/cpic/utils/PathUtil.java
  27. 83
      src/main/java/com/fr/plugin/cpic/utils/UrlUtils.java
  28. 22
      src/main/java/com/fr/plugin/cpic/web/CpicControllerRegisterProvider.java
  29. 50
      src/main/java/com/fr/plugin/cpic/web/CpicHomeOptionProvider.java
  30. 23
      src/main/java/com/fr/plugin/cpic/web/CpicWebResourceProvider.java
  31. 88
      src/main/java/com/fr/plugin/cpic/web/bean/TreeItemBean.java
  32. 52
      src/main/java/com/fr/plugin/cpic/web/bean/UserMenuBean.java
  33. 24
      src/main/java/com/fr/plugin/cpic/web/component/CpicHomeComponent.java
  34. 22
      src/main/java/com/fr/plugin/cpic/web/component/CpicThemeJsComponent.java
  35. 28
      src/main/java/com/fr/plugin/cpic/web/component/generator/CpicThemeJsGenerator.java
  36. 145
      src/main/java/com/fr/plugin/cpic/web/controller/CpicEntryController.java
  37. 119
      src/main/java/com/fr/plugin/cpic/web/controller/CpicHomeController.java
  38. 102
      src/main/java/com/fr/plugin/cpic/web/controller/CpicHomeIndexController.java
  39. 382
      src/main/java/com/fr/plugin/cpic/web/controller/CpicUserController.java
  40. 60
      src/main/java/com/fr/plugin/cpic/web/custom/CustomDecisionErrorInjectNode.java
  41. 131
      src/main/java/com/fr/plugin/cpic/web/custom/CustomDecisionSystemInjectNode.java
  42. 88
      src/main/java/com/fr/plugin/cpic/web/custom/CustomDecisionUserInjectNode.java
  43. 84
      src/main/resources/com/fr/plugin/cpic/web/html/error.html
  44. 570
      src/main/resources/com/fr/plugin/cpic/web/html/home.html
  45. 40
      src/main/resources/com/fr/plugin/cpic/web/html/resources/index.html
  46. 664
      src/main/resources/com/fr/plugin/cpic/web/html/user.html
  47. 46
      src/main/resources/com/fr/plugin/cpic/web/js/cpic_home.js
  48. 5821
      src/main/resources/com/fr/plugin/cpic/web/layui/css/layui.css
  49. 1
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/code.css
  50. 1
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/laydate/default/laydate.css
  51. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/icon-ext.png
  52. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/icon.png
  53. 914
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/layer.css
  54. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-0.gif
  55. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-1.gif
  56. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-2.gif
  57. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.eot
  58. 554
      src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.svg
  59. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.ttf
  60. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.woff
  61. BIN
      src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.woff2
  62. 2
      src/main/resources/com/fr/plugin/cpic/web/layui/jquery-3.6.0.min.js
  63. 7105
      src/main/resources/com/fr/plugin/cpic/web/layui/layui.js

6
README.md

@ -0,0 +1,6 @@
# open-JSD-9934
JSD-11642 做目录权限控制,通过不同的url过滤掉不同的目录结构。并且不同url单点过来的平台使用不同的主题样式\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。

BIN
lib/finekit-10.0-20220427.jar

Binary file not shown.

33
plugin.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin>
<id>com.fr.plugin.cpic.home</id>
<name><![CDATA[cpic-多门户配置]]></name>
<active>yes</active>
<version>1.1.4</version>
<env-version>11.0</env-version>
<jartime>2021-02-10</jartime>
<vendor>fr.open</vendor>
<main-package>com.fr.plugin</main-package>
<create-day>2022-12-21</create-day>
<description><![CDATA[2022-12-22 插件初始化]]>
</description>
<!-- 功能点 -->
<function-recorder class="com.fr.plugin.cpic.recorder.FunctionRecoder"/>
<!-- 生命周期 -->
<lifecycle-monitor class="com.fr.plugin.cpic.config.CpicLifeCycleMonitor"/>
<extra-core>
<!-- 注册Db自定义数据库-->
<DBAccessProvider class="com.fr.plugin.cpic.db.CpicDBAccessProvider"/>
</extra-core>
<extra-decision>
<!-- 拦截器 -->
<GlobalRequestFilterProvider class="com.fr.plugin.cpic.filter.EntryFilter"/>
<GlobalRequestFilterProvider class="com.fr.plugin.cpic.filter.LogoutFilter"/>
<!-- 新增管理菜单 -->
<SystemOptionProvider class="com.fr.plugin.cpic.web.CpicHomeOptionProvider"/>
<!-- 注册Spring的Controller -->
<ControllerRegisterProvider class="com.fr.plugin.cpic.web.CpicControllerRegisterProvider"/>
<!-- 注入JS(管理主页) -->
<WebResourceProvider class="com.fr.plugin.cpic.web.CpicWebResourceProvider"/>
</extra-decision>
</plugin>

53
src/main/java/com/fr/plugin/cpic/config/CpicCustomConfig.java

@ -0,0 +1,53 @@
package com.fr.plugin.cpic.config;
import com.fr.config.*;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
/**
* 插件参数配置
**/
@Visualization(category = "cpic-插件设置")
public class CpicCustomConfig extends DefaultConfiguration {
private static volatile CpicCustomConfig config = null;
public static CpicCustomConfig getInstance() {
if (config == null) {
config = ConfigContext.getConfigInstance(CpicCustomConfig.class);
}
return config;
}
// IP白名单
@Identifier(value = "ipWhiteValue", name = "IP白名单", description = "IP白名单,支持配置多个,用英文分号(;)分隔,示例:192.168.1.1;192.168.2.*;192.168.3.17-192.168.3.38", status = Status.SHOW)
private Conf<String> ipWhiteValue = Holders.simple("");
// 报表快照缓存地址
@Identifier(value = "cachePath", name = "报表快照缓存地址", description = "请输入绝对地址,示例:(windows)D:\\cache; (linux)/tmp/cache", status = Status.SHOW)
private Conf<String> cachePath = Holders.simple("");
public String getIpWhiteValue() {
return ipWhiteValue.get();
}
public void setIpWhiteValue(String ipWhiteValue) {
this.ipWhiteValue.set(ipWhiteValue);
}
public String getCachePath() {
return cachePath.get();
}
public void setCachePath(String cachePath) {
this.cachePath.set(cachePath);
}
@Override
public Object clone() throws CloneNotSupportedException {
CpicCustomConfig cloned = (CpicCustomConfig) super.clone();
cloned.ipWhiteValue = (Conf<String>) ipWhiteValue.clone();
cloned.cachePath = (Conf<String>) cachePath.clone();
return cloned;
}
}

18
src/main/java/com/fr/plugin/cpic/config/CpicLifeCycleMonitor.java

@ -0,0 +1,18 @@
package com.fr.plugin.cpic.config;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
public class CpicLifeCycleMonitor extends AbstractPluginLifecycleMonitor {
@Override
public void afterRun(PluginContext pluginContext) {
// 初始化自定义配置
CpicCustomConfig.getInstance();
}
@Override
public void beforeStop(PluginContext pluginContext) {
}
}

31
src/main/java/com/fr/plugin/cpic/db/CpicDBAccessProvider.java

@ -0,0 +1,31 @@
package com.fr.plugin.cpic.db;
import com.fr.db.fun.impl.AbstractDBAccessProvider;
import com.fr.plugin.cpic.db.dao.CpicEntryDao;
import com.fr.plugin.cpic.db.dao.CpicHomeDao;
import com.fr.plugin.cpic.db.dao.CpicUserDao;
import com.fr.stable.db.accessor.DBAccessor;
import com.fr.stable.db.dao.DAOProvider;
public class CpicDBAccessProvider extends AbstractDBAccessProvider {
private static DBAccessor accessor;
public static DBAccessor getAccessor() {
return accessor;
}
@Override
public DAOProvider[] registerDAO() {
return new DAOProvider[]{
CpicHomeDao.DAO,
CpicEntryDao.DAO,
CpicUserDao.DAO,
};
}
@Override
public void onDBAvailable(DBAccessor dbAccessor) {
accessor = dbAccessor;
}
}

74
src/main/java/com/fr/plugin/cpic/db/bean/CpicEntryBean.java

@ -0,0 +1,74 @@
package com.fr.plugin.cpic.db.bean;
public class CpicEntryBean {
public CpicEntryBean() {
}
private String id;
private String homeId;
private String homeName;
private String entryId;
private String entryName;
private String del;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getHomeId() {
return homeId;
}
public void setHomeId(String homeId) {
this.homeId = homeId;
}
public String getHomeName() {
return homeName;
}
public void setHomeName(String homeName) {
this.homeName = homeName;
}
public String getEntryId() {
return entryId;
}
public void setEntryId(String entryId) {
this.entryId = entryId;
}
public String getEntryName() {
return entryName;
}
public void setEntryName(String entryName) {
this.entryName = entryName;
}
public String getDel() {
return del;
}
public void setDel(String del) {
this.del = del;
}
@Override
public String toString() {
return "CpicEntryBean{" +
"id='" + id + '\'' +
", homeId='" + homeId + '\'' +
", homeName='" + homeName + '\'' +
", entryId='" + entryId + '\'' +
", entryName='" + entryName + '\'' +
", del='" + del + '\'' +
'}';
}
}

96
src/main/java/com/fr/plugin/cpic/db/bean/CpicHomeBean.java

@ -0,0 +1,96 @@
package com.fr.plugin.cpic.db.bean;
import java.util.Date;
public class CpicHomeBean {
public CpicHomeBean() {
}
private String id;
private String name;
private String themeId;
private String themeName;
private String path;
private String mhpath;
private String del;
private Date editDate;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getThemeId() {
return themeId;
}
public void setThemeId(String themeId) {
this.themeId = themeId;
}
public String getThemeName() {
return themeName;
}
public void setThemeName(String themeName) {
this.themeName = themeName;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getMhpath() {
return mhpath;
}
public void setMhpath(String mhpath) {
this.mhpath = mhpath;
}
public String getDel() {
return del;
}
public void setDel(String del) {
this.del = del;
}
public Date getEditDate() {
return editDate;
}
public void setEditDate(Date editDate) {
this.editDate = editDate;
}
@Override
public String toString() {
return "CpicHomeBean{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", themeId='" + themeId + '\'' +
", themeName='" + themeName + '\'' +
", path='" + path + '\'' +
", del='" + del + '\'' +
", editDate=" + editDate +
'}';
}
}

84
src/main/java/com/fr/plugin/cpic/db/bean/CpicUserBean.java

@ -0,0 +1,84 @@
package com.fr.plugin.cpic.db.bean;
public class CpicUserBean {
public CpicUserBean() {
}
private String id;
private String homeId;
private String homeName;
private String userId;
private String userAccount;
private String userName;
private String del;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getHomeId() {
return homeId;
}
public void setHomeId(String homeId) {
this.homeId = homeId;
}
public String getHomeName() {
return homeName;
}
public void setHomeName(String homeName) {
this.homeName = homeName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserAccount() {
return userAccount;
}
public void setUserAccount(String userAccount) {
this.userAccount = userAccount;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getDel() {
return del;
}
public void setDel(String del) {
this.del = del;
}
@Override
public String toString() {
return "CpicUserBean{" +
"id='" + id + '\'' +
", homeId='" + homeId + '\'' +
", homeName='" + homeName + '\'' +
", userId='" + userId + '\'' +
", userAccount='" + userAccount + '\'' +
", userName='" + userName + '\'' +
", del='" + del + '\'' +
'}';
}
}

84
src/main/java/com/fr/plugin/cpic/db/dao/CpicEntryDao.java

@ -0,0 +1,84 @@
package com.fr.plugin.cpic.db.dao;
import com.fanruan.api.util.StringKit;
import com.fr.plugin.cpic.db.entity.CpicEntryEntity;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CpicEntryDao extends BaseDAO<CpicEntryEntity> {
public CpicEntryDao(DAOSession daoSession) {
super(daoSession);
}
/**
* 如果重写了getEntityClass方法就可以不重写其他所有DAO<T>接口中的方法
* 推荐只重写getEntityClass方法保留原写法作为兼容
*
* @return
*/
@Override
protected Class<CpicEntryEntity> getEntityClass() {
return CpicEntryEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return CpicEntryEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return CpicEntryDao.class;
}
};
public CpicEntryEntity findById(String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.eq("id", id));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return findOne(condition);
}
public List<CpicEntryEntity> findEntryList(String homeId) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(homeId)) {
condition.addRestriction(RestrictionFactory.eq("homeId", homeId));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return find(condition);
}
public void realDel(String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.eq("id", id));
remove(condition);
}
}
public void logicDelByHomeId(String homeId) throws Exception {
Map<String, Object> updateParams = new HashMap<>();
updateParams.put("del", "1");
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(homeId)) {
condition.addRestriction(RestrictionFactory.eq("homeId", homeId));
update(updateParams, condition);
}
}
}

100
src/main/java/com/fr/plugin/cpic/db/dao/CpicHomeDao.java

@ -0,0 +1,100 @@
package com.fr.plugin.cpic.db.dao;
import com.fanruan.api.util.StringKit;
import com.fr.plugin.cpic.db.entity.CpicHomeEntity;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CpicHomeDao extends BaseDAO<CpicHomeEntity> {
public CpicHomeDao(DAOSession daoSession) {
super(daoSession);
}
/**
* 如果重写了getEntityClass方法就可以不重写其他所有DAO<T>接口中的方法
* 推荐只重写getEntityClass方法保留原写法作为兼容
*
* @return
*/
@Override
protected Class<CpicHomeEntity> getEntityClass() {
return CpicHomeEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return CpicHomeEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return CpicHomeDao.class;
}
};
public CpicHomeEntity findById(String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.eq("id", id));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return findOne(condition);
}
public CpicHomeEntity findByName(String name, String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.neq("id", id));
}
if (StringKit.isNotBlank(name)) {
condition.addRestriction(RestrictionFactory.eq("name", name));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return findOne(condition);
}
public CpicHomeEntity findByPath(String path, String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.neq("id", id));
}
if (StringKit.isNotBlank(path)) {
condition.addRestriction(RestrictionFactory.eq("path", path));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return findOne(condition);
}
public void logicDel(String id) throws Exception {
Map<String, Object> updateParams = new HashMap<>();
updateParams.put("del", "1");
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.eq("id", id));
update(updateParams, condition);
}
}
public List<CpicHomeEntity> findList() throws Exception {
QueryCondition condition = QueryFactory.create();
condition.addRestriction(RestrictionFactory.eq("del", "0"));
condition.addSort("editDate", true);
return find(condition);
}
}

96
src/main/java/com/fr/plugin/cpic/db/dao/CpicUserDao.java

@ -0,0 +1,96 @@
package com.fr.plugin.cpic.db.dao;
import com.fanruan.api.util.StringKit;
import com.fr.plugin.cpic.db.entity.CpicUserEntity;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CpicUserDao extends BaseDAO<CpicUserEntity> {
public CpicUserDao(DAOSession daoSession) {
super(daoSession);
}
/**
* 如果重写了getEntityClass方法就可以不重写其他所有DAO<T>接口中的方法
* 推荐只重写getEntityClass方法保留原写法作为兼容
*
* @return
*/
@Override
protected Class<CpicUserEntity> getEntityClass() {
return CpicUserEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return CpicUserEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return CpicUserDao.class;
}
};
public CpicUserEntity findById(String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.eq("id", id));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return findOne(condition);
}
public CpicUserEntity findHomeUserByUserId(String homeId, String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.eq("homeId", homeId));
condition.addRestriction(RestrictionFactory.eq("userId", id));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return findOne(condition);
}
public List<CpicUserEntity> findUserList(String homeId) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(homeId)) {
condition.addRestriction(RestrictionFactory.eq("homeId", homeId));
condition.addRestriction(RestrictionFactory.eq("del", "0"));
} else {
return null;
}
return find(condition);
}
public void realDel(String id) throws Exception {
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(id)) {
condition.addRestriction(RestrictionFactory.eq("id", id));
remove(condition);
}
}
public void logicDelByHomeId(String homeId) throws Exception {
Map<String, Object> updateParams = new HashMap<>();
updateParams.put("del", "1");
QueryCondition condition = QueryFactory.create();
if (StringKit.isNotBlank(homeId)) {
condition.addRestriction(RestrictionFactory.eq("homeId", homeId));
update(updateParams, condition);
}
}
}

71
src/main/java/com/fr/plugin/cpic/db/entity/CpicEntryEntity.java

@ -0,0 +1,71 @@
package com.fr.plugin.cpic.db.entity;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
@Entity
@Table(name = "fine_plugin_cpic_entry")
public class CpicEntryEntity extends BaseEntity {
private static final long serialVersionUID = -2004581862888013344L;
public CpicEntryEntity() {
}
@Column(name = "homeId", length = 255)
private String homeId;
@Column(name = "homeName", length = 255)
private String homeName;
@Column(name = "entryId", length = 255)
private String entryId;
@Column(name = "entryName", length = 255)
private String entryName;
@Column(name = "del", length = 255)
private String del;
public String getHomeId() {
return homeId;
}
public void setHomeId(String homeId) {
this.homeId = homeId;
}
public String getHomeName() {
return homeName;
}
public void setHomeName(String homeName) {
this.homeName = homeName;
}
public String getEntryId() {
return entryId;
}
public void setEntryId(String entryId) {
this.entryId = entryId;
}
public String getEntryName() {
return entryName;
}
public void setEntryName(String entryName) {
this.entryName = entryName;
}
public String getDel() {
return del;
}
public void setDel(String del) {
this.del = del;
}
}

94
src/main/java/com/fr/plugin/cpic/db/entity/CpicHomeEntity.java

@ -0,0 +1,94 @@
package com.fr.plugin.cpic.db.entity;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name = "fine_plugin_cpic_home")
public class CpicHomeEntity extends BaseEntity {
private static final long serialVersionUID = -638785764795126993L;
public CpicHomeEntity() {
}
@Column(name = "name", length = 255)
private String name;
@Column(name = "themeId", length = 255)
private String themeId;
@Column(name = "themeName", length = 255)
private String themeName;
@Column(name = "path", length = 255)
private String path;
@Column(name = "mhpath", length = 255)
private String mhpath;
@Column(name = "del", length = 255)
private String del;
@Column(name = "editDate")
private Date editDate;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getThemeId() {
return themeId;
}
public void setThemeId(String themeId) {
this.themeId = themeId;
}
public String getThemeName() {
return themeName;
}
public void setThemeName(String themeName) {
this.themeName = themeName;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getMhpath() {
return mhpath;
}
public void setMhpath(String mhpath) {
this.mhpath = mhpath;
}
public String getDel() {
return del;
}
public void setDel(String del) {
this.del = del;
}
public Date getEditDate() {
return editDate;
}
public void setEditDate(Date editDate) {
this.editDate = editDate;
}
}

82
src/main/java/com/fr/plugin/cpic/db/entity/CpicUserEntity.java

@ -0,0 +1,82 @@
package com.fr.plugin.cpic.db.entity;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
@Entity
@Table(name = "fine_plugin_cpic_user")
public class CpicUserEntity extends BaseEntity {
private static final long serialVersionUID = -2986626466229549903L;
public CpicUserEntity() {
}
@Column(name = "homeId", length = 255)
private String homeId;
@Column(name = "homeName", length = 255)
private String homeName;
@Column(name = "userId", length = 255)
private String userId;
@Column(name = "userAccount", length = 255)
private String userAccount;
@Column(name = "userName", length = 255)
private String userName;
@Column(name = "del", length = 255)
private String del;
public String getHomeId() {
return homeId;
}
public void setHomeId(String homeId) {
this.homeId = homeId;
}
public String getHomeName() {
return homeName;
}
public void setHomeName(String homeName) {
this.homeName = homeName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserAccount() {
return userAccount;
}
public void setUserAccount(String userAccount) {
this.userAccount = userAccount;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getDel() {
return del;
}
public void setDel(String del) {
this.del = del;
}
}

116
src/main/java/com/fr/plugin/cpic/db/service/CpicEntryService.java

@ -0,0 +1,116 @@
package com.fr.plugin.cpic.db.service;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.plugin.cpic.db.CpicDBAccessProvider;
import com.fr.plugin.cpic.db.bean.CpicEntryBean;
import com.fr.plugin.cpic.db.dao.CpicEntryDao;
import com.fr.plugin.cpic.db.dao.CpicHomeDao;
import com.fr.plugin.cpic.db.dao.CpicUserDao;
import com.fr.plugin.cpic.db.entity.CpicEntryEntity;
import com.fr.stable.core.UUID;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CpicEntryService {
/**
* 新增
*/
public static void saveOrUpdate(CpicEntryBean bean) {
try {
CpicDBAccessProvider.getAccessor().runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
CpicEntryEntity targetEntity = null;
// 尝试查询
if (bean.getId() != null && StringKit.isNotBlank(bean.getId())) {
targetEntity = context.getDAO(CpicEntryDao.class).findById(bean.getId());
}
if (targetEntity != null) {
// 更新
targetEntity.setHomeId(bean.getHomeId());
targetEntity.setHomeName(bean.getHomeName());
targetEntity.setEntryId(bean.getEntryId());
targetEntity.setEntryName(bean.getEntryName());
context.getDAO(CpicEntryDao.class).update(targetEntity);
} else {
// 新增
targetEntity = new CpicEntryEntity();
targetEntity.setId(UUID.randomUUID().toString().toLowerCase());
targetEntity.setHomeId(bean.getHomeId());
targetEntity.setHomeName(bean.getHomeName());
targetEntity.setEntryId(bean.getEntryId());
targetEntity.setEntryName(bean.getEntryName());
targetEntity.setDel("0");
context.getDAO(CpicEntryDao.class).add(targetEntity);
}
return true;
}
});
} catch (Exception e) {
LogKit.error("新增/更新失败:{}", e.getMessage());
}
}
/**
* 查询列表
*/
public static List<CpicEntryBean> findList(String homeId) {
try {
return CpicDBAccessProvider.getAccessor().runQueryAction(new DBAction<List<CpicEntryBean>>() {
@Override
public List<CpicEntryBean> run(DAOContext context) throws Exception {
List<CpicEntryEntity> items = context.getDAO(CpicEntryDao.class).findEntryList(homeId);
List<CpicEntryBean> result = new ArrayList<>();
for (CpicEntryEntity item : items) {
result.add(entityToBean(item));
}
return result;
}
});
} catch (Throwable e) {
LogKit.error("查询失败:{}", e.getMessage());
}
return Collections.emptyList();
}
/**
* 删除
*
* @return
*/
public static void realDel(String id) {
try {
CpicDBAccessProvider.getAccessor().runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
context.getDAO(CpicEntryDao.class).realDel(id);
return true;
}
});
} catch (Exception e) {
LogKit.error("删除失败:{}", e.getMessage());
}
}
public static CpicEntryBean entityToBean(CpicEntryEntity entity) {
if (null == entity) {
return null;
}
CpicEntryBean bean = new CpicEntryBean();
bean.setId(entity.getId());
bean.setHomeId(entity.getHomeId());
bean.setHomeName(entity.getHomeName());
bean.setEntryId(entity.getEntryId());
bean.setEntryName(entity.getEntryName());
bean.setDel(entity.getDel());
return bean;
}
}

177
src/main/java/com/fr/plugin/cpic/db/service/CpicHomeService.java

@ -0,0 +1,177 @@
package com.fr.plugin.cpic.db.service;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.plugin.cpic.db.CpicDBAccessProvider;
import com.fr.plugin.cpic.db.bean.CpicHomeBean;
import com.fr.plugin.cpic.db.dao.CpicEntryDao;
import com.fr.plugin.cpic.db.dao.CpicHomeDao;
import com.fr.plugin.cpic.db.dao.CpicUserDao;
import com.fr.plugin.cpic.db.entity.CpicHomeEntity;
import com.fr.stable.core.UUID;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
public class CpicHomeService {
/**
* 新增
*/
public static void saveOrUpdate(CpicHomeBean bean) {
try {
CpicDBAccessProvider.getAccessor().runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
CpicHomeEntity targetEntity = null;
// 尝试查询
if (bean.getId() != null && StringKit.isNotBlank(bean.getId())) {
targetEntity = context.getDAO(CpicHomeDao.class).findById(bean.getId());
}
if (targetEntity != null) {
// 更新
targetEntity.setName(bean.getName());
targetEntity.setThemeId(bean.getThemeId());
targetEntity.setThemeName(bean.getThemeName());
targetEntity.setPath(bean.getPath());
targetEntity.setMhpath(bean.getMhpath());
targetEntity.setEditDate(new Date());
context.getDAO(CpicHomeDao.class).update(targetEntity);
} else {
// 新增
targetEntity = new CpicHomeEntity();
targetEntity.setId(UUID.randomUUID().toString().toLowerCase());
targetEntity.setName(bean.getName());
targetEntity.setThemeId(bean.getThemeId());
targetEntity.setThemeName(bean.getThemeName());
targetEntity.setPath(bean.getPath());
targetEntity.setMhpath(bean.getMhpath());
targetEntity.setDel("0");
targetEntity.setEditDate(new Date());
context.getDAO(CpicHomeDao.class).add(targetEntity);
}
return true;
}
});
} catch (Exception e) {
LogKit.error("新增/更新失败:{}", e.getMessage());
}
}
/**
* 查询列表
*/
public static List<CpicHomeBean> findList() {
try {
return CpicDBAccessProvider.getAccessor().runQueryAction(new DBAction<List<CpicHomeBean>>() {
@Override
public List<CpicHomeBean> run(DAOContext context) throws Exception {
List<CpicHomeEntity> items = context.getDAO(CpicHomeDao.class).findList();
List<CpicHomeBean> result = new ArrayList<>();
for (CpicHomeEntity item : items) {
result.add(entityToBean(item));
}
return result;
}
});
} catch (Throwable e) {
LogKit.error("查询失败:{}", e.getMessage());
}
return Collections.emptyList();
}
/**
* 根据id查询
*/
public static CpicHomeBean findById(String id) {
try {
return CpicDBAccessProvider.getAccessor().runQueryAction(new DBAction<CpicHomeBean>() {
@Override
public CpicHomeBean run(DAOContext context) throws Exception {
CpicHomeEntity item = context.getDAO(CpicHomeDao.class).findById(id);
return entityToBean(item);
}
});
} catch (Throwable e) {
LogKit.error("查询失败:{}", e.getMessage());
}
return null;
}
/**
* 根据name查询
*/
public static CpicHomeBean findByName(String name, String id) {
try {
return CpicDBAccessProvider.getAccessor().runQueryAction(new DBAction<CpicHomeBean>() {
@Override
public CpicHomeBean run(DAOContext context) throws Exception {
CpicHomeEntity item = context.getDAO(CpicHomeDao.class).findByName(name, id);
return entityToBean(item);
}
});
} catch (Throwable e) {
LogKit.error("查询失败:{}", e.getMessage());
}
return null;
}
/**
* 根据path查询
*/
public static CpicHomeBean findByPath(String path, String id) {
try {
return CpicDBAccessProvider.getAccessor().runQueryAction(new DBAction<CpicHomeBean>() {
@Override
public CpicHomeBean run(DAOContext context) throws Exception {
CpicHomeEntity item = context.getDAO(CpicHomeDao.class).findByPath(path, id);
return entityToBean(item);
}
});
} catch (Throwable e) {
LogKit.error("查询失败:{}", e.getMessage());
}
return null;
}
/**
* 逻辑删除
*
* @return
*/
public static void logicDel(String id) {
try {
CpicDBAccessProvider.getAccessor().runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
context.getDAO(CpicHomeDao.class).logicDel(id);
context.getDAO(CpicEntryDao.class).logicDelByHomeId(id);
context.getDAO(CpicUserDao.class).logicDelByHomeId(id);
return true;
}
});
} catch (Exception e) {
LogKit.error("更新失败:{}", e.getMessage());
}
}
public static CpicHomeBean entityToBean(CpicHomeEntity entity) {
if (null == entity) {
return null;
}
CpicHomeBean bean = new CpicHomeBean();
bean.setId(entity.getId());
bean.setName(entity.getName());
bean.setThemeId(entity.getThemeId());
bean.setThemeName(entity.getThemeName());
bean.setPath(null == entity.getPath() ? "" : entity.getPath());
bean.setMhpath(null == entity.getMhpath() ? "" : entity.getMhpath());
return bean;
}
}

135
src/main/java/com/fr/plugin/cpic/db/service/CpicUserService.java

@ -0,0 +1,135 @@
package com.fr.plugin.cpic.db.service;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.plugin.cpic.db.CpicDBAccessProvider;
import com.fr.plugin.cpic.db.bean.CpicUserBean;
import com.fr.plugin.cpic.db.dao.CpicEntryDao;
import com.fr.plugin.cpic.db.dao.CpicUserDao;
import com.fr.plugin.cpic.db.entity.CpicUserEntity;
import com.fr.stable.core.UUID;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CpicUserService {
/**
* 新增
*/
public static void saveOrUpdate(CpicUserBean bean) {
try {
CpicDBAccessProvider.getAccessor().runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
CpicUserEntity targetEntity = null;
// 尝试查询
if (bean.getId() != null && StringKit.isNotBlank(bean.getId())) {
targetEntity = context.getDAO(CpicUserDao.class).findById(bean.getId());
}
if (targetEntity != null) {
// 更新
targetEntity.setHomeId(bean.getHomeId());
targetEntity.setHomeName(bean.getHomeName());
targetEntity.setUserId(bean.getUserId());
targetEntity.setUserName(bean.getUserName());
targetEntity.setUserAccount(bean.getUserAccount());
context.getDAO(CpicUserDao.class).update(targetEntity);
} else {
// 新增
targetEntity = new CpicUserEntity();
targetEntity.setId(UUID.randomUUID().toString().toLowerCase());
targetEntity.setHomeId(bean.getHomeId());
targetEntity.setHomeName(bean.getHomeName());
targetEntity.setUserId(bean.getUserId());
targetEntity.setUserName(bean.getUserName());
targetEntity.setUserAccount(bean.getUserAccount());
targetEntity.setDel("0");
context.getDAO(CpicUserDao.class).add(targetEntity);
}
return true;
}
});
} catch (Exception e) {
LogKit.error("新增/更新失败:{}", e.getMessage());
}
}
/**
* 查询用户
*/
public static CpicUserBean findHomeUserByUserId(String homeId, String userId) {
try {
return CpicDBAccessProvider.getAccessor().runQueryAction(new DBAction<CpicUserBean>() {
@Override
public CpicUserBean run(DAOContext context) throws Exception {
CpicUserEntity item = context.getDAO(CpicUserDao.class).findHomeUserByUserId(homeId, userId);
return entityToBean(item);
}
});
} catch (Throwable e) {
LogKit.error("查询失败:{}", e.getMessage());
}
return null;
}
/**
* 查询列表
*/
public static List<CpicUserBean> findList(String homeId) {
try {
return CpicDBAccessProvider.getAccessor().runQueryAction(new DBAction<List<CpicUserBean>>() {
@Override
public List<CpicUserBean> run(DAOContext context) throws Exception {
List<CpicUserEntity> items = context.getDAO(CpicUserDao.class).findUserList(homeId);
List<CpicUserBean> result = new ArrayList<>();
for (CpicUserEntity item : items) {
result.add(entityToBean(item));
}
return result;
}
});
} catch (Throwable e) {
LogKit.error("查询失败:{}", e.getMessage());
}
return Collections.emptyList();
}
/**
* 删除
*
* @return
*/
public static void realDel(String id) {
try {
CpicDBAccessProvider.getAccessor().runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
context.getDAO(CpicUserDao.class).realDel(id);
return true;
}
});
} catch (Exception e) {
LogKit.error("删除失败:{}", e.getMessage());
}
}
public static CpicUserBean entityToBean(CpicUserEntity entity) {
if (null == entity) {
return null;
}
CpicUserBean bean = new CpicUserBean();
bean.setId(entity.getId());
bean.setHomeId(entity.getHomeId());
bean.setHomeName(entity.getHomeName());
bean.setUserId(entity.getUserId());
bean.setUserName(entity.getUserName());
bean.setUserAccount(entity.getUserAccount());
return bean;
}
}

148
src/main/java/com/fr/plugin/cpic/filter/EntryFilter.java

@ -0,0 +1,148 @@
package com.fr.plugin.cpic.filter;
import com.fanruan.api.json.JSONKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.ServerConfig;
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider;
import com.fr.decision.webservice.bean.authority.PrivilegeDetailBean;
import com.fr.decision.webservice.bean.entry.DirectoryBean;
import com.fr.decision.webservice.bean.entry.EntryBean;
import com.fr.decision.webservice.v10.entry.EntryService;
import com.fr.plugin.cpic.db.bean.CpicEntryBean;
import com.fr.plugin.cpic.db.bean.CpicHomeBean;
import com.fr.plugin.cpic.db.service.CpicEntryService;
import com.fr.plugin.cpic.db.service.CpicHomeService;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.third.org.apache.commons.collections4.CollectionUtils;
import com.fr.web.utils.WebUtils;
import javax.servlet.FilterChain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.*;
/**
* 目录拦截器
*/
@FunctionRecorder(localeKey = "EntryFilter")
public class EntryFilter extends AbstractGlobalRequestFilterProvider {
@Override
public String filterName() {
return "EntryFilter";
}
@Override
public String[] urlPatterns() {
return new String[]{"/*"};
}
@Override
@ExecuteFunctionRecord
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain filterChain) {
try {
// 判断是否拦截
// String originalUrl = WebUtils.getOriginalURL(req);
String requestURI = req.getRequestURI();
if(!requestURI.endsWith("/v10/view/entry/tree") || !req.getMethod().equals("GET")){
filterChain.doFilter(req, res);
return;
}
// 判断请求来源
String referer = req.getHeader("Referer");
if (StringKit.isBlank(referer)) {
filterChain.doFilter(req, res);
return;
}
String[] refererSpArr = referer.split("/");
String h1 = "";
String h2 = "";
if (refererSpArr.length >= 2) {
h1 = refererSpArr[refererSpArr.length - 2];
h2 = refererSpArr[refererSpArr.length - 1];
if (StringKit.isBlank(h1) || !StringKit.equals("home", h1)) {
filterChain.doFilter(req, res);
return;
}
if (StringKit.isBlank(h2)) {
filterChain.doFilter(req, res);
return;
}
}
// 查询对应home的path是否存在
CpicHomeBean homeBean = CpicHomeService.findByPath(h2, "");
if (null == homeBean) {
filterChain.doFilter(req, res);
return;
}
// filterChain.doFilter(req, res);
// 当前门户配置的目录
List<CpicEntryBean> cpicEntryBeanList = CpicEntryService.findList(homeBean.getId());
LogKit.debug("门户目录: "+JSONKit.createJSONArray(cpicEntryBeanList).toString());
// 当前用户配置的目录
List<EntryBean> entryBeanList = EntryService.getInstance().getEntryTree(req);
LogKit.debug("用户目录: "+JSONKit.createJSONArray(entryBeanList).toString());
// 其中一个为空时交集一定为空,直接返回空
if (CollectionUtils.isEmpty(cpicEntryBeanList) || CollectionUtils.isEmpty(entryBeanList)) {
Map<String, Object> result = new HashMap<>();
result.put("data", Collections.EMPTY_LIST);
PrintWriter printer = res.getWriter();
printer.write(JSONKit.create(result).toString());
printer.flush();
printer.close();
}
// 取交集
List<EntryBean> resultList = new ArrayList<>();
for (EntryBean entry : entryBeanList) {
CpicEntryBean cpicEntryBean = cpicEntryBeanList.stream().filter(item -> item.getEntryId().equals(entry.getId())).findFirst().orElse(null);
if (null != cpicEntryBean) {
resultList.add(entry);
}
}
EntryBean root = entryBeanList.stream().filter(item -> "decision-directory-root".equals(item.getId())).findFirst().orElse(null);
if(null == root){
// 手动创建一个根目录
root = new DirectoryBean();
root.setId("decision-directory-root");
root.setText("Dec-Entry_Management");
root.setDeviceType(7);
root.setEntryType(3);
root.setSortIndex(0);
root.setIsParent(true);
root.setOpen(false);
root.setParentDeviceType(7);
List<PrivilegeDetailBean> privilegeDetailBeanList = new ArrayList<>();
PrivilegeDetailBean privilegeDetailBean = new PrivilegeDetailBean();
privilegeDetailBean.setPrivilegeType(1);
privilegeDetailBean.setPrivilegeValue(3);
root.setPrivilegeDetailBeanList(privilegeDetailBeanList);
}
resultList.add(root);
LogKit.debug("交集目录: "+JSONKit.createJSONArray(resultList).toString());
res.setContentType("text/html; charset="+ ServerConfig.getInstance().getServerCharset());
// 返回数据
Map<String, Object> result = new HashMap<>();
result.put("data", resultList);
PrintWriter printer = res.getWriter();
printer.write(JSONKit.create(result).toString());
printer.flush();
printer.close();
} catch (Exception e) {
LogKit.error(e.getMessage());
e.printStackTrace();
}
}
}

96
src/main/java/com/fr/plugin/cpic/filter/LogoutFilter.java

@ -0,0 +1,96 @@
package com.fr.plugin.cpic.filter;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider;
import com.fr.decision.webservice.v10.login.LoginService;
import com.fr.plugin.cpic.db.bean.CpicHomeBean;
import com.fr.plugin.cpic.db.service.CpicHomeService;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import javax.servlet.FilterChain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 登出拦截器
*/
@FunctionRecorder(localeKey = "LogoutFilter")
public class LogoutFilter extends AbstractGlobalRequestFilterProvider {
@Override
public String filterName() {
return "LogoutFilter";
}
@Override
public String[] urlPatterns() {
return new String[]{"/*"};
}
@Override
@ExecuteFunctionRecord
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain filterChain) {
try {
// 判断是否拦截
// String originalUrl = WebUtils.getOriginalURL(req);
String requestURI = req.getRequestURI();
if (!requestURI.endsWith("/logout") || !req.getMethod().equals("POST")) {
filterChain.doFilter(req, res);
return;
}
// 判断请求来源
String referer = req.getHeader("Referer");
if (StringKit.isBlank(referer)) {
filterChain.doFilter(req, res);
return;
}
String[] refererSpArr = referer.split("/");
String h1 = "";
String h2 = "";
if (refererSpArr.length >= 2) {
h1 = refererSpArr[refererSpArr.length - 2];
h2 = refererSpArr[refererSpArr.length - 1];
if (StringKit.isBlank(h1) || !StringKit.equals("home", h1)) {
filterChain.doFilter(req, res);
return;
}
if (StringKit.isBlank(h2)) {
filterChain.doFilter(req, res);
return;
}
}
// 查询对应home的path是否存在
CpicHomeBean homeBean = CpicHomeService.findByPath(h2, "");
if (null == homeBean) {
filterChain.doFilter(req, res);
return;
}
// 登出
LoginService.getInstance().logout(req, res);
// 跳转到门户首页
this.sendRedirect(res, referer);
return;
} catch (Exception e) {
LogKit.error(e.getMessage());
e.printStackTrace();
}
}
/**
* 重定向 1
*
* @param res
* @param url
*/
private void sendRedirect(HttpServletResponse res, String url) {
res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
res.setHeader("Location", url);
}
}

83
src/main/java/com/fr/plugin/cpic/filter/ResponseWrapper.java

@ -0,0 +1,83 @@
package com.fr.plugin.cpic.filter;
import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
public class ResponseWrapper extends HttpServletResponseWrapper {
private ByteArrayOutputStream bytes = new ByteArrayOutputStream();
;
private HttpServletResponse response;
private PrintWriter pwrite;
public ResponseWrapper(HttpServletResponse response) throws IOException {
super(response);
this.response = response;
}
@Override
public ServletOutputStream getOutputStream() throws IOException {
return new MyServletOutputStream(bytes);
}
/**
* 重写父类的 getWriter() 方法将响应数据缓存在 PrintWriter
*/
@Override
public PrintWriter getWriter() throws IOException {
pwrite = new PrintWriter(new OutputStreamWriter(bytes, StandardCharsets.UTF_8));
return pwrite;
}
/**
* 获取缓存在 PrintWriter 中的响应数据
*
* @return
*/
public byte[] getBytes() {
if (null != pwrite) {
pwrite.close();
return bytes.toByteArray();
}
if (null != bytes) {
try {
bytes.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
return bytes.toByteArray();
}
class MyServletOutputStream extends ServletOutputStream {
private ByteArrayOutputStream ostream;
public MyServletOutputStream(ByteArrayOutputStream ostream) {
this.ostream = ostream;
}
@Override
public void write(int b) throws IOException {
ostream.write(b); // 将数据写到 stream 
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setWriteListener(WriteListener writeListener) {
}
}
}

13
src/main/java/com/fr/plugin/cpic/recorder/FunctionRecoder.java

@ -0,0 +1,13 @@
package com.fr.plugin.cpic.recorder;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
@FunctionRecorder
public class FunctionRecoder {
@ExecuteFunctionRecord
public void exe() {
System.out.println("插件功能埋点");
}
}

295
src/main/java/com/fr/plugin/cpic/utils/ConvertUtil.java

@ -0,0 +1,295 @@
package com.fr.plugin.cpic.utils;
import com.fanruan.api.json.JSONKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.decision.authority.data.CustomRole;
import com.fr.decision.authority.data.Department;
import com.fr.decision.webservice.bean.entry.EntryBean;
import com.fr.json.JSONArray;
import com.fr.plugin.cpic.db.bean.CpicEntryBean;
import com.fr.plugin.cpic.web.bean.TreeItemBean;
import com.fr.plugin.cpic.web.bean.UserMenuBean;
import com.fr.third.org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ConvertUtil {
public static List<TreeItemBean> toTree(List<EntryBean> entryBeanList, List<CpicEntryBean> cpicEntryBeanList) {
// 转换
List<TreeItemBean> items = ConvertUtil.toTreeItems(entryBeanList, cpicEntryBeanList);
// 生成树
List<TreeItemBean> tree = ConvertUtil.toTreeItemBeanList(items);
return tree;
}
/**
* 目录列表转换为List<TreeItemBean>
*
* @param entryBeanList
* @return
*/
public static List<TreeItemBean> toTreeItems(List<EntryBean> entryBeanList, List<CpicEntryBean> cpicEntryBeanList) {
List<TreeItemBean> list = new ArrayList<>();
for (EntryBean entryBean : entryBeanList) {
TreeItemBean entry = ConvertUtil.toTreeItem(entryBean, cpicEntryBeanList);
if (null != entry) {
list.add(entry);
}
}
return list;
}
/**
* 转换为TreeItemBean同时设置是否选中
*
* @param entryBean
* @param cpicEntryBeanList
* @return
*/
public static TreeItemBean toTreeItem(EntryBean entryBean, List<CpicEntryBean> cpicEntryBeanList) {
TreeItemBean item = null;
if (entryBean != null) {
item = new TreeItemBean();
// 是否根目录
if ("decision-directory-root".equals(entryBean.getId())) {
item.setTitle("根目录");
item.setId(entryBean.getId());
item.setPid(StringKit.isBlank(entryBean.getpId()) ? "" : entryBean.getpId());
item.setField("");
item.setHref("");
item.setSpread(true);
item.setChecked(false);
item.setDisabled(true);
} else {
// 查询是否存在配置
// CpicEntryBean cpicEntryBean = cpicEntryBeanList.stream().filter(bean -> bean.getEntryId().equals(entryBean.getId())).findFirst().orElse(null);
item.setTitle(entryBean.getText());
item.setId(entryBean.getId());
item.setPid(StringKit.isBlank(entryBean.getpId()) ? "" : entryBean.getpId());
item.setField("");
item.setHref("");
item.setSpread(false);
item.setChecked(false);
// if (null == cpicEntryBean) {
// } else {
// item.setChecked(true);
// }
item.setDisabled(false);
}
}
return item;
}
// 返回构建好的树列表
public static List<TreeItemBean> toTreeItemBeanList(List<TreeItemBean> allTreeItemBeanList) {
// 获取所有根节点
List<TreeItemBean> treeList = new ArrayList<>();
List<String> rootCode = new ArrayList<>();
for (TreeItemBean treeItemBean : allTreeItemBeanList) {
if (rootCode.contains(treeItemBean.getId())) {
continue;
}
// 根据该节点查询根节点
TreeItemBean parent = ConvertUtil.getParentCode(allTreeItemBeanList, treeItemBean);
if (rootCode.contains(parent.getId())) {
continue;
}
treeList.add(parent);
rootCode.add(parent.getId());
}
// 根据所有根节点分别构建树
for (TreeItemBean parentItem : treeList) {
ConvertUtil.buildTree(allTreeItemBeanList, parentItem);
}
// 输出一下结果
JSONArray jsonArray = JSONKit.createJSONArray(treeList);
LogKit.debug(jsonArray.toString());
return treeList;
}
// 构建树
private static void buildTree(List<TreeItemBean> allTreeItemBeanList, TreeItemBean parentTreeItemBean) {
// 查询下级节点
List<TreeItemBean> childs = allTreeItemBeanList.stream().filter(item -> item.getPid().equals(parentTreeItemBean.getId())).collect(Collectors.toList());
// 下级节点继续构建
if (CollectionUtils.isNotEmpty(childs)) {
for (TreeItemBean treeItemBean : childs) {
ConvertUtil.buildTree(allTreeItemBeanList, treeItemBean);
}
}
parentTreeItemBean.setChildren(childs);
}
// 返回根节点
private static TreeItemBean getParentCode(List<TreeItemBean> allTreeItemBeanList, TreeItemBean treeItemBean) {
boolean haveNext = true;
List<TreeItemBean> parentTreeItemBeans;
TreeItemBean parentTreeItemBean = treeItemBean;
while (haveNext) {
TreeItemBean finalParentTreeItemBean = parentTreeItemBean;
parentTreeItemBeans = allTreeItemBeanList.stream().filter(item -> item.getId().equals(finalParentTreeItemBean.getPid())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(parentTreeItemBeans)) {
// 有父节点
parentTreeItemBean = parentTreeItemBeans.get(0);
} else {
haveNext = false;
}
}
return parentTreeItemBean;
}
/**
* 转换list
*
* @param tree
* @return
*/
public static List<CpicEntryBean> itemsToEntrys(List<TreeItemBean> tree) {
List<CpicEntryBean> result = new ArrayList<>();
CpicEntryBean entryBean;
for (TreeItemBean item : tree) {
if ("decision-directory-root".equals(item.getId())) {
continue;
}
entryBean = new CpicEntryBean();
entryBean.setEntryId(item.getId());
entryBean.setEntryName(item.getTitle());
result.add(entryBean);
}
return result;
}
/**
* tree转换为list
*
* @param tree
* @return
*/
public static List<CpicEntryBean> treeToList(List<TreeItemBean> tree) {
List<CpicEntryBean> result = new ArrayList<>();
for (TreeItemBean item : tree) {
ConvertUtil.buildList(result, item);
}
return result;
}
public static void buildList(List<CpicEntryBean> result, TreeItemBean treeBean) {
List<TreeItemBean> childrens = treeBean.getChildren();
if (CollectionUtils.isNotEmpty(childrens)) {
CpicEntryBean entryBean;
for (TreeItemBean item : childrens) {
ConvertUtil.buildList(result, item);
entryBean = new CpicEntryBean();
entryBean.setEntryId(item.getId());
entryBean.setEntryName(item.getTitle());
result.add(entryBean);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static List<UserMenuBean> deptListToMenuList(List<Department> departmentList) {
// 转换
List<UserMenuBean> list = new ArrayList<>();
UserMenuBean userMenuBean;
for (Department department : departmentList) {
userMenuBean = new UserMenuBean();
userMenuBean.setId(department.getId());
userMenuBean.setTitle(department.getName());
userMenuBean.setMtype("department");
userMenuBean.setPid(department.getParentId());
list.add(userMenuBean);
}
return list;
}
public static List<UserMenuBean> roleListToMenuList(List<CustomRole> departmentList) {
// 转换
List<UserMenuBean> list = new ArrayList<>();
UserMenuBean userMenuBean;
for (CustomRole department : departmentList) {
userMenuBean = new UserMenuBean();
userMenuBean.setId(department.getId());
userMenuBean.setTitle(department.getName());
userMenuBean.setMtype("customrole");
// userMenuBean.setPid(department.getParentId());
list.add(userMenuBean);
}
return list;
}
public static List<UserMenuBean> departmentListToTree(List<Department> departmentList) {
// 转换
List<UserMenuBean> list = ConvertUtil.deptListToMenuList(departmentList);
// 生成树
List<UserMenuBean> tree = ConvertUtil.departmentListToTreeItemBeanList(list);
return tree;
}
private static List<UserMenuBean> departmentListToTreeItemBeanList(List<UserMenuBean> userMenuBeanList) {
// 获取所有根节点
List<UserMenuBean> treeList = new ArrayList<>();
List<String> rootCode = new ArrayList<>();
for (UserMenuBean treeItemBean : userMenuBeanList) {
if (rootCode.contains(treeItemBean.getId())) {
continue;
}
// 根据该节点查询根节点
UserMenuBean parent = ConvertUtil.getParentCode2(userMenuBeanList, treeItemBean);
if (rootCode.contains(parent.getId())) {
continue;
}
treeList.add(parent);
rootCode.add(parent.getId());
}
// 根据所有根节点分别构建树
for (UserMenuBean parentItem : treeList) {
ConvertUtil.buildTree2(userMenuBeanList, parentItem);
}
return treeList;
}
// 返回根节点
private static UserMenuBean getParentCode2(List<UserMenuBean> allTreeItemBeanList, UserMenuBean treeItemBean) {
boolean haveNext = true;
List<UserMenuBean> parentTreeItemBeans;
UserMenuBean parentTreeItemBean = treeItemBean;
while (haveNext) {
UserMenuBean finalParentTreeItemBean = parentTreeItemBean;
parentTreeItemBeans = allTreeItemBeanList.stream().filter(item -> item.getId().equals(finalParentTreeItemBean.getPid())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(parentTreeItemBeans)) {
// 有父节点
parentTreeItemBean = parentTreeItemBeans.get(0);
} else {
haveNext = false;
}
}
return parentTreeItemBean;
}
// 构建树
private static void buildTree2(List<UserMenuBean> allTreeItemBeanList, UserMenuBean parentTreeItemBean) {
// 查询下级节点
List<UserMenuBean> childs = allTreeItemBeanList.stream().filter(item -> item.getPid().equals(parentTreeItemBean.getId())).collect(Collectors.toList());
// 下级节点继续构建
if (CollectionUtils.isNotEmpty(childs)) {
for (UserMenuBean treeItemBean : childs) {
ConvertUtil.buildTree2(allTreeItemBeanList, treeItemBean);
}
}
parentTreeItemBean.setChildren(childs);
}
}

88
src/main/java/com/fr/plugin/cpic/utils/DateUtils.java

@ -0,0 +1,88 @@
package com.fr.plugin.cpic.utils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
public class DateUtils {
/**
* 返回当前时间
*
* @return
*/
public static String getNowDateStr() {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDateTime date = LocalDateTime.now();
return date.format(df);
}
/**
* 返回1小时10分钟前时间
*
* @return
*/
public static String get1h10mDateStr() {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
LocalDateTime date = LocalDateTime.now();
date = date.minusHours(1).minusMinutes(10);
return date.format(df);
}
/**
* 返回昨天当前的时间
*
* @return
*/
public static String getYesterdayDateStr() {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
LocalDateTime date = LocalDateTime.now();
date = date.minusDays(1);
return date.format(df);
}
/**
* 返回N天当前的时间
*
* @return
*/
public static String getYesterdayDateStr(int daynum) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
LocalDateTime date = LocalDateTime.now();
date = date.minusDays(daynum);
return date.format(df);
}
/**
* 返回今天的DATE
*
* @return
*/
public static Date getNowDayDate() {
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(new Date());
Calendar calendar2 = Calendar.getInstance();
calendar2.set(Calendar.YEAR, calendar1.get(Calendar.YEAR));
calendar2.set(Calendar.MONTH, calendar1.get(Calendar.MONTH));
calendar2.set(Calendar.DATE, calendar1.get(Calendar.DATE));
return calendar2.getTime();
}
/**
* 返回一年后今天的DATE
*
* @return
*/
public static Date getYearDayDate() {
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(new Date());
Calendar calendar2 = Calendar.getInstance();
calendar2.set(Calendar.YEAR, calendar1.get(Calendar.YEAR) + 1);
calendar2.set(Calendar.MONTH, calendar1.get(Calendar.MONTH));
calendar2.set(Calendar.DATE, calendar1.get(Calendar.DATE));
return calendar2.getTime();
}
}

373
src/main/java/com/fr/plugin/cpic/utils/IPWhiteListUtil.java

@ -0,0 +1,373 @@
package com.fr.plugin.cpic.utils;
/**
* IP校验类的方法
*/
import com.fanruan.api.util.StringKit;
import com.fr.plugin.cpic.config.CpicCustomConfig;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
public class IPWhiteListUtil {
private static final String[] PROXYS = {"x-forwarded-for", "Proxy-Client-IP", "WL-Proxy-Client-IP", "X-Real-IP", "HTTP_CLIENT_IP"};
// IP的正则
private static Pattern pattern = Pattern
.compile("(1\\d{1,2}|2[0-4]\\d|25[0-5]|\\d{1,2})\\."
+ "(1\\d{1,2}|2[0-4]\\d|25[0-5]|\\d{1,2})\\."
+ "(1\\d{1,2}|2[0-4]\\d|25[0-5]|\\d{1,2})\\."
+ "(1\\d{1,2}|2[0-4]\\d|25[0-5]|\\d{1,2})");
/**
* getAvaliIpList:(根据IP白名单设置获取可用的IP列表).
*
* @return
*/
private static Set getAvaliIpList(String allowIp) {
Set<String> ipList = new HashSet();
for (String allow : allowIp.replaceAll("\\s", "").split(";")) {
if (allow.indexOf("*") > -1) {
String[] ips = allow.split("\\.");
String[] from = new String[]{"0", "0", "0", "0"};
String[] end = new String[]{"255", "255", "255", "255"};
List<String> tem = new ArrayList();
for (int i = 0; i < ips.length; i++)
if (ips[i].indexOf("*") > -1) {
tem = complete(ips[i]);
from[i] = null;
end[i] = null;
} else {
from[i] = ips[i];
end[i] = ips[i];
}
StringBuffer fromIP = new StringBuffer();
StringBuffer endIP = new StringBuffer();
for (int i = 0; i < 4; i++) {
if (from[i] != null) {
fromIP.append(from[i]).append(".");
endIP.append(end[i]).append(".");
} else {
fromIP.append("[*].");
endIP.append("[*].");
}
}
fromIP.deleteCharAt(fromIP.length() - 1);
endIP.deleteCharAt(endIP.length() - 1);
for (String s : tem) {
String ip = fromIP.toString().replace("[*]",
s.split(";")[0])
+ "-"
+ endIP.toString().replace("[*]", s.split(";")[1]);
if (validate(ip)) {
ipList.add(ip);
}
}
} else {
if (validate(allow)) {
ipList.add(allow);
}
}
}
return ipList;
}
private static Set getAvaliIpList(Set<String> ipSet) {
Set<String> ipList = new HashSet();
for (String allow : ipSet) {
if (allow.indexOf("*") > -1) {
String[] ips = allow.split("\\.");
String[] from = new String[]{"0", "0", "0", "0"};
String[] end = new String[]{"255", "255", "255", "255"};
List<String> tem = new ArrayList();
for (int i = 0; i < ips.length; i++)
if (ips[i].indexOf("*") > -1) {
tem = complete(ips[i]);
from[i] = null;
end[i] = null;
} else {
from[i] = ips[i];
end[i] = ips[i];
}
StringBuffer fromIP = new StringBuffer();
StringBuffer endIP = new StringBuffer();
for (int i = 0; i < 4; i++) {
if (from[i] != null) {
fromIP.append(from[i]).append(".");
endIP.append(end[i]).append(".");
} else {
fromIP.append("[*].");
endIP.append("[*].");
}
}
fromIP.deleteCharAt(fromIP.length() - 1);
endIP.deleteCharAt(endIP.length() - 1);
for (String s : tem) {
String ip = fromIP.toString().replace("[*]",
s.split(";")[0])
+ "-"
+ endIP.toString().replace("[*]", s.split(";")[1]);
if (validate(ip)) {
ipList.add(ip);
}
}
} else {
if (validate(allow)) {
ipList.add(allow);
}
}
}
return ipList;
}
/**
* 对单个IP节点进行范围限定
*
* @param arg
* @return 返回限定后的IP范围格式为List[10;19, 100;199]
*/
private static List complete(String arg) {
List com = new ArrayList();
if (arg.length() == 1) {
com.add("0;255");
} else if (arg.length() == 2) {
String s1 = complete(arg, 1);
if (s1 != null) {
com.add(s1);
}
String s2 = complete(arg, 2);
if (s2 != null) {
com.add(s2);
}
} else {
String s1 = complete(arg, 1);
if (s1 != null) {
com.add(s1);
}
}
return com;
}
private static String complete(String arg, int length) {
String from = "";
String end = "";
if (length == 1) {
from = arg.replace("*", "0");
end = arg.replace("*", "9");
} else {
from = arg.replace("*", "00");
end = arg.replace("*", "99");
}
if (Integer.valueOf(from) > 255) {
return null;
}
if (Integer.valueOf(end) > 255) {
end = "255";
}
return from + ";" + end;
}
/**
* 在添加至白名单时进行格式校验
*
* @param ip
* @return
*/
private static boolean validate(String ip) {
for (String s : ip.split("-")) {
if (!pattern.matcher(s).matches()) {
return false;
}
}
return true;
}
/**
* checkLoginIP:(根据IP,及可用Ip列表来判断ip是否包含在白名单之中).
*
* @param ip
* @param ipList
* @return
*/
private static boolean checkLoginIP(String ip, Set<String> ipList) {
if (ipList.contains(ip)) {
return true;
} else {
for (String allow : ipList) {
if (allow.indexOf("-") > -1) {
String[] from = allow.split("-")[0].split("\\.");
String[] end = allow.split("-")[1].split("\\.");
String[] tag = ip.split("\\.");
// 对IP从左到右进行逐段匹配
boolean check = true;
for (int i = 0; i < 4; i++) {
int s = Integer.valueOf(from[i]);
int t = Integer.valueOf(tag[i]);
int e = Integer.valueOf(end[i]);
if (!(s <= t && t <= e)) {
check = false;
break;
}
}
if (check) {
return true;
}
}
}
}
return false;
}
/**
* checkLoginIP:(根据IP地址及IP白名单设置规则判断IP是否包含在白名单).
*
* @param request
* @return
*/
public static boolean checkIpIsWhite(HttpServletRequest request) {
// 获取配置
CpicCustomConfig config = CpicCustomConfig.getInstance();
String ipWhiteValue = config.getIpWhiteValue();
if (StringKit.isBlank(ipWhiteValue)) {
return false;
}
// 获取当前请求IP
String ip = IPWhiteListUtil.getIpAddr(request);
// 获取白名单全部IP
Set ipList = getAvaliIpList(ipWhiteValue);
// 返回结果
return checkLoginIP(ip, ipList);
}
/**
* ip在ipList中则返回true
*
* @param ip
* @param ipList
* @return
*/
public static boolean checkIpList(String ip, List<String> ipList) {
Set<String> ipSet = new HashSet();
for (String ipStr : ipList) {
if (!ipStr.trim().startsWith("#")) {
ipSet.add(ipStr.trim());
}
}
ipSet = getAvaliIpList(ipSet);
return checkLoginIP(ip, ipSet);
}
/**
* 获取请求中的IP地址
*
* @param request
* @return
*/
public static String getIpAddr(HttpServletRequest request) {
String ipAddress = null;
try {
for (String proxy : PROXYS) {
ipAddress = request.getHeader(proxy);
if (StringKit.isNotBlank(ipAddress) && !"unknown".equalsIgnoreCase(ipAddress)) {
return ipAddress;
}
}
if (StringKit.isBlank(ipAddress) || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getRemoteAddr();
// if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) {
// // 根据网卡取本机配置的IP
// InetAddress inet = null;
// try {
// inet = InetAddress.getLocalHost();
// } catch (UnknownHostException e) {
// e.printStackTrace();
// }
// ipAddress = inet.getHostAddress();
// }
}
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
// "***.***.***.***".length() = 15
if (ipAddress != null && ipAddress.length() > 15) {
if (ipAddress.indexOf(",") > 0) {
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
}
}
} catch (Exception e) {
ipAddress = "";
}
return ipAddress;
}
// 测试
public static void main(String[] args) {
List<String> ipWhilte = new ArrayList<>();
ipWhilte.add("192.168.1.1"); //设置单个IP的白名单
ipWhilte.add("192.168.2.*"); //设置ip通配符,对一个ip段进行匹配
ipWhilte.add("192.168.3.17-192.168.3.38"); //设置一个IP范围
System.out.println(ipWhilte);
boolean flag = checkIpList("192.168.2.2", ipWhilte);
boolean flag2 = checkIpList("192.168.1.2", ipWhilte);
boolean flag3 = checkIpList("192.168.3.16", ipWhilte);
boolean flag4 = checkIpList("192.168.3.17", ipWhilte);
System.out.println(flag); //true
System.out.println(flag2); //false
System.out.println(flag3); //false
System.out.println(flag4); //true
}
}

48
src/main/java/com/fr/plugin/cpic/utils/PathUtil.java

@ -0,0 +1,48 @@
package com.fr.plugin.cpic.utils;
import com.fanruan.api.util.StringKit;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginContexts;
import java.net.URL;
import java.util.List;
/**
* 路径工具
*/
public class PathUtil {
/**
* 获取当前插件目录
*
* @return
* @throws Exception
*/
public static String getLocalCachePath() throws Exception {
PluginContext contexts = PluginContexts.currentContext();
List<URL> urls = contexts.getClassPaths();
String classPath = "";
for (URL url : urls) {
if (url.getPath().contains("classes")) {
classPath = StringKit.subStringByByteLength(url.getPath(), "UTF-8", url.getPath().indexOf("classes"));
}
}
return classPath;
}
/**
* 获取后缀名
*
* @param fileName
* @return
*/
public static String getLastName(String fileName) {
String[] split = fileName.split("\\.");
if (split.length > 1) {
return split[split.length - 1];
} else {
return "";
}
}
}

83
src/main/java/com/fr/plugin/cpic/utils/UrlUtils.java

@ -0,0 +1,83 @@
package com.fr.plugin.cpic.utils;
import com.fr.stable.StringUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class UrlUtils {
/**
* 获取URL的参数列表
*
* @param url
* @return
*/
public static String getBaseUrl(String url) {
String baseUrl = "";
if (StringUtils.isBlank(url)) {
return baseUrl;
}
url = url.trim();
String[] urlParts = url.split("\\?");
//没有参数
if (urlParts.length >= 1) {
baseUrl = urlParts[0];
}
return baseUrl;
}
/**
* 获取URL的参数列表
*
* @param url
* @return
*/
public static Map<String, String> getParams(String url) {
Map<String, String> params = new HashMap<>();
if (StringUtils.isBlank(url)) {
return params;
}
url = url.trim();
String[] urlParts = url.split("\\?");
//没有参数
if (urlParts.length <= 1) {
return params;
}
//有参数
String[] urlParams = urlParts[1].split("&");
for (String param : urlParams) {
String[] keyValue = param.split("=");
if (keyValue.length < 2) {
continue;
}
params.put(keyValue[0], keyValue[1]);
}
return params;
}
/**
* 生成完整url
*
* @param baseUrl
* @param params
* @return
*/
public static String getUrl(String baseUrl, Map<String, String> params) {
StringBuilder sb = new StringBuilder();
sb.append(baseUrl);
if (null != params && params.size() > 0) {
sb.append("?");
for (Entry<String, String> entry : params.entrySet()) {
sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
}
}
String url = sb.toString();
if (url.endsWith("&")) {
url = url.substring(0, url.length() - 1);
}
return url;
}
}

22
src/main/java/com/fr/plugin/cpic/web/CpicControllerRegisterProvider.java

@ -0,0 +1,22 @@
package com.fr.plugin.cpic.web;
import com.fr.decision.fun.impl.AbstractControllerRegisterProvider;
import com.fr.plugin.cpic.web.controller.CpicEntryController;
import com.fr.plugin.cpic.web.controller.CpicHomeController;
import com.fr.plugin.cpic.web.controller.CpicHomeIndexController;
import com.fr.plugin.cpic.web.controller.CpicUserController;
/**
* 注册新的接口
*/
public class CpicControllerRegisterProvider extends AbstractControllerRegisterProvider {
@Override
public Class<?>[] getControllers() {
return new Class[]{
CpicHomeIndexController.class,
CpicHomeController.class,
CpicUserController.class,
CpicEntryController.class,
};
}
}

50
src/main/java/com/fr/plugin/cpic/web/CpicHomeOptionProvider.java

@ -0,0 +1,50 @@
package com.fr.plugin.cpic.web;
import com.fr.decision.authority.base.AuthorityConstants;
import com.fr.decision.authority.base.constant.AuthorityStaticItemId;
import com.fr.decision.fun.impl.AbstractSystemOptionProvider;
import com.fr.decision.web.MainComponent;
import com.fr.plugin.cpic.web.component.CpicHomeComponent;
import com.fr.stable.fun.mark.API;
import com.fr.web.struct.Atom;
@API(level = CpicHomeOptionProvider.CURRENT_LEVEL)
public class CpicHomeOptionProvider extends AbstractSystemOptionProvider {
private static final String DEC_PLUGIN_HOME_ID = "dec_plugin_home_id";
@Override
public String id() {
return DEC_PLUGIN_HOME_ID;
}
@Override
public String displayName() {
return "门户管理";
}
@Override
public int sortIndex() {
return 0;
}
@Override
public String fullPath() {
// 判断后台实际权限
return AuthorityStaticItemId.DEC_MANAGEMENT_ID +
AuthorityConstants.FULL_PATH_SPLITTER +
DEC_PLUGIN_HOME_ID;
}
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return CpicHomeComponent.KEY;
}
}

23
src/main/java/com/fr/plugin/cpic/web/CpicWebResourceProvider.java

@ -0,0 +1,23 @@
package com.fr.plugin.cpic.web;
import com.fr.decision.fun.impl.AbstractWebResourceProvider;
import com.fr.decision.web.MainComponent;
import com.fr.plugin.cpic.web.component.CpicThemeJsComponent;
import com.fr.web.struct.Atom;
/**
* 注入JS
*/
public class CpicWebResourceProvider extends AbstractWebResourceProvider {
@Override
public Atom attach() {
return MainComponent.KEY;
}
public Atom[] clients() {
return new Atom[]{
CpicThemeJsComponent.KEY
};
}
}

88
src/main/java/com/fr/plugin/cpic/web/bean/TreeItemBean.java

@ -0,0 +1,88 @@
package com.fr.plugin.cpic.web.bean;
import java.util.List;
public class TreeItemBean {
private String title;
private String id;
private String field;
private String href;
private boolean spread;
private boolean checked;
private boolean disabled;
private String pid;
private List<TreeItemBean> children;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
public boolean isSpread() {
return spread;
}
public void setSpread(boolean spread) {
this.spread = spread;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
public List<TreeItemBean> getChildren() {
return children;
}
public void setChildren(List<TreeItemBean> children) {
this.children = children;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
}

52
src/main/java/com/fr/plugin/cpic/web/bean/UserMenuBean.java

@ -0,0 +1,52 @@
package com.fr.plugin.cpic.web.bean;
import java.util.List;
public class UserMenuBean {
private String id;
private String title;
private String pid;
private String mtype;
private List<UserMenuBean> children;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getMtype() {
return mtype;
}
public void setMtype(String mtype) {
this.mtype = mtype;
}
public List<UserMenuBean> getChildren() {
return children;
}
public void setChildren(List<UserMenuBean> children) {
this.children = children;
}
}

24
src/main/java/com/fr/plugin/cpic/web/component/CpicHomeComponent.java

@ -0,0 +1,24 @@
package com.fr.plugin.cpic.web.component;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath;
@FunctionRecorder
public class CpicHomeComponent extends Component {
public static CpicHomeComponent KEY = new CpicHomeComponent();
private CpicHomeComponent() {
}
@ExecuteFunctionRecord
@Override
public ScriptPath script(RequestClient requestClient) {
return ScriptPath.build("/com/fr/plugin/cpic/web/js/cpic_home.js");
}
}

22
src/main/java/com/fr/plugin/cpic/web/component/CpicThemeJsComponent.java

@ -0,0 +1,22 @@
package com.fr.plugin.cpic.web.component;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.FileType;
import com.fr.web.struct.category.ParserType;
import com.fr.web.struct.category.ScriptPath;
public class CpicThemeJsComponent extends Component {
public static CpicThemeJsComponent KEY = new CpicThemeJsComponent();
private CpicThemeJsComponent() {
}
@Override
public ScriptPath script(RequestClient requestClient) {
return ScriptPath.build("com.fr.plugin.cpic.web.component.generator.CpicThemeJsGenerator", FileType.CLASS, ParserType.DYNAMIC);
}
}

28
src/main/java/com/fr/plugin/cpic/web/component/generator/CpicThemeJsGenerator.java

@ -0,0 +1,28 @@
package com.fr.plugin.cpic.web.component.generator;
import com.fr.base.TemplateUtils;
import com.fr.gen.TextGenerator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
public class CpicThemeJsGenerator implements TextGenerator {
public String text(HttpServletRequest req, HttpServletResponse res) throws Exception {
Map<String, Object> renderMap = new HashMap();
return TemplateUtils.renderTemplate(this.template(), renderMap);
}
public String mimeType() {
return "text/javascript";
}
public String template() {
return "/com/fr/plugin/cpic/web/js/customexport.js";
}
}

145
src/main/java/com/fr/plugin/cpic/web/controller/CpicEntryController.java

@ -0,0 +1,145 @@
package com.fr.plugin.cpic.web.controller;
import com.fr.decision.authority.data.User;
import com.fr.decision.service.DecisionService;
import com.fr.decision.webservice.Response;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.decision.webservice.bean.entry.EntryBean;
import com.fr.decision.webservice.utils.ControllerFactory;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.plugin.cpic.db.bean.CpicEntryBean;
import com.fr.plugin.cpic.db.bean.CpicHomeBean;
import com.fr.plugin.cpic.db.service.CpicEntryService;
import com.fr.plugin.cpic.db.service.CpicHomeService;
import com.fr.plugin.cpic.utils.ConvertUtil;
import com.fr.plugin.cpic.web.bean.TreeItemBean;
import com.fr.stable.web.Device;
import com.fr.third.org.apache.commons.collections4.CollectionUtils;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.RequestBody;
import com.fr.third.springframework.web.bind.annotation.RequestMapping;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 目录
*/
@Controller
@LoginStatusChecker(required = false)
@RequestMapping(value = "/cpic")
public class CpicEntryController {
@RequestMapping(value = "/home/entrys", method = RequestMethod.GET)
@ResponseBody
public Response getAllEntry(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
String homeId = request.getParameter("homeId");
// 获取全部目录和报表
// String userId = UserService.getInstance().getAdminUserIdList().get(0);
String userId = DecisionService.getInstance().authority().userService().getAdminUserIdList().get(0);
List<EntryBean> entryBeanList = ControllerFactory.getInstance().getEntryController(userId).getEntryTree(userId, Device.PC);
// 获取门户勾选的目录
List<CpicEntryBean> cpicEntryBeanList = CpicEntryService.findList(homeId);
// 生成树结构数据
List<TreeItemBean> treeBean = ConvertUtil.toTree(entryBeanList, cpicEntryBeanList);
return Response.ok(treeBean);
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/home/entrychecked", method = RequestMethod.GET)
@ResponseBody
public Response getChecked(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
String homeId = request.getParameter("homeId");
// 获取门户勾选的目录
List<CpicEntryBean> cpicEntryBeanList = CpicEntryService.findList(homeId);
// 生成树结构数据
List<String> entryIdList = cpicEntryBeanList.stream().map(CpicEntryBean::getEntryId).collect(Collectors.toList());
return Response.ok(entryIdList);
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/home/entrys", method = RequestMethod.POST)
@ResponseBody
public Response saveOrUpdate(HttpServletRequest request, HttpServletResponse response, @RequestBody List<TreeItemBean> treeBean) throws Exception {
try {
// 校验输入
// if (null == treeBean || CollectionUtils.isEmpty(treeBean)) {
// return Response.success();
// }
String homeId = request.getParameter("homeId");
// 查询home信息
CpicHomeBean home = CpicHomeService.findById(homeId);
if (null == home) {
return Response.success();
}
// 获取现有保存的数据
List<CpicEntryBean> cpicEntryBeanList = CpicEntryService.findList(homeId);
// treeBean转换
List<CpicEntryBean> checkedEntry = ConvertUtil.itemsToEntrys(treeBean);
// 获取新增和更新列表
List<CpicEntryBean> updateList = new ArrayList<>();
List<CpicEntryBean> addList = new ArrayList<>();
for (CpicEntryBean item : checkedEntry) {
CpicEntryBean temp = cpicEntryBeanList.stream().filter(entry -> entry.getEntryId().equals(item.getEntryId())).findFirst().orElse(null);
if (null != temp) {
temp.setEntryName(item.getEntryName());
updateList.add(temp);
} else {
item.setHomeId(home.getId());
item.setHomeName(home.getName());
addList.add(item);
}
}
// 获取删除列表
List<CpicEntryBean> delList = new ArrayList<>();
for (CpicEntryBean item : cpicEntryBeanList) {
CpicEntryBean temp = checkedEntry.stream().filter(entry -> entry.getEntryId().equals(item.getEntryId())).findFirst().orElse(null);
if (null == temp) {
delList.add(item);
}
}
// 更新
if (CollectionUtils.isNotEmpty(updateList)) {
for (CpicEntryBean entry : updateList) {
CpicEntryService.saveOrUpdate(entry);
}
}
// 新增
if (CollectionUtils.isNotEmpty(addList)) {
for (CpicEntryBean entry : addList) {
CpicEntryService.saveOrUpdate(entry);
}
}
// 删除
if (CollectionUtils.isNotEmpty(delList)) {
for (CpicEntryBean entry : delList) {
CpicEntryService.realDel(entry.getId());
}
}
return Response.success();
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
}

119
src/main/java/com/fr/plugin/cpic/web/controller/CpicHomeController.java

@ -0,0 +1,119 @@
package com.fr.plugin.cpic.web.controller;
import com.fanruan.api.util.StringKit;
import com.fr.decision.webservice.Response;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.decision.webservice.bean.config.ThemeConfigBean;
import com.fr.decision.webservice.v10.config.ConfigService;
import com.fr.plugin.cpic.db.bean.CpicHomeBean;
import com.fr.plugin.cpic.db.service.CpicHomeService;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.RequestBody;
import com.fr.third.springframework.web.bind.annotation.RequestMapping;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 回调接口
*/
@Controller
@LoginStatusChecker(required = false)
@RequestMapping(value = "/cpic")
public class CpicHomeController {
@RequestMapping(value = "/home", method = RequestMethod.GET)
public void index(HttpServletRequest request, HttpServletResponse response) throws Exception {
HashMap hashMap = new HashMap();
hashMap.put("loginUser", "xx");
hashMap.put("callBack", "xx");
WebUtils.writeOutTemplate("/com/fr/plugin/cpic/web/html/home.html", response, hashMap);
}
@RequestMapping(value = "/home/list", method = RequestMethod.GET)
@ResponseBody
public Response getAll(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
List<CpicHomeBean> list = CpicHomeService.findList();
Map<String, Object> result = new HashMap<>();
result.put("homeList", list);
return Response.ok(result);
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/home/themes", method = RequestMethod.GET)
@ResponseBody
public Response getAllTheme(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
return Response.ok(ConfigService.getInstance().getAllThemes());
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/home/edit", method = RequestMethod.POST)
@ResponseBody
public Response saveOrUpdate(HttpServletRequest request, HttpServletResponse response, @RequestBody CpicHomeBean cpicHomeBean) throws Exception {
try {
// 校验输入
if (StringKit.isBlank(cpicHomeBean.getName())) {
return Response.error("-1", "请输入门户名称!");
}
if (StringKit.isBlank(cpicHomeBean.getPath())) {
return Response.error("-1", "请输入门户地址!");
}
// 校验重名
CpicHomeBean nameBean = CpicHomeService.findByName(cpicHomeBean.getName(), cpicHomeBean.getId());
if (null != nameBean) {
return Response.error("-1", "门户名称重复,请修改后重试!");
}
CpicHomeBean pathBean = CpicHomeService.findByPath(cpicHomeBean.getPath(), cpicHomeBean.getId());
if (null != pathBean) {
return Response.error("-1", "门户地址重复,请修改后重试!");
}
List<ThemeConfigBean> themeList = ConfigService.getInstance().getAllThemes();
ThemeConfigBean themeConfigBean = themeList.stream().filter(item -> item.getThemeId().equals(cpicHomeBean.getThemeId())).findFirst().orElse(null);
if (null != themeConfigBean) {
cpicHomeBean.setThemeName(themeConfigBean.getName());
}
if ("classic".equals(cpicHomeBean.getThemeId())) {
cpicHomeBean.setThemeName("经典");
}
if ("modern".equals(cpicHomeBean.getThemeId())) {
cpicHomeBean.setThemeName("扁平化");
}
// 保存
CpicHomeService.saveOrUpdate(cpicHomeBean);
// 返回成功的数据
CpicHomeBean result = CpicHomeService.findByName(cpicHomeBean.getName(), "");
return Response.ok(result);
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/home/del", method = RequestMethod.POST)
@ResponseBody
public Response delete(HttpServletRequest request, HttpServletResponse response, @RequestBody CpicHomeBean cpicHomeBean) throws Exception {
try {
// 删除
CpicHomeService.logicDel(cpicHomeBean.getId());
return Response.success();
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
}

102
src/main/java/com/fr/plugin/cpic/web/controller/CpicHomeIndexController.java

@ -0,0 +1,102 @@
package com.fr.plugin.cpic.web.controller;
import com.fanruan.api.log.LogKit;
import com.fr.base.ServerConfig;
import com.fr.decision.authority.data.User;
import com.fr.decision.inject.DecisionInjectExtraInfoBuilder;
import com.fr.decision.inject.DefaultDecisionInjectNodes;
import com.fr.decision.inject.node.DecisionInjectNode;
import com.fr.decision.inject.node.DecisionInjectNodeManager;
import com.fr.decision.service.DecisionService;
import com.fr.decision.web.MainComponent;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.decision.webservice.v10.login.TokenResource;
import com.fr.plugin.cpic.db.bean.CpicHomeBean;
import com.fr.plugin.cpic.db.bean.CpicUserBean;
import com.fr.plugin.cpic.db.service.CpicHomeService;
import com.fr.plugin.cpic.db.service.CpicUserService;
import com.fr.plugin.cpic.web.custom.CustomDecisionErrorInjectNode;
import com.fr.plugin.cpic.web.custom.CustomDecisionSystemInjectNode;
import com.fr.plugin.cpic.web.custom.CustomDecisionUserInjectNode;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.PathVariable;
import com.fr.third.springframework.web.bind.annotation.RequestMapping;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import com.fr.web.Browser;
import com.fr.web.struct.AtomBuilder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
/**
* 页面
*/
@Controller
//@LoginStatusChecker(required = false)
@RequestMapping(value = "/home")
public class CpicHomeIndexController {
@RequestMapping(
value = {"/{path}"},
produces = {"text/html"}
)
@ResponseBody
@LoginStatusChecker(
tokenResource = TokenResource.COOKIE
)
public String home(HttpServletRequest request, HttpServletResponse response, @PathVariable("path") String path) throws Exception {
HashMap params = new HashMap();
params.put("charset", ServerConfig.getInstance().getServerCharset());
// 根据path查询
CpicHomeBean home = CpicHomeService.findByPath(path, "");
if (null == home) {
DecisionInjectNode[] nodes = new DecisionInjectNode[]{
new CustomDecisionErrorInjectNode("NN", "", "门户地址[" + path + "]不存在")
};
return DecisionInjectNodeManager.box(
DecisionInjectExtraInfoBuilder.builder().request(request).user(DecisionService.getInstance().authority().userService().getUserByRequestCookie(request)).pagePath("/com/fr/plugin/cpic/web/html/error.html").pathGroup(AtomBuilder.create().buildAssembleFilePath(Browser.resolve(request), MainComponent.KEY)).build(),
nodes);
}
User user = DecisionService.getInstance().authority().userService().getUserByRequestCookie(request);
// 查询当前用户是否有登录权限
CpicUserBean cpicUserBean = CpicUserService.findHomeUserByUserId(home.getId(), user.getId());
// 没有权限的用户跳转到提示页面
if (null == cpicUserBean) {
DecisionInjectNode[] nodes = new DecisionInjectNode[]{
new CustomDecisionErrorInjectNode("YY", home.getPath(), "登录用户[" + user.getUserName() + "]没有门户[" + home.getName() + "]登录权限")
};
return DecisionInjectNodeManager.box(
DecisionInjectExtraInfoBuilder.builder().request(request).user(DecisionService.getInstance().authority().userService().getUserByRequestCookie(request)).pagePath("/com/fr/plugin/cpic/web/html/error.html").pathGroup(AtomBuilder.create().buildAssembleFilePath(Browser.resolve(request), MainComponent.KEY)).build(),
nodes);
}
// 主页
LogKit.debug("门户首页地址:", home.getMhpath());
CustomDecisionUserInjectNode customUserNode = new CustomDecisionUserInjectNode(home.getMhpath());
// 主题
LogKit.debug("门户主题:", home.getThemeId());
CustomDecisionSystemInjectNode customSystemNode = new CustomDecisionSystemInjectNode(home.getThemeId());
// 生成数据
DecisionInjectNode[] nodes = new DecisionInjectNode[]{
DefaultDecisionInjectNodes.scriptInfo(),
DefaultDecisionInjectNodes.styleInfo(),
DefaultDecisionInjectNodes.charsetInfo(),
// DefaultDecisionInjectNodes.systemInfo(),
customSystemNode,
// DefaultDecisionInjectNodes.userInfo(),
customUserNode,
DefaultDecisionInjectNodes.titleInfo()
};
return DecisionInjectNodeManager.box(
DecisionInjectExtraInfoBuilder.builder().request(request).user(DecisionService.getInstance().authority().userService().getUserByRequestCookie(request)).pagePath("/com/fr/plugin/cpic/web/html/resources/index.html").pathGroup(AtomBuilder.create().buildAssembleFilePath(Browser.resolve(request), MainComponent.KEY)).build(),
nodes);
}
}

382
src/main/java/com/fr/plugin/cpic/web/controller/CpicUserController.java

@ -0,0 +1,382 @@
package com.fr.plugin.cpic.web.controller;
import com.fr.decision.authority.AuthorityContext;
import com.fr.decision.authority.base.constant.type.authority.GradeManagementAuthorityType;
import com.fr.decision.authority.data.CustomRole;
import com.fr.decision.authority.data.Department;
import com.fr.decision.authority.data.Post;
import com.fr.decision.authority.data.User;
import com.fr.decision.service.DecisionService;
import com.fr.decision.webservice.Response;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.decision.webservice.utils.ControllerFactory;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.cpic.db.bean.CpicHomeBean;
import com.fr.plugin.cpic.db.bean.CpicUserBean;
import com.fr.plugin.cpic.db.service.CpicHomeService;
import com.fr.plugin.cpic.db.service.CpicUserService;
import com.fr.plugin.cpic.utils.ConvertUtil;
import com.fr.plugin.cpic.web.bean.UserMenuBean;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.data.DataList;
import com.fr.stable.query.restriction.RestrictionFactory;
import com.fr.third.org.apache.commons.collections4.CollectionUtils;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.RequestBody;
import com.fr.third.springframework.web.bind.annotation.RequestMapping;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* 用户
*/
@Controller
@LoginStatusChecker(required = false)
@RequestMapping(value = "/cpic")
public class CpicUserController {
@RequestMapping(value = "/user", method = RequestMethod.GET)
public void index(HttpServletRequest request, HttpServletResponse response) throws Exception {
// 查询初始化数据
String homeId = request.getParameter("homeId");
CpicHomeBean home = CpicHomeService.findById(homeId);
HashMap hashMap = new HashMap();
hashMap.put("homeId", home.getId());
hashMap.put("homeName", home.getName());
WebUtils.writeOutTemplate("/com/fr/plugin/cpic/web/html/user.html", response, hashMap);
}
@RequestMapping(value = "/user/menus", method = RequestMethod.GET)
@ResponseBody
public Response getMenus2(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
String dimensionType = request.getParameter("dimensionType");
// String adminId = UserService.getInstance().getAdminUserIdList().get(0);
String adminId = DecisionService.getInstance().authority().userService().getAdminUserIdList().get(0);
// 查询菜单结构
List<UserMenuBean> menuList = new ArrayList<>();
if ("department".equals(dimensionType)) {
// 部门
Department[] departments = ControllerFactory.getInstance().getDepartmentController(adminId).getDepartmentTree(adminId);
List<Department> departmentList = new ArrayList<Department>(departments.length);
Collections.addAll(departmentList, departments);
departmentList.sort((var0, var1x) -> ComparatorUtils.compare(var0.getAlias(), var1x.getAlias()));
menuList = ConvertUtil.departmentListToTree(departmentList);
}
if ("customrole".equals(dimensionType)) {
// 角色
List<CustomRole> customRoleList = ControllerFactory.getInstance().getCustomRoleController(adminId).getAllCustomRoles(adminId, "", GradeManagementAuthorityType.TYPE);
customRoleList.sort((var0, var1x) -> ComparatorUtils.compare(var0.getAlias(), var1x.getAlias()));
menuList = ConvertUtil.roleListToMenuList(customRoleList);
}
return Response.ok(menuList);
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/user/list", method = RequestMethod.GET)
@ResponseBody
public Response getUsers(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
String menuId = request.getParameter("menuId");
String menuType = request.getParameter("menuType");
String homeId = request.getParameter("homeId");
CpicHomeBean home = CpicHomeService.findById(homeId);
// 查询所有已配置的用户
List<CpicUserBean> userList = CpicUserService.findList(homeId);
List<CpicUserBean> resultUserList = new ArrayList<>();
// 获取全部用户
if ("all".equals(menuType)) {
// 查询
List<User> sysUserList = AuthorityContext.getInstance().getUserController().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("enable", true)));
CpicUserBean cpicUser;
if (CollectionUtils.isNotEmpty(sysUserList)) {
for (User user : sysUserList) {
cpicUser = new CpicUserBean();
cpicUser.setHomeId(home.getId());
cpicUser.setHomeName(home.getName());
cpicUser.setUserId(user.getId());
cpicUser.setUserAccount(user.getUserName());
cpicUser.setUserName(user.getRealName());
resultUserList.add(cpicUser);
}
}
// 剔除已配置的用户返回
return Response.ok(eliminateUser(resultUserList, userList));
} else {
List<User> sysUserList = new ArrayList<>();
if ("department".equals(menuType)) {
// 查询指定部门用户(部门下可能有多个职务)
sysUserList = this.getUserListByDept(menuId);
}
if ("customrole".equals(menuType)) {
// 查询指定角色用户
DataList<User> roleUserList = AuthorityContext.getInstance().getUserController().findByCustomRole(menuId, null);
if (!roleUserList.isEmpty()) {
sysUserList.addAll(roleUserList.getList());
}
}
if (CollectionUtils.isNotEmpty(sysUserList)) {
CpicUserBean cpicUser;
for (User user : sysUserList) {
cpicUser = new CpicUserBean();
cpicUser.setHomeId(home.getId());
cpicUser.setHomeName(home.getName());
cpicUser.setUserId(user.getId());
cpicUser.setUserAccount(user.getUserName());
cpicUser.setUserName(user.getRealName());
resultUserList.add(cpicUser);
}
}
// 筛选出当前部门或者角色已配置用户
List<CpicUserBean> filterUserList = new ArrayList<>();
for (CpicUserBean userBean : userList) {
CpicUserBean temp = resultUserList.stream().filter(item -> item.getUserId().equals(userBean.getUserId())).findFirst().orElse(null);
if (null != temp) {
filterUserList.add(userBean);
}
}
return Response.ok(eliminateUser(resultUserList, filterUserList));
}
} catch (
Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/user/list2", method = RequestMethod.GET)
@ResponseBody
public Response getUsers2(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
String menuId = request.getParameter("menuId");
String menuType = request.getParameter("menuType");
String homeId = request.getParameter("homeId");
CpicHomeBean home = CpicHomeService.findById(homeId);
// 查询所有已配置的用户
List<CpicUserBean> userList = CpicUserService.findList(homeId);
// 获取全部用户
if ("all".equals(menuType)) {
return Response.ok(userList);
} else {
List<CpicUserBean> allUserList = new ArrayList<>();
List<User> sysUserList = new ArrayList<>();
if ("department".equals(menuType)) {
// 查询指定部门用户
sysUserList = this.getUserListByDept(menuId);
}
if ("customrole".equals(menuType)) {
// 查询指定角色用户
DataList<User> roleUserList = AuthorityContext.getInstance().getUserController().findByCustomRole(menuId, null);
if (!roleUserList.isEmpty()) {
sysUserList.addAll(roleUserList.getList());
}
}
if (CollectionUtils.isNotEmpty(sysUserList)) {
CpicUserBean cpicUser;
for (User user : sysUserList) {
cpicUser = new CpicUserBean();
cpicUser.setHomeId(home.getId());
cpicUser.setHomeName(home.getName());
cpicUser.setUserId(user.getId());
cpicUser.setUserAccount(user.getUserName());
cpicUser.setUserName(user.getRealName());
allUserList.add(cpicUser);
}
}
// 筛选出当前部门或者角色已配置用户
List<CpicUserBean> filterUserList = new ArrayList<>();
for (CpicUserBean userBean : userList) {
CpicUserBean temp = allUserList.stream().filter(item -> item.getUserId().equals(userBean.getUserId())).findFirst().orElse(null);
if (null != temp) {
filterUserList.add(userBean);
}
}
return Response.ok(filterUserList);
}
} catch (
Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
@RequestMapping(value = "/user/add", method = RequestMethod.POST)
@ResponseBody
public Response saveOrUpdate(HttpServletRequest request, HttpServletResponse response, @RequestBody List<CpicUserBean> userBeanList) throws Exception {
try {
String menuId = request.getParameter("menuId");
String menuType = request.getParameter("menuType");
String homeId = request.getParameter("homeId");
CpicHomeBean home = CpicHomeService.findById(homeId);
if (null == home) {
return Response.success();
}
// 查询所有已配置的用户
List<CpicUserBean> userList = CpicUserService.findList(homeId);
Map<String, List<CpicUserBean>> result;
// 获取全部用户
if ("all".equals(menuType)) {
result = handleUserList(userList, userBeanList, home);
} else {
List<CpicUserBean> allUserList = new ArrayList<>();
List<User> sysUserList = new ArrayList<>();
if ("department".equals(menuType)) {
// 查询指定部门用户
sysUserList = this.getUserListByDept(menuId);
}
if ("customrole".equals(menuType)) {
// 查询指定角色用户
DataList<User> roleUserList = AuthorityContext.getInstance().getUserController().findByCustomRole(menuId, null);
if (!roleUserList.isEmpty()) {
sysUserList.addAll(roleUserList.getList());
}
}
if (CollectionUtils.isNotEmpty(sysUserList)) {
CpicUserBean cpicUser;
for (User user : sysUserList) {
cpicUser = new CpicUserBean();
cpicUser.setHomeId(home.getId());
cpicUser.setHomeName(home.getName());
cpicUser.setUserId(user.getId());
cpicUser.setUserAccount(user.getUserName());
cpicUser.setUserName(user.getRealName());
allUserList.add(cpicUser);
}
}
// 筛选出当前部门或者角色已配置用户
List<CpicUserBean> filterUserList = new ArrayList<>();
for (CpicUserBean userBean : userList) {
CpicUserBean temp = allUserList.stream().filter(item -> item.getUserId().equals(userBean.getUserId())).findFirst().orElse(null);
if (null != temp) {
filterUserList.add(userBean);
}
}
result = handleUserList(filterUserList, userBeanList, home);
}
// 新增/修改/删除列表
List<CpicUserBean> addList = result.getOrDefault("ADD", new ArrayList<>());
List<CpicUserBean> updateList = result.getOrDefault("UPDATE", new ArrayList<>());
List<CpicUserBean> delList = result.getOrDefault("DELETE", new ArrayList<>());
// 更新
if (CollectionUtils.isNotEmpty(updateList)) {
for (CpicUserBean user : updateList) {
CpicUserService.saveOrUpdate(user);
}
}
// 新增
if (CollectionUtils.isNotEmpty(addList)) {
for (CpicUserBean user : addList) {
CpicUserService.saveOrUpdate(user);
}
}
// 删除
if (CollectionUtils.isNotEmpty(delList)) {
for (CpicUserBean user : delList) {
CpicUserService.realDel(user.getId());
}
}
return Response.success();
} catch (Exception e) {
return Response.error("-1", "error:" + e.getMessage());
}
}
/**
* 返回新增/修改/删除列表
*
* @param oldList
* @param newList
* @return
*/
private Map<String, List<CpicUserBean>> handleUserList(List<CpicUserBean> oldList, List<CpicUserBean> newList, CpicHomeBean home) {
Map<String, List<CpicUserBean>> result = new HashMap<>();
List<CpicUserBean> addList = new ArrayList<>();
List<CpicUserBean> updateList = new ArrayList<>();
List<CpicUserBean> delList = new ArrayList<>();
// 获取新增和更新列表
for (CpicUserBean item : newList) {
CpicUserBean temp = oldList.stream().filter(entry -> entry.getUserId().equals(item.getUserId())).findFirst().orElse(null);
if (null != temp) {
temp.setHomeId(home.getId());
temp.setHomeName(home.getName());
temp.setUserName(item.getUserName());
updateList.add(temp);
} else {
item.setHomeId(home.getId());
item.setHomeName(home.getName());
addList.add(item);
}
}
// 获取删除列表
for (CpicUserBean item : oldList) {
CpicUserBean temp = newList.stream().filter(entry -> entry.getUserId().equals(item.getUserId())).findFirst().orElse(null);
if (null == temp) {
delList.add(item);
}
}
result.put("ADD", addList);
result.put("UPDATE", updateList);
result.put("DELETE", delList);
return result;
}
/**
* 已选择的用户不返回
*
* @param allList
* @param checkedList
* @return
*/
public List<CpicUserBean> eliminateUser(List<CpicUserBean> allList, List<CpicUserBean> checkedList) {
List<CpicUserBean> resultList = new ArrayList<>();
for (CpicUserBean item : allList) {
CpicUserBean temp = checkedList.stream().filter(entry -> entry.getUserId().equals(item.getUserId())).findFirst().orElse(null);
if (null == temp) {
resultList.add(item);
}
}
return resultList;
}
public List<User> getUserListByDept(String deptId) throws Exception {
List<User> sysUserList = new ArrayList<>();
DataList<User> deptUserList = AuthorityContext.getInstance().getUserController().findByDepartment(deptId, null);
if (!deptUserList.isEmpty()) {
sysUserList.addAll(deptUserList.getList());
}
// 部门下所有职务
List<Post> postList = AuthorityContext.getInstance().getPostController().findByDepartment(deptId, null);
// 循环查询职务下的用户
for (Post post : postList) {
DataList<User> postUserList = AuthorityContext.getInstance().getUserController().findByDepartmentAndPost(deptId, post.getId(), null);
if (!postUserList.isEmpty()) {
sysUserList.addAll(postUserList.getList());
}
}
// 去重
return sysUserList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(User::getId))), ArrayList::new));
}
}

60
src/main/java/com/fr/plugin/cpic/web/custom/CustomDecisionErrorInjectNode.java

@ -0,0 +1,60 @@
package com.fr.plugin.cpic.web.custom;
import com.fr.decision.inject.DecisionInjectExtraInfoBuilder;
import com.fr.decision.inject.node.impl.AbstractDecisionInjectNode;
import java.util.HashMap;
import java.util.Map;
public class CustomDecisionErrorInjectNode extends AbstractDecisionInjectNode {
private String type;
private String homepath;
private String message;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getHomepath() {
return homepath;
}
public void setHomepath(String homepath) {
this.homepath = homepath;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public CustomDecisionErrorInjectNode(String type, String homepath, String message) {
this.setType(type);
this.setHomepath(homepath);
this.setMessage(message);
}
public String name() {
return null;
}
@Override
protected Map<String, Object> calculate(DecisionInjectExtraInfoBuilder var1) throws Exception {
HashMap var2 = new HashMap();
if (var1.user() != null) {
var2.put("type", this.getType());
var2.put("homepath", "/" + this.getHomepath());
var2.put("message", this.getMessage());
}
return var2;
}
}

131
src/main/java/com/fr/plugin/cpic/web/custom/CustomDecisionSystemInjectNode.java

@ -0,0 +1,131 @@
package com.fr.plugin.cpic.web.custom;
import com.fanruan.api.util.StringKit;
import com.fr.base.ServerConfig;
import com.fr.base.email.EmailCenter;
import com.fr.cluster.ClusterBridge;
import com.fr.compatible.Version;
import com.fr.config.ServerPreferenceConfig;
import com.fr.decision.authority.base.constant.type.operation.ManualOperationType;
import com.fr.decision.authority.base.constant.type.operation.SyncOperationType;
import com.fr.decision.config.AppearanceConfig;
import com.fr.decision.config.DirectoryConfig;
import com.fr.decision.config.FSConfig;
import com.fr.decision.config.UserDataSetConfig;
import com.fr.decision.hyperlink.HyperlinkFactory;
import com.fr.decision.inject.DecisionInjectExtraInfoBuilder;
import com.fr.decision.inject.node.DecisionInjectNode;
import com.fr.decision.inject.node.impl.AbstractDecisionInjectNode;
import com.fr.decision.inject.node.impl.DecisionWebsocketInjectNode;
import com.fr.decision.migration.MigrationContext;
import com.fr.decision.service.DecisionService;
import com.fr.decision.update.acquirer.JSEngineInfo;
import com.fr.decision.webservice.bean.config.ThemeConfigBean;
import com.fr.decision.webservice.utils.theme.ThemeSubConfigFactory;
import com.fr.decision.webservice.v10.config.ConfigService;
import com.fr.decision.webservice.v10.login.LoginService;
import com.fr.decision.webservice.v10.register.RegisterService;
import com.fr.decision.webservice.v10.sms.SMSService;
import com.fr.decision.webservice.v10.system.SystemService;
import com.fr.general.CloudCenter;
import com.fr.general.CloudCenterConfig;
import com.fr.security.SecurityConfig;
import com.fr.security.encryption.irreversible.IrreversibleEncryptors;
import com.fr.security.encryption.transmission.TransmissionEncryptors;
import com.fr.security.encryption.transmission.impl.SM4TransmissionEncryption;
import com.fr.web.WebSocketConfig;
import java.util.*;
public class CustomDecisionSystemInjectNode extends AbstractDecisionInjectNode {
public String themeId;
public String getThemeId() {
return themeId;
}
public void setThemeId(String themeId) {
this.themeId = themeId;
}
public CustomDecisionSystemInjectNode(String themeId) {
this.setThemeId(themeId);
}
public String name() {
return "system";
}
@Override
protected Map<String, Object> calculate(DecisionInjectExtraInfoBuilder var1) throws Exception {
HashMap var2 = new HashMap();
if (!var1.isIgnoreDB()) {
var2.put("adminUser", DecisionService.getInstance().authority().userService().getAdminUserNameList());
var2.put("manualAuthentication", FSConfig.getInstance().getPassport(ManualOperationType.KEY).markType());
var2.put("syncAuthentication", FSConfig.getInstance().getPassport(SyncOperationType.KEY).markType());
var2.put("authConfig", DecisionService.getInstance().authority().authorityService().getAuthorityConfig());
var2.put("versionInfo", SystemService.getInstance().getSystemVersion());
var2.putAll(RegisterService.getInstance().getSupportedFunctions());
}
var2.put("themeConfig", ConfigService.getInstance().getAllThemes());
var2.put("styleConfig", ConfigService.getInstance().getStyleConfig());
var2.put("loginInfoRemind", FSConfig.getInstance().getLoginConfig().getShowLastLoginInfo());
var2.put("emailAvailable", EmailCenter.isEmailConfigValid());
var2.put("smsAvailable", SMSService.getInstance().isSMSAvailable());
var2.put("timeZone", TimeZone.getDefault().getOffset(System.currentTimeMillis()));
var2.put("hyperlink", HyperlinkFactory.getHyperlinks());
var2.put("authentication", FSConfig.getInstance().getPassport().markType());
var2.put("syncDataSet", UserDataSetConfig.getInstance().isTurnOn());
var2.put("weekBegins", ServerPreferenceConfig.getInstance().getFirstDayOfWeek().getConf());
var2.put("loginTimeout", FSConfig.getInstance().getLoginConfig().getLoginTimeout());
var2.put("frontSeed", SecurityConfig.getInstance().getFrontSeed());
var2.put("frontSM4Key", SM4TransmissionEncryption.getInstance().getTransmissionKey());
var2.put("transmissionEncryption", TransmissionEncryptors.getInstance().getCurrentTransmissionEncryption().getType());
var2.put("passwordEncryption", IrreversibleEncryptors.getInstance().getCurrentEncryptionMode().getType());
var2.put("cookiePath", ServerConfig.getInstance().getCookiePath());
var2.put("cluster", ClusterBridge.isClusterMode());
var2.put("syncUserStrategy", UserDataSetConfig.getInstance().getStrategy());
var2.put("httpOnly", ServerConfig.getInstance().isTokenFromCookie());
var2.put("runtimeVersion", Version.currVersion().getVersion());
var2.put("webSocketTokenInHeader", WebSocketConfig.getInstance().isWebSocketTokenInHeader());
var2.put("jsEngine", JSEngineInfo.getInfoMap());
var2.put("subThemeConfig", ThemeSubConfigFactory.getConfigById(AppearanceConfig.getInstance().getThemeId()));
var2.put("sidebarOpen", DirectoryConfig.getInstance().isSidebarOpen());
var2.put("transferred", MigrationContext.getInstance().isAlreadyTransferred());
var2.put("urlIP", CloudCenter.getInstance().acquireConf("decision.queryip", ""));
var2.put("cloudEnabled", CloudCenterConfig.getInstance().isOnline());
if (AppearanceConfig.getInstance().isCopyrightInfoDisplay()) {
var2.putAll(LoginService.getInstance().getCopyrightInfo(var1.request()));
}
// 设置主题
if (StringKit.isNotBlank(this.getThemeId())) {
var2.put("themeId", this.getThemeId());
// 第三方激活(尝试)
boolean themeChanged = false;
List<ThemeConfigBean> themeList = ConfigService.getInstance().getAllThemes();
for (ThemeConfigBean bean : themeList) {
// 设置主题
if (StringKit.equals(bean.getThemeId(), this.getThemeId())) {
bean.setActive(true);
themeChanged = true;
} else {
bean.setActive(false);
}
}
if (themeChanged) {
var2.put("themeConfig", themeList);
}
}
return var2;
}
public List<DecisionInjectNode> brothers() {
return Arrays.asList(DecisionWebsocketInjectNode.KEY);
}
}

88
src/main/java/com/fr/plugin/cpic/web/custom/CustomDecisionUserInjectNode.java

@ -0,0 +1,88 @@
package com.fr.plugin.cpic.web.custom;
import com.fr.decision.config.SystemConfig;
import com.fr.decision.inject.DecisionInjectExtraInfoBuilder;
import com.fr.decision.inject.node.impl.AbstractDecisionInjectNode;
import com.fr.decision.service.DecisionService;
import com.fr.decision.webservice.utils.WebServiceUtils;
import com.fr.decision.webservice.v10.entry.EntryService;
import com.fr.decision.webservice.v10.entry.homepage.HomePageInfo;
import com.fr.decision.webservice.v10.module.ManagerModuleService;
import com.fr.security.ipcheck.IPMatchHandler;
import com.fr.stable.core.UUID;
import com.fr.third.springframework.web.context.request.RequestContextHolder;
import com.fr.third.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CustomDecisionUserInjectNode extends AbstractDecisionInjectNode {
private String homepage;
public String getHomepage() {
return homepage;
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
public CustomDecisionUserInjectNode(String homepage){
this.setHomepage(homepage);
}
public String name() {
return "personal";
}
@Override
protected Map<String, Object> calculate(DecisionInjectExtraInfoBuilder var1) throws Exception {
HashMap var2 = new HashMap();
if (var1.user() != null) {
var2.put("username", var1.user().getUserName());
var2.put("userId", var1.user().getId());
var2.put("displayName", var1.user().getDisplayName());
var2.put("userExtraProps", DecisionService.getInstance().authority().userService().getUserExtraProperties(var1.user()));
var2.put("creationType", var1.user().getCreationType().toInteger());
var2.put("realName", var1.user().getRealName());
HttpServletRequest var3 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
if (!var1.isIgnoreDB()) {
var2.put("homepage", EntryService.getInstance().getHomePageUrl(var1.user().getId()));
var2.put("modules", this.checkAdminLoginIp(var3) ? ManagerModuleService.getInstance().getAllDecisionMgrModules(var1.user().getId(), "") : new ArrayList());
}
// 数据门户
List<HomePageInfo> homePageInfoList = new ArrayList<>();
HomePageInfo homePageInfo = new HomePageInfo();
homePageInfo.setId(UUID.randomUUID().toString().toLowerCase());
homePageInfo.setHomePageType(2);
homePageInfo.setText("首页");
homePageInfo.setPcURL(this.getHomepage());
homePageInfoList.add(homePageInfo);
var2.put("homepage", homePageInfoList);
}
return var2;
}
private boolean checkAdminLoginIp(HttpServletRequest var1) {
return this.checkAdminLoginIp(WebServiceUtils.getIpInfoFromRequest(var1));
}
private boolean checkAdminLoginIp(String var1) {
if (SystemConfig.getInstance().getEnableWhiteVerify()) {
String[] var2 = SystemConfig.getInstance().getWhiteIps();
if (IPMatchHandler.noneMatch(var1, IPMatchHandler.addLocalIP(var2))) {
return false;
}
}
return true;
}
}

84
src/main/resources/com/fr/plugin/cpic/web/html/error.html

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${charset}">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>错误</title>
<script type="text/javascript"
src="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/layui.js"></script>
<link href="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/css/layui.css" rel="stylesheet">
</head>
<body>
</body>
<script>
layui.use(function () {
var fineServletURL = "${fineServletURL}";
var type = "${type}";
var homepath = "${homepath}";
var message = "${message}";
var layer = layui.layer
, form = layui.form
, laypage = layui.laypage
, element = layui.element
, laydate = layui.laydate
, util = layui.util
, dropdown = layui.dropdown
, tree = layui.tree
, table = layui.table;
// 弹出报错信息
//显示自动关闭倒计秒数
layer.alert(message, {
time: 10 * 1000
, success: function (layero, index) {
var timeNum = this.time / 1000, setText = function (start) {
layer.title((start ? timeNum : --timeNum), index);
};
setText(!0);
this.timer = setInterval(setText, 1000);
if (timeNum <= 0) clearInterval(this.timer);
}
, end: function () {
clearInterval(this.timer);
if (type === 'NN') {
// 不做操作
}
if (type === 'YY') {
// console.log("登出");
// 登出
$.ajax({
type: "POST",
headers: {
"Authorization": "Bearer " + getCookie("fine_auth_token")
},
url: "${fineServletURL}/logout",
contentType: "application/json",
success: function (res) {
// 返回首页
window.location = window.location.origin + fineServletURL + "/home" + homepath;
}
});
}
}
});
function getCookie(cookieName) {
const strCookie = document.cookie
const cookieList = strCookie.split(';')
for (let i = 0; i < cookieList.length; i++) {
const arr = cookieList[i].split('=')
if (cookieName === arr[0].trim()) {
return arr[1]
}
}
return ''
}
});
</script>
</html>

570
src/main/resources/com/fr/plugin/cpic/web/html/home.html

@ -0,0 +1,570 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>门户管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript"
src="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/layui.js"></script>
<link href="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/css/layui.css" rel="stylesheet">
<style>
.layui-field-title-2 {
margin: 10px 0 10px;
border-width: 1px 0 0;
}
.layui-layout-right-15 {
position: absolute !important;
right: 15px;
top: 0
}
.layui-card-body-overflow {
overflow: auto;
}
.users-body{
padding:10px;
margin: 10px;
min-height: 200px;
overflow: auto;
}
.users-body .layui-btn{
margin: 5px;
}
.users-header{
width: 100%;
height: 40px;
}
.user-home-path{
height: 38px;
line-height: 38px;
}
</style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title-2">
<legend>门户管理</legend>
</fieldset>
<div class="layui-bg-gray" style="padding: 15px;">
<div class="layui-row layui-col-space15">
<div class="layui-col-md3">
<div class="layui-card">
<div class="layui-card-body layui-card-body-overflow">
<div class="layui-card-header">
<p>门户列表</p>
<div class="layui-btn-group layui-layout-right-15">
<button id="homeAdd" type="button" class="layui-btn layui-btn-primary layui-btn-sm"><i
class="layui-icon layui-icon-addition"></i></button>
<!-- <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"><i class="layui-icon layui-icon-edit"></i></button>-->
<button id="homeDel" type="button" class="layui-btn layui-btn-primary layui-btn-sm"><i
class="layui-icon layui-icon-delete"></i></button>
</div>
</div>
<ul class="layui-menu" id="homeList">
</ul>
</div>
</div>
</div>
<div class="layui-col-md9">
<div class="layui-card">
<!-- <div class="layui-card-header">卡片面板</div>-->
<div class="layui-card-body">
<div class="layui-tab layui-tab-brief" lay-filter="homeTabBrief">
<ul class="layui-tab-title">
<li lay-id="111" class="layui-this">门户信息</li>
<li lay-id="222">目录权限</li>
<li lay-id="333">用户列表</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="layui-form" lay-filter="homeForm">
<div class="layui-form-item">
<label class="layui-form-label">门户名称</label>
<div class="layui-input-block">
<input type="text" name="name" lay-verify="required" autocomplete="off"
placeholder="门户名称" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">门户主题</label>
<div class="layui-input-block">
<select name="themeId" lay-filter="themeId" id="themeSelect">
<!-- <option value=""></option>-->
<option value="classic" selected="">经典</option>
<option value="modern">扁平化</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">业务门户地址</label>
<div class="layui-input-block">
<input type="text" name="path" lay-verify="required" autocomplete="off"
placeholder="门户地址" class="layui-input" oninput="pathInput(this, '${fineServletURL}')">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">地址预览</label>
<div class="layui-input-block">
<p class="user-home-path" id="homePath"></p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">数据门户地址</label>
<div class="layui-input-block">
<input type="text" name="mhpath" lay-verify="required" autocomplete="off"
placeholder="数据门户地址" class="layui-input">
</div>
</div>
<input type="hidden" id="id" name="id" value="">
<input type="hidden" id="themeName" name="themeName" value="">
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn layui-btn-normal" id="subBtn" lay-submit
lay-filter="submitHome">保存
</button>
<!-- <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>-->
</div>
</div>
</div>
</div>
<div class="layui-tab-item">
<div class="home-entry-tree" id="entryTree" style="margin: 20px;display: block; overflow: auto;"></div>
</div>
<div class="layui-tab-item">
<div class="users-header">
<button type="button" id="userEdit" class="layui-btn layui-btn-primary layui-border-blue" style="float: right;">编辑用户</button>
</div>
<div class="users-body" >
<div class="users-body-list" id="userList">
</div>
</div>
<div class="users-toolbar" id="userPageBar">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
layui.use(function () {
var this_ = this;
var currentHomeId = "";
var currentHomeName = "";
var fineServletURL = "${fineServletURL}";
var treeData = [];
var layer = layui.layer
, form = layui.form
, laypage = layui.laypage
, element = layui.element
, laydate = layui.laydate
, util = layui.util
, dropdown = layui.dropdown
, tree = layui.tree
, table = layui.table;
// 动态设置页面高度
var docClientH = document.documentElement.clientHeight; // 可见区域高度
$(".layui-card-body").height(docClientH - 95);
$(".users-body").height(docClientH - 95 - 180);
$(".home-entry-tree").height(docClientH - 95 - 90);
$(window).resize(function () {
docClientH = document.documentElement.clientHeight;
$(".layui-card-body").height(docClientH - 95);
$(".users-body").height(docClientH - 95 - 180);
$(".home-entry-tree").height(docClientH - 95 - 90);
});
// 初始化
// initThemeList(form);
initHomeList(currentHomeId, currentHomeName);
initEntryTree(this_, currentHomeId, currentHomeName);
// url预览
$("#homePath").text(window.location.origin + fineServletURL + '/home/');
// 新增门户按钮事件
$("#homeAdd").bind("click", function () {
// 清除选中
currentHomeId = "";
currentHomeName = "";
initHomeList(currentHomeId, currentHomeName);
// 切换选项卡
element.tabChange('homeTabBrief', '111');
// 初始化表单
form.val('homeForm', {
id: "",
name: "",
themeId: "classic",
themeName: "经典",
path: "",
mhpath: ""
});
// url预览
$("#homePath").text(origin + fineServletURL + '/home/');
});
// 删除门户按钮事件
$("#homeDel").bind("click", function () {
if(!currentHomeId || currentHomeId === ""){
layer.msg("请选择门户!");
return false;
}
layer.confirm('确定要删除门户['+currentHomeName+']?', {
btn: ['确定','取消'] //按钮
}, function(index, layero){
// 删除选中门户
$.ajax({
type: "POST",
url: "${fineServletURL}/cpic/home/del",
contentType: "application/json",
data: JSON.stringify({
id: currentHomeId
}),
success: function (result) {
if (result.data === "success") {
layer.msg("删除成功!");
// 清除选中
currentHomeId = "";
currentHomeName = "";
initHomeList(currentHomeId, currentHomeName);
// 切换选项卡
element.tabChange('homeTabBrief', '111');
// 初始化表单
form.val('homeForm', {
id: "",
name: "",
themeId: "classic",
themeName: "经典",
path: "",
mhpath: ""
});
} else if (result.errorCode === "-1" || result.errorCode === "500") {
layer.msg(result.errorMsg);
}
},
error: function (result) {
}
});
// 关闭弹窗
layer.close(index);
}, function(index){
layer.close(index);
});
});
// 门户保存按钮
form.on('submit(submitHome)', function (data) {
$(data.elem).attr("disabled", true);
// 保存
$.ajax({
type: "POST",
url: "${fineServletURL}/cpic/home/edit",
contentType: "application/json",
data: JSON.stringify(data.field),
success: function (result) {
layer.msg("保存成功!");
var home = result.data;
currentHomeId = home.id;
currentHomeName = home.name;
// 刷新列表
initHomeList(currentHomeId, currentHomeName);
$(data.elem).attr("disabled", false);
},
error: function (result) {
$(data.elem).attr("disabled", false);
layer.msg('失败:' + result, {
icon: 1,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
//do something
});
}
});
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
// 选项卡切换事件
element.on('tab(homeTabBrief)', function(data){
var index = data.index;
if(index > 0){
if(!currentHomeId || currentHomeId === ""){
layer.msg("请选择门户!");
element.tabChange('homeTabBrief', '111');
return;
}
}
if(index === 1){
// 加载目录树
initEntryTree(this_, currentHomeId, currentHomeName);
}
if(index === 2){
// 加载用户列表
initUserList(this_, currentHomeId, currentHomeName);
}
});
// 门户列表点击事件
dropdown.on('click(homeList)', function (options) {
var othis = $(this); //当前菜单列表的 DOM 对象
// console.log(options); //菜单列表的 lay-options 中的参数
// 切换选项卡
// element.tabChange('homeTabBrief', '111');
// 初始化表单
form.val('homeForm', {
id: options.id,
name: options.name,
themeId: options.themeId,
themeName: options.themeName,
path: options.path,
mhpath: options.mhpath
});
// url预览
$("#homePath").text(window.location.origin + fineServletURL + '/home/' + options.path);
// 当前选中
currentHomeId = options.id;
currentHomeName = options.name;
// 重新渲染
form.render('select', 'homeForm');
// 加载目录树
initEntryTree(this_, currentHomeId, currentHomeName);
// initEntryTreeChecked(tree, this_.currentHomeId);
// 加载用户列表
initUserList(this_, currentHomeId, currentHomeName);
});
// 编辑用户按钮事件
$("#userEdit").bind("click", function () {
if(!currentHomeId || currentHomeId === ""){
layer.msg("请选择门户!");
// element.tabChange('homeTabBrief', '111');
return;
}
// 可见区域宽度
var docClientW = document.documentElement.clientWidth;
// 可见区域高度
var docClientH = document.documentElement.clientHeight;
// 计算宽高
var openwidth = (docClientW * 90)/100;
var openheight = (docClientH * 90)/100;
//iframe层
var index = layer.open({
title: '编辑用户',
type: 2,
area: [docClientW + 'px', docClientH + 'px'],
fixed: false, //不固定
maxmin: false, // 是否显示最大/最小化
content: "${fineServletURL}/cpic/user?homeId="+currentHomeId,
end: function(){
// 关闭iframe后刷新用户列表
initUserList(this_, currentHomeId, currentHomeName);
}
});
layer.full(index);
});
});
// 输入事件
function pathInput(inputItem, fineServletURL){
var origin = window.location.origin;
// url预览
$("#homePath").text(origin + fineServletURL + '/home/'+ inputItem.value);
}
// 加载门户列表
function initHomeList(homeId, homeName) {
$.ajax({
url: "${fineServletURL}/cpic/home/list",
success: function (result) {
// console.log("门户列表", result, result.data.homeList.length);
// 清空元素
$("#homeList").children().remove();
// 加载元素
if (result && result.data.homeList.length > 0) {
for (let i = 0; i < result.data.homeList.length; i++) {
let item = result.data.homeList[i];
if (homeId && homeId === item.id) {
$("#homeList").append('<li lay-options=\"{index:\'' + i + '\', id:\'' + item.id + '\', name:\'' + item.name + '\', path:\'' + item.path + '\', mhpath:\'' + item.mhpath + '\', themeId:\'' + item.themeId + '\', themeName:\'' + item.themeName + '\'}\" class=\"layui-menu-item-checked\">' +
'<div class=\"layui-menu-body-title\">' + item.name + '</div>' +
'</li>');
} else {
$("#homeList").append('<li lay-options=\"{index:\'' + i + '\', id:\'' + item.id + '\', name:\'' + item.name + '\', path:\'' + item.path + '\', mhpath:\'' + item.mhpath + '\', themeId:\'' + item.themeId + '\', themeName:\'' + item.themeName + '\'}\"' +
'<div class=\"layui-menu-body-title\">' + item.name + '</div>' +
'</li>');
}
}
} else {
$("#homeList").html("<p>没有数据</p>");
}
}
});
}
// 加载主题列表
function initThemeList(form) {
$.ajax({
url: "${fineServletURL}/cpic/home/themes",
success: function (result) {
// console.log("主题列表", result, result.data.length);
// 加载元素
if (result && result.data.length > 0) {
for (let i = 0; i < result.data.length; i++) {
let item = result.data[i];
$("#themeSelect").append('<option value=\'' + item.themeId + '\'>' + item.name + '</option>');
}
}
// 重新渲染
form.render('select', 'homeForm');
}
});
}
// 加载目录树
function initEntryTree(this_, currentHomeId, currentHomeName) {
// 清空元素
$('#entryTree').children().remove();
$.ajax({
async: false,
url: "${fineServletURL}/cpic/home/entrys?homeId=" + currentHomeId,
success: function (result) {
this_.tree.render({
elem: '#entryTree'
,data: result.data
,showCheckbox: true //是否显示复选框
,showLine: false
,id: 'entryTree1'
,oncheck: function(obj){
var itemData = obj.data;
// console.log("当前选择项",itemData);
// itemData.checked = obj.checked;
// var checkData = this_.tree.getChecked('entryTree1');
// console.log("全部选择项",checkData);
// 获取所有选中项
var checkeditems = [];
$('#entryTree').find('.layui-form-checked').each(function(){
var itemvalue = $(this).prev().val();
var itemtext = $(this).next().text();
checkeditems.push({
id: itemvalue,
title: itemtext
});
});
// console.log("全部选择项2",checkeditems);
$.ajax({
type: "POST",
async: false,
url:"${fineServletURL}/cpic/home/entrys?homeId=" + currentHomeId,
contentType: "application/json",
data: JSON.stringify(checkeditems),
success:function(res){
if(res.data === "success"){
// initEntryTree(tree, this_.currentHomeId);
initEntryTreeChecked(this_.tree, currentHomeId);
}else if(res.errorCode === "-1"){
layer.msg('更新目录失败');
}
}
});
}
});
initEntryTreeChecked(this_.tree, currentHomeId);
}
});
}
// 加载用户列表
function initUserList(this_, currentHomeId, currentHomeName) {
// 清空元素
$('#userList').children().remove();
$.ajax({
async: false,
url: "${fineServletURL}/cpic/user/list2?homeId=" + currentHomeId+ "&menuId=100&menuType=all",
success: function (result) {
// 加载列表
var userList = result.data;
// 加载分页
this_.laypage.render({
elem: 'userPageBar'
,count: userList.length
,limit: 50
,groups: 2
// ,limits: [50, 100, 200]
// ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
,layout: ['count', 'prev', 'page', 'next']
,theme: '#1E9FFF'
,jump: function(obj){
//渲染
document.getElementById('userList').innerHTML = function(){
var arr = []
,thisData = userList.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
layui.each(thisData, function(index, item){
// arr.push('<li>'+ item +'</li>');
arr.push('<button type=\"button\" class=\"layui-btn layui-btn-radius layui-btn-primary\">'+item.userName+'('+item.userAccount+')</button>');
});
return arr.join('');
}();
}
});
}
});
}
// 加载目录树选中
function initEntryTreeChecked(tree, homeId) {
// console.log(homeId);
if(!homeId){
return;
}
// 复选框勾选
$.ajax({
async: false,
url: "${fineServletURL}/cpic/home/entrychecked?homeId=" + homeId,
success: function (result1) {
if(result1.data && result1.data.length > 0 ){
// 清空全部选中
$("input[same='layuiTreeCheck']").attr("checked", false);
$(".layui-form-checked").removeClass("layui-form-checked");
for (var item in result1.data) {
var checkinputname = "layuiTreeCheck_"+result1.data[item];
// console.log($('input[name='+checkinputname+']'));
$('input[name='+checkinputname+']').attr("checked", true);
$('input[name='+checkinputname+']').next().addClass("layui-form-checked");
}
// tree.reload('entryTree1', {});
}
}
});
}
</script>
</html>

40
src/main/resources/com/fr/plugin/cpic/web/html/resources/index.html

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${charset}">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>${title}</title>
<link rel="preload" href="${fineServletURL}/resources?path=/com/fr/web/ui/font/iconfont.woff" as="font" type="font/woff" crossorigin>
<!--css文件-->
${styleTag}
</head>
<body>
<div id="wrapper"></div>
<script type="text/javascript">
window.Dec = window.Dec || {};
window.Dec.injection = window.Dec.injection || {};
</script>
<script type="text/javascript">
Dec.fineServletURL = "${fineServletURL}";
Dec.system = ${system};
// 设置主题
// Dec.system.themeId = "${themeId}";
Dec.personal = ${personal};
</script>
${scriptTag}
<script>
Dec.start({
theme: {
name: "custom"
}
});
// 设置网页标题
// Dec.platformStyles.platformTitle = "${title}";
</script>
</body>
</html>

664
src/main/resources/com/fr/plugin/cpic/web/html/user.html

@ -0,0 +1,664 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>编辑用户</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript"
src="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/layui.js"></script>
<link href="${fineServletURL}/file?path=/com/fr/plugin/cpic/web/layui/css/layui.css" rel="stylesheet">
<style>
.layui-layout-right-15 {
position: absolute !important;
right: 15px;
top: 2px
}
.users-body{
padding:10px;
margin: 10px;
min-height: 200px;
overflow: auto;
}
.users-body .users-left-list .layui-btn{
margin: 5px;
}
.users-body .users-right-list .layui-btn{
margin: 5px;
}
</style>
</head>
<body>
<div class="layui-bg-gray" style="padding: 10px;">
<div class="layui-row layui-col-space15">
<div class="layui-col-md2">
<div class="layui-card">
<div class="layui-card-header">
<p>筛选维度</p>
</div>
<div class="layui-card-body">
<div class="users-dimension" >
<div class="users-dimension-list" id="dimensionList">
<form class="layui-form" action="" lay-filter="dimensionForm">
<div class="layui-form-item">
<div class="layui-input-block" style="margin-left: 0px;">
<input type="radio" name="dimension" lay-filter="dimension-radio" value="all" title="全部用户" checked="">
<input type="radio" name="dimension" lay-filter="dimension-radio" value="department" title="部门">
<input type="radio" name="dimension" lay-filter="dimension-radio" value="customrole" title="角色">
</div>
</div>
</form>
</div>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
<legend></legend>
</fieldset>
<div class="users-dimension-body" style="overflow: auto;">
<div class="users-dimension-tree" id="dimensionTree">
</div>
</div>
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-card">
<div class="layui-card-header">
<p>用户列表</p>
<div class="layui-layout-right-15">
<button type="button" id="allSelect" class="layui-btn layui-btn-radius layui-btn-primary" style="float: right;">全选</button>
</div>
</div>
<div class="layui-card-body">
<div class="users-body" >
<div class="users-left-list" id="leftList">
</div>
</div>
<div class="left-toolbar" id="leftPageBar"></div>
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-card">
<div class="layui-card-header">
<p>选中列表</p>
<div class="layui-layout-right-15">
<button type="button" id="allCancel" class="layui-btn layui-btn-radius layui-btn-primary" style="float: right;">清空</button>
</div>
</div>
<div class="layui-card-body">
<div class="users-body" >
<div class="users-right-list" id="rightList">
</div>
</div>
<div class="right-toolbar" id="rightPageBar"></div>
</div>
</div>
</div>
</div>
</div>
<div style="width: 100%;height: 50px;">
<div style="float: right;padding: 6px;padding-right: 30px;">
<button type="button" id="userSubmit" class="layui-btn layui-btn-normal" style="float: left;margin-right: 15px;">保存</button>
<button type="button" id="userCancel" class="layui-btn layui-btn-primary" style="float: right;">关闭</button>
</div>
</div>
</body>
<script>
layui.use(function () {
var this_ = this;
var leftData = [];
var leftRemoveData = [];
var rightData = [];
var rightRemoveData = [];
var selectMenuId = "100";
var selectMenuType = "all";
var layer = layui.layer
, form = layui.form
, laypage = layui.laypage
, element = layui.element
, laydate = layui.laydate
, util = layui.util
, dropdown = layui.dropdown
, tree = layui.tree
, table = layui.table;
// 窗口索引
var iframeIndex = parent.layer.getFrameIndex(window.name);
// 动态设置页面高度
var docClientH = document.documentElement.clientHeight; // 可见区域高度
$(".layui-card-body").height(docClientH - 133);
$(".users-body").height(docClientH - 133 - 80);
$(".users-dimension-body").height(docClientH - 163 - 80);
$(window).resize(function () {
docClientH = document.documentElement.clientHeight;
$(".layui-card-body").height(docClientH - 133);
$(".users-body").height(docClientH - 133 - 80);
$(".users-dimension-body").height(docClientH - 163 - 80);
});
// 单选事件
form.on('radio(dimension-radio)', function(data){
if(selectMenuType === data.value){
return;
}
if((leftRemoveData && leftRemoveData.length > 0) || (rightRemoveData && rightRemoveData.length > 0)){
layer.confirm('放弃修改?', {
btn: ['确定','取消'] //按钮
}, function(index, layero){
// 清空记录
selectMenuType = data.value;
this_.leftData = [];
this_.rightData = [];
leftRemoveData = [];
rightRemoveData = [];
changeDimension();
// 关闭弹窗
layer.close(index);
}, function(index){
// console.log(selectMenuType);
form.val("dimensionForm",{
dimension: selectMenuType
});
layer.close(index);
});
}else{
selectMenuType = data.value;
this_.leftData = [];
this_.rightData = [];
leftRemoveData = [];
rightRemoveData = [];
// console.log(this_.leftData, this_.rightData);
changeDimension();
}
});
function changeDimension(){
// 切换菜单
if(selectMenuType === "all"){
// 加载左侧用户列表
initLeftListData(this_, '100', "all");
// 加载右侧用户列表
initRightListData(this_, '100', "all");
}else{
// 先清空数据
initLeftList(this_);
initRightList(this_);
// 获取菜单
$.ajax({
url: "${fineServletURL}/cpic/user/menus?dimensionType=" + selectMenuType,
success: function (result) {
this_.tree.render({
elem: '#dimensionTree'
,data: result.data
,onlyIconControl: true //是否仅允许节点左侧图标控制展开收缩
,click: function(obj){
// layer.msg(JSON.stringify(obj.data));
selectMenuId = obj.data.id;
// 根据类型加载用户
// 有操作记录时提示是否放弃
if((leftRemoveData && leftRemoveData.length > 0) || (rightRemoveData && rightRemoveData.length > 0)){
layer.confirm('放弃修改?', {
btn: ['确定','取消'] //按钮
}, function(index, layero){
// 加载左侧用户列表
initLeftListData(this_, selectMenuId, selectMenuType);
// 加载右侧用户列表
initRightListData(this_, selectMenuId, selectMenuType);
// 清空记录
leftRemoveData = [];
rightRemoveData = [];
// 关闭弹窗
layer.close(index);
}, function(index){
layer.close(index);
});
}else{
// 加载左侧用户列表
initLeftListData(this_, selectMenuId, selectMenuType);
// 加载右侧用户列表
initRightListData(this_, selectMenuId, selectMenuType);
// 清空记录
leftRemoveData = [];
rightRemoveData = [];
}
}
});
}
});
}
}
$.ajax({
url: "${fineServletURL}/cpic/user/menu",
success: function (result) {
this_.menuData = eval('(' + result.data + ')');
dropdown.render({
elem: '#userFilterMenu'
,data: this_.menuData
,click: function(data, othis){
var that = this;
// 有操作记录时提示是否放弃
if((leftRemoveData && leftRemoveData.length > 0) || (rightRemoveData && rightRemoveData.length > 0)){
layer.confirm('放弃修改?', {
btn: ['确定','取消'] //按钮
}, function(index, layero){
that.elem.val(data.title);
selectMenuId = data.id;
selectMenuType = data.mtype;
// 加载左侧用户列表
initLeftListData(this_, selectMenuId, selectMenuType);
// 加载右侧用户列表
initRightListData(this_, selectMenuId, selectMenuType);
// 清空记录
leftRemoveData = [];
rightRemoveData = [];
// 关闭弹窗
layer.close(index);
}, function(index){
layer.close(index);
});
}else{
that.elem.val(data.title);
selectMenuId = data.id;
selectMenuType = data.mtype;
// 加载左侧用户列表
initLeftListData(this_, selectMenuId, selectMenuType);
// 加载右侧用户列表
initRightListData(this_, selectMenuId, selectMenuType);
// 清空记录
leftRemoveData = [];
rightRemoveData = [];
}
}
,style: 'width: 235px;'
});
}
});
// 左侧用户列表点击事件监听
$(document).on("click", ".left-user-btn", function () {
var userId = $(this).attr("userId");
var userName = $(this).attr("userName");
var userAccount = $(this).attr("userAccount");
// 右侧列表add
var userItem = {
userId: userId,
userName: userName,
userAccount: userAccount
}
var isadd = rightListAdd(this_, userItem);
if(isadd){
// 右侧新增成功时记录左侧删除数据
var leftRemoveTemp;
for (const index in leftRemoveData) {
if(leftRemoveData[index]['userId'] === userId){
leftRemoveTemp = index;
break;
}
}
if(!leftRemoveTemp){
leftRemoveData.unshift(userItem);
}
// 右侧新增成功时去除右侧删除记录(如果有)
rightRemoveData = arrRemoveItem(rightRemoveData, 'userId', userId);
}
// console.log("leftClick", this_.leftData, " || ", leftRemoveData, " || ", this_.rightData, " || ", rightRemoveData);
});
// 右侧用户列表点击事件监听
$(document).on("click", ".right-user-btn", function () {
var userId = $(this).attr("userId");
var userName = $(this).attr("userName");
var userAccount = $(this).attr("userAccount");
// 右侧列表add
var userItem = {
userId: userId,
userName: userName,
userAccount: userAccount
}
var isadd = leftListAdd(this_, userItem);
if(isadd){
// 左侧新增成功时记录右侧删除数据
var rightRemoveTemp;
for (const index in rightRemoveData) {
if(rightRemoveData[index]['userId'] === userId){
rightRemoveTemp = index;
break;
}
}
if(!rightRemoveTemp){
rightRemoveData.unshift(userItem);
}
// 左侧新增成功时去除左侧删除记录(如果有)
leftRemoveData = arrRemoveItem(leftRemoveData, 'userId', userId);
}
// console.log("rightClick", this_.leftData, " || ", leftRemoveData, " || ", this_.rightData, " || ", rightRemoveData);
});
// 全选按钮事件
$("#allSelect").bind("click", function () {
// 加入右侧
var tempList = [];
for (const index in this_.leftData) {
var hasit = false;
for (const index2 in this_.rightData) {
if(this_.leftData[index]['userId'] === this_.rightData[index2]['userId']){
hasit = true;
break;
}
}
if(!hasit){
tempList.unshift(this_.leftData[index]);
this_.rightData.unshift(this_.leftData[index]);
}
}
// 记录移除
for (const index in tempList) {
var hasit = false;
for (const index2 in leftRemoveData) {
if(tempList[index]['userId'] === leftRemoveData[index2]['userId']){
hasit = true;
break;
}
}
if(!hasit){
leftRemoveData.unshift(tempList[index]);
}
}
// 清空左侧
this_.leftData = [];
// 清空右侧删除记录
rightRemoveData = [];
// console.log("allSelect", this_.leftData, " || ", leftRemoveData, " || ", this_.rightData, " || ", rightRemoveData);
// 重新渲染
initLeftList(this_);
initRightList(this_);
});
// 清空按钮事件
$("#allCancel").bind("click", function () {
// 加入左侧
var tempList = [];
for (const index in this_.rightData) {
var hasit = false;
for (const index2 in this_.leftData) {
if(this_.rightData[index]['userId'] === this_.leftData[index2]['userId']){
hasit = true;
break;
}
}
if(!hasit){
tempList.unshift(this_.rightData[index]);
this_.leftData.unshift(this_.rightData[index]);
}
}
// 记录移除
for (const index in tempList) {
var hasit = false;
for (const index2 in rightRemoveData) {
if(tempList[index]['userId'] === rightRemoveData[index2]['userId']){
hasit = true;
break;
}
}
if(!hasit){
rightRemoveData.unshift(tempList[index]);
}
}
// 清空右侧
this_.rightData = [];
// 清除左侧删除记录
leftRemoveData = [];
// console.log("allCancel", this_.leftData, " || ", leftRemoveData, " || ", this_.rightData, " || ", rightRemoveData);
// 重新渲染
initLeftList(this_);
initRightList(this_);
});
// 保存按钮事件
$("#userSubmit").bind("click", function () {
if((leftRemoveData && leftRemoveData.length > 0) || (rightRemoveData && rightRemoveData.length > 0)){
// 保存
$.ajax({
type: "POST",
async: false,
url:"${fineServletURL}/cpic/user/add?homeId=" + GetQueryString("homeId") + "&menuId="+selectMenuId + "&menuType=" + selectMenuType,
contentType: "application/json",
data: JSON.stringify(this_.rightData),
success:function(res){
if(res.data === "success"){
layer.msg("保存成功");
// 加载左侧用户列表
initLeftListData(this_, selectMenuId, selectMenuType);
// 加载右侧用户列表
initRightListData(this_, selectMenuId, selectMenuType);
// 清除记录
leftRemoveData = [];
rightRemoveData = [];
}else if(res.errorCode === "-1"){
layer.msg('更新用户失败');
}
}
});
}else{
return false;
}
});
// 取消按钮
$('#userCancel').click(function(){
// 有操作记录时提示是否放弃
if((leftRemoveData && leftRemoveData.length > 0) || (rightRemoveData && rightRemoveData.length > 0)){
layer.confirm('放弃修改?', {
btn: ['确定','取消'] //按钮
}, function(index, layero){
// 关闭弹窗
layer.close(index);
// 关闭页面
parent.layer.close(iframeIndex);
}, function(index){
layer.close(index);
});
}else{
parent.layer.close(iframeIndex);
}
});
// 加载左侧用户列表
initLeftListData(this_, '100', "all");
// 加载右侧用户列表
initRightListData(this_, '100', "all");
});
// 右侧列表数据add
function rightListAdd(this_, userItem){
if(!userItem){
return false;
}
var userId = userItem.userId;
// 查询当前用户是否在右侧存在
var rightTemp;
for (const index in this_.rightData) {
if(this_.rightData[index].userId === userId){
rightTemp = index;
break;
}
}
// 存在
if(rightTemp){
return false;
}
// 新增右侧数据
this_.rightData.unshift(userItem);
// 删除左侧数据
this_.leftData = arrRemoveItem(this_.leftData, 'userId', userId);
// 重新渲染
initLeftList(this_);
initRightList(this_);
return true;
}
// 左侧列表数据add
function leftListAdd(this_, userItem){
if(!userItem){
return false;
}
var userId = userItem.userId;
// 查询当前用户是否在左侧存在
var leftTemp;
for (const index in this_.leftData) {
if(this_.leftData[index].userId === userId){
leftTemp = index;
break;
}
}
// 存在
if(leftTemp){
return false;
}
// 新增左侧数据
this_.leftData.unshift(userItem);
// 删除右侧数据
this_.rightData = arrRemoveItem(this_.rightData, 'userId', userId);
// 重新渲染
initLeftList(this_);
initRightList(this_);
return true;
}
function arrRemoveItem (arr, attr, value) {
if (!arr || arr.length == 0) {
return [];
}
let newArr = arr.filter(function (item, index) {
return item[attr] != value;
})
return newArr;
}
// 获取url参数
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
var context = "";
if (r != null)
context = decodeURIComponent(r[2]);
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "" : context;
}
// 加载用户列表
function initLeftListData(this_, menuId, mtype) {
$.ajax({
async: false,
url: "${fineServletURL}/cpic/user/list?homeId=" + GetQueryString("homeId") + "&menuId="+menuId + "&menuType=" + mtype,
success: function (result) {
// 加载列表
this_.leftData = result.data;
// 渲染
initLeftList(this_);
}
});
}
// 加载用户列表
function initLeftList(this_) {
// 清空元素
$('#leftList').children().remove();
// 加载分页
this_.laypage.render({
elem: 'leftPageBar'
,count: this_.leftData.length
,limit: 5
,groups: 2
// ,limits: [50, 100, 200]
// ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
,layout: ['count', 'prev', 'page', 'next']
,theme: '#1E9FFF'
,jump: function(obj){
//渲染
document.getElementById('leftList').innerHTML = function(){
var arr = []
,thisData = this_.leftData.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
layui.each(thisData, function(index, item){
// arr.push('<li>'+ item +'</li>');
arr.push('<button type=\"button\" class=\"layui-btn layui-btn-radius layui-btn-primary left-user-btn\" userId=\"'+item.userId+'\" userName=\"'+item.userName+'\" userAccount=\"'+item.userAccount+'\">'+item.userName+'('+item.userAccount+')</button>');
});
return arr.join('');
}();
}
});
}
// 加载用户列表
function initRightListData(this_, menuId, mtype) {
$.ajax({
async: false,
url: "${fineServletURL}/cpic/user/list2?homeId=" + GetQueryString("homeId") + "&menuId="+menuId + "&menuType=" + mtype,
success: function (result) {
// 加载列表
this_.rightData = result.data;
// 渲染
initRightList(this_);
}
});
}
// 加载用户列表
function initRightList(this_) {
// 清空元素
$('#rightList').children().remove();
// 加载分页
this_.laypage.render({
elem: 'rightPageBar'
,count: this_.rightData.length
,limit: 50
,groups: 2
// ,limits: [50, 100, 200]
// ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
,layout: ['count', 'prev', 'page', 'next']
,theme: '#1E9FFF'
,jump: function(obj){
//渲染
document.getElementById('rightList').innerHTML = function(){
var arr = []
,thisData = this_.rightData.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
layui.each(thisData, function(index, item){
// arr.push('<li>'+ item +'</li>');
arr.push('<button type=\"button\" class=\"layui-btn layui-btn-radius layui-btn-primary right-user-btn\" userId=\"'+item.userId+'\" userName=\"'+item.userName+'\" userAccount=\"'+item.userAccount+'\">'+item.userName+'('+item.userAccount+')</button>');
});
return arr.join('');
}();
}
});
}
</script>
</html>

46
src/main/resources/com/fr/plugin/cpic/web/js/cpic_home.js

@ -0,0 +1,46 @@
;
Dec.Utils = Dec.Utils || {};
!(function () {
// 向管理系统节点加入 报表权限审批
BI.config("dec.provider.management", function (provider) {
provider.inject({
modules: [
{
value: "pluginhome",
id: "dec_plugin_home_id",
text: BI.i18nText("门户管理"),
cardType: "dec.plugin.management.home",
cls: "management-plugin-font"
}
]
});
});
// 组件实现,效果为使用绝对布局组件放置了一个iframe
var HomeWidget = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-management-cpic"
},
render: function () {
return {
type: "bi.absolute",
items: [
{
el: {
type: "bi.iframe",
src: Dec.fineServletURL + "/cpic/home"
},
top: 0,
left: 0,
right: 0,
bottom: 0
}
]
};
}
});
BI.shortcut("dec.plugin.management.home", HomeWidget);
}());

5821
src/main/resources/com/fr/plugin/cpic/web/layui/css/layui.css

File diff suppressed because it is too large Load Diff

1
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/code.css

@ -0,0 +1 @@
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#FAFAFA;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}

1
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/laydate/default/laydate.css

File diff suppressed because one or more lines are too long

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/icon-ext.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

914
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/layer.css

@ -0,0 +1,914 @@
.layui-layer-imgbar, .layui-layer-imgtit a, .layui-layer-tab .layui-layer-title span, .layui-layer-title {
text-overflow: ellipsis;
white-space: nowrap
}
html #layuicss-layer {
display: none;
position: absolute;
width: 1989px
}
.layui-layer, .layui-layer-shade {
position: fixed;
_position: absolute;
pointer-events: auto
}
.layui-layer-shade {
top: 0;
left: 0;
width: 100%;
height: 100%;
_height: expression(document.body.offsetHeight+"px")
}
.layui-layer {
-webkit-overflow-scrolling: touch;
top: 150px;
left: 0;
margin: 0;
padding: 0;
background-color: #fff;
-webkit-background-clip: content;
border-radius: 2px;
box-shadow: 1px 1px 50px rgba(0, 0, 0, .3)
}
.layui-layer-close {
position: absolute
}
.layui-layer-content {
position: relative
}
.layui-layer-border {
border: 1px solid #B2B2B2;
border: 1px solid rgba(0, 0, 0, .1);
box-shadow: 1px 1px 5px rgba(0, 0, 0, .2)
}
.layui-layer-load {
background: url(resources?path=com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-1.gif) center center no-repeat #eee
}
.layui-layer-ico {
background: url(resources?path=com/fr/plugin/cpic/web/layui/css/modules/layer/default/icon.png) no-repeat
}
.layui-layer-btn a, .layui-layer-dialog .layui-layer-ico, .layui-layer-setwin a {
display: inline-block;
*display: inline;
*zoom: 1;
vertical-align: top
}
.layui-layer-move {
display: none;
position: fixed;
*position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
cursor: move;
opacity: 0;
filter: alpha(opacity=0);
background-color: #fff;
z-index: 2147483647
}
.layui-layer-resize {
position: absolute;
width: 15px;
height: 15px;
right: 0;
bottom: 0;
cursor: se-resize
}
.layer-anim {
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-duration: .3s;
animation-duration: .3s
}
@-webkit-keyframes layer-bounceIn {
0% {
opacity: 0;
-webkit-transform: scale(.5);
transform: scale(.5)
}
100% {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1)
}
}
@keyframes layer-bounceIn {
0% {
opacity: 0;
-webkit-transform: scale(.5);
-ms-transform: scale(.5);
transform: scale(.5)
}
100% {
opacity: 1;
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1)
}
}
.layer-anim-00 {
-webkit-animation-name: layer-bounceIn;
animation-name: layer-bounceIn
}
@-webkit-keyframes layer-zoomInDown {
0% {
opacity: 0;
-webkit-transform: scale(.1) translateY(-2000px);
transform: scale(.1) translateY(-2000px);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out
}
60% {
opacity: 1;
-webkit-transform: scale(.475) translateY(60px);
transform: scale(.475) translateY(60px);
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out
}
}
@keyframes layer-zoomInDown {
0% {
opacity: 0;
-webkit-transform: scale(.1) translateY(-2000px);
-ms-transform: scale(.1) translateY(-2000px);
transform: scale(.1) translateY(-2000px);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out
}
60% {
opacity: 1;
-webkit-transform: scale(.475) translateY(60px);
-ms-transform: scale(.475) translateY(60px);
transform: scale(.475) translateY(60px);
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out
}
}
.layer-anim-01 {
-webkit-animation-name: layer-zoomInDown;
animation-name: layer-zoomInDown
}
@-webkit-keyframes layer-fadeInUpBig {
0% {
opacity: 0;
-webkit-transform: translateY(2000px);
transform: translateY(2000px)
}
100% {
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0)
}
}
@keyframes layer-fadeInUpBig {
0% {
opacity: 0;
-webkit-transform: translateY(2000px);
-ms-transform: translateY(2000px);
transform: translateY(2000px)
}
100% {
opacity: 1;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0)
}
}
.layer-anim-02 {
-webkit-animation-name: layer-fadeInUpBig;
animation-name: layer-fadeInUpBig
}
@-webkit-keyframes layer-zoomInLeft {
0% {
opacity: 0;
-webkit-transform: scale(.1) translateX(-2000px);
transform: scale(.1) translateX(-2000px);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out
}
60% {
opacity: 1;
-webkit-transform: scale(.475) translateX(48px);
transform: scale(.475) translateX(48px);
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out
}
}
@keyframes layer-zoomInLeft {
0% {
opacity: 0;
-webkit-transform: scale(.1) translateX(-2000px);
-ms-transform: scale(.1) translateX(-2000px);
transform: scale(.1) translateX(-2000px);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out
}
60% {
opacity: 1;
-webkit-transform: scale(.475) translateX(48px);
-ms-transform: scale(.475) translateX(48px);
transform: scale(.475) translateX(48px);
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out
}
}
.layer-anim-03 {
-webkit-animation-name: layer-zoomInLeft;
animation-name: layer-zoomInLeft
}
@-webkit-keyframes layer-rollIn {
0% {
opacity: 0;
-webkit-transform: translateX(-100%) rotate(-120deg);
transform: translateX(-100%) rotate(-120deg)
}
100% {
opacity: 1;
-webkit-transform: translateX(0) rotate(0);
transform: translateX(0) rotate(0)
}
}
@keyframes layer-rollIn {
0% {
opacity: 0;
-webkit-transform: translateX(-100%) rotate(-120deg);
-ms-transform: translateX(-100%) rotate(-120deg);
transform: translateX(-100%) rotate(-120deg)
}
100% {
opacity: 1;
-webkit-transform: translateX(0) rotate(0);
-ms-transform: translateX(0) rotate(0);
transform: translateX(0) rotate(0)
}
}
.layer-anim-04 {
-webkit-animation-name: layer-rollIn;
animation-name: layer-rollIn
}
@keyframes layer-fadeIn {
0% {
opacity: 0
}
100% {
opacity: 1
}
}
.layer-anim-05 {
-webkit-animation-name: layer-fadeIn;
animation-name: layer-fadeIn
}
@-webkit-keyframes layer-shake {
0%, 100% {
-webkit-transform: translateX(0);
transform: translateX(0)
}
10%, 30%, 50%, 70%, 90% {
-webkit-transform: translateX(-10px);
transform: translateX(-10px)
}
20%, 40%, 60%, 80% {
-webkit-transform: translateX(10px);
transform: translateX(10px)
}
}
@keyframes layer-shake {
0%, 100% {
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0)
}
10%, 30%, 50%, 70%, 90% {
-webkit-transform: translateX(-10px);
-ms-transform: translateX(-10px);
transform: translateX(-10px)
}
20%, 40%, 60%, 80% {
-webkit-transform: translateX(10px);
-ms-transform: translateX(10px);
transform: translateX(10px)
}
}
.layer-anim-06 {
-webkit-animation-name: layer-shake;
animation-name: layer-shake
}
@-webkit-keyframes fadeIn {
0% {
opacity: 0
}
100% {
opacity: 1
}
}
.layui-layer-title {
padding: 0 80px 0 20px;
height: 50px;
line-height: 50px;
border-bottom: 1px solid #F0F0F0;
font-size: 14px;
color: #333;
overflow: hidden;
border-radius: 2px 2px 0 0
}
.layui-layer-setwin {
position: absolute;
right: 15px;
*right: 0;
top: 17px;
font-size: 0;
line-height: initial
}
.layui-layer-setwin a {
position: relative;
width: 16px;
height: 16px;
margin-left: 10px;
font-size: 12px;
_overflow: hidden
}
.layui-layer-setwin .layui-layer-min cite {
position: absolute;
width: 14px;
height: 2px;
left: 0;
top: 50%;
margin-top: -1px;
background-color: #2E2D3C;
cursor: pointer;
_overflow: hidden
}
.layui-layer-setwin .layui-layer-min:hover cite {
background-color: #2D93CA
}
.layui-layer-setwin .layui-layer-max {
background-position: -32px -40px
}
.layui-layer-setwin .layui-layer-max:hover {
background-position: -16px -40px
}
.layui-layer-setwin .layui-layer-maxmin {
background-position: -65px -40px
}
.layui-layer-setwin .layui-layer-maxmin:hover {
background-position: -49px -40px
}
.layui-layer-setwin .layui-layer-close1 {
background-position: 1px -40px;
cursor: pointer
}
.layui-layer-setwin .layui-layer-close1:hover {
opacity: .7
}
.layui-layer-setwin .layui-layer-close2 {
position: absolute;
right: -28px;
top: -28px;
width: 30px;
height: 30px;
margin-left: 0;
background-position: -149px -31px;
*right: -18px;
_display: none
}
.layui-layer-setwin .layui-layer-close2:hover {
background-position: -180px -31px
}
.layui-layer-btn {
text-align: right;
padding: 0 15px 12px;
pointer-events: auto;
user-select: none;
-webkit-user-select: none
}
.layui-layer-btn a {
height: 28px;
line-height: 28px;
margin: 5px 5px 0;
padding: 0 15px;
border: 1px solid #dedede;
background-color: #fff;
color: #333;
border-radius: 2px;
font-weight: 400;
cursor: pointer;
text-decoration: none
}
.layui-layer-btn a:hover {
opacity: .9;
text-decoration: none
}
.layui-layer-btn a:active {
opacity: .8
}
.layui-layer-btn .layui-layer-btn0 {
border-color: #1E9FFF;
background-color: #1E9FFF;
color: #fff
}
.layui-layer-btn-l {
text-align: left
}
.layui-layer-btn-c {
text-align: center
}
.layui-layer-dialog {
min-width: 300px
}
.layui-layer-dialog .layui-layer-content {
position: relative;
padding: 20px;
line-height: 24px;
word-break: break-all;
overflow: hidden;
font-size: 14px;
overflow-x: hidden;
overflow-y: auto
}
.layui-layer-dialog .layui-layer-content .layui-layer-ico {
position: absolute;
top: 16px;
left: 15px;
_left: -40px;
width: 30px;
height: 30px
}
.layui-layer-ico1 {
background-position: -30px 0
}
.layui-layer-ico2 {
background-position: -60px 0
}
.layui-layer-ico3 {
background-position: -90px 0
}
.layui-layer-ico4 {
background-position: -120px 0
}
.layui-layer-ico5 {
background-position: -150px 0
}
.layui-layer-ico6 {
background-position: -180px 0
}
.layui-layer-rim {
border: 6px solid #8D8D8D;
border: 6px solid rgba(0, 0, 0, .3);
border-radius: 5px;
box-shadow: none
}
.layui-layer-msg {
min-width: 180px;
border: 1px solid #D3D4D3;
box-shadow: none
}
.layui-layer-hui {
min-width: 100px;
background-color: #000;
filter: alpha(opacity=60);
background-color: rgba(0, 0, 0, .6);
color: #fff;
border: none
}
.layui-layer-hui .layui-layer-content {
padding: 12px 25px;
text-align: center
}
.layui-layer-dialog .layui-layer-padding {
padding: 20px 20px 20px 55px;
text-align: left
}
.layui-layer-page .layui-layer-content {
position: relative;
overflow: auto
}
.layui-layer-iframe .layui-layer-btn, .layui-layer-page .layui-layer-btn {
padding-top: 10px
}
.layui-layer-nobg {
background: 0 0
}
.layui-layer-iframe iframe {
display: block;
width: 100%
}
.layui-layer-loading {
border-radius: 100%;
background: 0 0;
box-shadow: none;
border: none
}
.layui-layer-loading .layui-layer-content {
width: 60px;
height: 24px;
background: url(resources?path=com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-0.gif) no-repeat
}
.layui-layer-loading .layui-layer-loading1 {
width: 37px;
height: 37px;
background: url(resources?path=com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-1.gif) no-repeat
}
.layui-layer-ico16, .layui-layer-loading .layui-layer-loading2 {
width: 32px;
height: 32px;
background: url(resources?path=com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-2.gif) no-repeat
}
.layui-layer-tips {
background: 0 0;
box-shadow: none;
border: none
}
.layui-layer-tips .layui-layer-content {
position: relative;
line-height: 22px;
min-width: 12px;
padding: 8px 15px;
font-size: 12px;
_float: left;
border-radius: 2px;
box-shadow: 1px 1px 3px rgba(0, 0, 0, .2);
background-color: #000;
color: #fff
}
.layui-layer-tips .layui-layer-close {
right: -2px;
top: -1px
}
.layui-layer-tips i.layui-layer-TipsG {
position: absolute;
width: 0;
height: 0;
border-width: 8px;
border-color: transparent;
border-style: dashed;
*overflow: hidden
}
.layui-layer-tips i.layui-layer-TipsB, .layui-layer-tips i.layui-layer-TipsT {
left: 5px;
border-right-style: solid;
border-right-color: #000
}
.layui-layer-tips i.layui-layer-TipsT {
bottom: -8px
}
.layui-layer-tips i.layui-layer-TipsB {
top: -8px
}
.layui-layer-tips i.layui-layer-TipsL, .layui-layer-tips i.layui-layer-TipsR {
top: 5px;
border-bottom-style: solid;
border-bottom-color: #000
}
.layui-layer-tips i.layui-layer-TipsR {
left: -8px
}
.layui-layer-tips i.layui-layer-TipsL {
right: -8px
}
.layui-layer-lan[type=dialog] {
min-width: 280px
}
.layui-layer-lan .layui-layer-title {
background: #4476A7;
color: #fff;
border: none
}
.layui-layer-lan .layui-layer-btn {
padding: 5px 10px 10px;
text-align: right;
border-top: 1px solid #E9E7E7
}
.layui-layer-lan .layui-layer-btn a {
background: #fff;
border-color: #E9E7E7;
color: #333
}
.layui-layer-lan .layui-layer-btn .layui-layer-btn1 {
background: #C9C5C5
}
.layui-layer-molv .layui-layer-title {
background: #009f95;
color: #fff;
border: none
}
.layui-layer-molv .layui-layer-btn a {
background: #009f95;
border-color: #009f95
}
.layui-layer-molv .layui-layer-btn .layui-layer-btn1 {
background: #92B8B1
}
.layui-layer-iconext {
background: url(resources?path=com/fr/plugin/cpic/web/layui/css/modules/layer/default/icon-ext.png) no-repeat
}
.layui-layer-prompt .layui-layer-input {
display: block;
width: 260px;
height: 36px;
margin: 0 auto;
line-height: 30px;
padding-left: 10px;
border: 1px solid #e6e6e6;
color: #333
}
.layui-layer-prompt textarea.layui-layer-input {
width: 300px;
height: 100px;
line-height: 20px;
padding: 6px 10px
}
.layui-layer-prompt .layui-layer-content {
padding: 20px
}
.layui-layer-prompt .layui-layer-btn {
padding-top: 0
}
.layui-layer-tab {
box-shadow: 1px 1px 50px rgba(0, 0, 0, .4)
}
.layui-layer-tab .layui-layer-title {
padding-left: 0;
overflow: visible
}
.layui-layer-tab .layui-layer-title span {
position: relative;
float: left;
min-width: 80px;
max-width: 300px;
padding: 0 20px;
text-align: center;
overflow: hidden;
cursor: pointer
}
.layui-layer-tab .layui-layer-title span.layui-this {
height: 51px;
border-left: 1px solid #eee;
border-right: 1px solid #eee;
background-color: #fff;
z-index: 10
}
.layui-layer-tab .layui-layer-title span:first-child {
border-left: none
}
.layui-layer-tabmain {
line-height: 24px;
clear: both
}
.layui-layer-tabmain .layui-layer-tabli {
display: none
}
.layui-layer-tabmain .layui-layer-tabli.layui-this {
display: block
}
.layui-layer-photos {
background: 0 0;
box-shadow: none
}
.layui-layer-photos .layui-layer-content {
overflow: hidden;
text-align: center
}
.layui-layer-photos .layui-layer-phimg img {
position: relative;
width: 100%;
display: inline-block;
*display: inline;
*zoom: 1;
vertical-align: top
}
.layui-layer-imgnext, .layui-layer-imgprev {
position: fixed;
top: 50%;
width: 27px;
_width: 44px;
height: 44px;
margin-top: -22px;
outline: 0;
blr: expression(this.onFocus=this.blur())
}
.layui-layer-imgprev {
left: 30px;
background-position: -5px -5px;
_background-position: -70px -5px
}
.layui-layer-imgprev:hover {
background-position: -33px -5px;
_background-position: -120px -5px
}
.layui-layer-imgnext {
right: 30px;
_right: 8px;
background-position: -5px -50px;
_background-position: -70px -50px
}
.layui-layer-imgnext:hover {
background-position: -33px -50px;
_background-position: -120px -50px
}
.layui-layer-imgbar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 40px;
line-height: 40px;
background-color: #000 \9;
filter: Alpha(opacity=60);
background-color: rgba(2, 0, 0, .35);
color: #fff;
overflow: hidden;
font-size: 0
}
.layui-layer-imgtit * {
display: inline-block;
*display: inline;
*zoom: 1;
vertical-align: top;
font-size: 12px
}
.layui-layer-imgtit a {
max-width: 65%;
overflow: hidden;
color: #fff
}
.layui-layer-imgtit a:hover {
color: #fff;
text-decoration: underline
}
.layui-layer-imgtit em {
padding-left: 10px;
font-style: normal
}
@-webkit-keyframes layer-bounceOut {
100% {
opacity: 0;
-webkit-transform: scale(.7);
transform: scale(.7)
}
30% {
-webkit-transform: scale(1.05);
transform: scale(1.05)
}
0% {
-webkit-transform: scale(1);
transform: scale(1)
}
}
@keyframes layer-bounceOut {
100% {
opacity: 0;
-webkit-transform: scale(.7);
-ms-transform: scale(.7);
transform: scale(.7)
}
30% {
-webkit-transform: scale(1.05);
-ms-transform: scale(1.05);
transform: scale(1.05)
}
0% {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1)
}
}
.layer-anim-close {
-webkit-animation-name: layer-bounceOut;
animation-name: layer-bounceOut;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-duration: .2s;
animation-duration: .2s
}
@media screen and (max-width: 1100px) {
.layui-layer-iframe {
overflow-y: auto;
-webkit-overflow-scrolling: touch
}
}

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-0.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-1.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/css/modules/layer/default/loading-2.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.eot

Binary file not shown.

554
src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 299 KiB

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.ttf

Binary file not shown.

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.woff

Binary file not shown.

BIN
src/main/resources/com/fr/plugin/cpic/web/layui/font/iconfont.woff2

Binary file not shown.

2
src/main/resources/com/fr/plugin/cpic/web/layui/jquery-3.6.0.min.js vendored

File diff suppressed because one or more lines are too long

7105
src/main/resources/com/fr/plugin/cpic/web/layui/layui.js vendored

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save