Commit dc2e4ce4 by liuhui

首页微服务后台拆分

parent 764704c5
Showing with 3283 additions and 101 deletions
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.common.project.facet.core.builder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.validation.validationbuilder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
......@@ -4,18 +4,45 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sinobase</groupId>
<artifactId>sinobase-empty</artifactId>
<artifactId>sinobase-homepage</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>sinobase-homepage</name>
<description>示例子工程(空)</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
<spring-boot.version>2.1.1.RELEASE</spring-boot.version>
<spring.cloud.alibaba.version>2.1.0.RELEASE</spring.cloud.alibaba.version>
</properties>
<parent>
<groupId>com.sinobase</groupId>
<artifactId>sinobase</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--阿里数据库连接池 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring.cloud.alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
......@@ -36,6 +63,10 @@
</profiles>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringBoot 核心包 -->
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -4,15 +4,17 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan({"com.sinobase.empty.*.mapper"})
@ImportResource(value = {"classpath:dubbo.xml"})
public class EmptyApplication {
@EnableDiscoveryClient
public class HomePageApplication {
public static void main(String[] args){
SpringApplication.run(EmptyApplication.class, args);
SpringApplication.run(HomePageApplication.class, args);
}
}
......@@ -3,11 +3,11 @@ package com.sinobase;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class EmptyServletInitializer extends SpringBootServletInitializer{
public class HomePageServletInitializer extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(EmptyApplication.class);
return application.sources(HomePageApplication.class);
}
}
package com.sinobase.common.bean;
import java.io.Serializable;
import java.util.LinkedHashMap;
public class User implements Serializable {
private String id; //用户Id
private String loginName; //登录名
private String userName; //用户名
private String gender; //性别
private LinkedHashMap<String, String> dept; //所在部门(第一个是当前登录时所在的部门)
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public LinkedHashMap<String, String> getDept() {
return dept;
}
public void setDept(LinkedHashMap<String, String> dept) {
this.dept = dept;
}
}
package com.sinobase.common.util;
/**
* 常量专用类
*
* @author liuhui001
*
*/
public class CommonContent {
/**
* 国投智能外部单位
*
*/
public static String COMPANY_EXTEND = "231560";
}
package com.sinobase.common.utils;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.sinobase.common.support.Convert;
/**
* 客户端工具类
*
* @author sinobase
*/
public class ServletUtils {
public static String[] getParameters(String name) {
return getRequest().getParameterValues(name);
}
/**
* 获取String参数
*/
public static String getParameter(String name) {
return Convert.toStr(getRequest().getParameter(name), "");
}
/**
* 获取String参数
*/
public static String getParameter(String name, String defaultValue) {
return Convert.toStr(getRequest().getParameter(name), defaultValue);
}
/**
* 获取Integer参数
*/
public static Integer getParameterToInt(String name) {
return Convert.toInt(getRequest().getParameter(name));
}
/**
* 获取Integer参数
*/
public static Integer getParameterToInt(String name, Integer defaultValue) {
return Convert.toInt(getRequest().getParameter(name), defaultValue);
}
/**
* 获取Boolean参数
* @return
*/
public static Boolean getParameterToBoolean(String name) {
return Convert.toBool(getRequest().getParameter(name));
}
/**
* 获取request
*/
public static HttpServletRequest getRequest() {
return getRequestAttributes().getRequest();
}
/**
* 获取response
*/
public static HttpServletResponse getResponse() {
return getRequestAttributes().getResponse();
}
/**
* 获取session
*/
public static HttpSession getSession() {
return getRequest().getSession();
}
public static ServletRequestAttributes getRequestAttributes() {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes) attributes;
}
/**
* 将字符串渲染到客户端
*
* @param response 渲染对象
* @param string 待渲染的字符串
* @return null
*/
public static String renderString(HttpServletResponse response, String string) {
try {
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().print(string);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 是否是Ajax异步请求
*
* @param request
*/
public static boolean isAjaxRequest(HttpServletRequest request) {
String accept = request.getHeader("accept");
if (accept != null && accept.indexOf("application/json") != -1) {
return true;
}
String xRequestedWith = request.getHeader("X-Requested-With");
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) {
return true;
}
String uri = request.getRequestURI();
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) {
return true;
}
String ajax = request.getParameter("__ajax");
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) {
return true;
}
return false;
}
}
package com.sinobase.common.utils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.sinobase.project.system.menu.domain.Menu;
/**
* 权限数据处理
*
* @author sinobase
*/
public class TreeUtils {
/**
* 根据父节点的ID获取所有子节点
*
* @param list 分类表
* @param parentId 传入的父节点ID
* @return String
*/
public static List<Menu> getChildPerms(List<Menu> list, String parentId) {
List<Menu> returnList = new ArrayList<Menu>();
for (Iterator<Menu> iterator = list.iterator(); iterator.hasNext();) {
Menu t = (Menu) iterator.next();
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
if (t.getParentId().equals(parentId)) {
//System.out.println((t.getUrl().indexOf("parse_tab") > -1)+"------------"+ t.getMenuName()+"--------"+ t.getUrl());
if(t.getUrl().indexOf("parse_tab") < 0){
recursionFn(list, t);
}
returnList.add(t);
}
}
return returnList;
}
/**
* 递归列表
*
* @param list
* @param t
*/
private static void recursionFn(List<Menu> list, Menu t) {
// 得到子节点列表
List<Menu> childList = getChildList(list, t);
t.setChildren(childList);
for (Menu tChild : childList) {
if (hasChild(list, tChild)) {
// 判断是否有子节点
Iterator<Menu> it = childList.iterator();
while (it.hasNext()) {
Menu n = (Menu) it.next();
recursionFn(list, n);
}
}
}
}
/**
* 得到子节点列表
*/
private static List<Menu> getChildList(List<Menu> list, Menu t) {
List<Menu> tlist = new ArrayList<Menu>();
//20200103 LoubBin 添加 模块设置 标签页面功能无效BUG
if(t.getUrl().indexOf("parse_tab") < 0 && !t.getMenuType().equals("C")){
//System.out.println(t.getMenuName() + "------------"+t.getUrl());
Iterator<Menu> it = list.iterator();
while (it.hasNext()) {
Menu n = (Menu) it.next();
if (n.getParentId().equals(t.getMenuId())) {
tlist.add(n);
}
}
}
return tlist;
}
List<Menu> returnList = new ArrayList<Menu>();
/**
* 根据父节点的ID获取所有子节点
*
* @param list 分类表
* @param typeId 传入的父节点ID
* @param prefix 子节点前缀
*/
public List<Menu> getChildPerms(List<Menu> list, int typeId, String prefix) {
if (list == null) {
return null;
}
for (Iterator<Menu> iterator = list.iterator(); iterator.hasNext();) {
Menu node = (Menu) iterator.next();
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
if (node.getParentId().equals(typeId)) {
recursionFn(list, node, prefix);
}
// 二、遍历所有的父节点下的所有子节点
/*
* if (node.getParentId()==0) { recursionFn(list, node); }
*/
}
return returnList;
}
private void recursionFn(List<Menu> list, Menu node, String p) {
// 得到子节点列表
List<Menu> childList = getChildList(list, node);
if (hasChild(list, node)) {
// 判断是否有子节点
returnList.add(node);
Iterator<Menu> it = childList.iterator();
while (it.hasNext()) {
Menu n = (Menu) it.next();
n.setMenuName(p + n.getMenuName());
recursionFn(list, n, p + p);
}
} else {
returnList.add(node);
}
}
/**
* 判断是否有子节点
*/
private static boolean hasChild(List<Menu> list, Menu t) {
return getChildList(list, t).size() > 0 ? true : false;
}
}
package com.sinobase.common.utils.bean;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Bean 工具类
*
* @author sinobase
*/
public class BeanUtils
{
/** Bean方法名中属性名开始的下标 */
private static final int BEAN_METHOD_PROP_INDEX = 3;
/** * 匹配getter方法的正则表达式 */
private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
/** * 匹配setter方法的正则表达式 */
private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
/**
* Bean属性复制工具方法。
*
* @param dest 目标对象
* @param src 源对象
*/
public static void copyBeanProp(Object dest, Object src)
{
List<Method> destSetters = getSetterMethods(dest);
List<Method> srcGetters = getGetterMethods(src);
try
{
for (Method setter : destSetters)
{
for (Method getter : srcGetters)
{
if (isMethodPropEquals(setter.getName(), getter.getName())
&& setter.getParameterTypes()[0].equals(getter.getReturnType()))
{
setter.invoke(dest, getter.invoke(src));
}
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 获取对象的setter方法。
*
* @param obj 对象
* @return 对象的setter方法列表
*/
public static List<Method> getSetterMethods(Object obj)
{
// setter方法列表
List<Method> setterMethods = new ArrayList<Method>();
// 获取所有方法
Method[] methods = obj.getClass().getMethods();
// 查找setter方法
for (Method method : methods)
{
Matcher m = SET_PATTERN.matcher(method.getName());
if (m.matches() && (method.getParameterTypes().length == 1))
{
setterMethods.add(method);
}
}
// 返回setter方法列表
return setterMethods;
}
/**
* 获取对象的getter方法。
*
* @param obj 对象
* @return 对象的getter方法列表
*/
public static List<Method> getGetterMethods(Object obj)
{
// getter方法列表
List<Method> getterMethods = new ArrayList<Method>();
// 获取所有方法
Method[] methods = obj.getClass().getMethods();
// 查找getter方法
for (Method method : methods)
{
Matcher m = GET_PATTERN.matcher(method.getName());
if (m.matches() && (method.getParameterTypes().length == 0))
{
getterMethods.add(method);
}
}
// 返回getter方法列表
return getterMethods;
}
/**
* 检查Bean方法名中的属性名是否相等。<br>
* 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。
*
* @param m1 方法名1
* @param m2 方法名2
* @return 属性名一样返回true,否则返回false
*/
public static boolean isMethodPropEquals(String m1, String m2)
{
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
}
}
package com.sinobase.common.utils.security;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.RealmSecurityManager;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
import com.sinobase.common.utils.StringUtils;
import com.sinobase.common.utils.bean.BeanUtils;
import com.sinobase.framework.shiro.realm.UserRealm;
import com.sinobase.project.system.user.domain.User;
/**
* shiro 工具类
*
* @author sinobase
*/
public class ShiroUtils {
public static Subject getSubject() {
return SecurityUtils.getSubject();
}
public static Session getSession() {
return SecurityUtils.getSubject().getSession();
}
public static void logout() {
getSubject().logout();
}
public static User getSysUser() {
User user = null;
Object obj = getSubject().getPrincipal();
if (StringUtils.isNotNull(obj)) {
user = new User();
BeanUtils.copyBeanProp(user, obj);
}
return user;
}
public static void setSysUser(User user) {
Subject subject = getSubject();
PrincipalCollection principalCollection = subject.getPrincipals();
String realmName = principalCollection.getRealmNames().iterator().next();
PrincipalCollection newPrincipalCollection = new SimplePrincipalCollection(user, realmName);
// 重新加载Principal
subject.runAs(newPrincipalCollection);
}
public static void clearCachedAuthorizationInfo() {
RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager();
UserRealm realm = (UserRealm) rsm.getRealms().iterator().next();
realm.clearCachedAuthorizationInfo();
}
public static String getUserId() {
return getSysUser().getUserId();
}
public static String getLoginName() {
return getSysUser().getLoginName();
}
public static String getIp() {
return getSubject().getSession().getHost();
}
public static String getSessionId() {
return String.valueOf(getSubject().getSession().getId());
}
}
package com.sinobase.framework.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.io.File;
/**
* 读取项目相关配置
*
* @author sinobase
*/
@Component("sinoBaseConfig")
@ConfigurationProperties(prefix = "sinobase")
public class SinoBaseConfig {
/**
* 项目名称
*/
private String name;
/**
* 版本
*/
private String version;
/**
* 版权年份
*/
private String copyrightYear;
/**
* 上传路径
*/
private static String profile;
/**
* 获取地址开关
*/
private static boolean addressEnabled;
/**
* 文件服务地址<上传 /upload,下载 /get/{id},删除/delete/{id}
*/
private static String fileServer;
/**
* 映射路径
*/
private static String mappingUrl;
/**
* 是否集成公司的微服务平台
*/
private static boolean isPlatform;
private String templatePath;
/** 获取流程图JSON的IP地址 **/
private static String flowChartIp;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getCopyrightYear() {
return copyrightYear;
}
public void setCopyrightYear(String copyrightYear) {
this.copyrightYear = copyrightYear;
}
public static String getProfile() {
return profile;
}
public void setProfile(String profile) {
SinoBaseConfig.profile = profile;
}
public static boolean isAddressEnabled() {
return addressEnabled;
}
public void setAddressEnabled(boolean addressEnabled) {
SinoBaseConfig.addressEnabled = addressEnabled;
}
public static String getAvatarPath() {
return profile + "avatar" + File.separator;
}
public static String getDownloadPath() {
return profile + "download" + File.separator;
}
public void setIsPlatform(boolean isPlatform) {
SinoBaseConfig.isPlatform = isPlatform;
}
public static String getUploadPath() {
return profile + "upload" + File.separator;
}
/**
* 文件上传服务地址
*/
public static String getFileServer() {
return fileServer;
}
public void setFileServer(String fileServer) {
SinoBaseConfig.fileServer = fileServer;
}
public static String getMappingUrl() {
return mappingUrl;
}
public void setMappingUrl(String mappingUrl) {
SinoBaseConfig.mappingUrl = mappingUrl;
}
/**
* 是否集成公司的微服务平台
*
* @return
*/
public static boolean isPlatform() {
return isPlatform;
}
public String getTemplatePath() {
return templatePath;
}
public void setTemplatePath(String templatePath) {
this.templatePath = templatePath;
}
public static String getFlowChartIp() {
return flowChartIp;
}
public void setFlowChartIp(String flowChartIp) {
SinoBaseConfig.flowChartIp = flowChartIp;
}
}
package com.sinobase.framework.service;
import java.util.LinkedHashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.sinobase.common.bean.User;
import com.sinobase.common.utils.StringUtils;
import com.sinobase.common.utils.TreeUtils;
import com.sinobase.project.system.dept.domain.Dept;
import com.sinobase.project.system.menu.domain.Menu;
import com.sinobase.project.system.role.domain.Role;
import com.sinobase.project.system.user.domain.User;
import com.sinobase.transfer.service.ResourceService;
import com.sinobase.transfer.service.WorkflowService;
@Service
public class PlatformService {
......@@ -20,23 +27,91 @@ public class PlatformService {
@Autowired
private ResourceService resource;
@Autowired
private WorkflowService workflowService;
/**
* 在平台上业务系统的注册 ID
*/
@Value("${sinobase.system_id}")
private String SYSTEM_ID;
@SuppressWarnings("unchecked")
public User getUserByLoginname(String loginName) {
Map<String, Object> userMap = resource.getUserInfo(loginName, "");
User user = new User();
user.setLoginName(loginName);
user.setId(getStr(userMap, "userId"));
user.setUserName(getStr(userMap, "userFullName"));
user.setGender(getStr(userMap, "userSex"));
Map<String, Object> userMap = resource.getUserInfo(loginName, SYSTEM_ID);
User user = new User();
user.setUserId(getStr(userMap, "userId"));
user.setHistoryId(getStr(userMap, "historyId"));
user.setLoginName(getStr(userMap, "userName"));
user.setUserName(getStr(userMap, "userFullName"));
user.setSex(getStr(userMap, "userSex"));
user.setPhonenumber(getStr(userMap, "phone"));
user.setEmail(getStr(userMap, "email"));
user.setIdcNumber(getStr(userMap, "idCard"));
user.setPassword(getStr(userMap,"password"));
List<Map<String, String>> deptInfo = (List<Map<String, String>>) userMap.get("deptInfo");
LinkedHashMap<String, String> deptMap = new LinkedHashMap<String, String>();
for (Map<String, String> map : deptInfo) {
deptMap.put(map.get("deptId"), map.get("deptName"));
}
user.setDept(deptMap);
List<Dept> deptList = new ArrayList<Dept>();
int deptCount = 1;
for (Map<String, String> map : deptInfo) {
//平台返回的部门信息不全,根据平台返回的部门id,查询业务库部门信息
Dept dept = new Dept();
dept.setDeptId(getStr(map, "deptId"));
dept.setDeptName(getStr(map, "deptName"));
dept.setDeptShort(getStr(map, "abbreviation"));
dept.setParentId(getStr(map, "superId"));
dept.setHistoryId(getStr(map, "historyId"));
dept.setUnitType(getStr(map, "unitType"));
//父级相关信息
Map<String, Object> supermap = resource.getSuperDepMessage(getStr(map, "superId"));
dept.setHistoryCompanyId(getStr(supermap, "historyId"));
dept.setCompanyShortNameDept(getStr(supermap, "abbreviation"));
dept.setCompanyIdDept(getStr(supermap, "deptId"));
dept.setCompanyNameDept(getStr(supermap, "deptName"));
//单个主部门
if (("true".equals(map.get("isDefault") + "") && StringUtils.isEmpty(user.getDeptId()))) {
setDeptInfo(user, dept);
} else if (deptCount == deptInfo.size() && StringUtils.isEmpty(user.getDeptId())) {
setDeptInfo(user, dept);
}
deptCount++;
deptList.add(dept);
}
user.setDepts(deptList); //部门集合
//用户权限
ArrayList<Role> userRoles = new ArrayList<Role>();
List<Map<String, String>> rolsMap = (List<Map<String, String>>) userMap.get("sysRoles");
for (Map<String, String> map : rolsMap) {
Role role = new Role();
role.setRoleId(getStr(map, "roleId"));
role.setRoleName(getStr(map, "roleName"));
userRoles.add(role);
}
user.setRoles(userRoles);
user.setRoleIds(getStr(userMap, "sysRoleIds"));
List<Map<String, String>> flowRoles = (List<Map<String, String>>) userMap.get("flowRoles");
user.setFlowRoles(flowRoles);
user.setFlowRoleIds(getStr(userMap, "flowRoleIds"));
return user;
}
private void setDeptInfo(User user, Dept dept) {
user.setDept(dept);
user.setDeptId(dept.getDeptId());
user.setDeptName(dept.getDeptName());
user.setCompanyId(dept.getCompanyId());
user.setCompanyName(dept.getCompanyName());
}
private String getStr(Map map, String key) {
if (map == null || map.get(key) == null) {
return "";
......@@ -44,4 +119,35 @@ public class PlatformService {
return map.get(key) + "";
}
public WorkflowService getWorkflowService() {
return workflowService;
}
public void setWorkflowService(WorkflowService workflowService) {
this.workflowService = workflowService;
}
/**
* 获取资源目录
*
* @param list 当前用户的所有资源
* @return
*/
public List<Menu> getMenus(List<Menu> list) {
List<Menu> rList = new ArrayList<Menu>();
if (list == null) {
return rList;
}
for (Menu menu : list) {
if (menu.getMenuType().equals("M") || "C".equals(menu.getMenuType())) {
rList.add(menu);
}
}
return TreeUtils.getChildPerms(list, "0");
}
}
package com.sinobase.framework.shiro.realm;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
......@@ -12,8 +13,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.sinobase.common.bean.User;
import com.sinobase.framework.service.PlatformService;
import com.sinobase.project.system.user.domain.User;
public class UserRealm extends AuthorizingRealm {
......@@ -49,5 +50,12 @@ public class UserRealm extends AuthorizingRealm {
}
return null;
}
/**
* 清理缓存权限
*/
public void clearCachedAuthorizationInfo() {
this.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals());
}
}
package com.sinobase.framework.web.controller;
import java.util.Map;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.sinobase.common.utils.StringUtils;
import com.sinobase.common.utils.security.ShiroUtils;
import com.sinobase.framework.web.domain.AjaxResult;
import com.sinobase.project.system.user.domain.User;
/**
* web层通用数据处理
*
* @author sinobase
*/
public class BaseController {
/**
* 响应返回结果
*
* @param rows
* 影响行数
* @return 操作结果
*/
protected AjaxResult toAjax(int rows) {
return rows > 0 ? success() : error();
}
/**
* 响应返回结果
*
* @param result 结果
* @return 操作结果
*/
protected AjaxResult toAjax(boolean result) {
return result ? success() : error();
}
/**
* 响应返回结果
* @param result 结果<br/>message:返回消息, map:返回对象
* @return 操作结果
*/
protected AjaxResult toAjax(boolean result,String message,Map<String,Object> map) {
return result ? success(message,map) : error(message);
}
/**
* 返回成功
*/
public AjaxResult success() {
return AjaxResult.success();
}
/**
* 返回成功
*/
public AjaxResult success(Map<String,Object> map) {
return AjaxResult.success("操作成功",map);
}
/**
* 返回失败消息
*/
public AjaxResult error() {
return AjaxResult.error();
}
/**
* 返回成功消息
*/
public AjaxResult success(String message,Map<String,Object> map) {
return AjaxResult.success(message,map);
}
/**
* 返回成功消息
*/
public AjaxResult success(String message) {
return AjaxResult.success(message);
}
/**
* 返回失败消息
*/
public AjaxResult error(String message) {
return AjaxResult.error(message);
}
/**
* 返回错误码消息
*/
public AjaxResult error(int code, String message) {
return AjaxResult.error(code, message);
}
/**
* 页面跳转
*/
public String redirect(String url) {
return StringUtils.format("redirect:{}", url);
}
public User getSysUser() {
return ShiroUtils.getSysUser();
}
public void setSysUser(User user) {
ShiroUtils.setSysUser(user);
}
public String getUserId() {
return getSysUser().getUserId();
}
public String getLoginName() {
return getSysUser().getLoginName();
}
/**
* 去除特殊符号
* @param obj
* @return
*/
public Object clearSpecialSymbols(Object obj){
//去除换行及空格
if(ObjectUtils.isNotEmpty(obj)){
obj = obj.toString().replaceAll("\\r\\n","").trim();
}
return obj;
}
}
package com.sinobase.framework.web.domain;
import java.util.HashMap;
import java.util.Map;
import com.sinobase.common.utils.StringUtils;
/**
* 操作消息提醒
*/
public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public static final String CODE_TAG = "code";
public static final String MSG_TAG = "msg";
public static final String DATA_TAG = "data";
/**
* 状态类型
*/
public enum Type {
/** 成功 */
SUCCESS(0),
/** 警告 */
WARN(301),
/** 错误 */
ERROR(500);
private final int value;
Type(int value) {
this.value = value;
}
public int value() {
return this.value;
}
}
/** 状态类型 */
private Type type;
/** 状态码 */
private int code;
/** 返回内容 */
private String msg;
/** 数据对象 */
private Object data;
/**
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
*/
public AjaxResult() {
}
/**
* 初始化一个新创建的 AjaxResult 对象
*
* @param type 状态类型
* @param msg 返回内容
*/
public AjaxResult(Type type, String msg) {
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
}
/**
* 初始化一个新创建的 AjaxResult 对象
*
* @param type 状态类型
* @param msg 返回内容
* @param data 数据对象
*/
public AjaxResult(Type type, String msg, Object data) {
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
if (StringUtils.isNotNull(data)) {
super.put(DATA_TAG, data);
}
}
/**
* 返回错误消息
*
* @return 错误消息
*/
public static AjaxResult error() {
return error(1, "操作失败");
}
/**
* 返回错误消息
*
* @param msg 内容
* @return 错误消息
*/
public static AjaxResult error(String msg) {
return error(500, msg);
}
/**
* 返回错误消息
*
* @param code 错误码
* @param msg 内容
* @return 错误消息
*/
public static AjaxResult error(int code, String msg) {
AjaxResult json = new AjaxResult();
json.put("code", code);
json.put("msg", msg);
return json;
}
/**
* 返回成功数据
* @return 成功消息
*/
public static AjaxResult success(Object data) {
return AjaxResult.success("操作成功", data);
}
/**
* 返回成功消息
* @param msg 内容
* @return 成功消息
*/
public static AjaxResult success(String msg) {
AjaxResult json = new AjaxResult();
json.put("msg", msg);
json.put("code", 0);
return json;
}
/**
* 返回成功消息
*
* @param msg 内容
* @param map 返回的数据对象
* @return 成功消息 + data
*/
public static AjaxResult success(String msg, Map<String, Object> map) {
AjaxResult json = new AjaxResult();
json.put("msg", msg);
json.put("code", 0);
json.put("data", map);
return json;
}
/**
* 返回成功消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 成功消息
*/
public static AjaxResult success(String msg, Object data) {
return new AjaxResult(Type.SUCCESS, msg, data);
}
/**
* 返回成功消息
*
* @return 成功消息
*/
public static AjaxResult success() {
return AjaxResult.success("操作成功");
}
/**
* 返回成功消息
*
* @param key 键值
* @param value 内容
* @return 成功消息
*/
@Override
public AjaxResult put(String key, Object value) {
super.put(key, value);
return this;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
package com.sinobase.framework.web.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Maps;
/**
* Entity基类
*/
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/** 搜索值 */
@TableField(exist=false)
private String searchValue;
/** 创建者 */
@TableField(exist=false)
private String createBy;
/** 创建时间 */
@TableField(exist=false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新者 */
@TableField(exist=false)
private String updateBy;
/** 更新时间 */
@TableField(exist=false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")//因为我们是东八区(北京时间),所以在格式化的时候要指定时区(timezone )
private Date updateTime;
/** 备注 */
@TableField(exist=false)
private String remark;
/** 请求参数 */
@TableField(exist=false)
private Map<String, Object> params;
/**请求类型*/
@TableField(exist=false)
private String requestType;
public String getSearchValue() {
return searchValue;
}
public void setSearchValue(String searchValue) {
this.searchValue = searchValue;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Map<String, Object> getParams() {
if (params == null) {
params = Maps.newHashMap();
}
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
public String getRequestType() {
return requestType;
}
public void setRequestType(String requestType) {
this.requestType = requestType;
}
}
package com.sinobase.framework.web.domain;
import java.util.Date;
public class FlowBaseEntity {
/** 创建人 */
private String creUserId;
/** 创建人名称 */
private String creUserName;
/** 创建部门id */
private String creDeptId;
/** 创建部门名称 */
private String creDeptName;
/** 创建日志 */
private Date creDate;
/** 流程标识 */
private String subflag;
/** 流程类型 */
private String flowType;
public void setCreUserId(String creUserId){
this.creUserId = creUserId;
}
public String getCreUserId(){
return creUserId;
}
public void setCreUserName(String creUserName){
this.creUserName = creUserName;
}
public String getCreUserName(){
return creUserName;
}
public void setCreDeptId(String creDeptId){
this.creDeptId = creDeptId;
}
public String getCreDeptId(){
return creDeptId;
}
public void setCreDeptName(String creDeptName){
this.creDeptName = creDeptName;
}
public String getCreDeptName(){
return creDeptName;
}
public void setCreDate(Date creDate){
this.creDate = creDate;
}
public Date getCreDate(){
return creDate;
}
public void setSubflag(String subflag){
this.subflag = subflag;
}
public String getSubflag(){
return subflag;
}
public String getFlowType() {
return flowType;
}
public void setFlowType(String flowType) {
this.flowType = flowType;
}
}
package com.sinobase.framework.web.domain;
import java.io.Serializable;
/**
* Ztree树结构实体类
*/
public class Ztree implements Serializable {
private static final long serialVersionUID = 1L;
/** 节点ID */
private Long id;
/** 节点父ID */
private Long pId;
/** 节点名称 */
private String name;
/** 节点标题 */
private String title;
/** 是否勾选 */
private boolean checked = false;
/** 是否展开 */
private boolean open = false;
/** 是否能勾选 */
private boolean nocheck = false;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getpId() {
return pId;
}
public void setpId(Long pId) {
this.pId = pId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
public boolean isNocheck() {
return nocheck;
}
public void setNocheck(boolean nocheck) {
this.nocheck = nocheck;
}
}
package com.sinobase.project.system.menu.domain;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.sinobase.framework.web.domain.BaseEntity;
/**
* 菜单权限表 sys_menu
* @author sinobase
*/
public class Menu extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 资源类型:标签解析页
*/
public static final String TYPE_TAB = "C";
/**
* 资源类型:标签解析页
*/
public static final String TYPE_MODULE = "M";
/**
* 资源类型:独立的首页
*/
public static final String TYPE_INDEX = "I";
/**
* 资源类型:按钮
*/
public static final String TYPE_BUTTON = "F";
/** 菜单ID */
private String menuId;
/** 菜单名称 */
private String menuName;
/** 父菜单名称 */
private String parentName;
/** 父菜单ID */
private String parentId;
/** 显示顺序 */
private String orderNum;
/** 菜单URL */
private String url;
/** 类型:0目录,1菜单,2按钮 <2019-3-21 loubin ,修改:菜单类型<M:模块,C:标签,F:按钮>> */
private String menuType;
/** 菜单状态:0显示,1隐藏 */
private String visible;
/** 权限字符串 */
private String perms;
/** 菜单图标 */
private String icon;
/** 子菜单 */
private List<Menu> children = new ArrayList<Menu>();
public String getMenuId() {
return menuId;
}
public void setMenuId(String menuId) {
this.menuId = menuId;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getOrderNum() {
return orderNum;
}
public void setOrderNum(String orderNum) {
this.orderNum = orderNum;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMenuType() {
return menuType;
}
public void setMenuType(String menuType) {
this.menuType = menuType;
}
public String getVisible() {
return visible;
}
public void setVisible(String visible) {
this.visible = visible;
}
public String getPerms() {
return perms;
}
public void setPerms(String perms) {
this.perms = perms;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public List<Menu> getChildren() {
return children;
}
public void setChildren(List<Menu> children) {
this.children = children;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("menuId", getMenuId())
.append("menuName", getMenuName()).append("parentId", getParentId()).append("orderNum", getOrderNum())
.append("url", getUrl()).append("menuType", getMenuType()).append("visible", getVisible())
.append("perms", getPerms()).append("icon", getIcon()).append("createBy", getCreateBy())
.append("createTime", getCreateTime()).append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()).append("remark", getRemark()).toString();
}
}
package com.sinobase.project.system.portal.domain;
import java.util.LinkedHashMap;
import java.util.Map;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
/**
* 快捷方式
* @author LouBin
*/
@TableName(value = "sys_shortcut")
public class Shortcut {
/**
* 类别:OA系统
*/
@TableField(exist = false)
public static String CATEGORY_OA = "OA";
/**
* 类别:第三方系统
*/
@TableField(exist = false)
public static String CATEGORY_THIRDPARTY= "THIRDPARTY";
/**
* 类别:个人配置
*/
@TableField(exist = false)
public static String CATEGORY_PERSON= "PERSON";
@TableField(exist = false)
public static Map<String, String> TYPE_ARRAY = new LinkedHashMap<String, String>();
static{
TYPE_ARRAY.put("SC-QB","签报");
TYPE_ARRAY.put("SC-SF","收发文");
TYPE_ARRAY.put("SC-HYJY","会议纪要");
TYPE_ARRAY.put("SC-DAILY","日常");
TYPE_ARRAY.put("SC-OTHER","其他");
}
private String id;
private String name;
private String url;
private String ico;
private String type;
private String category;
private String status;
private int orderNum;
private String companyId;
private String remark;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrderNum() {
return orderNum;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public void setOrderNum(int orderNum) {
this.orderNum = orderNum;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getIco() {
return ico;
}
public void setIco(String ico) {
this.ico = ico;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
}
package com.sinobase.project.system.portal.service;
import java.util.List;
import java.util.Map;
import com.sinobase.project.system.portal.domain.Shortcut;
/**
* 个人工作台服务类
* @author LouBin
*/
public interface IWorkbenchService {
/**
* 返回快捷方式列表
* @param shortcut
* @return
*/
public List<Shortcut> listShortcut(Shortcut shortcut);
/**
* 获取快捷方式
* @param id
* @return
*/
public Shortcut shortcut(String id);
/**
* 快捷方式保存
* @param shortcut
* @return
*/
public Shortcut saveShortcut(Shortcut shortcut);
/**
* 快捷方式删除
* @param id
* @return
*/
public int delShortcut(String id);
/**
* 我的快捷方式
* @param userId
* @param moduleType
* @return
*/
public List<Shortcut> myShortcut(String userId,String moduleType);
/**
* 我的快捷方式保存
* @param shortcutIds
* @return
*/
public boolean myShortcutSave(String moduleType,String shortcuts);
/**
* 导入OA系统启动资源
* @return
*/
public int importRes();
/**
* 获取OA系统的起草地址
* @return
*/
public List<Map<String,Object>> getOaDraftList(String moduleType);
/**
*
* 获取当前人是否又多身份
* @param loginname
* @return
*/
boolean ishasAccount(String loginname);
}
package com.sinobase.project.system.role.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.sinobase.framework.web.domain.BaseEntity;
/**
* 角色表 sys_role
*
* @author ruoyi
*/
public class Role extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 角色ID */
private String roleId;
/** 角色名称 */
private String roleName;
/** 角色权限 */
private String roleKey;
/** 角色排序 */
private String roleSort;
/** 数据范围(1:所有数据权限;2:自定义数据权限) */
private String dataScope;
/** 角色状态(0正常 1停用) */
private String status;
/** 删除标志(0代表存在 2代表删除) */
private String delFlag;
/** 用户是否存在此角色标识 默认不存在 */
private boolean flag = false;
/** 菜单组 */
private String[] menuIds;
/** 部门组(数据权限) */
private String[] deptIds;
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getDataScope() {
return dataScope;
}
public void setDataScope(String dataScope) {
this.dataScope = dataScope;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRoleKey() {
return roleKey;
}
public void setRoleKey(String roleKey) {
this.roleKey = roleKey;
}
public String getRoleSort() {
return roleSort;
}
public void setRoleSort(String roleSort) {
this.roleSort = roleSort;
}
public String getStatus() {
return status;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public void setStatus(String status) {
this.status = status;
}
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
public String[] getMenuIds() {
return menuIds;
}
public void setMenuIds(String[] menuIds) {
this.menuIds = menuIds;
}
public String[] getDeptIds() {
return deptIds;
}
public void setDeptIds(String[] deptIds) {
this.deptIds = deptIds;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("roleId", getRoleId())
.append("roleName", getRoleName()).append("roleKey", getRoleKey()).append("roleSort", getRoleSort())
.append("dataScope", getDataScope()).append("status", getStatus()).append("delFlag", getDelFlag())
.append("createBy", getCreateBy()).append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime()).append("remark", getRemark())
.toString();
}
}
package com.sinobase.project.system.user.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.sinobase.common.util.CommonContent;
import com.sinobase.common.utils.ServletUtils;
import com.sinobase.common.utils.security.ShiroUtils;
import com.sinobase.framework.config.SinoBaseConfig;
import com.sinobase.framework.service.PlatformService;
import com.sinobase.framework.web.controller.BaseController;
import com.sinobase.oldoa.util.JdbcProperties;
import com.sinobase.oldoa.util.ManagerOldOADate;
import com.sinobase.project.system.menu.domain.Menu;
import com.sinobase.project.system.portal.service.IWorkbenchService;
import com.sinobase.project.system.user.domain.User;
import com.sinobase.project.system.user.service.ILoginHistoryLogService;
/**
* 首页 业务处理
*
* @author sinobase
*/
@Controller
public class IndexController extends BaseController {
@Value("${sinobase.isIntranet}")
private boolean isIntranet;
@Value("${environment}")
private String environment;
@Autowired
private ILoginHistoryLogService loginHistoryService;
@Autowired
private SessionDAO sessionDao;
@Autowired
private PlatformService platformService; //集成公司平台时用
@Autowired
private SinoBaseConfig sinoBaseConfig;
@Autowired
private IWorkbenchService workbench;
JdbcProperties jdbc = new JdbcProperties();
private final String IP = jdbc.get("IP");
@Value("${sinobase.isextendnet}")
private boolean isextendnet;
// 系统首页
@GetMapping("/workbench")
public String index(ModelMap mmap) {
String type = ServletUtils.getParameter("_type","oa");
User user = ShiroUtils.getSysUser();
if (user != null) {
mmap.put("onlineTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getLoginDate()));
} else {
mmap.put("onlineTime", "未知时间");
}
// 取身份信息
List<Menu> menus = new ArrayList<Menu>();
if (SinoBaseConfig.isPlatform()) {
menus = platformService.getMenus(user.getMenus());
} else {
}
if("law".equals(type)) {//只保留法律模块
menus = menus.stream().filter(m -> m.getMenuType().equals("OLDOA-LAW")).collect(Collectors.toList()).get(0).getChildren();
}else if("db".equals(type)){//只保留督办模块
menus = menus.stream().filter(m -> m.getMenuType().equals("OLDOA-DB")).collect(Collectors.toList()).get(0).getChildren();
}else if("bf".equals(type)){//只保留督办模块
menus = menus.stream().filter(m -> m.getMenuType().equals("OLDOA-BF")).collect(Collectors.toList()).get(0).getChildren();
}else {//过滤掉法律模块和督办模块
menus = menus.stream().filter(m -> (!m.getMenuType().equals("OLDOA-BF")&&!m.getMenuType().equals("OLDOA-LAW")&&!m.getMenuType().equals("OLDOA-DB"))).collect(Collectors.toList());
}
mmap.put("_type", type);
mmap.put("ip", IP);
mmap.put("user", user);
mmap.put("deptHistoryId", user.getDept().getHistoryId());
mmap.put("loginName", user.getLoginName());
mmap.put("password", user.getPassword());
if (SinoBaseConfig.isPlatform()) {
mmap.put("oldUserId",user.getHistoryId());
}else{
mmap.put("oldUserId","");
}
mmap.put("isextendnet", isextendnet);
//项目组登录oa,只能看到项目组使用的单独模块,同事设置成外网模式,不需要看到法律,督办等模块
if(CommonContent.COMPANY_EXTEND.equals(user.getDept().getParentId())) {
menus = menus.stream().filter(m -> m.getMenuType().equals("OLDOA-EXTEND")).collect(Collectors.toList()).get(0).getChildren();
mmap.put("isextendnet", true);
}
mmap.put("menus", menus);
//系统消息
mmap.put("copyrightYear", sinoBaseConfig.getCopyrightYear());
mmap.put("location", "location");
mmap.put("ishasAccount",workbench.ishasAccount(user.getLoginName())+"");
mmap.put("environment", environment);
return "index";
// return "workbench";
}
//获取法律模块导航
@GetMapping("/workbench/changetype/{type}")
@ResponseBody
public List<Menu> getlawurl(@PathVariable("type") String type){
User user = ShiroUtils.getSysUser();
List<Menu> menus = new ArrayList<Menu>();
if (SinoBaseConfig.isPlatform()) {
menus = platformService.getMenus(user.getMenus());
} else {
}
if("law".equals(type)) {
//法律导航特殊判断,只显示法律相关模块
for (Menu menu : menus) {
if("OLDOA-LAW".equals(menu.getMenuType())) {
menus = menu.getChildren();
}
}
}else if("db".equals(type)){
for (Menu menu : menus) {
if("OLDOA-DB".equals(menu.getMenuType())) {
menus = menu.getChildren();
}
}
}else if("act".equals(type)){
for (Menu menu : menus) {
if("OLDOA-ACT".equals(menu.getMenuType())) {
menus = menu.getChildren();
}
}
}else if("bf".equals(type)){
for (Menu menu : menus) {
if("OLDOA-BF".equals(menu.getMenuType())) {
menus = menu.getChildren();
}
}
}else{
//过滤掉法律模块
menus = menus.stream().filter(m -> (!m.getMenuType().equals("OLDOA-BF")&&!m.getMenuType().equals("OLDOA-LAW")&&!m.getMenuType().equals("OLDOA-DB"))).collect(Collectors.toList());
}
return menus;
}
@GetMapping("/workbench/index")
public String workbench(ModelMap mmap) {
if(SinoBaseConfig.isPlatform()){
User user = ShiroUtils.getSysUser();
mmap.put("user", user);
ManagerOldOADate man = new ManagerOldOADate();
/*man.listOldOAWorkFlowRead(user.getUserId(),null)*/
mmap.put("oldUserId",user.getHistoryId());
mmap.put("ip", IP);
mmap.put("deptHistoryId", user.getDept().getHistoryId());
mmap.put("isextendnet", isextendnet);
/*
* 系统当前在线人数信息,系统今日登录人数,系统总登录人数次数
*/
int size = sessionDao.getActiveSessions().size(); //当前在线人数
long loginTimesToday = 0; //系统当天登录次数(所有人)
long loginTimesAll = 0; //系统总登录次数(所有人)
mmap.put("onlineNow", size);
if(isIntranet) {
loginTimesToday = loginHistoryService.getLoginTimesToday();
loginTimesAll = loginHistoryService.getLoginTimesAll();
}
mmap.put("loginTimesToday", loginTimesToday);
mmap.put("loginTimesAll", loginTimesAll);
return "/workbench/index";
}else{
return "/workbench/singleIndex";
}
}
@GetMapping("/system/tip")
public String tip() {
return "tip";
}
@GetMapping("/demo")
public String demo() {
return "/demo/demo";
}
// 系统介绍
@GetMapping("/system/main")
public String main(ModelMap mmap) {
mmap.put("version", sinoBaseConfig.getVersion());
return "main";
}
@ResponseBody
@RequestMapping(value = "/workbench/gotoOtherdb")
public ModelAndView submitworkflow(HttpServletRequest request) throws Exception {
String url =request.getParameter("url");
if(url!=null && url.indexOf("-|-")>-1){
url = url.replace("-|-","&");
}
ModelAndView mv = new ModelAndView("/workbench/gotoOtherdb");
mv.addObject("urlValue", url);
return mv;
}
// @GetMapping("/workbench/refresh_page/{methodName}/{recordid}")
// public ModelAndView convert(@PathVariable("methodName") String methodName,@PathVariable("recordid") String recordid) {
// ModelAndView mv = new ModelAndView("/workbench/convert");
// mv.addObject("methodName", methodName);
// mv.addObject("recordid", recordid);
// return mv;
// }
}
package com.sinobase.project.system.user.domain;
import com.sinobase.framework.web.domain.BaseEntity;
import com.sinobase.project.system.dept.domain.Dept;
import com.sinobase.project.system.menu.domain.Menu;
import com.sinobase.project.system.role.domain.Role;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 用户对象 sys_user
* @author sinobase
*/
public class User extends BaseEntity {
private static final long serialVersionUID = 1L;
//------ 单体应用用开始 ------------
/** 角色ID */
private String roleId;
//------ 单体应用用结束 ------------
/** 所在公司id **/
private String companyId;
/** 所在公司名称 **/
private String companyName;
/** 个人快捷方式 **/
private String shortcut;
/** 身份证号码 **/
private String idNo;
/** 用户ID */
private String userId;
/** 部门ID */
private String deptId;
/** 部门名称 */
private String deptName;
/** 登录名称 */
private String loginName;
/** 用户名称 */
private String userName;
/** 用户邮箱 */
private String email;
/** 手机号码 */
private String phonenumber;
//用户座机号码
private String tel;
/** 用户性别 */
private String sex;
/** 用户头像 */
private String avatar;
/** 密码 */
private String password;
/** 盐加密 */
private String salt;
/** 帐号状态(0正常 1停用) */
private String status;
/** 删除标志(0代表存在 2代表删除) */
private String delFlag;
/** 最后登陆IP */
private String loginIp;
/** 最后登陆时间 */
private Date loginDate;
/** 部门对象 */
private Dept dept;
/** 国泰历史用户数据id */
private String historyId;
/** 用户身份 */
private String userStatus;
/**手机imei码*/
private String phoneImei;
/**组织编码*/
private String masterCode;
/**部门对象*/
private List<Dept> depts;
/**
*员工编号,统一认证后可能需要员工编号进行登录
*/
private String userCode;
/**
* 身份证
*/
private String idcNumber;
/** 角色集合 */
private List<Role> roles;
/** 系统角色组,以","号分割 */
private String roleIds;
/** 岗位组 */
private Long[] postIds;
/** 业务角色集合 */
private List<Map<String,String>> flowRoles;
/** 系统角色组,以","号分割 */
private String flowRoleIds;
/** 资源集合(从平台获取的资源存放在这个属性中) */
private List<Menu> menus;
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getIdcNumber() {
return idcNumber;
}
public void setIdcNumber(String idcNumber) {
this.idcNumber = idcNumber;
}
public List<Dept> getDepts() {
return depts;
}
public void setDepts(List<Dept> depts) {
this.depts = depts;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public List<Menu> getMenus() {
return menus;
}
public void setMenus(List<Menu> menus) {
this.menus = menus;
}
public String getHistoryId() {
return historyId;
}
public void setHistoryId(String historyId) {
this.historyId = historyId;
}
public String getUserStatus() {
return userStatus;
}
public void setUserStatus(String userStatus) {
this.userStatus = userStatus;
}
public String getPhoneImei() {
return phoneImei;
}
public void setPhoneImei(String phoneImei) {
this.phoneImei = phoneImei;
}
public String getMasterCode() {
return masterCode;
}
public void setMasterCode(String masterCode) {
this.masterCode = masterCode;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public boolean isAdmin() {
return isAdmin(this.userId);
}
public static boolean isAdmin(String userId) {
return userId != null && userId.equals("1".toString());
}
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
/**
* 生成随机盐
*/
public void randomSalt() {
// 一个Byte占两个字节,此处生成的3字节,字符串长度为6
SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator();
String hex = secureRandom.nextBytes(3).toHex();
setSalt(hex);
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp;
}
public Date getLoginDate() {
return loginDate;
}
public void setLoginDate(Date loginDate) {
this.loginDate = loginDate;
}
public Dept getDept() {
return dept;
}
public void setDept(Dept dept) {
this.dept = dept;
}
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
public String getRoleIds() {
return roleIds;
}
public void setRoleIds(String roleIds) {
this.roleIds = roleIds;
}
public Long[] getPostIds() {
return postIds;
}
public void setPostIds(Long[] postIds) {
this.postIds = postIds;
}
public List<Map<String, String>> getFlowRoles() {
return flowRoles;
}
public void setFlowRoles(List<Map<String, String>> flowRoles) {
this.flowRoles = flowRoles;
}
public String getFlowRoleIds() {
return flowRoleIds;
}
public void setFlowRoleIds(String flowRoleIds) {
this.flowRoleIds = flowRoleIds;
}
public String getShortcut() {
return shortcut;
}
public void setShortcut(String shortcut) {
this.shortcut = shortcut;
}
@Override
public String toString() {
return "User{" +
"userId='" + userId + '\'' +
", deptId='" + deptId + '\'' +
", deptName='" + deptName + '\'' +
", loginName='" + loginName + '\'' +
", userName='" + userName + '\'' +
", email='" + email + '\'' +
", phonenumber='" + phonenumber + '\'' +
", sex='" + sex + '\'' +
", avatar='" + avatar + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", status='" + status + '\'' +
", delFlag='" + delFlag + '\'' +
", loginIp='" + loginIp + '\'' +
", loginDate=" + loginDate +
", dept=" + dept +
", historyId='" + historyId + '\'' +
", userStatus='" + userStatus + '\'' +
", phoneImei='" + phoneImei + '\'' +
", masterCode='" + masterCode + '\'' +
", depts=" + depts +
", roles=" + roles +
", roleIds='" + roleIds + '\'' +
", postIds=" + Arrays.toString(postIds) +
", menus=" + menus +
", userCode=" + userCode +
", idcNumber=" + idcNumber +
'}';
}
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
}
package com.sinobase.project.system.user.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface LoginHistoryLogMapper {
/**
* 获取所有的登录次数
* @return 表中数据的条数,每登录一次就会产生一条记录。
*/
public long getLoginTimesAll();
/**
* 获取某天的登录次数,yyyy-MM-dd
* @return 根据时间获取某天的登录条数
*/
public long getLoginTimesOfday( @Param("date") String date);
}
package com.sinobase.project.system.user.service;
public interface ILoginHistoryLogService {
public long getLoginTimesAll();
public long getLoginTimesToday();
}
package com.sinobase.project.system.user.service;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sinobase.datasource.aspectj.lang.annotation.DataSource;
import com.sinobase.datasource.aspectj.lang.enums.DataSourceType;
import com.sinobase.project.system.user.mapper.LoginHistoryLogMapper;
@Service
@DataSource(DataSourceType.ORACLE)
public class LoginHistoryLogServiceImpl implements ILoginHistoryLogService {
@Autowired
private LoginHistoryLogMapper loginHistoryMapper;
@Override
public long getLoginTimesAll() {
return loginHistoryMapper.getLoginTimesAll();
}
@Override
public long getLoginTimesToday() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date = sdf.format(new Date());
// date = "2017-07-03"; //测试数据,因为互联网开发环境没有数据
return loginHistoryMapper.getLoginTimesOfday(date);
}
}
......@@ -15,42 +15,46 @@ spring:
database: 0
datasource:
type: com.alibaba.druid.pool.DruidDataSource
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKDtJnmwIAqtrpHN4IFaUqdCxcweVXMuKTQHRdH3bABiaCAHSvY4cqz/OoDEexzAwGc8ygz8gmp90b14njhZJwkCAwEAAQ==
druid:
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://152.136.74.6:3306/sinooa?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
username: root
password: bug48625
# 初始连接数
url: jdbc:mysql://172.30.13.55:3306/sinooa?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: developer
password: 123456
initial-size: 2
# 最大连接池数量
max-active: 100
# 最小连接池数量
min-idle: 2
#passwordCallbackClassName: com.sinobase.framework.config.DbPasswordCallback
#connection-properties: config.decrypt=true;publicKey=${spring.datasource.publicKey};password=${spring.datasource.druid.master.password}
# 从库数据源
slave:
driver-class-name: com.mysql.cj.jdbc.Driver
enabled: false
url: jdbc:mysql://152.136.74.6:3306/davehan?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
username: davehan
password: bug48625
# 初始连接数
# 从数据源开关/默认关闭
enabled: true
url: jdbc:mysql://172.30.13.55:3306/sinooa?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: developer
password: 123456
initial-size: 2
# 最大连接池数量
max-active: 100
# 最小连接池数量
min-idle: 2
#passwordCallbackClassName: com.sinobase.framework.config.DbPasswordCallback
#connection-properties: config.decrypt=true;publicKey=${spring.datasource.publicKey};password=${spring.datasource.druid.slave.password}
oracle:
driver-class-name: oracle.jdbc.OracleDriver
driver-class-name: oracle.jdbc.driver.OracleDriver
enabled: true
url: jdbc:oracle:thin:@111.204.29.117:1521:orcl
username: sysfw
password: sysfw
# 初始连接数
url: jdbc:oracle:thin:@172.30.13.55:1521/sinoepuias
username: sdicoa
password: 09544cb8b95eac2859ea81c4a77c7e86
initial-size: 2
# 最大连接池数量
max-active: 100
# 最小连接池数量
min-idle: 2
passwordCallbackClassName: com.sinobase.framework.config.DbPasswordCallback
connection-properties: config.decrypt=true;publicKey=${spring.datasource.publicKey};password=${spring.datasource.druid.oracle.password}
initialSize: 20
maxActive: 100
# 最小连接池数量
minIdle: 2
# 配置获取连接等待超时的时间
maxWait: 60000
# 打开PSCache,并且指定每个连接上PSCache的大小
......@@ -83,13 +87,40 @@ shiro:
user:
unauthorizedUrl: /failed
session:
expireTime: 30
expireTime: 120
sso:
loginPageURL: "http://111.204.29.117:8500/sso"
validateURL: "http://111.204.29.117:8500/sso/ticket"
loginPageURL: "http://172.30.13.53:8080/sso"
validateURL: "http://172.30.13.53:8080/sso/ticket"
setCookie: /setCookie
location: "http://172.30.13.53:8080/"
oldOaPath : "http://172.30.15.73:7001/"
budgetlocation : "http://localhost:8400/"
esbPath : "http://172.30.15.90:9099"
notice:
shortmessage: "http://192.168.100.100:8080"
open: false
# app推送通知
pushOpen: false
sinobase:
# 文件上传服务地址(本地地址:/file/upload)
fileServer: http://172.30.13.53:8501/
# 映射路径 mappingUrl: http://10.0.191.70/getFile/,10.0.191.70为服务器地址,getFile在FileConfig中进行资源映射
mappingUrl: http://172.30.13.53:8501/getFile/
# 文件上传路径(window路径:d:/)
profile: D:/uploadTemp/dev/
#导出文件模板
#templatePath: D:/work/java/SinoBase/sinobase-web/src/main/resources/static/file
templatePath: /home/webapp/WEB-INF/classes/static/file
#获取流程图JSON的IP地址
flowChartIp: http://172.30.13.54:18003
#是否为内网
isIntranet: false
#是否为外网
isextendnet: false
#是否为手机端
isphone: false
workflow:
# 旧平台远程工作流提交
workflowurl: http://111.204.29.117:7001/workflow/workflow-convert.jsp
flowChartIp: http://111.204.29.117:18003
workflowMobileIP: http://111.204.29.117:7001
\ No newline at end of file
workflowurl: http://172.30.15.73:7001/workflow/workflow-convert.jsp
flowChartIp: http://172.30.15.73:18003
workflowMobileIP: http://172.30.15.73:7001
\ No newline at end of file
......@@ -2,6 +2,8 @@
sinobase:
# 是否集成公司的微服务平台
isPlatform: true
# 在公司微服务平台上的注册系统ID
system_id: 97465
# 开发环境配置
server:
......@@ -9,7 +11,7 @@ server:
port: 8400
servlet:
# 项目contextPath
context-path: /empty
context-path: /homepage
spring:
profiles:
......@@ -21,6 +23,12 @@ spring:
encoding: UTF-8
content-type: text/html
cache: false
application:
name: homepage-server
cloud:
nacos:
discovery:
server-addr: http://172.30.13.54:8848/
mybatis-plus:
mapper-location: classpath*:mybatis/**/*Mapper.xml ##默认是mapper-locations,这里是自定义的属性,在DruidConfig中读取
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sinobase.project.system.user.mapper.LoginHistoryLogMapper">
<select id="getLoginTimesAll" resultType="java.lang.Long">
select count(1) from login_history_log
</select>
<select id="getLoginTimesOfday" resultType="java.lang.Long" parameterType="java.lang.String">
<bind name="_date" value="date + '%'"/>
select count(1) from login_history_log where login_time like #{_date, jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment