parent
3926872ff9
commit
9e702d1aea
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.api.thread.factory;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Created Date by 2019/12/26 0026.
|
||||
* 自定义线程池工厂
|
||||
* @author Parker
|
||||
*/
|
||||
public class NameableThreadFactory implements ThreadFactory{
|
||||
|
||||
private final AtomicInteger poolNumber = new AtomicInteger(1);
|
||||
|
||||
private final ThreadGroup threadGroup;
|
||||
|
||||
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
|
||||
public final String namePrefix;
|
||||
|
||||
public NameableThreadFactory(String name){
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
threadGroup = (s != null) ? s.getThreadGroup() :
|
||||
Thread.currentThread().getThreadGroup();
|
||||
if (null==name || "".equals(name.trim())){
|
||||
name = "pool";
|
||||
}
|
||||
namePrefix = name +"-"+
|
||||
poolNumber.getAndIncrement() +
|
||||
"-thread-";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(threadGroup, r,
|
||||
namePrefix + threadNumber.getAndIncrement(),
|
||||
0);
|
||||
if (t.isDaemon())
|
||||
t.setDaemon(false);
|
||||
if (t.getPriority() != Thread.NORM_PRIORITY)
|
||||
t.setPriority(Thread.NORM_PRIORITY);
|
||||
return t;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.api.wrapper.system.role;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.common.annotation.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.test.entity
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-16 17:33
|
||||
* @Description: 角色表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class RoleMenuRefModel implements Serializable {
|
||||
|
||||
/** 角色ID */
|
||||
@ApiModelProperty(value = "角色ID")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
|
||||
@ValidationArgsLenMax(50)
|
||||
private String roleId;
|
||||
|
||||
/** 权限数组 */
|
||||
@ApiModelProperty(value = "权限数组")
|
||||
// 验证器
|
||||
private String[] permsIds;
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.api.wrapper.system.tenant;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.api.base.warpper.ApiWrapper;
|
||||
import org.opsli.common.annotation.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
import org.opsli.plugins.excel.annotation.ExcelInfo;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.test.entity
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-16 17:33
|
||||
* @Description: 租户表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TenantModel extends ApiWrapper {
|
||||
|
||||
|
||||
/** 租户名称 */
|
||||
@ApiModelProperty(value = "租户名称")
|
||||
@ExcelProperty(value = "租户名称", order = 1)
|
||||
@ExcelInfo
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE})
|
||||
@ValidationArgsLenMax(50)
|
||||
private String tenantName;
|
||||
|
||||
/** 是否启用 0是 1否*/
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
@ExcelProperty(value = "是否启用", order = 2)
|
||||
@ExcelInfo(dictType = "no_yes")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
|
||||
@ValidationArgsLenMax(1)
|
||||
private Character izUsable;
|
||||
|
||||
/** 备注 */
|
||||
@ApiModelProperty(value = "备注")
|
||||
@ExcelProperty(value = "备注", order = 3)
|
||||
@ExcelInfo
|
||||
// 验证器
|
||||
@ValidationArgsLenMax(255)
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.api.wrapper.system.user;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.api.base.warpper.ApiWrapper;
|
||||
import org.opsli.common.annotation.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.test.entity
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-16 17:33
|
||||
* @Description: 用户信息表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class UserInfo extends ApiWrapper {
|
||||
|
||||
|
||||
/** 登录账户 */
|
||||
@ApiModelProperty(value = "登录账户")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL})
|
||||
@ValidationArgsLenMax(32)
|
||||
private String username;
|
||||
|
||||
/** 真实姓名 */
|
||||
@ApiModelProperty(value = "真实姓名")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE})
|
||||
@ValidationArgsLenMax(50)
|
||||
private String realName;
|
||||
|
||||
/** 手机 */
|
||||
@ApiModelProperty(value = "手机")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_MOBILE})
|
||||
private String mobile;
|
||||
|
||||
/** 邮箱 */
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
@ExcelProperty(value = "邮箱", order = 3)
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_EMAIL})
|
||||
private String email;
|
||||
|
||||
/** 工号 */
|
||||
@ApiModelProperty(value = "工号")
|
||||
@ExcelProperty(value = "工号", order = 4)
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_GENERAL})
|
||||
@ValidationArgsLenMax(32)
|
||||
private String no;
|
||||
|
||||
/** 头像 */
|
||||
@ApiModelProperty(value = "头像")
|
||||
// 验证器
|
||||
@ValidationArgsLenMax(255)
|
||||
private String avatar;
|
||||
|
||||
/** 备注 */
|
||||
@ApiModelProperty(value = "备注")
|
||||
// 验证器
|
||||
@ValidationArgsLenMax(255)
|
||||
private String remark;
|
||||
|
||||
/** 签名 */
|
||||
@ApiModelProperty(value = "签名")
|
||||
// 验证器
|
||||
@ValidationArgsLenMax(255)
|
||||
private String sign;
|
||||
|
||||
/** 角色列表 */
|
||||
@ApiModelProperty(value = "角色列表")
|
||||
private List<String> roles;
|
||||
|
||||
/** 权限列表 */
|
||||
@ApiModelProperty(value = "权限列表")
|
||||
private List<String> perms;
|
||||
|
||||
|
||||
/** 是否是超级管理员 */
|
||||
@ApiModelProperty(value = "是否是超级管理员")
|
||||
private boolean izSuperAdmin;
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.api.wrapper.system.user;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.common.annotation.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.test.entity
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-16 17:33
|
||||
* @Description: 用户 修改密码
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class UserPassword implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** User Id */
|
||||
@ApiModelProperty(value = "用户Id")
|
||||
private String userId;
|
||||
|
||||
/** 旧密码 */
|
||||
@ApiModelProperty(value = "旧密码")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
|
||||
@ValidationArgsLenMax(50)
|
||||
private String oldPassword;
|
||||
|
||||
/** 新密码 */
|
||||
@ApiModelProperty(value = "新密码")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
|
||||
@ValidationArgsLenMax(50)
|
||||
private String newPassword;
|
||||
|
||||
/** 盐值,密码秘钥 */
|
||||
@ApiModelProperty(value = "盐值,密码秘钥")
|
||||
@ExcelIgnore
|
||||
// 验证器
|
||||
@ValidationArgsLenMax(50)
|
||||
private String salt;
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.api.wrapper.system.user;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.common.annotation.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.test.entity
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-16 17:33
|
||||
* @Description: 角色表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class UserRoleRefModel implements Serializable {
|
||||
|
||||
/** 用户ID */
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
|
||||
@ValidationArgsLenMax(50)
|
||||
private String userId;
|
||||
|
||||
/** 角色数组 */
|
||||
@ApiModelProperty(value = "权限数组")
|
||||
// 验证器
|
||||
private String[] roleIds;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 自定义操作日志注解
|
||||
* @author parker
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface EnableLog {
|
||||
|
||||
/** 标题 */
|
||||
String title() default "";
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.common.annotation.validation;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.common.annotation
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-22 17:07
|
||||
* @Description: 字段验证器 - 字段最大长度
|
||||
*
|
||||
* 对应 数据库 真实长度数
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Documented
|
||||
public @interface ValidationArgsLenMax {
|
||||
|
||||
int value();
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.common.annotation.validation;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.common.annotation
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-22 17:07
|
||||
* @Description: 字段验证器 - 字段最大长度
|
||||
*
|
||||
* 对应 数据库 真实长度数
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Documented
|
||||
public @interface ValidationArgsLenMin {
|
||||
|
||||
int value();
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package org.opsli.common.annotation.validation;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.common.annotation
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-22 17:07
|
||||
* @Description: 字段验证器 - 字段最大长度
|
||||
*
|
||||
* 对应 数据库 真实长度数
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Documented
|
||||
public @interface ValidationArgsMax {
|
||||
|
||||
int value();
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package org.opsli.common.annotation.validation;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.common.annotation
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-22 17:07
|
||||
* @Description: 字段验证器 - 字段最大长度
|
||||
*
|
||||
* 对应 数据库 真实长度数
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Documented
|
||||
public @interface ValidationArgsMin {
|
||||
|
||||
int value();
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.opsli.common.enums;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: 周鹏程
|
||||
* @CreateTime: 2020-09-17 23:40
|
||||
* @Description: 字典
|
||||
*/
|
||||
public enum DictType {
|
||||
|
||||
/** no_yes */
|
||||
NO_YES_NO("0"),
|
||||
NO_YES_YES("1"),
|
||||
|
||||
;
|
||||
|
||||
private String code;
|
||||
|
||||
DictType(String code){
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
public String getCode(){
|
||||
return this.code;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.common.exception;
|
||||
|
||||
import org.opsli.common.base.msg.BaseMsg;
|
||||
|
||||
/**
|
||||
* Java 防火墙 异常类
|
||||
*
|
||||
* @author Parker
|
||||
* @date 2020-10-09
|
||||
*/
|
||||
public class WafException extends ServiceException {
|
||||
|
||||
public WafException(Integer code, String errorMessage) {
|
||||
super(code, errorMessage);
|
||||
}
|
||||
|
||||
public WafException(BaseMsg msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.common.utils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.common.utils
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-10-08 10:24
|
||||
* @Description: IP 工具类
|
||||
*/
|
||||
public final class IPUtil {
|
||||
|
||||
/**
|
||||
* 获取客户端ip地址(可以穿透代理)
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getRemoteAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
private static final String[] HEADERS_TO_TRY = {
|
||||
"X-Forwarded-For",
|
||||
"Proxy-Client-IP",
|
||||
"WL-Proxy-Client-IP",
|
||||
"HTTP_X_FORWARDED_FOR",
|
||||
"HTTP_X_FORWARDED",
|
||||
"HTTP_X_CLUSTER_CLIENT_IP",
|
||||
"HTTP_CLIENT_IP",
|
||||
"HTTP_FORWARDED_FOR",
|
||||
"HTTP_FORWARDED",
|
||||
"HTTP_VIA",
|
||||
"REMOTE_ADDR",
|
||||
"X-Real-IP"};
|
||||
|
||||
/***
|
||||
* 获取客户端ip地址(可以穿透代理)
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getClientIpAddress(HttpServletRequest request) {
|
||||
for (String header : HEADERS_TO_TRY) {
|
||||
String ip = request.getHeader(header);
|
||||
if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
/***
|
||||
* 获取客户端ip地址(可以穿透代理)
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getClientIpAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_CLUSTER_CLIENT_IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_FORWARDED_FOR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_FORWARDED");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_VIA");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("REMOTE_ADDR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("X-Real-IP");
|
||||
if (null != ip && !"".equals(ip.trim())
|
||||
&& !"unknown".equalsIgnoreCase(ip)) {
|
||||
return ip;
|
||||
}
|
||||
ip = request.getHeader("X-Forwarded-For");
|
||||
if (null != ip && !"".equals(ip.trim())
|
||||
&& !"unknown".equalsIgnoreCase(ip)) {
|
||||
// get first ip from proxy ip
|
||||
int index = ip.indexOf(',');
|
||||
if (index != -1) {
|
||||
return ip.substring(0, index);
|
||||
} else {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
|
||||
|
||||
// ===============
|
||||
private IPUtil(){}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.core.cache.pushsub.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.opsli.common.constants.CacheConstants;
|
||||
import org.opsli.core.cache.local.CacheUtil;
|
||||
import org.opsli.core.cache.pushsub.enums.MsgArgsType;
|
||||
import org.opsli.core.cache.pushsub.enums.PushSubType;
|
||||
import org.opsli.core.utils.MenuUtil;
|
||||
import org.opsli.plugins.cache.EhCachePlugin;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.core.cache.pushsub.handler
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-15 16:24
|
||||
* @Description: 字典消息处理
|
||||
*/
|
||||
@Slf4j
|
||||
public class MenuHandler implements RedisPushSubHandler{
|
||||
|
||||
@Autowired
|
||||
EhCachePlugin ehCachePlugin;
|
||||
|
||||
@Override
|
||||
public PushSubType getType() {
|
||||
return PushSubType.MENU;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handler(JSONObject msgJson) {
|
||||
// 用户刷新
|
||||
this.menuHandler(msgJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户数据处理
|
||||
* @param msgJson
|
||||
*/
|
||||
private void menuHandler(JSONObject msgJson){
|
||||
JSONObject data = msgJson.getJSONObject(MsgArgsType.MENU_MODEL_DATA.toString());
|
||||
// 数据为空则不执行
|
||||
if(data == null) return;
|
||||
|
||||
// 获得用户ID 和 用户名
|
||||
String menuCode = (String) msgJson.get(MsgArgsType.MENU_CODE.toString());
|
||||
if(StringUtils.isEmpty(menuCode)){
|
||||
return;
|
||||
}
|
||||
|
||||
// 先删除
|
||||
ehCachePlugin.delete(CacheConstants.HOT_DATA, MenuUtil.PREFIX_CODE + menuCode);
|
||||
// 清除空拦截
|
||||
CacheUtil.delNilFlag(MenuUtil.PREFIX_CODE + menuCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.core.cache.pushsub.msgs;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.opsli.api.wrapper.system.menu.MenuModel;
|
||||
import org.opsli.core.cache.pushsub.enums.MsgArgsType;
|
||||
import org.opsli.core.cache.pushsub.enums.PushSubType;
|
||||
import org.opsli.core.cache.pushsub.receiver.RedisPushSubReceiver;
|
||||
import org.opsli.plugins.redis.pushsub.entity.BaseSubMessage;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.core.cache.pushsub.msgs
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-15 16:50
|
||||
* @Description: 用户消息
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public final class MenuMsgFactory extends BaseSubMessage{
|
||||
|
||||
/** 通道 */
|
||||
private static final String CHANNEL = RedisPushSubReceiver.BASE_CHANNEL+RedisPushSubReceiver.CHANNEL;
|
||||
|
||||
private MenuMsgFactory(){}
|
||||
|
||||
/**
|
||||
* 构建消息 - 菜单
|
||||
*/
|
||||
public static BaseSubMessage createMenuMsg(MenuModel menuModel){
|
||||
BaseSubMessage baseSubMessage = new BaseSubMessage();
|
||||
// 数据
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put(MsgArgsType.MENU_CODE.toString(), menuModel.getMenuCode());
|
||||
jsonObj.put(MsgArgsType.MENU_MODEL_DATA.toString(), menuModel);
|
||||
|
||||
// 用户
|
||||
baseSubMessage.build(CHANNEL,PushSubType.MENU.toString(),jsonObj);
|
||||
return baseSubMessage;
|
||||
}
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue