Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -62,6 +62,7 @@
|
|||||||
<docker.image.prefix>hub.zlt.com:8080/microservices-platform</docker.image.prefix>
|
<docker.image.prefix>hub.zlt.com:8080/microservices-platform</docker.image.prefix>
|
||||||
<docker.java.security.egd>-Djava.security.egd=file:/dev/./urandom</docker.java.security.egd>
|
<docker.java.security.egd>-Djava.security.egd=file:/dev/./urandom</docker.java.security.egd>
|
||||||
<docker.java.opts>-Xms128m -Xmx128m</docker.java.opts>
|
<docker.java.opts>-Xms128m -Xmx128m</docker.java.opts>
|
||||||
|
<guava.version>20.0</guava.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -430,6 +431,11 @@
|
|||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
+18
@@ -7,6 +7,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.central.common.annotation.LoginUser;
|
import com.central.common.annotation.LoginUser;
|
||||||
import com.central.common.constant.CommonConstant;
|
import com.central.common.constant.CommonConstant;
|
||||||
import com.central.common.model.*;
|
import com.central.common.model.*;
|
||||||
@@ -286,6 +287,23 @@ public class SysUserController {
|
|||||||
return queryService.strQuery("sys_user", searchDto, SEARCH_LOGIC_DEL_DTO);
|
return queryService.strQuery("sys_user", searchDto, SEARCH_LOGIC_DEL_DTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户并返回角色列表
|
||||||
|
* @param username
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/users/roleUser/{username}")
|
||||||
|
@ApiOperation(value = "查询用户-带角色信息")
|
||||||
|
@Cacheable(value = "userRoles", key = "#username")
|
||||||
|
public SysUser selectRoleUser(@PathVariable("username") String username){
|
||||||
|
SysUser sysUser = selectByUsername(username);
|
||||||
|
if(ObjectUtil.isNotNull(sysUser)){
|
||||||
|
List<SysRole> roleList = findRolesByUserId(sysUser.getId());
|
||||||
|
sysUser.setRoles(roleList);
|
||||||
|
}
|
||||||
|
return sysUser;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否超级管理员
|
* 是否超级管理员
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -89,5 +89,9 @@
|
|||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
+268
@@ -0,0 +1,268 @@
|
|||||||
|
package com.central.common.datascope.mp.interceptor;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
||||||
|
import com.central.common.datascope.mp.sql.handler.SqlHandler;
|
||||||
|
import com.central.common.properties.DataScopeProperties;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.jsqlparser.JSQLParserException;
|
||||||
|
import net.sf.jsqlparser.expression.Alias;
|
||||||
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
|
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
|
||||||
|
import net.sf.jsqlparser.parser.CCJSqlParserManager;
|
||||||
|
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
||||||
|
import net.sf.jsqlparser.schema.Table;
|
||||||
|
import net.sf.jsqlparser.statement.select.*;
|
||||||
|
import org.apache.ibatis.executor.Executor;
|
||||||
|
import org.apache.ibatis.mapping.BoundSql;
|
||||||
|
import org.apache.ibatis.mapping.MappedStatement;
|
||||||
|
import org.apache.ibatis.session.ResultHandler;
|
||||||
|
import org.apache.ibatis.session.RowBounds;
|
||||||
|
import org.springframework.http.server.PathContainer;
|
||||||
|
import org.springframework.web.util.pattern.PathPatternParser;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.central.common.datascope.mp.sql.handler.SqlHandler.ALIAS_SYNBOL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据权限拦截器
|
||||||
|
*
|
||||||
|
* @author jarvis create by 2023/1/7
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DataScopeInnerInterceptor implements InnerInterceptor {
|
||||||
|
|
||||||
|
private DataScopeProperties dataScopeProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限的where条件
|
||||||
|
*/
|
||||||
|
private SqlHandler sqlHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对表配置进行缓存,优先读取缓存,在进行匹配
|
||||||
|
*/
|
||||||
|
private Map<String, TableConfig> tableInfoMap = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通配符
|
||||||
|
*/
|
||||||
|
private PathPatternParser pathPatternParser = new PathPatternParser();
|
||||||
|
|
||||||
|
public DataScopeInnerInterceptor(DataScopeProperties dataScopeProperties, SqlHandler sqlHandler) {
|
||||||
|
this.dataScopeProperties = dataScopeProperties;
|
||||||
|
this.sqlHandler = sqlHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
|
||||||
|
if(CollUtil.isEmpty(dataScopeProperties.getIgnoreSqls())|| !dataScopeProperties.getIgnoreSqls().contains(ms.getId())){
|
||||||
|
PluginUtils.MPBoundSql mpBs = PluginUtils.mpBoundSql(boundSql);
|
||||||
|
String sql = boundSql.getSql();
|
||||||
|
try {
|
||||||
|
Select select = explainQuerySql(sql);
|
||||||
|
reform(select.getSelectBody());
|
||||||
|
mpBs.sql(select.toString());
|
||||||
|
} catch (JSQLParserException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Select explainQuerySql(String sql) throws JSQLParserException {
|
||||||
|
CCJSqlParserManager parserManager = new CCJSqlParserManager();
|
||||||
|
Select select = (Select) parserManager.parse(new StringReader(sql));
|
||||||
|
return select;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归对查询和解析后的子查询进行改造
|
||||||
|
* @param selectBody
|
||||||
|
* @param <T>
|
||||||
|
* @throws JSQLParserException
|
||||||
|
*/
|
||||||
|
public <T extends SelectBody>void reform(SelectBody selectBody) throws JSQLParserException {
|
||||||
|
// 如果是plainSelect的话进行改造
|
||||||
|
if(selectBody instanceof PlainSelect&& ObjectUtil.isNotNull(sqlHandler)){
|
||||||
|
PlainSelect select = (PlainSelect) selectBody;
|
||||||
|
// 获取权限的where条件
|
||||||
|
String scopeWhereSql = sqlHandler.handleScopeSql();
|
||||||
|
// 如果条件不是空的话才对select进行改造
|
||||||
|
if(StrUtil.isNotBlank(scopeWhereSql)){
|
||||||
|
// 需要改造的别名列表,自动增加到where条件中
|
||||||
|
List<String> tableAliasList = new ArrayList<>();
|
||||||
|
FromItem fromItem = select.getFromItem();
|
||||||
|
String tableAlias = explainFromItem(fromItem);
|
||||||
|
// 获取from的表字段,如果from是子查询则进行递归
|
||||||
|
if(fromItem instanceof Table){
|
||||||
|
|
||||||
|
String upperTableName = ((Table) fromItem).getName().toUpperCase();
|
||||||
|
if(tableInfoMap.containsKey(upperTableName)){
|
||||||
|
if (!tableInfoMap.get(upperTableName).getIgnore()) {
|
||||||
|
tableAliasList.add(StrUtil.isNotBlank(tableAlias)? tableAlias: "");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
boolean ignore = true;
|
||||||
|
if(isReformTable(upperTableName)){
|
||||||
|
tableAliasList.add(StrUtil.isNotBlank(tableAlias)? tableAlias: "");
|
||||||
|
ignore = false;
|
||||||
|
}
|
||||||
|
// 写入缓存
|
||||||
|
tableInfoMap.put(upperTableName, new TableConfig(upperTableName, ignore));
|
||||||
|
}
|
||||||
|
}else if(fromItem instanceof SubSelect){
|
||||||
|
reform(((SubSelect) fromItem).getSelectBody());
|
||||||
|
}
|
||||||
|
// 获取join列表,然后获取对应的表或者递归子查询
|
||||||
|
List<Join> joinList = select.getJoins();
|
||||||
|
if (CollUtil.isNotEmpty(joinList)) {
|
||||||
|
for (Join join : joinList) {
|
||||||
|
if(join.getRightItem() instanceof Table){
|
||||||
|
String joinTable = ((Table) join.getRightItem()).getName().toUpperCase();
|
||||||
|
String joinAlias = ((Table) join.getRightItem()).getAlias().getName();
|
||||||
|
if(tableInfoMap.containsKey(joinTable)){
|
||||||
|
if (!tableInfoMap.get(joinTable).getIgnore()) {
|
||||||
|
tableAliasList.add(StrUtil.isNotBlank(joinAlias)? joinAlias: "");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
boolean ignore = true;
|
||||||
|
if(isReformTable(joinTable)){
|
||||||
|
tableAliasList.add(StrUtil.isNotBlank(joinAlias)? joinAlias: "");
|
||||||
|
ignore = false;
|
||||||
|
}
|
||||||
|
// 写入缓存
|
||||||
|
tableInfoMap.put(joinTable, new TableConfig(joinTable, ignore));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(join.getRightItem() instanceof SubSelect){
|
||||||
|
reform(((SubSelect) join.getRightItem()).getSelectBody());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果改造的表是空的话则不改造对应的select
|
||||||
|
if(CollUtil.isNotEmpty(tableAliasList)){
|
||||||
|
reformWhere(select, scopeWhereSql, tableAliasList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果select不是plainSelect的话则进行递归改造
|
||||||
|
}else if(selectBody instanceof WithItem&& Objects.nonNull(((WithItem)selectBody).getSubSelect())){
|
||||||
|
reform(((WithItem)selectBody).getSubSelect().getSelectBody());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断表是否需要改造
|
||||||
|
* @param table
|
||||||
|
* @return
|
||||||
|
* 1. 判断表是否在需要改造的范围
|
||||||
|
* 1.1 如果表在inclde的set中(是否存在没用通配符的情况写入配置)
|
||||||
|
* 1.2 进行通配符匹配判断范围
|
||||||
|
* 2. 在改造的范围中进行提出
|
||||||
|
* 2.1 判断是不是完全匹配上ignore列表中
|
||||||
|
* 2.2 判断是否在通配符过滤
|
||||||
|
*/
|
||||||
|
private boolean isReformTable(String table){
|
||||||
|
return
|
||||||
|
// 1. 判断表是否在需要改造的范围
|
||||||
|
(dataScopeProperties.getIncludeTables().contains(table)
|
||||||
|
||dataScopeProperties.getIncludeTables().stream().anyMatch(item->
|
||||||
|
pathPatternParser.parse(item.toUpperCase()).matches(PathContainer.parsePath(table))
|
||||||
|
))&& (
|
||||||
|
// 如果没有忽略列表的话在范围中直接返回
|
||||||
|
CollUtil.isEmpty(dataScopeProperties.getIgnoreTables())
|
||||||
|
// 在改造的范围中进行忽略表
|
||||||
|
||!(dataScopeProperties.getIgnoreTables().contains(table)||
|
||||||
|
dataScopeProperties.getIgnoreTables().stream().anyMatch(item->
|
||||||
|
pathPatternParser.parse(item.toUpperCase()).matches(PathContainer.parsePath(table))
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析from中的东西
|
||||||
|
* @param fromItem
|
||||||
|
* @return
|
||||||
|
* @throws JSQLParserException
|
||||||
|
*/
|
||||||
|
private String explainFromItem(FromItem fromItem) throws JSQLParserException {
|
||||||
|
// 别名
|
||||||
|
String alias = "";
|
||||||
|
if(Objects.nonNull(fromItem)){
|
||||||
|
// 如果from的东西是表的话
|
||||||
|
if (fromItem instanceof Table) {
|
||||||
|
Alias tablealias = ((Table) fromItem).getAlias();
|
||||||
|
if(Objects.nonNull(tablealias)&& StrUtil.isNotBlank(tablealias.getName())){
|
||||||
|
alias = tablealias.getName();
|
||||||
|
}else{
|
||||||
|
alias = ALIAS_SYNBOL;
|
||||||
|
((Table) fromItem).setAlias(new Alias(ALIAS_SYNBOL, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果from的子查询
|
||||||
|
if(fromItem instanceof SubSelect){
|
||||||
|
SelectBody subSelectBody = ((SubSelect) fromItem).getSelectBody();
|
||||||
|
reform(subSelectBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 改造where条件
|
||||||
|
* @param select
|
||||||
|
* @param whereSql where 条件
|
||||||
|
* @param aliasName 需要添加权限的表别名
|
||||||
|
* @return
|
||||||
|
* @throws JSQLParserException
|
||||||
|
*/
|
||||||
|
private SelectBody reformWhere(PlainSelect select, String whereSql, List<String> aliasName) throws JSQLParserException {
|
||||||
|
Expression where = select.getWhere();
|
||||||
|
// todo 处理exists
|
||||||
|
if(StrUtil.isNotBlank(whereSql)&& CollUtil.isNotEmpty(aliasName)){
|
||||||
|
String andWhereSql = aliasName.stream()
|
||||||
|
.map(item -> whereSql.replaceAll(ALIAS_SYNBOL, StrUtil.isNotBlank(item) ? item : ""))
|
||||||
|
.collect(Collectors.joining(" and "));
|
||||||
|
if(StrUtil.isNotBlank(andWhereSql)){
|
||||||
|
Expression expression = CCJSqlParserUtil
|
||||||
|
.parseCondExpression(andWhereSql);
|
||||||
|
if(ObjectUtil.isNull(where)){
|
||||||
|
select.setWhere(expression);
|
||||||
|
}else {
|
||||||
|
AndExpression andExpression = new AndExpression(where, expression);
|
||||||
|
select.setWhere(andExpression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return select;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class TableConfig{
|
||||||
|
private String tableName;
|
||||||
|
private Boolean isIgnore;
|
||||||
|
|
||||||
|
public TableConfig(String tableName, Boolean isIgnore) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.isIgnore = isIgnore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIgnore() {
|
||||||
|
return isIgnore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package com.central.common.datascope.mp.sql.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.central.common.context.LoginUserContextHolder;
|
||||||
|
import com.central.common.enums.DataScope;
|
||||||
|
import com.central.common.feign.UserService;
|
||||||
|
import com.central.common.model.SysRole;
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
|
import com.central.common.properties.DataScopeProperties;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人权限的处理器
|
||||||
|
*
|
||||||
|
* @author jarvis create by 2023/1/10
|
||||||
|
*/
|
||||||
|
public class CreatorDataScopeSqlHandler implements SqlHandler{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataScopeProperties dataScopeProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回需要增加的where条件,返回空字符的话则代表不需要权限控制
|
||||||
|
*
|
||||||
|
* @return where条件
|
||||||
|
* 如果角色是全部权限的话则不进行控制,如果是个人权限的话则自动加入create_id = user_id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String handleScopeSql() {
|
||||||
|
SysUser user = LoginUserContextHolder.getUser();
|
||||||
|
Assert.notNull(user, "登陆人不能为空");
|
||||||
|
List<SysRole> roleList = userService.findRolesByUserId(user.getId());
|
||||||
|
return StrUtil.isBlank(dataScopeProperties.getCreatorIdColumnName())
|
||||||
|
||CollUtil.isEmpty(roleList)
|
||||||
|
|| roleList.stream().anyMatch(item-> Objects.nonNull(item.getDataScope()) || DataScope.ALL.equals(item.getDataScope()))
|
||||||
|
? DO_NOTHING:
|
||||||
|
// 这里确保有配置权限范围控制的字段
|
||||||
|
// 1. 如果没有配置角色的情况默认采用只读全部的记录
|
||||||
|
// 2. 如果有配置角色的话判断是否存在有ALL获取null的情况,如果没有ALL的话读取个人创建记录
|
||||||
|
String.format("%s.%s = '%s'", ALIAS_SYNBOL, dataScopeProperties.getCreatorIdColumnName(), user.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.central.common.datascope.mp.sql.handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 示例
|
||||||
|
*
|
||||||
|
* @author jarvis create by 2023/1/8
|
||||||
|
*/
|
||||||
|
public class DefaultSqlHandler implements SqlHandler{
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String handleScopeSql() {
|
||||||
|
return DO_NOTHING;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.central.common.datascope.mp.sql.handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据权限的sql获取接口
|
||||||
|
*
|
||||||
|
* @author jarvis create by 2023/1/8
|
||||||
|
*/
|
||||||
|
public interface SqlHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过这个字符替换成别名,自动的
|
||||||
|
*/
|
||||||
|
String ALIAS_SYNBOL = "alias_";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 空字符串
|
||||||
|
*/
|
||||||
|
String DO_NOTHING = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回需要增加的where条件,返回空字符的话则代表不需要权限控制
|
||||||
|
* @return where条件
|
||||||
|
*/
|
||||||
|
String handleScopeSql();
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.central.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 枚举类型
|
||||||
|
*
|
||||||
|
* @author jarvis create by 2023/1/10
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum DataScope implements ZltEnum{
|
||||||
|
ALL(0, "全部权限"), CREATOR(1, "创建者权限");
|
||||||
|
|
||||||
|
DataScope(Integer id, String content) {
|
||||||
|
this.id = id;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String content;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.central.common.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口
|
||||||
|
*
|
||||||
|
* @author jarvis create by 2023/1/20
|
||||||
|
*/
|
||||||
|
public interface ZltEnum {
|
||||||
|
/**
|
||||||
|
* 获取id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取内容
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getContent();
|
||||||
|
}
|
||||||
@@ -3,12 +3,15 @@ package com.central.common.feign;
|
|||||||
import com.central.common.constant.ServiceNameConstants;
|
import com.central.common.constant.ServiceNameConstants;
|
||||||
import com.central.common.feign.fallback.UserServiceFallbackFactory;
|
import com.central.common.feign.fallback.UserServiceFallbackFactory;
|
||||||
import com.central.common.model.LoginAppUser;
|
import com.central.common.model.LoginAppUser;
|
||||||
|
import com.central.common.model.SysRole;
|
||||||
import com.central.common.model.SysUser;
|
import com.central.common.model.SysUser;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zlt
|
* @author zlt
|
||||||
*/
|
*/
|
||||||
@@ -48,4 +51,22 @@ public interface UserService {
|
|||||||
*/
|
*/
|
||||||
@GetMapping(value = "/users-anon/openId", params = "openId")
|
@GetMapping(value = "/users-anon/openId", params = "openId")
|
||||||
LoginAppUser findByOpenId(@RequestParam("openId") String openId);
|
LoginAppUser findByOpenId(@RequestParam("openId") String openId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取带角色的用户信息
|
||||||
|
* @param username
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/users/roleUser/{username}")
|
||||||
|
public SysUser selectRoleUser(@PathVariable("username") String username);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的角色
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/users/{id}/roles")
|
||||||
|
public List<SysRole> findRolesByUserId(@PathVariable("id") Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
+27
@@ -2,10 +2,14 @@ package com.central.common.feign.fallback;
|
|||||||
|
|
||||||
import com.central.common.feign.UserService;
|
import com.central.common.feign.UserService;
|
||||||
import com.central.common.model.LoginAppUser;
|
import com.central.common.model.LoginAppUser;
|
||||||
|
import com.central.common.model.SysRole;
|
||||||
import com.central.common.model.SysUser;
|
import com.central.common.model.SysUser;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* userService降级工场
|
* userService降级工场
|
||||||
*
|
*
|
||||||
@@ -40,6 +44,29 @@ public class UserServiceFallbackFactory implements FallbackFactory<UserService>
|
|||||||
log.error("通过openId查询用户异常:{}", openId, throwable);
|
log.error("通过openId查询用户异常:{}", openId, throwable);
|
||||||
return new LoginAppUser();
|
return new LoginAppUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取带角色的用户信息
|
||||||
|
*
|
||||||
|
* @param username
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysUser selectRoleUser(String username) {
|
||||||
|
log.error("通过用户名查询用户异常:{}", username, throwable);
|
||||||
|
return new SysUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的角色
|
||||||
|
*
|
||||||
|
* @param id@return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysRole> findRolesByUserId(Long id) {
|
||||||
|
log.error("通过用户id查询角色列表异常:{}", id, throwable);
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.central.common.model;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.central.common.enums.DataScope;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@@ -18,4 +19,8 @@ public class SysRole extends SuperEntity {
|
|||||||
private String name;
|
private String name;
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 数据权限字段
|
||||||
|
*/
|
||||||
|
private DataScope dataScope;
|
||||||
}
|
}
|
||||||
|
|||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package com.central.common.properties;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 示例
|
||||||
|
*
|
||||||
|
* @author jarvis create by 2023/1/8
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "zlt.datascope")
|
||||||
|
@Getter
|
||||||
|
public class DataScopeProperties {
|
||||||
|
/**
|
||||||
|
* 是否开启权限控制
|
||||||
|
*/
|
||||||
|
private Boolean enabled = Boolean.FALSE;
|
||||||
|
/**
|
||||||
|
* 在includeTables的匹配符中过滤某几个表不需要权限的,仅enabled=true
|
||||||
|
*/
|
||||||
|
private Set<String> ignoreTables = Collections.singleton("SYS*");
|
||||||
|
/**
|
||||||
|
* 指定某几条sql不执行权限控制, 仅enabled=true生效
|
||||||
|
*/
|
||||||
|
private Set<String> ignoreSqls = Collections.emptySet();
|
||||||
|
/**
|
||||||
|
* 指定某几个表接受权限控制,仅enabled=true,默认当开启时全部表
|
||||||
|
*/
|
||||||
|
private Set<String> includeTables = Collections.singleton("*");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定需要的字段名
|
||||||
|
*/
|
||||||
|
private String creatorIdColumnName;
|
||||||
|
|
||||||
|
public void setEnabled(Boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnoreTables(Set<String> ignoreTables) {
|
||||||
|
HashSet<String> ignoreSet = new HashSet<>();
|
||||||
|
CollUtil.addAll(ignoreSet, ignoreTables);
|
||||||
|
CollUtil.addAll(ignoreSet, this.ignoreTables);
|
||||||
|
this.ignoreTables = ignoreSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnoreSqls(Set<String> ignoreSqls) {
|
||||||
|
this.ignoreSqls = ignoreSqls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncludeTables(Set<String> includeTables) {
|
||||||
|
this.includeTables = includeTables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatorIdColumnName(String creatorIdColumnName) {
|
||||||
|
this.creatorIdColumnName = creatorIdColumnName;
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
-2
@@ -5,6 +5,10 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import com.central.common.datascope.mp.interceptor.DataScopeInnerInterceptor;
|
||||||
|
import com.central.common.datascope.mp.sql.handler.CreatorDataScopeSqlHandler;
|
||||||
|
import com.central.common.datascope.mp.sql.handler.SqlHandler;
|
||||||
|
import com.central.common.properties.DataScopeProperties;
|
||||||
import com.central.common.properties.TenantProperties;
|
import com.central.common.properties.TenantProperties;
|
||||||
import com.central.db.interceptor.CustomTenantInterceptor;
|
import com.central.db.interceptor.CustomTenantInterceptor;
|
||||||
import com.central.db.properties.MybatisPlusAutoFillProperties;
|
import com.central.db.properties.MybatisPlusAutoFillProperties;
|
||||||
@@ -23,7 +27,7 @@ import org.springframework.context.annotation.Bean;
|
|||||||
* Blog: https://zlt2000.gitee.io
|
* Blog: https://zlt2000.gitee.io
|
||||||
* Github: https://github.com/zlt2000
|
* Github: https://github.com/zlt2000
|
||||||
*/
|
*/
|
||||||
@EnableConfigurationProperties(MybatisPlusAutoFillProperties.class)
|
@EnableConfigurationProperties({MybatisPlusAutoFillProperties.class, DataScopeProperties.class})
|
||||||
public class MybatisPlusAutoConfigure {
|
public class MybatisPlusAutoConfigure {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenantLineHandler tenantLineHandler;
|
private TenantLineHandler tenantLineHandler;
|
||||||
@@ -34,11 +38,20 @@ public class MybatisPlusAutoConfigure {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MybatisPlusAutoFillProperties autoFillProperties;
|
private MybatisPlusAutoFillProperties autoFillProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataScopeProperties dataScopeProperties;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public SqlHandler sqlHandler(){
|
||||||
|
return new CreatorDataScopeSqlHandler();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页插件,自动识别数据库类型
|
* 分页插件,自动识别数据库类型
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MybatisPlusInterceptor paginationInterceptor() {
|
public MybatisPlusInterceptor paginationInterceptor(SqlHandler sqlHandler) {
|
||||||
MybatisPlusInterceptor mpInterceptor = new MybatisPlusInterceptor();
|
MybatisPlusInterceptor mpInterceptor = new MybatisPlusInterceptor();
|
||||||
boolean enableTenant = tenantProperties.getEnable();
|
boolean enableTenant = tenantProperties.getEnable();
|
||||||
//是否开启多租户隔离
|
//是否开启多租户隔离
|
||||||
@@ -47,6 +60,9 @@ public class MybatisPlusAutoConfigure {
|
|||||||
tenantLineHandler, tenantProperties.getIgnoreSqls());
|
tenantLineHandler, tenantProperties.getIgnoreSqls());
|
||||||
mpInterceptor.addInnerInterceptor(tenantInterceptor);
|
mpInterceptor.addInnerInterceptor(tenantInterceptor);
|
||||||
}
|
}
|
||||||
|
if(dataScopeProperties.getEnabled()){
|
||||||
|
mpInterceptor.addInnerInterceptor(new DataScopeInnerInterceptor(dataScopeProperties, sqlHandler));
|
||||||
|
}
|
||||||
mpInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
mpInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
return mpInterceptor;
|
return mpInterceptor;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,5 +1,6 @@
|
|||||||
package org.txlcn.demo;
|
package org.txlcn.demo;
|
||||||
|
|
||||||
|
import com.central.common.lb.annotation.EnableFeignInterceptor;
|
||||||
import com.codingapi.txlcn.tc.config.EnableDistributedTransaction;
|
import com.codingapi.txlcn.tc.config.EnableDistributedTransaction;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@@ -14,6 +15,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@EnableDistributedTransaction
|
@EnableDistributedTransaction
|
||||||
|
@EnableFeignInterceptor
|
||||||
public class ServiceAApplication {
|
public class ServiceAApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ServiceAApplication.class, args);
|
SpringApplication.run(ServiceAApplication.class, args);
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
FROM nginx:1.21.0
|
|
||||||
|
|
||||||
LABEL MAINTAINER=Andy
|
|
||||||
RUN rm -rf /usr/share/nginx/html/*
|
|
||||||
COPY src/main/resources/static/ /usr/share/nginx/html/
|
|
||||||
|
|
||||||
# docker run --name zlt-web \
|
|
||||||
# -v /host/path/apiUrl.js:/usr/share/nginx/html/module/apiUrl.js:ro
|
|
||||||
# -d zlt-web:4.5
|
|
||||||
@@ -1,95 +1,95 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<title>zlt-mp</title>
|
<title>zlt-mp</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
<link rel="stylesheet" href="assets/libs/layui/css/layui.css"/>
|
<link rel="stylesheet" href="assets/libs/layui/css/layui.css"/>
|
||||||
<link rel="stylesheet" href="assets/css/admin.css"/>
|
<link rel="stylesheet" href="assets/css/admin.css"/>
|
||||||
<link rel="stylesheet" href="module/formSelects/formSelects-v4.css"/>
|
<link rel="stylesheet" href="module/formSelects/formSelects-v4.css"/>
|
||||||
<link rel="stylesheet" href="assets/libs/zTree/css/metroStyle/metroStyle.css"/>
|
<link rel="stylesheet" href="assets/libs/zTree/css/metroStyle/metroStyle.css"/>
|
||||||
<!-- 自定义主题,使用EasyWeb主题生成器生成 -->
|
<!-- 自定义主题,使用EasyWeb主题生成器生成 -->
|
||||||
<!--<link rel="stylesheet" href="assets/css/theme-blue.css"/>-->
|
<!--<link rel="stylesheet" href="assets/css/theme-blue.css"/>-->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="layui-layout-body">
|
<body class="layui-layout-body">
|
||||||
<div class="layui-layout layui-layout-admin">
|
<div class="layui-layout layui-layout-admin">
|
||||||
<!-- 头部 存放用户登录信息-->
|
<!-- 头部 存放用户登录信息-->
|
||||||
<div class="layui-header" p-com="header"></div>
|
<div class="layui-header" p-com="header"></div>
|
||||||
|
|
||||||
<!-- 左边菜单栏 关联 config.js index.js side.html -->
|
<!-- 左边菜单栏 关联 config.js index.js side.html -->
|
||||||
<div class="layui-side" p-com="side"></div>
|
<div class="layui-side" p-com="side"></div>
|
||||||
|
|
||||||
<!-- 主体部分 -->
|
<!-- 主体部分 -->
|
||||||
<div class="layui-body">
|
<div class="layui-body">
|
||||||
<div class="layui-tab" lay-allowClose="true" lay-filter="admin-pagetabs">
|
<div class="layui-tab" lay-allowClose="true" lay-filter="admin-pagetabs">
|
||||||
<ul class="layui-tab-title">
|
<ul class="layui-tab-title">
|
||||||
</ul>
|
</ul>
|
||||||
<div class="layui-tab-content">
|
<div class="layui-tab-content">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-icon admin-tabs-control layui-icon-prev" ew-event="leftPage"></div>
|
<div class="layui-icon admin-tabs-control layui-icon-prev" ew-event="leftPage"></div>
|
||||||
<div class="layui-icon admin-tabs-control layui-icon-next" ew-event="rightPage"></div>
|
<div class="layui-icon admin-tabs-control layui-icon-next" ew-event="rightPage"></div>
|
||||||
<div class="layui-icon admin-tabs-control layui-icon-down">
|
<div class="layui-icon admin-tabs-control layui-icon-down">
|
||||||
<ul class="layui-nav admin-tabs-select" lay-filter="admin-pagetabs-nav">
|
<ul class="layui-nav admin-tabs-select" lay-filter="admin-pagetabs-nav">
|
||||||
<li class="layui-nav-item" lay-unselect>
|
<li class="layui-nav-item" lay-unselect>
|
||||||
<a href="javascript:"></a>
|
<a href="javascript:"></a>
|
||||||
<dl class="layui-nav-child layui-anim-fadein">
|
<dl class="layui-nav-child layui-anim-fadein">
|
||||||
<dd ew-event="closeThisTabs" lay-unselect><a href="javascript:">关闭当前标签页</a></dd>
|
<dd ew-event="closeThisTabs" lay-unselect><a href="javascript:">关闭当前标签页</a></dd>
|
||||||
<dd ew-event="closeOtherTabs" lay-unselect><a href="javascript:">关闭其它标签页</a></dd>
|
<dd ew-event="closeOtherTabs" lay-unselect><a href="javascript:">关闭其它标签页</a></dd>
|
||||||
<dd ew-event="closeAllTabs" lay-unselect><a href="javascript:">关闭全部标签页</a></dd>
|
<dd ew-event="closeAllTabs" lay-unselect><a href="javascript:">关闭全部标签页</a></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
<div class="layui-footer"> </span>
|
<div class="layui-footer"> </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 手机屏幕遮罩层 -->
|
<!-- 手机屏幕遮罩层 -->
|
||||||
<div class="site-mobile-shade"></div>
|
<div class="site-mobile-shade"></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="module/apiUrl.js"></script>
|
<script type="text/javascript" src="module/apiUrl.js"></script>
|
||||||
<script type="text/javascript" src="assets/libs/jquery-3.2.1.min.js"></script>
|
<script type="text/javascript" src="assets/libs/jquery-3.2.1.min.js"></script>
|
||||||
<script type="text/javascript" src="assets/libs/q.js"></script>
|
<script type="text/javascript" src="assets/libs/q.js"></script>
|
||||||
<script type="text/javascript" src="assets/libs/pandyle.min.js"></script>
|
<script type="text/javascript" src="assets/libs/pandyle.min.js"></script>
|
||||||
<script type="text/javascript" src="assets/libs/layui/layui.js"></script>
|
<script type="text/javascript" src="assets/libs/layui/layui.js"></script>
|
||||||
<script type="text/javascript" src="assets/libs/zTree/js/jquery.ztree.all-3.5.min.js"></script>
|
<script type="text/javascript" src="assets/libs/zTree/js/jquery.ztree.all-3.5.min.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
layui.config({
|
layui.config({
|
||||||
base: 'module/'
|
base: 'module/'
|
||||||
}).extend({
|
}).extend({
|
||||||
formSelects: 'formSelects/formSelects-v4',
|
formSelects: 'formSelects/formSelects-v4',
|
||||||
treetable: 'treetable-lay/treetable'
|
treetable: 'treetable-lay/treetable'
|
||||||
}).use(['config', 'index', 'element'], function () {
|
}).use(['config', 'index', 'element'], function () {
|
||||||
let config = layui.config;
|
let config = layui.config;
|
||||||
let index = layui.index;
|
let index = layui.index;
|
||||||
let element = layui.element;
|
let element = layui.element;
|
||||||
|
|
||||||
// 检查是否登录
|
// 检查是否登录
|
||||||
if (!config.getToken() || config.getToken() == '') {
|
if (!config.getToken() || config.getToken() == '') {
|
||||||
location.replace('login.html');
|
location.replace('login.html');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查多标签功能是否开启
|
// 检查多标签功能是否开启
|
||||||
index.checkPageTabs();
|
index.checkPageTabs();
|
||||||
|
|
||||||
// 获取当前用户信息
|
// 获取当前用户信息
|
||||||
index.getUser(function (user) {
|
index.getUser(function (user) {
|
||||||
$('.layui-layout-admin .layui-header').vm(user);
|
$('.layui-layout-admin .layui-header').vm(user);
|
||||||
index.initLeftNav();
|
index.initLeftNav();
|
||||||
element.render('nav');
|
element.render('nav');
|
||||||
index.initRouter();
|
index.initRouter();
|
||||||
index.bindEvent();
|
index.bindEvent();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -1,129 +1,129 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<title>用户登录</title>
|
<title>用户登录</title>
|
||||||
<link rel="stylesheet" href="assets/libs/layui/css/layui.css"/>
|
<link rel="stylesheet" href="assets/libs/layui/css/layui.css"/>
|
||||||
<link rel="stylesheet" href="assets/css/login.css" media="all">
|
<link rel="stylesheet" href="assets/css/login.css" media="all">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="login-wrapper">
|
<div class="login-wrapper">
|
||||||
<div class="login-body">
|
<div class="login-body">
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-header">
|
<div class="layui-card-header">
|
||||||
<i class="layui-icon layui-icon-engine"></i> 用户登录
|
<i class="layui-icon layui-icon-engine"></i> 用户登录
|
||||||
</div>
|
</div>
|
||||||
<form class="layui-card-body layui-form layui-form-pane">
|
<form class="layui-card-body layui-form layui-form-pane">
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
|
<label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="username" type="text" lay-verify="required" placeholder="账号"
|
<input name="username" type="text" lay-verify="required" placeholder="账号"
|
||||||
class="layui-input">
|
class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
|
<label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="password" type="password" lay-verify="required" placeholder="密码"
|
<input name="password" type="password" lay-verify="required" placeholder="密码"
|
||||||
class="layui-input">
|
class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
|
<label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<div class="layui-row inline-block">
|
<div class="layui-row inline-block">
|
||||||
<div class="layui-col-xs7">
|
<div class="layui-col-xs7">
|
||||||
<input name="validCode" style="width:170px" type="text" lay-verify="required" placeholder="验证码" class="layui-input">
|
<input name="validCode" style="width:170px" type="text" lay-verify="required" placeholder="验证码" class="layui-input">
|
||||||
<input name="deviceId" type="hidden"/>
|
<input name="deviceId" type="hidden"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-xs5" style="padding-left: 10px;">
|
<div class="layui-col-xs5" style="padding-left: 10px;">
|
||||||
<img class="login-captcha" src="#" style="display:none">
|
<img class="login-captcha" src="#" style="display:none">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<input name="grant_type" type="hidden" value="password_code"/>
|
<input name="grant_type" type="hidden" value="password_code"/>
|
||||||
<button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
|
<button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="login-footer">
|
<div class="login-footer">
|
||||||
<p>© 2018 <a href="javascript:;" target="_blank">zlt版权所有</a></p>
|
<p>© 2018 <a href="javascript:;" target="_blank">zlt版权所有</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="module/apiUrl.js"></script>
|
<script type="text/javascript" src="module/apiUrl.js"></script>
|
||||||
<script type="text/javascript" src="assets/libs/layui/layui.js"></script>
|
<script type="text/javascript" src="assets/libs/layui/layui.js"></script>
|
||||||
<script type="text/javascript" src="assets/libs/login.js"></script>
|
<script type="text/javascript" src="assets/libs/login.js"></script>
|
||||||
<script type="text/javascript" src="module/Math.uuid.js"></script>
|
<script type="text/javascript" src="module/Math.uuid.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
layui.config({
|
layui.config({
|
||||||
base: 'module/'
|
base: 'module/'
|
||||||
}).use(['config', 'form'], function () {
|
}).use(['config', 'form'], function () {
|
||||||
//页面唯一标识
|
//页面唯一标识
|
||||||
let uuid = Math.uuid();
|
let uuid = Math.uuid();
|
||||||
let $ = layui.jquery;
|
let $ = layui.jquery;
|
||||||
let form = layui.form;
|
let form = layui.form;
|
||||||
let config = layui.config;
|
let config = layui.config;
|
||||||
|
|
||||||
if (config.getToken()) {
|
if (config.getToken()) {
|
||||||
location.replace('./');
|
location.replace('./');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$("input[name='deviceId']").val(uuid);
|
$("input[name='deviceId']").val(uuid);
|
||||||
|
|
||||||
// 表单提交
|
// 表单提交
|
||||||
form.on('submit(login-submit)', function (obj) {
|
form.on('submit(login-submit)', function (obj) {
|
||||||
layer.load(2);
|
layer.load(2);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: config.base_server + 'api-uaa/oauth/token',
|
url: config.base_server + 'api-uaa/oauth/token',
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
},
|
},
|
||||||
data: obj.field,
|
data: obj.field,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
beforeSend: function (xhr) {
|
beforeSend: function (xhr) {
|
||||||
xhr.setRequestHeader('Authorization', 'Basic ' + window.btoa(config.clientId + ":" + config.clientSecret));
|
xhr.setRequestHeader('Authorization', 'Basic ' + window.btoa(config.clientId + ":" + config.clientSecret));
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
//console.log(JSON.stringify(data));
|
//console.log(JSON.stringify(data));
|
||||||
if (data.resp_code === 0) {
|
if (data.resp_code === 0) {
|
||||||
config.putToken(data.datas);
|
config.putToken(data.datas);
|
||||||
layer.msg('登录成功', {icon: 1, time: 500}, function () {
|
layer.msg('登录成功', {icon: 1, time: 500}, function () {
|
||||||
location.replace('./');
|
location.replace('./');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
layer.closeAll('loading');
|
layer.closeAll('loading');
|
||||||
layer.msg(data.resp_msg, {icon: 5, time: 500});
|
layer.msg(data.resp_msg, {icon: 5, time: 500});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (xhr) {
|
error: function (xhr) {
|
||||||
//console.log(xhr)
|
//console.log(xhr)
|
||||||
layer.closeAll('loading');
|
layer.closeAll('loading');
|
||||||
layer.msg(xhr.responseJSON.resp_msg, {icon: 5, time: 500});
|
layer.msg(xhr.responseJSON.resp_msg, {icon: 5, time: 500});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//阻止表单跳转
|
//阻止表单跳转
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 图形验证码
|
// 图形验证码
|
||||||
$('.login-captcha').attr("src", config.base_server + "api-uaa/validata/code/"+uuid);
|
$('.login-captcha').attr("src", config.base_server + "api-uaa/validata/code/"+uuid);
|
||||||
$('.login-captcha').attr("style", "");
|
$('.login-captcha').attr("style", "");
|
||||||
|
|
||||||
// 图形验证码
|
// 图形验证码
|
||||||
$('.login-captcha').click(function () {
|
$('.login-captcha').click(function () {
|
||||||
this.src = this.src + '?t=' + (new Date).getTime();
|
this.src = this.src + '?t=' + (new Date).getTime();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,291 +1,291 @@
|
|||||||
//add by owen 修复 path 无法引用http://页面的问题 begin
|
//add by owen 修复 path 无法引用http://页面的问题 begin
|
||||||
String.prototype.startWith = function(str) {
|
String.prototype.startWith = function(str) {
|
||||||
if (str == null || str == "" || this.length == 0
|
if (str == null || str == "" || this.length == 0
|
||||||
|| str.length > this.length)
|
|| str.length > this.length)
|
||||||
return false;
|
return false;
|
||||||
if (this.substr(0, str.length) == str)
|
if (this.substr(0, str.length) == str)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function initIFrame() {
|
function initIFrame() {
|
||||||
var $parent = $(".admin-iframe").parent();
|
var $parent = $(".admin-iframe").parent();
|
||||||
if ($parent.hasClass('layui-body')) {
|
if ($parent.hasClass('layui-body')) {
|
||||||
$parent.addClass('admin-iframe-body');
|
$parent.addClass('admin-iframe-body');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($parent.hasClass('layui-tab-item')) {
|
if ($parent.hasClass('layui-tab-item')) {
|
||||||
$parent.css({'padding': '0', 'overflow-y': 'hidden'});
|
$parent.css({'padding': '0', 'overflow-y': 'hidden'});
|
||||||
} else {
|
} else {
|
||||||
$parent.css({'width': '100%', 'height': '100%'});
|
$parent.css({'width': '100%', 'height': '100%'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//add by owen 修复 path 无法引用http://页面的问题 end
|
//add by owen 修复 path 无法引用http://页面的问题 end
|
||||||
|
|
||||||
layui.define(['config', 'admin', 'layer', 'laytpl', 'element', 'form'], function (exports) {
|
layui.define(['config', 'admin', 'layer', 'laytpl', 'element', 'form'], function (exports) {
|
||||||
var $ = layui.$;
|
var $ = layui.$;
|
||||||
var config = layui.config;
|
var config = layui.config;
|
||||||
var admin = layui.admin;
|
var admin = layui.admin;
|
||||||
var layer = layui.layer;
|
var layer = layui.layer;
|
||||||
var laytpl = layui.laytpl;
|
var laytpl = layui.laytpl;
|
||||||
var element = layui.element;
|
var element = layui.element;
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
|
|
||||||
var index = {
|
var index = {
|
||||||
// 渲染左侧菜单栏
|
// 渲染左侧菜单栏
|
||||||
initLeftNav: function () {
|
initLeftNav: function () {
|
||||||
admin.req('api-user/menus/current', {}, function (data) {
|
admin.req('api-user/menus/current', {}, function (data) {
|
||||||
//data = data[1];
|
//data = data[1];
|
||||||
admin.putTempData("menus",data);
|
admin.putTempData("menus",data);
|
||||||
var menus = data;
|
var menus = data;
|
||||||
// 判断权限
|
// 判断权限
|
||||||
for (var i = menus.length - 1; i >= 0; i--) {
|
for (var i = menus.length - 1; i >= 0; i--) {
|
||||||
var tempMenu = menus[i];
|
var tempMenu = menus[i];
|
||||||
if (tempMenu.auth && !admin.hasPerm(tempMenu.auth)) {
|
if (tempMenu.auth && !admin.hasPerm(tempMenu.auth)) {
|
||||||
menus.splice(i, 1);
|
menus.splice(i, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!tempMenu.subMenus) {
|
if (!tempMenu.subMenus) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
|
for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
|
||||||
var jMenus = tempMenu.subMenus[j];
|
var jMenus = tempMenu.subMenus[j];
|
||||||
if (jMenus.auth && !admin.hasPerm(jMenus.auth)) {
|
if (jMenus.auth && !admin.hasPerm(jMenus.auth)) {
|
||||||
tempMenu.subMenus.splice(j, 1);
|
tempMenu.subMenus.splice(j, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!jMenus.subMenus) {
|
if (!jMenus.subMenus) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var k = jMenus.subMenus.length - 1; k >= 0; k--) {
|
for (var k = jMenus.subMenus.length - 1; k >= 0; k--) {
|
||||||
if (jMenus.subMenus[k].auth && !admin.hasPerm(jMenus.subMenus[k].auth)) {
|
if (jMenus.subMenus[k].auth && !admin.hasPerm(jMenus.subMenus[k].auth)) {
|
||||||
jMenus.subMenus.splice(k, 1);
|
jMenus.subMenus.splice(k, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 去除空的目录
|
// 去除空的目录
|
||||||
for (var i = menus.length - 1; i >= 0; i--) {
|
for (var i = menus.length - 1; i >= 0; i--) {
|
||||||
var tempMenu = menus[i];
|
var tempMenu = menus[i];
|
||||||
if (tempMenu.subMenus && tempMenu.subMenus.length <= 0) {
|
if (tempMenu.subMenus && tempMenu.subMenus.length <= 0) {
|
||||||
menus.splice(i, 1);
|
menus.splice(i, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!tempMenu.subMenus) {
|
if (!tempMenu.subMenus) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
|
for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
|
||||||
var jMenus = tempMenu.subMenus[j];
|
var jMenus = tempMenu.subMenus[j];
|
||||||
if (jMenus.subMenus && jMenus.subMenus.length <= 0) {
|
if (jMenus.subMenus && jMenus.subMenus.length <= 0) {
|
||||||
tempMenu.splice(j, 1);
|
tempMenu.splice(j, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 渲染
|
// 渲染
|
||||||
$('.layui-layout-admin .layui-side').load('pages/side.html', function () {
|
$('.layui-layout-admin .layui-side').load('pages/side.html', function () {
|
||||||
laytpl(sideNav.innerHTML).render(menus, function (html) {
|
laytpl(sideNav.innerHTML).render(menus, function (html) {
|
||||||
$('#sideNav').after(html);
|
$('#sideNav').after(html);
|
||||||
});
|
});
|
||||||
element.render('nav');
|
element.render('nav');
|
||||||
admin.activeNav(Q.lash);
|
admin.activeNav(Q.lash);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}, 'GET');
|
}, 'GET');
|
||||||
},
|
},
|
||||||
// 路由注册
|
// 路由注册
|
||||||
initRouter: function () {
|
initRouter: function () {
|
||||||
|
|
||||||
index.regRouter(admin.getTempData("menus"));
|
index.regRouter(admin.getTempData("menus"));
|
||||||
// index.regRouter(config.menus);
|
// index.regRouter(config.menus);
|
||||||
Q.reg('console', function () {
|
Q.reg('console', function () {
|
||||||
var menuPath = 'pages/console.html'
|
var menuPath = 'pages/console.html'
|
||||||
index.loadView('console', menuPath, '主页');
|
index.loadView('console', menuPath, '主页');
|
||||||
});
|
});
|
||||||
|
|
||||||
Q.init({
|
Q.init({
|
||||||
index: 'console'
|
index: 'console'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 使用递归循环注册
|
// 使用递归循环注册
|
||||||
regRouter: function (menus) {
|
regRouter: function (menus) {
|
||||||
$.each(menus, function (i, data) {
|
$.each(menus, function (i, data) {
|
||||||
if (data.url && data.url.indexOf('#!') == 0) {
|
if (data.url && data.url.indexOf('#!') == 0) {
|
||||||
Q.reg(data.url.substring(2), function () {
|
Q.reg(data.url.substring(2), function () {
|
||||||
if (data.path.startWith("http://")) {
|
if (data.path.startWith("http://")) {
|
||||||
window.open(data.path);
|
window.open(data.path);
|
||||||
} else {
|
} else {
|
||||||
//临时保存url
|
//临时保存url
|
||||||
data.path.startWith("http://") ? admin.putTempData("params",data.path) : null ;
|
data.path.startWith("http://") ? admin.putTempData("params",data.path) : null ;
|
||||||
|
|
||||||
var menuId = data.url.substring(2);
|
var menuId = data.url.substring(2);
|
||||||
//add by owen 修复 path 无法引用http://页面的问题
|
//add by owen 修复 path 无法引用http://页面的问题
|
||||||
var menuPath = data.path.startWith("http://") ? 'pages/tpl/iframe.html' : 'pages/' + data.path
|
var menuPath = data.path.startWith("http://") ? 'pages/tpl/iframe.html' : 'pages/' + data.path
|
||||||
index.loadView(menuId, menuPath, data.name);
|
index.loadView(menuId, menuPath, data.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (data.subMenus) {
|
if (data.subMenus) {
|
||||||
index.regRouter(data.subMenus);
|
index.regRouter(data.subMenus);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 路由加载组件
|
// 路由加载组件
|
||||||
loadView: function (menuId, menuPath, menuName) {
|
loadView: function (menuId, menuPath, menuName) {
|
||||||
var contentDom = '.layui-layout-admin .layui-body';
|
var contentDom = '.layui-layout-admin .layui-body';
|
||||||
admin.showLoading('.layui-layout-admin .layui-body');
|
admin.showLoading('.layui-layout-admin .layui-body');
|
||||||
var flag; // 选项卡是否添加
|
var flag; // 选项卡是否添加
|
||||||
flag = menuPath.startWith("http://") ? false : flag ;
|
flag = menuPath.startWith("http://") ? false : flag ;
|
||||||
// 判断是否开启了选项卡功能
|
// 判断是否开启了选项卡功能
|
||||||
if (config.pageTabs) {
|
if (config.pageTabs) {
|
||||||
$('.layui-layout-admin .layui-body .layui-tab .layui-tab-title>li').each(function (index) {
|
$('.layui-layout-admin .layui-body .layui-tab .layui-tab-title>li').each(function (index) {
|
||||||
if ($(this).attr('lay-id') === menuId) {
|
if ($(this).attr('lay-id') === menuId) {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
element.tabAdd('admin-pagetabs', {
|
element.tabAdd('admin-pagetabs', {
|
||||||
title: menuName,
|
title: menuName,
|
||||||
//add by owen 修复 path 无法引用http://页面的问题
|
//add by owen 修复 path 无法引用http://页面的问题
|
||||||
content: menuPath.startWith("http://") ? '<div id="admin-iframe" style="width: 100%; height: 100%;"><iframe id="' + menuId + '" src="' + menuPath + '" marginwidth="0" marginheight="0" width="100%" height="100%" frameborder="0" onload="initIFrame()"></iframe> </div>' : '<div id="' + menuId + '"></div>' ,
|
content: menuPath.startWith("http://") ? '<div id="admin-iframe" style="width: 100%; height: 100%;"><iframe id="' + menuId + '" src="' + menuPath + '" marginwidth="0" marginheight="0" width="100%" height="100%" frameborder="0" onload="initIFrame()"></iframe> </div>' : '<div id="' + menuId + '"></div>' ,
|
||||||
id: menuId
|
id: menuId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
contentDom = '#' + menuId;
|
contentDom = '#' + menuId;
|
||||||
element.tabChange('admin-pagetabs', menuId);
|
element.tabChange('admin-pagetabs', menuId);
|
||||||
admin.rollPage('auto');
|
admin.rollPage('auto');
|
||||||
// 切换tab关闭表格内浮窗
|
// 切换tab关闭表格内浮窗
|
||||||
$('.layui-table-tips-c').trigger('click');
|
$('.layui-table-tips-c').trigger('click');
|
||||||
// 解决切换tab滚动条时而消失的问题
|
// 解决切换tab滚动条时而消失的问题
|
||||||
var $iframe = $('.layui-layout-admin .layui-body .layui-tab-content .layui-tab-item.layui-show .admin-iframe')[0];
|
var $iframe = $('.layui-layout-admin .layui-body .layui-tab-content .layui-tab-item.layui-show .admin-iframe')[0];
|
||||||
if ($iframe) {
|
if ($iframe) {
|
||||||
$iframe.style.height = "99%";
|
$iframe.style.height = "99%";
|
||||||
$iframe.scrollWidth;
|
$iframe.scrollWidth;
|
||||||
$iframe.style.height = "100%";
|
$iframe.style.height = "100%";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!flag || admin.isRefresh) {
|
if (!flag || admin.isRefresh) {
|
||||||
$(contentDom).load(menuPath, function () {
|
$(contentDom).load(menuPath, function () {
|
||||||
admin.isRefresh = false;
|
admin.isRefresh = false;
|
||||||
element.render('breadcrumb');
|
element.render('breadcrumb');
|
||||||
form.render('select');
|
form.render('select');
|
||||||
admin.removeLoading('.layui-layout-admin .layui-body');
|
admin.removeLoading('.layui-layout-admin .layui-body');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
admin.removeLoading('.layui-layout-admin .layui-body');
|
admin.removeLoading('.layui-layout-admin .layui-body');
|
||||||
}
|
}
|
||||||
admin.activeNav(Q.lash);
|
admin.activeNav(Q.lash);
|
||||||
// 移动设备切换页面隐藏侧导航
|
// 移动设备切换页面隐藏侧导航
|
||||||
if (document.body.clientWidth <= 750) {
|
if (document.body.clientWidth <= 750) {
|
||||||
admin.flexible(true);
|
admin.flexible(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 从服务器获取登录用户的信息
|
// 从服务器获取登录用户的信息
|
||||||
getUser: function (success) {
|
getUser: function (success) {
|
||||||
layer.load(2);
|
layer.load(2);
|
||||||
admin.req('api-user/users/current', {}, function (data) {
|
admin.req('api-user/users/current', {}, function (data) {
|
||||||
layer.closeAll('loading');
|
layer.closeAll('loading');
|
||||||
if (data && data.resp_code === 0) {
|
if (data && data.resp_code === 0) {
|
||||||
let user = data.datas;
|
let user = data.datas;
|
||||||
config.putUser(user);
|
config.putUser(user);
|
||||||
admin.putTempData("permissions",user.permissions);
|
admin.putTempData("permissions",user.permissions);
|
||||||
success(user);
|
success(user);
|
||||||
} else {
|
} else {
|
||||||
layer.msg('获取用户失败', {icon: 2});
|
layer.msg('获取用户失败', {icon: 2});
|
||||||
config.removeToken();
|
config.removeToken();
|
||||||
location.replace('login.html');
|
location.replace('login.html');
|
||||||
}
|
}
|
||||||
}, 'GET');
|
}, 'GET');
|
||||||
},
|
},
|
||||||
//获取菜单
|
//获取菜单
|
||||||
getMenus: function () {
|
getMenus: function () {
|
||||||
admin.req('api-user/menus/current', {}, function (data) {
|
admin.req('api-user/menus/current', {}, function (data) {
|
||||||
admin.putTempData("menus",data);
|
admin.putTempData("menus",data);
|
||||||
}, 'GET');
|
}, 'GET');
|
||||||
},
|
},
|
||||||
// 页面元素绑定事件监听
|
// 页面元素绑定事件监听
|
||||||
bindEvent: function () {
|
bindEvent: function () {
|
||||||
// 退出登录
|
// 退出登录
|
||||||
$('#btnLogout').click(function () {
|
$('#btnLogout').click(function () {
|
||||||
layer.confirm('确定退出登录?', function () {
|
layer.confirm('确定退出登录?', function () {
|
||||||
let token = config.getToken();
|
let token = config.getToken();
|
||||||
let isExistsToken = false;
|
let isExistsToken = false;
|
||||||
if (token) {
|
if (token) {
|
||||||
let accessToken = token.access_token;
|
let accessToken = token.access_token;
|
||||||
config.removeToken();
|
config.removeToken();
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
isExistsToken = true;
|
isExistsToken = true;
|
||||||
admin.req('api-uaa/oauth/check_token?token='+accessToken, {}, function (data) {
|
admin.req('api-uaa/oauth/check_token?token='+accessToken, {}, function (data) {
|
||||||
if (data.active) {
|
if (data.active) {
|
||||||
let loginPageUrl = window.location.protocol + '//' + window.location.host + '/login.html';
|
let loginPageUrl = window.location.protocol + '//' + window.location.host + '/login.html';
|
||||||
window.location = config.base_server + 'api-uaa/oauth/remove/token?redirect_uri='+loginPageUrl+'&access_token='+accessToken;
|
window.location = config.base_server + 'api-uaa/oauth/remove/token?redirect_uri='+loginPageUrl+'&access_token='+accessToken;
|
||||||
} else {
|
} else {
|
||||||
location.replace('login.html');
|
location.replace('login.html');
|
||||||
}
|
}
|
||||||
}, 'POST');
|
}, 'POST');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isExistsToken) {
|
if (!isExistsToken) {
|
||||||
location.replace('login.html');
|
location.replace('login.html');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// 修改密码
|
// 修改密码
|
||||||
$('#setPsw').click(function () {
|
$('#setPsw').click(function () {
|
||||||
admin.popupRight('pages/tpl/password.html');
|
admin.popupRight('pages/tpl/password.html');
|
||||||
});
|
});
|
||||||
// 个人信息
|
// 个人信息
|
||||||
$('#setInfo').click(function () {
|
$('#setInfo').click(function () {
|
||||||
Q.go('myInfo');
|
Q.go('myInfo');
|
||||||
});
|
});
|
||||||
// 消息
|
// 消息
|
||||||
$('#btnMessage').click(function () {
|
$('#btnMessage').click(function () {
|
||||||
admin.popupRight('pages/tpl/message.html');
|
admin.popupRight('pages/tpl/message.html');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 检查多标签功能是否开启
|
// 检查多标签功能是否开启
|
||||||
checkPageTabs: function () {
|
checkPageTabs: function () {
|
||||||
// 加载主页
|
// 加载主页
|
||||||
if (config.pageTabs) {
|
if (config.pageTabs) {
|
||||||
$('.layui-layout-admin').addClass('open-tab');
|
$('.layui-layout-admin').addClass('open-tab');
|
||||||
element.tabAdd('admin-pagetabs', {
|
element.tabAdd('admin-pagetabs', {
|
||||||
title: '<i class="layui-icon layui-icon-home"></i>',
|
title: '<i class="layui-icon layui-icon-home"></i>',
|
||||||
content: '<div id="console"></div>',
|
content: '<div id="console"></div>',
|
||||||
id: 'console'
|
id: 'console'
|
||||||
});
|
});
|
||||||
$('#console').load('pages/console.html', function () {
|
$('#console').load('pages/console.html', function () {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$('.layui-layout-admin').removeClass('open-tab');
|
$('.layui-layout-admin').removeClass('open-tab');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 打开新页面
|
// 打开新页面
|
||||||
openNewTab: function (param) {
|
openNewTab: function (param) {
|
||||||
var url = param.url;
|
var url = param.url;
|
||||||
var title = param.title;
|
var title = param.title;
|
||||||
var menuId = param.menuId;
|
var menuId = param.menuId;
|
||||||
if (!menuId) {
|
if (!menuId) {
|
||||||
menuId = url.replace(/[?:=&/]/g, '_');
|
menuId = url.replace(/[?:=&/]/g, '_');
|
||||||
}
|
}
|
||||||
index.loadView(menuId, url, title);
|
index.loadView(menuId, url, title);
|
||||||
},
|
},
|
||||||
// 关闭选项卡
|
// 关闭选项卡
|
||||||
closeTab: function (menuId) {
|
closeTab: function (menuId) {
|
||||||
element.tabDelete('admin-pagetabs', menuId);
|
element.tabDelete('admin-pagetabs', menuId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// tab选项卡切换监听
|
// tab选项卡切换监听
|
||||||
element.on('tab(admin-pagetabs)', function (data) {
|
element.on('tab(admin-pagetabs)', function (data) {
|
||||||
var layId = $(this).attr('lay-id');
|
var layId = $(this).attr('lay-id');
|
||||||
Q.go(layId);
|
Q.go(layId);
|
||||||
});
|
});
|
||||||
|
|
||||||
exports('index', index);
|
exports('index', index);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,237 +1,237 @@
|
|||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-header">
|
<div class="layui-card-header">
|
||||||
<h2 class="header-title">应用管理</h2>
|
<h2 class="header-title">应用管理</h2>
|
||||||
<span class="layui-breadcrumb pull-right">
|
<span class="layui-breadcrumb pull-right">
|
||||||
<a href="#!home_console">首页</a>
|
<a href="#!home_console">首页</a>
|
||||||
<a><cite>应用管理</cite></a>
|
<a><cite>应用管理</cite></a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<div class="layui-form toolbar">
|
<div class="layui-form toolbar">
|
||||||
搜索:<input id="app-edit-search" class="layui-input search-input" type="text" placeholder="输入关键字"/> 
|
搜索:<input id="app-edit-search" class="layui-input search-input" type="text" placeholder="输入关键字"/> 
|
||||||
<button id="app-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
<button id="app-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
||||||
<button id="app-btn-add" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button>
|
<button id="app-btn-add" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 数据表格 -->
|
<!-- 数据表格 -->
|
||||||
<table class="layui-table" id="app-table" lay-filter="app-table"></table>
|
<table class="layui-table" id="app-table" lay-filter="app-table"></table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 表格操作列 -->
|
<!-- 表格操作列 -->
|
||||||
<script type="text/html" id="app-table-bar">
|
<script type="text/html" id="app-table-bar">
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- 表单弹窗 -->
|
<!-- 表单弹窗 -->
|
||||||
<script type="text/html" id="app-model">
|
<script type="text/html" id="app-model">
|
||||||
<form id="app-form" method="POST" lay-filter="app-form" class="layui-form model-form">
|
<form id="app-form" method="POST" lay-filter="app-form" class="layui-form model-form">
|
||||||
<input name="id" type="hidden"/>
|
<input name="id" type="hidden"/>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">应用标识</label>
|
<label class="layui-form-label">应用标识</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="clientId" placeholder="请输入应用标识" type="text" class="layui-input" maxlength="20"
|
<input name="clientId" placeholder="请输入应用标识" type="text" class="layui-input" maxlength="20"
|
||||||
lay-verify="required" required/>
|
lay-verify="required" required/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">应用名称</label>
|
<label class="layui-form-label">应用名称</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="clientName" placeholder="请输入应用名称" type="text" class="layui-input" maxlength="20"/>
|
<input name="clientName" placeholder="请输入应用名称" type="text" class="layui-input" maxlength="20"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">应用密钥</label>
|
<label class="layui-form-label">应用密钥</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="clientSecretStr" placeholder="请输入应用密钥" type="text" class="layui-input" maxlength="20"
|
<input name="clientSecretStr" placeholder="请输入应用密钥" type="text" class="layui-input" maxlength="20"
|
||||||
lay-verify="required" required />
|
lay-verify="required" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">回调地址</label>
|
<label class="layui-form-label">回调地址</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="webServerRedirectUri" placeholder="请输入回调地址" type="text" class="layui-input" maxlength="20"/>
|
<input name="webServerRedirectUri" placeholder="请输入回调地址" type="text" class="layui-input" maxlength="20"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">自动审批</label>
|
<label class="layui-form-label">自动审批</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="radio" name="autoapprove" value="true" title="是" checked/>
|
<input type="radio" name="autoapprove" value="true" title="是" checked/>
|
||||||
<input type="radio" name="autoapprove" value="false" title="否"/>
|
<input type="radio" name="autoapprove" value="false" title="否"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">授权模式</label>
|
<label class="layui-form-label">授权模式</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="授权码模式" value="authorization_code" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="授权码模式" value="authorization_code" checked>
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="密码模式" value="password" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="密码模式" value="password" checked>
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="客户端模式" value="client_credentials" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="客户端模式" value="client_credentials" checked>
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="简化模式" value="implicit" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="简化模式" value="implicit" checked>
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="刷新Token" value="refresh_token" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="刷新Token" value="refresh_token" checked>
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="密码验证码模式" value="password_code" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="密码验证码模式" value="password_code" checked>
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="openId模式" value="openId" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="openId模式" value="openId" checked>
|
||||||
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="手机号密码模式" value="mobile_password" checked>
|
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="手机号密码模式" value="mobile_password" checked>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">令牌时效(s)</label>
|
<label class="layui-form-label">令牌时效(s)</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="accessTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="18000"/>
|
<input name="accessTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="18000"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">刷新时效(s)</label>
|
<label class="layui-form-label">刷新时效(s)</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="refreshTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="28800"/>
|
<input name="refreshTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="28800"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">支持ID令牌</label>
|
<label class="layui-form-label">支持ID令牌</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="radio" name="supportIdToken" value="true" title="是" checked/>
|
<input type="radio" name="supportIdToken" value="true" title="是" checked/>
|
||||||
<input type="radio" name="supportIdToken" value="false" title="否"/>
|
<input type="radio" name="supportIdToken" value="false" title="否"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">ID时效(s)</label>
|
<label class="layui-form-label">ID时效(s)</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input name="idTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="60"/>
|
<input name="idTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="60"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item model-form-footer">
|
<div class="layui-form-item model-form-footer">
|
||||||
<button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
|
<button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
|
||||||
<button class="layui-btn" lay-filter="app-form-submit" lay-submit>保存</button>
|
<button class="layui-btn" lay-filter="app-form-submit" lay-submit>保存</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
layui.use(['form', 'table', 'util', 'config', 'admin'],function () {
|
layui.use(['form', 'table', 'util', 'config', 'admin'],function () {
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
var table = layui.table;
|
var table = layui.table;
|
||||||
var config = layui.config;
|
var config = layui.config;
|
||||||
var layer = layui.layer;
|
var layer = layui.layer;
|
||||||
var util = layui.util;
|
var util = layui.util;
|
||||||
var admin = layui.admin;
|
var admin = layui.admin;
|
||||||
|
|
||||||
// 渲染表格
|
// 渲染表格
|
||||||
table.render({
|
table.render({
|
||||||
elem: '#app-table',
|
elem: '#app-table',
|
||||||
url: config.base_server + 'api-uaa/clients/list',
|
url: config.base_server + 'api-uaa/clients/list',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers:{'Authorization': 'Bearer ' + config.getToken().access_token},
|
headers:{'Authorization': 'Bearer ' + config.getToken().access_token},
|
||||||
page: true,
|
page: true,
|
||||||
cols: [[
|
cols: [[
|
||||||
{type: 'numbers'},
|
{type: 'numbers'},
|
||||||
{field: 'clientId',width:180, sort: true, title: '应用标识'},
|
{field: 'clientId',width:180, sort: true, title: '应用标识'},
|
||||||
{field: 'clientName',width:180, sort: true, title: '应用名称'},
|
{field: 'clientName',width:180, sort: true, title: '应用名称'},
|
||||||
{field: 'webServerRedirectUri', width:250,sort: true, title: '回调地址'},
|
{field: 'webServerRedirectUri', width:250,sort: true, title: '回调地址'},
|
||||||
{field: 'authorizedGrantTypes',width:250, sort: true, title: 'oauth授权方式'},
|
{field: 'authorizedGrantTypes',width:250, sort: true, title: 'oauth授权方式'},
|
||||||
{width:110, sort: true, title: '自动审批', templet:function (d) {
|
{width:110, sort: true, title: '自动审批', templet:function (d) {
|
||||||
return d.autoapprove == 'true' ? "是" : "否"
|
return d.autoapprove == 'true' ? "是" : "否"
|
||||||
}},
|
}},
|
||||||
{field: 'accessTokenValiditySeconds',width:130, sort: true, title: '令牌时效(s)'},
|
{field: 'accessTokenValiditySeconds',width:130, sort: true, title: '令牌时效(s)'},
|
||||||
{field: 'refreshTokenValiditySeconds',width:130, sort: true, title: '刷新时效(s)'},
|
{field: 'refreshTokenValiditySeconds',width:130, sort: true, title: '刷新时效(s)'},
|
||||||
{width:120, sort: true, title: '支持ID令牌', templet:function (d) {
|
{width:120, sort: true, title: '支持ID令牌', templet:function (d) {
|
||||||
return d.supportIdToken ? "是" : "否"
|
return d.supportIdToken ? "是" : "否"
|
||||||
}},
|
}},
|
||||||
{field: 'idTokenValiditySeconds',width:130, sort: true, title: 'ID时效(s)'},
|
{field: 'idTokenValiditySeconds',width:130, sort: true, title: 'ID时效(s)'},
|
||||||
{fixed: 'right', align: 'center',width:150, toolbar: '#app-table-bar', title: '操作'}
|
{fixed: 'right', align: 'center',width:150, toolbar: '#app-table-bar', title: '操作'}
|
||||||
]]
|
]]
|
||||||
});
|
});
|
||||||
|
|
||||||
// 工具条点击事件
|
// 工具条点击事件
|
||||||
table.on('tool(app-table)', function (obj) {
|
table.on('tool(app-table)', function (obj) {
|
||||||
var data = obj.data;
|
var data = obj.data;
|
||||||
var layEvent = obj.event;
|
var layEvent = obj.event;
|
||||||
|
|
||||||
if (layEvent === 'del') { // 删除
|
if (layEvent === 'del') { // 删除
|
||||||
doDelete(obj);
|
doDelete(obj);
|
||||||
}else if (layEvent === 'edit'){ //修改
|
}else if (layEvent === 'edit'){ //修改
|
||||||
showEditModel(data);
|
showEditModel(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
var doDelete = function (obj) {
|
var doDelete = function (obj) {
|
||||||
layer.confirm('确定要删除吗?', function (i) {
|
layer.confirm('确定要删除吗?', function (i) {
|
||||||
layer.close(i);
|
layer.close(i);
|
||||||
layer.load(2);
|
layer.load(2);
|
||||||
admin.req('api-uaa/clients/' + obj.data.id, {}, function (data) {
|
admin.req('api-uaa/clients/' + obj.data.id, {}, function (data) {
|
||||||
layer.closeAll('loading');
|
layer.closeAll('loading');
|
||||||
layer.msg('成功', {icon: 1, time: 500});
|
layer.msg('成功', {icon: 1, time: 500});
|
||||||
obj.del();
|
obj.del();
|
||||||
}, 'DELETE');
|
}, 'DELETE');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 搜索按钮点击事件
|
// 搜索按钮点击事件
|
||||||
$('#app-btn-search').click(function () {
|
$('#app-btn-search').click(function () {
|
||||||
var key = $('#app-edit-search').val();
|
var key = $('#app-edit-search').val();
|
||||||
table.reload('app-table', {where: {searchKey: key}});
|
table.reload('app-table', {where: {searchKey: key}});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 添加按钮点击事件
|
// 添加按钮点击事件
|
||||||
$('#app-btn-add').click(function () {
|
$('#app-btn-add').click(function () {
|
||||||
showEditModel();
|
showEditModel();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 显示编辑弹窗
|
// 显示编辑弹窗
|
||||||
var showEditModel = function (data) {
|
var showEditModel = function (data) {
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 1,
|
type: 1,
|
||||||
title: data ? '修改应用' : '添加应用',
|
title: data ? '修改应用' : '添加应用',
|
||||||
area: '750px',
|
area: '750px',
|
||||||
offset: '30px',
|
offset: '30px',
|
||||||
content: $('#app-model').html(),
|
content: $('#app-model').html(),
|
||||||
success: function () {
|
success: function () {
|
||||||
$('#app-form')[0].reset();
|
$('#app-form')[0].reset();
|
||||||
if (data) {
|
if (data) {
|
||||||
$("input[name='clientId']").attr('disabled',true);
|
$("input[name='clientId']").attr('disabled',true);
|
||||||
$("input[name='clientId']").attr('class',"layui-input layui-disabled");
|
$("input[name='clientId']").attr('class',"layui-input layui-disabled");
|
||||||
$("input[name='webServerRedirectUri']").attr('disabled',true);
|
$("input[name='webServerRedirectUri']").attr('disabled',true);
|
||||||
$("input[name='webServerRedirectUri']").attr('class',"layui-input layui-disabled");
|
$("input[name='webServerRedirectUri']").attr('class',"layui-input layui-disabled");
|
||||||
form.val('app-form', data);
|
form.val('app-form', data);
|
||||||
|
|
||||||
let authorizedGrantTypesArr = data.authorizedGrantTypes.split(",");
|
let authorizedGrantTypesArr = data.authorizedGrantTypes.split(",");
|
||||||
$('input[type=checkbox][name=authorizedGrantTypes]').each(function() {
|
$('input[type=checkbox][name=authorizedGrantTypes]').each(function() {
|
||||||
let typeValue = $(this).val();
|
let typeValue = $(this).val();
|
||||||
let isCheck = false;
|
let isCheck = false;
|
||||||
for (var i = 0; i < authorizedGrantTypesArr.length; i++) {
|
for (var i = 0; i < authorizedGrantTypesArr.length; i++) {
|
||||||
if (typeValue === authorizedGrantTypesArr[i]) {
|
if (typeValue === authorizedGrantTypesArr[i]) {
|
||||||
isCheck = true;
|
isCheck = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(this).prop("checked", isCheck);
|
$(this).prop("checked", isCheck);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 表单提交事件
|
// 表单提交事件
|
||||||
form.on('submit(app-form-submit)', function (data) {
|
form.on('submit(app-form-submit)', function (data) {
|
||||||
let authorizedGrantTypesArr = [];
|
let authorizedGrantTypesArr = [];
|
||||||
$('input[type=checkbox][name=authorizedGrantTypes]:checked').each(function() {
|
$('input[type=checkbox][name=authorizedGrantTypes]:checked').each(function() {
|
||||||
authorizedGrantTypesArr.push($(this).val());
|
authorizedGrantTypesArr.push($(this).val());
|
||||||
});
|
});
|
||||||
data.field.authorizedGrantTypes = authorizedGrantTypesArr.join(",");
|
data.field.authorizedGrantTypes = authorizedGrantTypesArr.join(",");
|
||||||
layer.load(2);
|
layer.load(2);
|
||||||
admin.req('api-uaa/clients/saveOrUpdate', JSON.stringify(data.field), function (data) {
|
admin.req('api-uaa/clients/saveOrUpdate', JSON.stringify(data.field), function (data) {
|
||||||
layer.closeAll('loading');
|
layer.closeAll('loading');
|
||||||
if (data.resp_code == 0) {
|
if (data.resp_code == 0) {
|
||||||
layer.msg(data.resp_msg, {icon: 1, time: 500});
|
layer.msg(data.resp_msg, {icon: 1, time: 500});
|
||||||
table.reload('app-table');
|
table.reload('app-table');
|
||||||
layer.closeAll('page');
|
layer.closeAll('page');
|
||||||
} else {
|
} else {
|
||||||
layer.msg(data.resp_msg, {icon: 2, time: 500});
|
layer.msg(data.resp_msg, {icon: 2, time: 500});
|
||||||
}
|
}
|
||||||
}, $('#app-form').attr('method'));
|
}, $('#app-form').attr('method'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -1,106 +1,106 @@
|
|||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-header">
|
<div class="layui-card-header">
|
||||||
<h2 class="header-title">系统日志</h2>
|
<h2 class="header-title">系统日志</h2>
|
||||||
<span class="layui-breadcrumb pull-right">
|
<span class="layui-breadcrumb pull-right">
|
||||||
<a href="#!console">首页</a>
|
<a href="#!console">首页</a>
|
||||||
<a><cite>系统日志</cite></a>
|
<a><cite>系统日志</cite></a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<div class="layui-form toolbar">
|
<div class="layui-form toolbar">
|
||||||
搜索:
|
搜索:
|
||||||
<select id="sysLog-search-key">
|
<select id="sysLog-search-key">
|
||||||
<option value="_all">全文搜索</option>
|
<option value="_all">全文搜索</option>
|
||||||
<option value="message">日志信息</option>
|
<option value="message">日志信息</option>
|
||||||
<option value="logLevel">日志级别</option>
|
<option value="logLevel">日志级别</option>
|
||||||
<option value="appName">应用名</option>
|
<option value="appName">应用名</option>
|
||||||
<option value="classname">类名</option>
|
<option value="classname">类名</option>
|
||||||
<option value="traceId">链路追踪id</option>
|
<option value="traceId">链路追踪id</option>
|
||||||
</select> 
|
</select> 
|
||||||
<input id="sysLog-search-value" class="layui-input search-input" style="width: 300px" type="text" placeholder="输入关键字"/> 
|
<input id="sysLog-search-value" class="layui-input search-input" style="width: 300px" type="text" placeholder="输入关键字"/> 
|
||||||
<button id="sysLog-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
<button id="sysLog-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="layui-table" id="sysLog-table" lay-filter="sysLog-table"></table>
|
<table class="layui-table" id="sysLog-table" lay-filter="sysLog-table"></table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
layui.use(['form', 'table', 'util', 'config', 'admin', 'upload'], function () {
|
layui.use(['form', 'table', 'util', 'config', 'admin', 'upload'], function () {
|
||||||
let table = layui.table;
|
let table = layui.table;
|
||||||
let config = layui.config;
|
let config = layui.config;
|
||||||
let admin = layui.admin;
|
let admin = layui.admin;
|
||||||
|
|
||||||
// 渲染表格
|
// 渲染表格
|
||||||
table.render({
|
table.render({
|
||||||
elem: '#sysLog-table',
|
elem: '#sysLog-table',
|
||||||
url: config.base_server + 'api-log/sysLog?sortCol=timestamp&isHighlighter=true',
|
url: config.base_server + 'api-log/sysLog?sortCol=timestamp&isHighlighter=true',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers:{'Authorization': 'Bearer ' + config.getToken().access_token},
|
headers:{'Authorization': 'Bearer ' + config.getToken().access_token},
|
||||||
page: true,
|
page: true,
|
||||||
cols: [[
|
cols: [[
|
||||||
{type: 'numbers'},
|
{type: 'numbers'},
|
||||||
{
|
{
|
||||||
field: 'timestamp', width: 180, sort: true, templet: function (d) {
|
field: 'timestamp', width: 180, sort: true, templet: function (d) {
|
||||||
let newDate = Date.parse(d.timestamp);
|
let newDate = Date.parse(d.timestamp);
|
||||||
newDate = new Date(newDate);
|
newDate = new Date(newDate);
|
||||||
let yyyy = newDate.getFullYear();
|
let yyyy = newDate.getFullYear();
|
||||||
let MM = (newDate.getMonth()+1);
|
let MM = (newDate.getMonth()+1);
|
||||||
let dd = newDate.getDate();
|
let dd = newDate.getDate();
|
||||||
let hh = newDate.getHours()<10 ? "0"+newDate.getHours() : newDate.getHours();
|
let hh = newDate.getHours()<10 ? "0"+newDate.getHours() : newDate.getHours();
|
||||||
let mm = newDate.getMinutes()<10 ? "0"+newDate.getMinutes() : newDate.getMinutes();
|
let mm = newDate.getMinutes()<10 ? "0"+newDate.getMinutes() : newDate.getMinutes();
|
||||||
let ss = newDate.getSeconds()<10 ? "0"+newDate.getSeconds() : newDate.getSeconds();
|
let ss = newDate.getSeconds()<10 ? "0"+newDate.getSeconds() : newDate.getSeconds();
|
||||||
let SSS = newDate.getMilliseconds();
|
let SSS = newDate.getMilliseconds();
|
||||||
return yyyy+"-"+MM+"-"+dd+" "+hh+":"+mm+":"+ss+"."+SSS;
|
return yyyy+"-"+MM+"-"+dd+" "+hh+":"+mm+":"+ss+"."+SSS;
|
||||||
}, title: '时间'
|
}, title: '时间'
|
||||||
},
|
},
|
||||||
{field: 'message', sort: true, title: '日志信息', width: 350},
|
{field: 'message', sort: true, title: '日志信息', width: 350},
|
||||||
{field: 'logLevel', sort: true, title: '日志级别', width: 110},
|
{field: 'logLevel', sort: true, title: '日志级别', width: 110},
|
||||||
{field: 'appName', sort: true, title: '应用名', width: 120},
|
{field: 'appName', sort: true, title: '应用名', width: 120},
|
||||||
{field: 'traceId', sort: false, title: '追踪id', width: 180, templet: function (d) {
|
{field: 'traceId', sort: false, title: '追踪id', width: 180, templet: function (d) {
|
||||||
if (d.traceId){
|
if (d.traceId){
|
||||||
return '<a class="layui-table-link" href="javascript:void(0);" lay-event="traceLog">'+d.traceId+'</a>';
|
return '<a class="layui-table-link" href="javascript:void(0);" lay-event="traceLog">'+d.traceId+'</a>';
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
{field: 'spanId', sort: false, title: 'spanId', width: 80},
|
{field: 'spanId', sort: false, title: 'spanId', width: 80},
|
||||||
{field: 'classname', sort: true, title: '类名', width: 250},
|
{field: 'classname', sort: true, title: '类名', width: 250},
|
||||||
{field: 'threadName', sort: true, title: '线程名', width: 150},
|
{field: 'threadName', sort: true, title: '线程名', width: 150},
|
||||||
{field: 'serverIp', sort: true, title: '服务ip', width: 130},
|
{field: 'serverIp', sort: true, title: '服务ip', width: 130},
|
||||||
{field: 'serverPort', sort: true, title: '服务端口', width: 110}
|
{field: 'serverPort', sort: true, title: '服务端口', width: 110}
|
||||||
]]
|
]]
|
||||||
});
|
});
|
||||||
|
|
||||||
// 工具条点击事件
|
// 工具条点击事件
|
||||||
table.on('tool(sysLog-table)', function (obj) {
|
table.on('tool(sysLog-table)', function (obj) {
|
||||||
if (obj.event === 'traceLog') {
|
if (obj.event === 'traceLog') {
|
||||||
showTraceLog(obj.data.traceId);
|
showTraceLog(obj.data.traceId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//显示表单弹窗
|
//显示表单弹窗
|
||||||
let showTraceLog = function (traceId) {
|
let showTraceLog = function (traceId) {
|
||||||
traceId = traceId.replace('<mark>', '');
|
traceId = traceId.replace('<mark>', '');
|
||||||
traceId = traceId.replace('</mark>', '');
|
traceId = traceId.replace('</mark>', '');
|
||||||
admin.putTempData('traceId', traceId);
|
admin.putTempData('traceId', traceId);
|
||||||
admin.popupCenter({
|
admin.popupCenter({
|
||||||
title: '日志链路',
|
title: '日志链路',
|
||||||
area: '670px',
|
area: '670px',
|
||||||
path: 'pages/log/traceLog.html'
|
path: 'pages/log/traceLog.html'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 搜索按钮点击事件
|
// 搜索按钮点击事件
|
||||||
$('#sysLog-btn-search').click(function () {
|
$('#sysLog-btn-search').click(function () {
|
||||||
let key = $('#sysLog-search-key').val();
|
let key = $('#sysLog-search-key').val();
|
||||||
let value = $('#sysLog-search-value').val();
|
let value = $('#sysLog-search-value').val();
|
||||||
if (key != '_all' && value) {
|
if (key != '_all' && value) {
|
||||||
value = key + ':' + value;
|
value = key + ':' + value;
|
||||||
}
|
}
|
||||||
table.reload('sysLog-table', {
|
table.reload('sysLog-table', {
|
||||||
where: {queryStr: value}
|
where: {queryStr: value}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<!-- 数据表格 -->
|
|
||||||
<table class="layui-table" id="trace-table" lay-filter="trace-table"></table>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
layui.use(['config', 'admin', 'table', 'treetable'],function () {
|
|
||||||
let layer = layui.layer;
|
|
||||||
let treetable = layui.treetable;
|
|
||||||
let config = layui.config;
|
|
||||||
let admin = layui.admin;
|
|
||||||
|
|
||||||
let traceId = admin.getTempData('traceId');
|
|
||||||
// 渲染表格
|
|
||||||
let renderTable = function () {
|
|
||||||
layer.load(2);
|
|
||||||
treetable.render({
|
|
||||||
treeColIndex: 1,
|
|
||||||
treeSpid: '-1',
|
|
||||||
treeIdName: 'spanId',
|
|
||||||
treePidName: 'parentId',
|
|
||||||
elem: '#trace-table',
|
|
||||||
url: config.base_server + 'api-log/traceLog',
|
|
||||||
where: {
|
|
||||||
access_token: config.getToken().access_token,
|
|
||||||
queryStr: 'traceId:'+traceId,
|
|
||||||
sortCol: 'timestamp',
|
|
||||||
sortOrder: 'ASC'
|
|
||||||
},
|
|
||||||
page: false,
|
|
||||||
cols: [[
|
|
||||||
{type: 'numbers'},
|
|
||||||
{field: 'appName', sort: true, title: '应用名', width: 220},
|
|
||||||
{field: 'spanId', sort: false, title: 'spanId', width: 130},
|
|
||||||
{field: 'serverIp', sort: true, title: '服务ip', width: 150},
|
|
||||||
{field: 'serverPort', sort: true, title: '服务端口', width: 120}
|
|
||||||
]],
|
|
||||||
done: function() {
|
|
||||||
layer.closeAll('loading');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
if (traceId) {
|
|
||||||
renderTable();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,188 +1,188 @@
|
|||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-header">
|
<div class="layui-card-header">
|
||||||
<h2 class="header-title">菜单管理</h2>
|
<h2 class="header-title">菜单管理</h2>
|
||||||
<span class="layui-breadcrumb pull-right">
|
<span class="layui-breadcrumb pull-right">
|
||||||
<a href="#!home_console">首页</a>
|
<a href="#!home_console">首页</a>
|
||||||
<a><cite>菜单管理</cite></a>
|
<a><cite>菜单管理</cite></a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<div class="layui-form toolbar">
|
<div class="layui-form toolbar">
|
||||||
所属应用:<select id="menu_clients" lay-filter="menu_clients"></select>
|
所属应用:<select id="menu_clients" lay-filter="menu_clients"></select>
|
||||||
 搜索:<input id="menus-edit-search" class="layui-input search-input" type="text" placeholder="输入关键字"/> 
|
 搜索:<input id="menus-edit-search" class="layui-input search-input" type="text" placeholder="输入关键字"/> 
|
||||||
<button id="menus-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
<button id="menus-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
||||||
<button id="menus-btn-add" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button>
|
<button id="menus-btn-add" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button>
|
||||||
<button id="menus-btn-expand" class="layui-btn">全部展开</button>
|
<button id="menus-btn-expand" class="layui-btn">全部展开</button>
|
||||||
<button id="menus-btn-fold" class="layui-btn">全部折叠</button>
|
<button id="menus-btn-fold" class="layui-btn">全部折叠</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 数据表格 -->
|
<!-- 数据表格 -->
|
||||||
<table class="layui-table" id="menus-table" lay-filter="menus-table"></table>
|
<table class="layui-table" id="menus-table" lay-filter="menus-table"></table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 表格操作列 -->
|
<!-- 表格操作列 -->
|
||||||
<script type="text/html" id="menus-state">
|
<script type="text/html" id="menus-state">
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
layui.use(['form', 'table', 'util', 'config', 'admin', 'formSelects', 'treetable'],function () {
|
layui.use(['form', 'table', 'util', 'config', 'admin', 'formSelects', 'treetable'],function () {
|
||||||
let table = layui.table;
|
let table = layui.table;
|
||||||
let layer = layui.layer;
|
let layer = layui.layer;
|
||||||
let admin = layui.admin;
|
let admin = layui.admin;
|
||||||
let treetable = layui.treetable;
|
let treetable = layui.treetable;
|
||||||
let config = layui.config;
|
let config = layui.config;
|
||||||
let form = layui.form;
|
let form = layui.form;
|
||||||
|
|
||||||
// 渲染表格
|
// 渲染表格
|
||||||
var renderTable = function (tenantId) {
|
var renderTable = function (tenantId) {
|
||||||
treetable.render({
|
treetable.render({
|
||||||
treeColIndex: 1,
|
treeColIndex: 1,
|
||||||
treeSpid: -1,
|
treeSpid: -1,
|
||||||
treeIdName: 'id',
|
treeIdName: 'id',
|
||||||
treePidName: 'parentId',
|
treePidName: 'parentId',
|
||||||
elem: '#menus-table',
|
elem: '#menus-table',
|
||||||
url: config.base_server + 'api-user/menus/findAlls',
|
url: config.base_server + 'api-user/menus/findAlls',
|
||||||
where: {
|
where: {
|
||||||
access_token: config.getToken().access_token,
|
access_token: config.getToken().access_token,
|
||||||
tenantId: tenantId
|
tenantId: tenantId
|
||||||
},
|
},
|
||||||
page: false,
|
page: false,
|
||||||
cols: [[
|
cols: [[
|
||||||
{type: 'numbers'},
|
{type: 'numbers'},
|
||||||
{field: 'name', minWidth: 200, title: '菜单名称'},
|
{field: 'name', minWidth: 200, title: '菜单名称'},
|
||||||
{field: 'url', title: '菜单url'},
|
{field: 'url', title: '菜单url'},
|
||||||
{field: 'path', title: '菜单path'},
|
{field: 'path', title: '菜单path'},
|
||||||
{field: 'css', align: 'center', title: '样式'},
|
{field: 'css', align: 'center', title: '样式'},
|
||||||
{field: 'sort', width: 80, align: 'center', title: '排序号'},
|
{field: 'sort', width: 80, align: 'center', title: '排序号'},
|
||||||
{
|
{
|
||||||
field: 'type', width: 80, align: 'center', templet: function (d) {
|
field: 'type', width: 80, align: 'center', templet: function (d) {
|
||||||
if (d.type === 2) {
|
if (d.type === 2) {
|
||||||
return '<span class="layui-badge layui-bg-gray">资源</span>';
|
return '<span class="layui-badge layui-bg-gray">资源</span>';
|
||||||
}
|
}
|
||||||
if (d.parentId === -1) {
|
if (d.parentId === -1) {
|
||||||
return '<span class="layui-badge layui-bg-blue">目录</span>';
|
return '<span class="layui-badge layui-bg-blue">目录</span>';
|
||||||
} else {
|
} else {
|
||||||
return '<span class="layui-badge-rim">菜单</span>';
|
return '<span class="layui-badge-rim">菜单</span>';
|
||||||
}
|
}
|
||||||
}, title: '类型'
|
}, title: '类型'
|
||||||
},
|
},
|
||||||
{templet: '#menus-state', width: 120, align: 'center', title: '操作'}
|
{templet: '#menus-state', width: 120, align: 'center', title: '操作'}
|
||||||
]]
|
]]
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
renderTable(config.clientId);
|
renderTable(config.clientId);
|
||||||
|
|
||||||
// 获取应用列表
|
// 获取应用列表
|
||||||
layer.load(2);
|
layer.load(2);
|
||||||
admin.req('api-uaa/clients/all', {}, function (data) {
|
admin.req('api-uaa/clients/all', {}, function (data) {
|
||||||
layer.closeAll('loading');
|
layer.closeAll('loading');
|
||||||
if (0 === data.resp_code) {
|
if (0 === data.resp_code) {
|
||||||
let selected = false;
|
let selected = false;
|
||||||
$.each(data.datas,function(index,item){
|
$.each(data.datas,function(index,item){
|
||||||
if (config.clientId === item.clientId) {
|
if (config.clientId === item.clientId) {
|
||||||
selected = true;
|
selected = true;
|
||||||
} else {
|
} else {
|
||||||
selected = false;
|
selected = false;
|
||||||
}
|
}
|
||||||
//往下拉菜单里添加元素
|
//往下拉菜单里添加元素
|
||||||
$('#menu_clients').append(new Option(item.clientName, item.clientId, false, selected));
|
$('#menu_clients').append(new Option(item.clientName, item.clientId, false, selected));
|
||||||
})
|
})
|
||||||
form.render();
|
form.render();
|
||||||
} else {
|
} else {
|
||||||
layer.msg(data.resp_msg, {icon: 2, time: 500});
|
layer.msg(data.resp_msg, {icon: 2, time: 500});
|
||||||
}
|
}
|
||||||
}, 'GET');
|
}, 'GET');
|
||||||
|
|
||||||
// 工具条点击事件
|
// 工具条点击事件
|
||||||
table.on('tool(menus-table)', function (obj) {
|
table.on('tool(menus-table)', function (obj) {
|
||||||
var data = obj.data;
|
var data = obj.data;
|
||||||
var layEvent = obj.event;
|
var layEvent = obj.event;
|
||||||
|
|
||||||
if (layEvent === 'edit') { // 修改
|
if (layEvent === 'edit') { // 修改
|
||||||
showEditModel(data);
|
showEditModel(data);
|
||||||
} else if (layEvent === 'del') {
|
} else if (layEvent === 'del') {
|
||||||
layer.confirm('确定删除此菜单吗?', function () {
|
layer.confirm('确定删除此菜单吗?', function () {
|
||||||
layer.load(2);
|
layer.load(2);
|
||||||
let tenantId = $('#menu_clients').val();
|
let tenantId = $('#menu_clients').val();
|
||||||
admin.req('api-user/menus/'+obj.data.id+'?tenantId='+tenantId, {}, function (data) {
|
admin.req('api-user/menus/'+obj.data.id+'?tenantId='+tenantId, {}, function (data) {
|
||||||
layer.closeAll('loading');
|
layer.closeAll('loading');
|
||||||
if (0 === data.resp_code) {
|
if (0 === data.resp_code) {
|
||||||
layer.msg(data.resp_msg, {icon: 1, time: 500});
|
layer.msg(data.resp_msg, {icon: 1, time: 500});
|
||||||
renderTable(tenantId);
|
renderTable(tenantId);
|
||||||
} else {
|
} else {
|
||||||
layer.msg(data.resp_msg, {icon: 2, time: 500});
|
layer.msg(data.resp_msg, {icon: 2, time: 500});
|
||||||
}
|
}
|
||||||
}, 'DELETE');
|
}, 'DELETE');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 显示编辑弹窗
|
// 显示编辑弹窗
|
||||||
var showEditModel = function (data) {
|
var showEditModel = function (data) {
|
||||||
let tenantId = $('#menu_clients').val();
|
let tenantId = $('#menu_clients').val();
|
||||||
let title = data ? '修改菜单' : '添加菜单';
|
let title = data ? '修改菜单' : '添加菜单';
|
||||||
if (data){
|
if (data){
|
||||||
data.type = data.type.toString();
|
data.type = data.type.toString();
|
||||||
data.hidden = data.hidden.toString();
|
data.hidden = data.hidden.toString();
|
||||||
} else {
|
} else {
|
||||||
data = {};
|
data = {};
|
||||||
}
|
}
|
||||||
data.tenantId = tenantId;
|
data.tenantId = tenantId;
|
||||||
admin.putTempData('t_menus', data);
|
admin.putTempData('t_menus', data);
|
||||||
|
|
||||||
admin.popupCenter({
|
admin.popupCenter({
|
||||||
title: title,
|
title: title,
|
||||||
path: 'pages/system/menus_form.html',
|
path: 'pages/system/menus_form.html',
|
||||||
finish: function () {
|
finish: function () {
|
||||||
renderTable(tenantId);
|
renderTable(tenantId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加按钮点击事件
|
// 添加按钮点击事件
|
||||||
$('#menus-btn-add').click(function () {
|
$('#menus-btn-add').click(function () {
|
||||||
showEditModel();
|
showEditModel();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 搜索按钮点击事件
|
// 搜索按钮点击事件
|
||||||
$('#menus-btn-search').click(function () {
|
$('#menus-btn-search').click(function () {
|
||||||
var keyword = $('#menus-edit-search').val();
|
var keyword = $('#menus-edit-search').val();
|
||||||
var searchCount = 0;
|
var searchCount = 0;
|
||||||
$('#menus-table').next('.treeTable').find('.layui-table-body tbody tr td').each(function () {
|
$('#menus-table').next('.treeTable').find('.layui-table-body tbody tr td').each(function () {
|
||||||
$(this).css('background-color', 'transparent');
|
$(this).css('background-color', 'transparent');
|
||||||
var text = $(this).text();
|
var text = $(this).text();
|
||||||
if (keyword !== '' && text.indexOf(keyword) >= 0) {
|
if (keyword !== '' && text.indexOf(keyword) >= 0) {
|
||||||
$(this).css('background-color', 'rgba(250,230,160,0.5)');
|
$(this).css('background-color', 'rgba(250,230,160,0.5)');
|
||||||
if (searchCount === 0) {
|
if (searchCount === 0) {
|
||||||
$('.layui-tab-item.layui-show').stop(true);
|
$('.layui-tab-item.layui-show').stop(true);
|
||||||
$('.layui-tab-item.layui-show').animate({scrollTop: $(this).offset().top - 150}, 500);
|
$('.layui-tab-item.layui-show').animate({scrollTop: $(this).offset().top - 150}, 500);
|
||||||
}
|
}
|
||||||
searchCount++;
|
searchCount++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (keyword !== '' && searchCount === 0) {
|
if (keyword !== '' && searchCount === 0) {
|
||||||
layer.msg("没有匹配结果", {icon: 5, time: 500});
|
layer.msg("没有匹配结果", {icon: 5, time: 500});
|
||||||
} else {
|
} else {
|
||||||
treetable.expandAll('#menus-table');
|
treetable.expandAll('#menus-table');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#menus-btn-expand').click(function () {
|
$('#menus-btn-expand').click(function () {
|
||||||
treetable.expandAll('#menus-table');
|
treetable.expandAll('#menus-table');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#menus-btn-fold').click(function () {
|
$('#menus-btn-fold').click(function () {
|
||||||
treetable.foldAll('#menus-table');
|
treetable.foldAll('#menus-table');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 应用下来框点击事件
|
// 应用下来框点击事件
|
||||||
form.on('select(menu_clients)', function(data){
|
form.on('select(menu_clients)', function(data){
|
||||||
renderTable(data.value);
|
renderTable(data.value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
+56
-56
@@ -1,56 +1,56 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.zlt</groupId>
|
<groupId>com.zlt</groupId>
|
||||||
<artifactId>zlt-web</artifactId>
|
<artifactId>zlt-web</artifactId>
|
||||||
<version>5.4.0</version>
|
<version>5.4.0</version>
|
||||||
<description>前端</description>
|
<description>前端</description>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>8</java.version>
|
<java.version>8</java.version>
|
||||||
<spring-boot-dependencies.version>2.5.14</spring-boot-dependencies.version>
|
<spring-boot-dependencies.version>2.5.14</spring-boot-dependencies.version>
|
||||||
<docker-maven-plugin.version>1.2.2</docker-maven-plugin.version>
|
<docker-maven-plugin.version>1.2.2</docker-maven-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<version>${spring-boot-dependencies.version}</version>
|
<version>${spring-boot-dependencies.version}</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>${spring-boot-dependencies.version}</version>
|
<version>${spring-boot-dependencies.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.spotify</groupId>
|
<groupId>com.spotify</groupId>
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
<version>${docker-maven-plugin.version}</version>
|
<version>${docker-maven-plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<!-- Layui开发的前端 -->
|
<!-- Layui开发的前端 -->
|
||||||
<module>layui-web</module>
|
<module>layui-web</module>
|
||||||
<!-- React开发的前端(Ant Design) -->
|
<!-- React开发的前端(Ant Design) -->
|
||||||
<module>react-web</module>
|
<module>react-web</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user