开源核心代码

v1.4.1
Parker 4 years ago
parent 3926872ff9
commit 9e702d1aea

1
.gitignore vendored

@ -1,3 +1,4 @@
.DS_Store
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar

@ -1,3 +1,18 @@
/**
* 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.base.result;
import com.alibaba.fastjson.JSONObject;
@ -179,4 +194,4 @@ public class ResultVo<T> implements Serializable {
return ret;
}
}
}

@ -1,3 +1,18 @@
/**
* 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.base.warpper;
import com.alibaba.excel.annotation.ExcelIgnore;
@ -94,4 +109,8 @@ public abstract class ApiWrapper implements Serializable {
/** 是否是内部Api调用 */
@TableField(exist = false)
private Boolean izApi = false;
/** 是否 手动操控 如果为true 则可以手动指定创建人和修改人 如果为空则默认) */
@TableField(exist = false)
private Boolean izManual = false;
}

@ -1,9 +1,29 @@
/**
* 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.conf;
import lombok.extern.slf4j.Slf4j;
import org.opsli.api.conf.prop.ApiPathProperties;
import org.opsli.common.annotation.ApiRestController;
import org.opsli.common.utils.Props;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -17,6 +37,14 @@ import javax.annotation.Resource;
@Configuration
public class SpringWebMvcConfig implements WebMvcConfigurer {
/** 虚拟根路径 */
private static final String BASE_DIR;
static {
Props props = new Props("application.yaml");
BASE_DIR = props.getStr("server.tomcat.basedir");
}
@Resource
private ApiPathProperties apiPathProperties;
@ -30,5 +58,24 @@ public class SpringWebMvcConfig implements WebMvcConfigurer {
.addPathPrefix(apiPathProperties.getGlobalPrefix(),c -> c.isAnnotationPresent(ApiRestController.class));
}
/**
*
* @return
*/
@Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
final CorsConfiguration corsConfiguration = new CorsConfiguration();
/* 是否允许请求带有验证信息 */
corsConfiguration.setAllowCredentials(true);
/* 允许访问的客户端域名 */
corsConfiguration.addAllowedOrigin("*");
/* 允许服务端访问的客户端请求头 */
corsConfiguration.addAllowedHeader("*");
/* 允许访问的方法名,GET POST等 */
corsConfiguration.addAllowedMethod("*");
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
return new CorsFilter(urlBasedCorsConfigurationSource);
}
}

@ -1,3 +1,18 @@
/**
* 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.conf.prop;
import lombok.Data;
@ -15,4 +30,4 @@ public class ApiPathProperties {
String globalPrefix = "api";
}
}

@ -1,3 +1,18 @@
/**
* 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.msg;
import org.opsli.common.base.msg.BaseMsg;

@ -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;
}
}

@ -1,3 +1,18 @@
/**
* 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.utils;
import cn.hutool.core.lang.Validator;
@ -8,8 +23,8 @@ import org.apache.commons.lang3.StringUtils;
import org.opsli.api.msg.ValidationMsg;
import org.opsli.api.wrapper.system.dict.DictModel;
import org.opsli.common.annotation.validation.ValidationArgs;
import org.opsli.common.annotation.validation.ValidationArgsMax;
import org.opsli.common.annotation.validation.ValidationArgsMin;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.common.exception.ServiceException;
@ -49,7 +64,7 @@ public final class ValidationUtil {
}
// 获得 最大长度 注解
ValidationArgsMax validationArgsMax = field.getAnnotation(ValidationArgsMax.class);
ValidationArgsLenMax validationArgsMax = field.getAnnotation(ValidationArgsLenMax.class);
if(validationArgsMax != null){
int maxLength = validationArgsMax.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field);
@ -57,7 +72,7 @@ public final class ValidationUtil {
}
// 获得 最小长度 注解
ValidationArgsMin validationArgsMin = field.getAnnotation(ValidationArgsMin.class);
ValidationArgsLenMin validationArgsMin = field.getAnnotation(ValidationArgsLenMin.class);
if(validationArgsMin != null){
int minLength = validationArgsMin.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field);
@ -284,7 +299,7 @@ public final class ValidationUtil {
// 循环验证
try {
String value = String.valueOf(fieldValue);
if(value != null){
if(value != null && !"null".equals(value)){
// 转换为 数据库真实 长度
int strLength = value.getBytes(CHARSET_NAME).length;
if(strLength > maxLength){
@ -317,7 +332,7 @@ public final class ValidationUtil {
// 循环验证
try {
String value = String.valueOf(fieldValue);
if(value != null){
if(value != null && !"null".equals(value)){
// 转换为 数据库真实 长度
int strLength = value.getBytes(CHARSET_NAME).length;
if(strLength < minLength){

@ -1,9 +1,25 @@
/**
* 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.web.system.dict;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.dict.DictModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@ -58,7 +74,7 @@ public interface DictApi {
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(DictModel model);
ResultVo<?> insert(@RequestBody DictModel model);
/**
*
@ -66,7 +82,7 @@ public interface DictApi {
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(DictModel model);
ResultVo<?> update(@RequestBody DictModel model);
/**
*
@ -109,4 +125,13 @@ public interface DictApi {
@GetMapping("/exportImport/template")
ResultVo<?> importTemplate(HttpServletResponse response);
/**
*
*
* @param typeCode
* @return
*/
@GetMapping("/getDictListByCode")
ResultVo<?> getDictListByCode(String typeCode);
}

@ -1,9 +1,25 @@
/**
* 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.web.system.dict;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.dict.DictDetailModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@ -58,7 +74,7 @@ public interface DictDetailApi {
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(DictDetailModel model);
ResultVo<?> insert(@RequestBody DictDetailModel model);
/**
*
@ -66,7 +82,7 @@ public interface DictDetailApi {
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(DictDetailModel model);
ResultVo<?> update(@RequestBody DictDetailModel model);
/**
*

@ -0,0 +1,85 @@
/**
* 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.web.system.logs;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.logs.LogsModel;
import org.opsli.api.wrapper.system.menu.MenuModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.modulars.test.web
* @Author: Parker
* @CreateTime: 2020-09-13 17:40
* @Description: API
*
* API @GetMapping @PostMapping
* Mapping Controller
*
*
*
*
*/
public interface LogsApi {
/** 标题 */
String TITLE = "日志";
/**
*
* @param model
* @return ResultVo
*/
@GetMapping("/get")
ResultVo<LogsModel> get(LogsModel model);
/**
*
* @param pageNo
* @param pageSize
* @param request request
* @return ResultVo
*/
@GetMapping("/findPage")
ResultVo<?> findPage(
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request
);
/**
*
* @return ResultVo
*/
@PostMapping("/emptyByOneMonth")
ResultVo<?> emptyByOneMonth();
/**
*
* @param model
* @return ResultVo
*/
ResultVo<?> insert(LogsModel model);
}

@ -1,15 +1,31 @@
/**
* 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.web.system.menu;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.menu.MenuModel;
import org.opsli.api.wrapper.system.user.UserModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -31,6 +47,37 @@ public interface MenuApi {
/** 标题 */
String TITLE = "菜单";
/**
*
* @return ResultVo
*/
@GetMapping("/findMenuTreePage")
ResultVo<?> findMenuTreePage(HttpServletRequest request);
/**
*
* @return ResultVo
*/
@PostMapping("/findMenuTree")
ResultVo<?> findMenuTree();
/**
* -
* @return ResultVo
*/
@GetMapping("/getMenuAndPermsTree")
ResultVo<?> getMenuAndPermsTree();
/**
*
* @return ResultVo
*/
@GetMapping("/findList")
ResultVo<List<MenuModel>> findList();
/**
*
* @param model
@ -59,7 +106,7 @@ public interface MenuApi {
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(MenuModel model);
ResultVo<?> insert(@RequestBody MenuModel model);
/**
*
@ -67,7 +114,7 @@ public interface MenuApi {
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(MenuModel model);
ResultVo<?> update(@RequestBody MenuModel model);
/**
*
@ -110,4 +157,13 @@ public interface MenuApi {
@GetMapping("/exportImport/template")
ResultVo<?> importTemplate(HttpServletResponse response);
// ================= 普通
/**
*
* @param menuCode
* @return ResultVo
*/
ResultVo<MenuModel> getByCode(String menuCode);
}

@ -1,9 +1,25 @@
/**
* 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.web.system.role;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.role.RoleModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@ -58,7 +74,7 @@ public interface RoleApi {
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(RoleModel model);
ResultVo<?> insert(@RequestBody RoleModel model);
/**
*
@ -66,7 +82,7 @@ public interface RoleApi {
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(RoleModel model);
ResultVo<?> update(@RequestBody RoleModel model);
/**
*

@ -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.web.system.role;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.role.RoleMenuRefModel;
import org.opsli.api.wrapper.system.role.RoleModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.modulars.test.web
* @Author: Parker
* @CreateTime: 2020-09-13 17:40
* @Description: API
*
* API @GetMapping @PostMapping
* Mapping Controller
*
*
*
*
*/
public interface RoleMenuRefApi {
/** 标题 */
String TITLE = "角色权限";
/**
*
* @param model Id
* @return ResultVo
*/
@GetMapping("/getPerms")
ResultVo<?> getPerms(RoleMenuRefModel model);
/**
*
* @param model roleId Id
* @param model permsIds Id
* @return ResultVo
*/
@PostMapping("/setPerms")
ResultVo<?> setPerms(@RequestBody RoleMenuRefModel model);
}

@ -0,0 +1,128 @@
/**
* 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.web.system.tenant;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.tenant.TenantModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.modulars.test.web
* @Author: Parker
* @CreateTime: 2020-09-13 17:40
* @Description: API
*
* API @GetMapping @PostMapping
* Mapping Controller
*
*
*
*
*/
public interface TenantApi {
/** 标题 */
String TITLE = "租户";
/**
*
* @param model
* @return ResultVo
*/
@GetMapping("/get")
ResultVo<TenantModel> get(TenantModel model);
/**
*
* @param pageNo
* @param pageSize
* @param request request
* @return ResultVo
*/
@GetMapping("/findPage")
ResultVo<?> findPage(
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request
);
/**
*
* @param model
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(@RequestBody TenantModel model);
/**
*
* @param model
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(@RequestBody TenantModel model);
/**
*
* @param id ID
* @return ResultVo
*/
@PostMapping("/del")
ResultVo<?> del(String id);
/**
*
* @param ids ID
* @return ResultVo
*/
@PostMapping("/delAll")
ResultVo<?> delAll(String[] ids);
/**
* Excel
* @param request request
* @param response response
* @return ResultVo
*/
@GetMapping("/exportExcel")
ResultVo<?> exportExcel(HttpServletRequest request, HttpServletResponse response);
/**
* Excel
* @param request request
* @return ResultVo
*/
@GetMapping("/exportImport")
ResultVo<?> excelImport(MultipartHttpServletRequest request);
/**
* Excel
* @param response response
* @return ResultVo
*/
@GetMapping("/exportImport/template")
ResultVo<?> importTemplate(HttpServletResponse response);
}

@ -1,12 +1,31 @@
/**
* 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.web.system.user;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.menu.MenuModel;
import org.opsli.api.wrapper.system.role.RoleModel;
import org.opsli.api.wrapper.system.user.UserInfo;
import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.api.wrapper.system.user.UserPassword;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
@ -33,6 +52,53 @@ public interface UserApi {
/** 标题 */
String TITLE = "用户信息";
/**
*
* @return ResultVo
*/
@GetMapping("/getInfo")
ResultVo<UserInfo> getInfo(HttpServletRequest request);
/**
*
* @return ResultVo
*/
@GetMapping("/getInfoById")
ResultVo<UserInfo> getInfoById(@RequestParam(name = "userId") String userId);
/**
* userId Id
* @param userId Id
* @return ResultVo
*/
@GetMapping("/getRoleIdsByUserId")
ResultVo<List<String>> getRoleIdsByUserId(String userId);
/**
*
* @return ResultVo
*/
@PostMapping("/updatePassword")
ResultVo<?> updatePassword(@RequestBody UserPassword userPassword);
/**
* ID
* @return ResultVo
*/
@PostMapping("/updatePasswordById")
ResultVo<?> updatePasswordById(@RequestBody UserPassword userPassword);
/**
*
* @param request request
* @return ResultVo
*/
@PostMapping("/updateAvatar")
ResultVo<?> updateAvatar(MultipartHttpServletRequest request);
/**
*
* @param model
@ -61,7 +127,7 @@ public interface UserApi {
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(UserModel model);
ResultVo<?> insert(@RequestBody UserModel model);
/**
*
@ -69,7 +135,7 @@ public interface UserApi {
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(UserModel model);
ResultVo<?> update(@RequestBody UserModel model);
/**
*
@ -104,6 +170,7 @@ public interface UserApi {
@GetMapping("/exportImport")
ResultVo<?> excelImport(MultipartHttpServletRequest request);
/**
* Excel
* @param response response

@ -0,0 +1,55 @@
/**
* 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.web.system.user;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.role.RoleMenuRefModel;
import org.opsli.api.wrapper.system.user.UserRoleRefModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.modulars.test.web
* @Author: Parker
* @CreateTime: 2020-09-13 17:40
* @Description: API
*
* API @GetMapping @PostMapping
* Mapping Controller
*
*
*
*
*/
public interface UserRoleRefApi {
/** 标题 */
String TITLE = "用户角色";
/**
*
* @param model userId Id
* @param model roleIds Id
* @return ResultVo
*/
@PostMapping("/setRoles")
ResultVo<?> setRoles(@RequestBody UserRoleRefModel model);
}

@ -0,0 +1,128 @@
/**
* 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.web.test;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.test.TestModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.modulars.test.web
* @Author: Parker
* @CreateTime: 2020-09-13 17:40
* @Description: API
*
* API @GetMapping @PostMapping
* Mapping Controller
*
*
*
*
*/
public interface TestRestApi {
/** 标题 */
String TITLE = "测试";
/**
*
* @param model
* @return ResultVo
*/
@GetMapping("/get")
ResultVo<TestModel> get(TestModel model);
/**
*
* @param pageNo
* @param pageSize
* @param request request
* @return ResultVo
*/
@GetMapping("/findPage")
ResultVo<?> findPage(
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request
);
/**
*
* @param model
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(@RequestBody TestModel model);
/**
*
* @param model
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(@RequestBody TestModel model);
/**
*
* @param id ID
* @return ResultVo
*/
@PostMapping("/del")
ResultVo<?> del(String id);
/**
*
* @param ids ID
* @return ResultVo
*/
@PostMapping("/delAll")
ResultVo<?> delAll(String[] ids);
/**
* Excel
* @param request request
* @param response response
* @return ResultVo
*/
@GetMapping("/exportExcel")
ResultVo<?> exportExcel(HttpServletRequest request, HttpServletResponse response);
/**
* Excel
* @param request request
* @return ResultVo
*/
@GetMapping("/exportImport")
ResultVo<?> excelImport(MultipartHttpServletRequest request);
/**
* Excel
* @param response response
* @return ResultVo
*/
@GetMapping("/exportImport/template")
ResultVo<?> importTemplate(HttpServletResponse response);
}

@ -1,3 +1,18 @@
/**
* 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.dict;
import com.alibaba.excel.annotation.ExcelIgnore;
@ -7,7 +22,7 @@ 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.ValidationArgsMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
@ -34,7 +49,7 @@ public class DictDetailModel extends ApiWrapper {
@ExcelIgnore
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL})
@ValidationArgsMax(120)
@ValidationArgsLenMax(120)
private String typeCode;
/** 字典名称 */
@ -43,7 +58,7 @@ public class DictDetailModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsMax(120)
@ValidationArgsLenMax(120)
private String dictName;
/** 字典值 */
@ -52,16 +67,16 @@ public class DictDetailModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
@ValidationArgsMax(120)
@ValidationArgsLenMax(120)
private String dictValue;
/** 是否内置数据 0是 1否*/
@ApiModelProperty(value = "是否内置数据 0是 1否")
@ExcelProperty(value = "是否内置数据", order = 2)
@ExcelInfo(dictType = "yes_no")
@ExcelInfo(dictType = "no_yes")
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
@ValidationArgsMax(1)
@ValidationArgsLenMax(1)
private Character izLock;
/** 排序 */
@ -70,7 +85,7 @@ public class DictDetailModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_NUMBER})
@ValidationArgsMax(10)
@ValidationArgsLenMax(10)
private Integer sortNo;
/** 备注 */
@ -78,7 +93,7 @@ public class DictDetailModel extends ApiWrapper {
@ExcelProperty(value = "备注", order = 2)
@ExcelInfo
// 验证器
@ValidationArgsMax(255)
@ValidationArgsLenMax(255)
private String remark;

@ -1,3 +1,18 @@
/**
* 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.dict;
import com.alibaba.excel.annotation.ExcelProperty;
@ -6,7 +21,7 @@ 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.ValidationArgsMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
@ -29,7 +44,7 @@ public class DictModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL})
@ValidationArgsMax(120)
@ValidationArgsLenMax(120)
private String typeCode;
/** 字典类型名称 */
@ -38,16 +53,16 @@ public class DictModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsMax(120)
@ValidationArgsLenMax(120)
private String typeName;
/** 是否内置数据 0是 1否*/
@ApiModelProperty(value = "是否内置数据 0是 1否")
@ExcelProperty(value = "是否内置数据", order = 3)
@ExcelInfo(dictType = "yes_no")
@ExcelInfo(dictType = "no_yes")
// 验证器
@ValidationArgs(ValiArgsType.IS_NOT_NULL)
@ValidationArgsMax(1)
@ValidationArgsLenMax(1)
private Character izLock;
/** 备注 */
@ -55,7 +70,7 @@ public class DictModel extends ApiWrapper {
@ExcelProperty(value = "备注", order = 4)
@ExcelInfo
// 验证器
@ValidationArgsMax(255)
@ValidationArgsLenMax(255)
private String remark;

@ -1,3 +1,18 @@
/**
* 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.dict;
import lombok.Data;

@ -0,0 +1,77 @@
/**
* 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.logs;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper;
/**
* @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 LogsModel extends ApiWrapper {
/** 日志类型1接入日志2错误日志 */
public static final String TYPE_ACCESS = "1";
public static final String TYPE_EXCEPTION = "2";
/** 日志类型1接入日志2错误日志 */
@ApiModelProperty(value = "日志类型")
private String type;
/** 日志标题 */
@ApiModelProperty(value = "日志标题")
private String title;
/** 操作用户的IP地址 */
@ApiModelProperty(value = "操作用户的IP地址")
private String remoteAddr;
/** 操作用户代理信息 */
@ApiModelProperty(value = "操作用户代理信息")
private String userAgent;
/** 执行时间 */
@ApiModelProperty(value = "执行时间")
private Long timeout;
/** 操作的URI */
@ApiModelProperty(value = "操作的URI")
private String requestUri;
/** 操作的方式 */
@ApiModelProperty(value = "操作的方式")
private String method;
/** 操作提交的数据 */
@ApiModelProperty(value = "操作提交的数据")
private String params;
/** 异常信息 */
@ApiModelProperty(value = "异常信息")
private String exception;
}

@ -1,3 +1,18 @@
/**
* 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.menu;
import com.alibaba.excel.annotation.ExcelProperty;
@ -6,7 +21,7 @@ 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.ValidationArgsMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
@ -26,26 +41,25 @@ public class MenuModel extends ApiWrapper {
@ExcelProperty(value = "父级主键", order = 1)
@ExcelInfo
// 验证器
@ValidationArgs(ValiArgsType.IS_NOT_NULL)
@ValidationArgsMax(20)
@ValidationArgsLenMax(20)
private String parentId;
/** 菜单编号 */
@ApiModelProperty(value = "菜单编号")
@ExcelProperty(value = "菜单编号", order = 2)
@ApiModelProperty(value = "编号")
@ExcelProperty(value = "编号", order = 2)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL})
@ValidationArgsMax(50)
@ValidationArgsLenMax(50)
private String menuCode;
/** 菜单名称 */
@ApiModelProperty(value = "菜单名称")
@ExcelProperty(value = "菜单名称", order = 3)
@ApiModelProperty(value = "名称")
@ExcelProperty(value = "名称", order = 3)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsMax(50)
@ValidationArgsLenMax(50)
private String menuName;
/** 图标 */
@ -53,16 +67,16 @@ public class MenuModel extends ApiWrapper {
@ExcelProperty(value = "图标", order = 4)
@ExcelInfo
// 验证器
@ValidationArgsMax(50)
@ValidationArgsLenMax(50)
private String icon;
/** 项目类型:1-菜单2-按钮3-链接4-表单 */
@ApiModelProperty(value = "项目类型:1-菜单2-按钮3-链接4-表单")
/** 项目类型: 1-菜单 2-按钮 3-链接 */
@ApiModelProperty(value = "项目类型")
@ExcelProperty(value = "项目类型", order = 5)
@ExcelInfo(dictType = "menuType")
@ExcelInfo(dictType = "menu_type")
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
@ValidationArgsMax(20)
@ValidationArgsLenMax(20)
private String type;
/** url地址 */
@ -70,8 +84,39 @@ public class MenuModel extends ApiWrapper {
@ExcelProperty(value = "url地址", order = 6)
@ExcelInfo
// 验证器
@ValidationArgsMax(200)
@ValidationArgsLenMax(200)
private String url;
/** 组件 - vue 对应组件 */
@ApiModelProperty(value = "组件")
@ExcelProperty(value = "组件", order = 7)
@ExcelInfo
// 验证器
@ValidationArgsLenMax(200)
private String component;
/** 重定向 */
@ApiModelProperty(value = "重定向")
@ExcelProperty(value = "重定向", order = 8)
@ExcelInfo
// 验证器
@ValidationArgsLenMax(200)
private String redirect;
/** 排序 */
@ApiModelProperty(value = "排序")
@ExcelProperty(value = "排序", order = 8)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
private Integer sortNo;
/** 是否隐藏 0为否 1为是 */
@ApiModelProperty(value = "是否隐藏")
@ExcelProperty(value = "是否隐藏", order = 8)
@ExcelInfo(dictType = "no_yes")
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
private String hidden;
}

@ -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;
}

@ -1,12 +1,28 @@
/**
* 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.ExcelIgnore;
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.ValidationArgsMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
@ -29,7 +45,7 @@ public class RoleModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL})
@ValidationArgsMax(50)
@ValidationArgsLenMax(50)
private String roleCode;
/** 角色名称 */
@ -37,8 +53,8 @@ public class RoleModel extends ApiWrapper {
@ExcelProperty(value = "角色编码", order = 2)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL})
@ValidationArgsMax(50)
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50)
private String roleName;
/** 是否内置数据 0是 1否*/
@ -46,8 +62,8 @@ public class RoleModel extends ApiWrapper {
@ExcelProperty(value = "是否内置数据", order = 3)
@ExcelInfo(dictType = "yes_no")
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL})
@ValidationArgsMax(1)
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
@ValidationArgsLenMax(1)
private Character izLock;
/** 备注 */
@ -55,7 +71,15 @@ public class RoleModel extends ApiWrapper {
@ExcelProperty(value = "备注", order = 4)
@ExcelInfo
// 验证器
@ValidationArgsMax(255)
@ValidationArgsLenMax(255)
private String remark;
/** 多租户字段 */
@ApiModelProperty(value = "多租户ID")
@ExcelIgnore
// 验证器
@ValidationArgsLenMax(20)
private String tenantId;
}

@ -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;
}

@ -1,3 +1,18 @@
/**
* 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;
@ -7,7 +22,7 @@ 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.ValidationArgsMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
@ -28,21 +43,21 @@ public class UserModel extends ApiWrapper {
@ExcelIgnore
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL})
@ValidationArgsMax(32)
@ValidationArgsLenMax(32)
private String username;
/** 登录密码 */
@ApiModelProperty(value = "登录密码")
@ExcelIgnore
// 验证器
@ValidationArgsMax(50)
@ValidationArgsLenMax(50)
private String password;
/** 盐值,密码秘钥 */
@ApiModelProperty(value = "盐值,密码秘钥")
@ExcelIgnore
// 验证器
@ValidationArgsMax(50)
@ValidationArgsLenMax(50)
private String secretkey;
/** 是否锁定 */
@ -50,7 +65,7 @@ public class UserModel extends ApiWrapper {
@ExcelIgnore
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
@ValidationArgsMax(1)
@ValidationArgsLenMax(1)
private Character locked;
/** 真实姓名 */
@ -59,7 +74,7 @@ public class UserModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsMax(50)
@ValidationArgsLenMax(50)
private String realName;
/** 手机 */
@ -76,6 +91,7 @@ public class UserModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_EMAIL})
@ValidationArgsLenMax(100)
private String email;
/** 工号 */
@ -84,14 +100,14 @@ public class UserModel extends ApiWrapper {
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_GENERAL})
@ValidationArgsMax(32)
@ValidationArgsLenMax(32)
private String no;
/** 头像 */
@ApiModelProperty(value = "头像")
@ExcelIgnore
// 验证器
@ValidationArgsMax(255)
@ValidationArgsLenMax(255)
private String avatar;
/** 最后登陆IP */
@ -106,15 +122,23 @@ public class UserModel extends ApiWrapper {
@ExcelProperty(value = "备注", order = 5)
@ExcelInfo
// 验证器
@ValidationArgsMax(255)
@ValidationArgsLenMax(255)
private String remark;
/** 签名 */
@ApiModelProperty(value = "签名")
@ExcelProperty(value = "签名", order = 5)
@ExcelInfo
// 验证器
@ValidationArgsLenMax(255)
private String sign;
/** 多租户字段 */
@ApiModelProperty(value = "多租户ID")
@ExcelIgnore
// 验证器
@ValidationArgsMax(20)
@ValidationArgsLenMax(20)
private String tenantId;

@ -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;
}

@ -1,3 +1,18 @@
/**
* 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.test;
import com.alibaba.excel.annotation.ExcelProperty;
@ -28,7 +43,7 @@ public class TestModel extends ApiWrapper {
@ApiModelProperty(value = "分类")
@ExcelProperty(value = "分类", order = 2)
@ExcelInfo(dictType = "testType")
@ExcelInfo(dictType = "test_type")
private String type;
@ApiModelProperty(value = "备注")

@ -1,3 +1,18 @@
/**
* 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 org.springframework.core.annotation.AliasFor;

@ -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 "";
}

@ -1,3 +1,18 @@
/**
* 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.hotdata;
import java.lang.annotation.*;

@ -1,3 +1,18 @@
/**
* 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.hotdata;
import org.opsli.common.constants.CacheConstants;

@ -1,3 +1,18 @@
/**
* 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.hotdata;
import org.opsli.common.constants.CacheConstants;

@ -1,3 +1,18 @@
/**
* 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 org.opsli.common.enums.ValiArgsType;

@ -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();
}

@ -1,3 +1,18 @@
/**
* 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.api;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -82,7 +97,7 @@ public class ResultDto<T> implements Serializable {
public void setSuccess(boolean success) {
resultMap.put("success", success);
}
// ---------------------------------
@ -104,4 +119,4 @@ public class ResultDto<T> implements Serializable {
return data;
}
}
}

@ -1,3 +1,18 @@
/**
* 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.api;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -13,11 +28,11 @@ import java.util.Map;
*
* @date 202051510:40:54
* @author Parker
*
*
*/
public class ResultVoMap extends HashMap<String,Object> implements Serializable {
public ResultVoMap(){
this.put("success", true);
this.put("code", HttpStatus.OK.value());
@ -33,7 +48,7 @@ public class ResultVoMap extends HashMap<String,Object> implements Serializable
public String getMsg() {
return (String)this.get("msg");
}
public void setMsg(String msg) {//向json中添加属性在js中访问请调用data.msg
this.put("msg", msg);
}
@ -49,7 +64,7 @@ public class ResultVoMap extends HashMap<String,Object> implements Serializable
public boolean isSuccess() {
return (boolean)this.get("success");
}
public void setSuccess(boolean success) {
this.put("success", success);
}
@ -81,17 +96,17 @@ public class ResultVoMap extends HashMap<String,Object> implements Serializable
public static ResultVoMap success() {
return new ResultVoMap();
}
@Override
public ResultVoMap put(String key, Object value) {
super.put(key, value);
return this;
}
public ResultVoMap putMap(Map m) {
super.putAll(m);
return this;
}
}
}

@ -1,3 +1,18 @@
/**
* 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.api;

@ -1,3 +1,18 @@
/**
* 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.base.msg;
/**

@ -1,3 +1,18 @@
/**
* 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.constants;
/**

@ -1,3 +1,18 @@
/**
* 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.constants;
/**
@ -9,10 +24,13 @@ package org.opsli.common.constants;
*/
public interface DictConstants {
/** 缓存前缀 */
/** 缓存前缀 NAME */
String CACHE_PREFIX_NAME = "dict:name:";
/** 缓存前缀 */
/** 缓存前缀 VALUE*/
String CACHE_PREFIX_VALUE = "dict:value:";
/** 缓存前缀 LIST*/
String CACHE_PREFIX_LIST = "dict:list:";
}

@ -1,6 +1,22 @@
/**
* 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.constants;
import cn.hutool.setting.dialect.Props;
import org.opsli.common.utils.Props;
/**
* @BelongsProject: opsli-boot
@ -11,7 +27,7 @@ import cn.hutool.setting.dialect.Props;
*/
public final class MyBatisConstants {
private static final Props prop = Props.getProp("application.yaml");
private static final Props prop = new Props("application.yaml");
/** 逻辑删除值 */
public static final char LOGIC_DELETE_VALUE =

@ -1,3 +1,18 @@
/**
* 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.constants;
/**
@ -7,6 +22,9 @@ package org.opsli.common.constants;
*/
public interface OrderConstants {
/** Util 加载顺序 */
int UTIL_ORDER = 140;
/** token */
int TOKEN_AOP_SORT = 150;
@ -19,6 +37,9 @@ public interface OrderConstants {
/** SQL 切面执行顺序 */
int SQL_ORDER = 190;
/** 参数非法验证顺序 */
int LOG_ORDER = 200;
/** Controller异常拦截顺序 */
int EXCEPTION_HANDLER_ORDER = 260;

@ -1,3 +1,18 @@
/**
* 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.constants;
/**

@ -1,3 +1,18 @@
/**
* 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.constants;
/**
@ -10,6 +25,6 @@ package org.opsli.common.constants;
public interface TokenConstants {
/** ACCESS_TOKEN */
String ACCESS_TOKEN = "token";
String ACCESS_TOKEN = "X-Token";
}

@ -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;
}
}

@ -1,3 +1,18 @@
/**
* 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.enums;

@ -1,3 +1,18 @@
/**
* 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.enums;
import java.util.UUID;

@ -1,3 +1,18 @@
/**
* 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.enums;

@ -1,3 +1,18 @@
/**
* 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;

@ -1,3 +1,18 @@
/**
* 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;

@ -1,3 +1,18 @@
/**
* 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;

@ -1,3 +1,18 @@
/**
* 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;

@ -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);
}
}

@ -1,3 +1,18 @@
/**
* 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.msg;
import org.opsli.common.base.msg.BaseMsg;

@ -1,3 +1,18 @@
/**
* 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;
/**

@ -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(){}
}

@ -1,3 +1,18 @@
/**
* 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 java.io.File;
@ -375,4 +390,4 @@ public final class PackageUtil {
return src;
}
}
}

@ -0,0 +1,361 @@
/**
* 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 cn.hutool.core.convert.Convert;
import lombok.extern.slf4j.Slf4j;
import org.yaml.snakeyaml.Yaml;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* resourcesyaml
*
* 使maven
* <dependency>
* <groupId>org.yaml</groupId>
* <artifactId>snakeyaml</artifactId>
* <version>1.25</version>
* </dependency>
* map->bean使
* <dependency>
* <groupId>commons-beanutils</groupId>
* <artifactId>commons-beanutils-core</artifactId>
* <version>1.8.3</version>
* </dependency>
*
*使
*eg:
* opsli:
* config:
* key: value
* list:
* -
* -
* map:
* - name: map
* age: 12
* - name: map
* age: 121
*
*,"opsli.config" : new ConfigBean().prefix("opsli.config").getObj()
*
*list,"opsli.config.list.1" : new ConfigBean().prefix("opsli.config.list.1").getObj()
*
*list,"opsli.config.map.1.name" :new ConfigBean().prefix("opsli.config.list.1").getString()
*
*
* hutool Props Yaml
* @author Parker
*/
@Slf4j
public class Props {
/** 缓存 Prop 防止重复开启IO 注: 多线程安全 */
private static final Map<String, Map<String, Object>> CACHE_MAP = new ConcurrentHashMap<>();
/** 文件名 */
private final String fileName;
/**
*
*/
private Map<String, Object> temp;
public Props(String fileName){
this.fileName = fileName;
this.load();
}
/**
*
*/
private void load() {
if(CACHE_MAP.get(this.fileName) != null){
temp = CACHE_MAP.get(this.fileName);
return;
}
try (InputStream inputStream = Props.class.getResourceAsStream("/" + this.fileName)) {
Yaml yaml = new Yaml();
temp = yaml.load(inputStream);
// 初始化保护
if(temp == null){
temp = new LinkedHashMap<>();
}
CACHE_MAP.put(this.fileName, temp);
} catch (Exception e) {
log.error("load config file {} error", this.fileName, e);
}
}
/**
* Obj
* @return
*/
public Object getObj(String key){
return this.getObj(key, null);
}
/**
* Obj
* @return
*/
public Object getObj(String key, Object def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
*
* @return
*/
public String getStr(String key){
return this.getStr(key, null);
}
/**
*
* @return
*/
public String getStr(String key, String def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
* Int
* @return
*/
public Integer getInt(String key){
return this.getInt(key, null);
}
/**
* Int
* @return
*/
public Integer getInt(String key, Integer def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
* Long
* @return
*/
public Long getLong(String key){
return this.getLong(key, null);
}
/**
* Long
* @return
*/
public Long getLong(String key, Long def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
* Double
* @return
*/
public Double getDouble(String key){
return this.getDouble(key, null);
}
/**
* Double
* @return
*/
public Double getDouble(String key, Double def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
* Float
* @return
*/
public Float getFloat(String key){
return this.getFloat(key, null);
}
/**
* Float
* @return
*/
public Float getFloat(String key, Float def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
* Char
* @return
*/
public Character getChar(String key){
return this.getChar(key, null);
}
/**
* Char
* @return
*/
public Character getChar(String key, Character def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
*
* @return
*/
public Boolean getBool(String key){
return this.getBool(key, null);
}
/**
*
* @return
*/
public Boolean getBool(String key, Boolean def){
if(key == null || "".equals(key) ){
return def;
}
// key 集合
String[] keys = key.split("\\.");
// 获得对象
Object obj = this.getObject(keys);
if(obj != null){
def = Convert.convert(def.getClass(), obj);
}
return def;
}
/**
*
* @param keys
* @return
*/
private Object getObject(String[] keys){
// 循环查找
Object obj = null;
for (String k : keys) {
if(obj == null){
obj = temp.get(k);
} else if(obj instanceof LinkedHashMap){
obj = ((LinkedHashMap) obj).get(k);
}
}
return obj;
}
}

@ -1,13 +1,30 @@
/**
* 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 cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @BelongsProject: opsli-boot
@ -77,6 +94,33 @@ public final class WrapperUtil {
return toInstanceList;
}
/**
*
* @param froms
* @param toClass
* @param <M>
* @return
*/
public static <T,M> Set<M> transformInstance(Set<T> froms, Class<M> toClass){
Set<M> toInstanceList = Sets.newHashSetWithExpectedSize(froms.size());
try {
for (Object from : froms) {
Object toObj = ReflectUtil.newInstance(toClass);
Map<String, Object> stringBeanMap = BeanUtil.beanToMap(from);
if(stringBeanMap != null){
Object toInstance = BeanUtil.fillBeanWithMapIgnoreCase(stringBeanMap, toObj, true);
if(toInstance != null){
toInstanceList.add((M) toInstance);
}
}
}
}catch (Exception e){
log.error(e.getMessage(),e);
}
return toInstanceList;
}
/**
*
* @param from
@ -102,4 +146,16 @@ public final class WrapperUtil {
return transformInstance(ts,toClass);
}
/**
*
* @param froms
* @param toClass
* @param <M>
* @return
*/
public static <T,M> Set<M> cloneTransformInstance(Set<T> froms, Class<M> toClass){
Set<T> ts = ObjectUtil.cloneByStream(froms);
return transformInstance(ts,toClass);
}
}

@ -1,3 +1,18 @@
/**
* 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.aspect;
import com.google.common.collect.Lists;

@ -1,3 +1,18 @@
/**
* 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.aspect;
import lombok.extern.slf4j.Slf4j;

@ -1,5 +1,22 @@
/**
* 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.aspect;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
@ -8,6 +25,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.opsli.common.api.TokenThreadLocal;
import org.opsli.common.exception.ServiceException;
import org.opsli.core.utils.LogUtil;
import org.opsli.core.utils.UserTokenUtil;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@ -47,11 +65,13 @@ public class TokenAop {
try {
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
HttpServletRequest request = sra.getRequest();
String requestToken = UserTokenUtil.getRequestToken(request);
if(StringUtils.isNotEmpty(requestToken)){
// 放入当前线程缓存中
TokenThreadLocal.put(requestToken);
if(sra != null) {
HttpServletRequest request = sra.getRequest();
String requestToken = UserTokenUtil.getRequestToken(request);
if(StringUtils.isNotEmpty(requestToken)){
// 放入当前线程缓存中
TokenThreadLocal.put(requestToken);
}
}
}catch (ServiceException e){
throw e;
@ -59,13 +79,23 @@ public class TokenAop {
log.error(e.getMessage(),e);
}
// 计时器
TimeInterval timer = DateUtil.timer();
// 执行
Exception exception = null;
// 防止线程抛异常 线程变量不回收 导致oom
Object returnValue = null;
Object returnValue;
try {
// 执行正常操作
Object[] args= point.getArgs();
returnValue = point.proceed(args);
returnValue = point.proceed();
}catch (Exception e){
exception = e;
throw e;
} finally {
// 花费毫秒数
long timerCount = timer.interval();
//保存日志
LogUtil.saveLog(point, exception, timerCount);
// 线程销毁时 删除 token
TokenThreadLocal.remove();
}

@ -1,3 +1,18 @@
/**
* 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.aspect;
import com.google.common.collect.Maps;

@ -1,3 +1,18 @@
/**
* 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.aspect;
import lombok.extern.slf4j.Slf4j;
@ -45,6 +60,7 @@ public class ValitaionArgsAop {
try {
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
if(sra == null) return;
HttpServletRequest request = sra.getRequest();
String method = request.getMethod();
@ -53,7 +69,11 @@ public class ValitaionArgsAop {
for (Object arg : args) {
// 参数校验
if(arg instanceof ApiWrapper){
ValidationUtil.verify(arg);
ApiWrapper apiWrapper = (ApiWrapper) arg;
// 如果是内部调用 则不判断参数非法情况
if(apiWrapper.getIzApi() != null && !apiWrapper.getIzApi()){
ValidationUtil.verify(arg);
}
}
}
}

@ -1,3 +1,18 @@
/**
* 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.base.concroller;
@ -13,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.annotation.hotdata.EnableHotData;
import org.opsli.common.exception.ServiceException;
import org.opsli.common.msg.CommonMsg;
@ -22,10 +38,12 @@ import org.opsli.core.base.service.interfaces.CrudServiceInterface;
import org.opsli.core.cache.local.CacheUtil;
import org.opsli.core.msg.CoreMsg;
import org.opsli.core.utils.ExcelUtil;
import org.opsli.core.utils.UserUtil;
import org.opsli.plugins.excel.exception.ExcelPluginException;
import org.opsli.plugins.redis.RedisLockPlugins;
import org.opsli.plugins.redis.lock.RedisLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@ -52,6 +70,9 @@ import java.util.List;
@RestController
public abstract class BaseRestController <T extends BaseEntity, E extends ApiWrapper, S extends CrudServiceInterface<T,E>>{
@Value("${opsli.enable-demo}")
private boolean enableDemo;
/** 开启热点数据状态 */
protected boolean hotDataFlag = false;
@ -243,6 +264,17 @@ public abstract class BaseRestController <T extends BaseEntity, E extends ApiWra
return resultVo;
}
/**
*
*/
protected void demoError(){
UserModel user = UserUtil.getUser();
// 演示模式 不允许操作 (超级管理员可以操作)
if(enableDemo && !UserUtil.SUPER_ADMIN.equals(user.getUsername())){
throw new ServiceException(CoreMsg.EXCEPTION_ENABLE_DEMO);
}
}
// =================================================
@PostConstruct

@ -1,3 +1,18 @@
/**
* 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.base.entity;
import lombok.Data;

@ -1,3 +1,18 @@
/**
* 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.base.service.base;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

@ -1,3 +1,18 @@
/**
* 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.base.service.impl;
import cn.hutool.core.convert.Convert;
@ -75,6 +90,15 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Transactional(readOnly = false)
public E insert(E model) {
if(model == null) return null;
// 默认清空 创建人和修改人
if(model.getIzManual() != null && !model.getIzManual()){
model.setCreateBy(null);
model.setCreateTime(null);
model.setUpdateBy(null);
model.setUpdateTime(null);
}
T entity = transformM2T(model);
boolean ret = super.save(entity);
if(ret){
@ -87,6 +111,18 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Transactional(readOnly = false)
public boolean insertBatch(List<E> models) {
if(models == null || models.size() == 0) return false;
for (E model : models) {
// 默认清空 创建人和修改人
if(model.getIzManual() != null && !model.getIzManual()){
model.setCreateBy(null);
model.setCreateTime(null);
model.setUpdateBy(null);
model.setUpdateTime(null);
}
}
List<T> entitys = transformMs2Ts(models);
return super.saveBatch(entitys);
}
@ -95,6 +131,13 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Transactional(readOnly = false)
public E update(E model) {
if(model == null) return null;
// 默认清空 创建人和修改人
if(model.getIzManual() != null && !model.getIzManual()){
model.setUpdateBy(null);
model.setUpdateTime(null);
}
T entity = transformM2T(model);
boolean ret = super.updateById(entity);
if(ret){
@ -157,9 +200,9 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
page.pageHelperBegin();
try{
List<T> list = this.findList(page.getQueryWrapper());
List<E> es = WrapperUtil.transformInstance(list, modelClazz);
PageInfo<E> pageInfo = new PageInfo<>(es);
page.instance(pageInfo);
PageInfo<T> pageInfo = new PageInfo<>(list);
List<E> es = transformTs2Ms(pageInfo.getList());
page.instance(pageInfo, es);
} finally {
page.pageHelperEnd();
}

@ -1,3 +1,18 @@
/**
* 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.base.service.interfaces;
import com.baomidou.mybatisplus.extension.service.IService;

@ -1,8 +1,25 @@
/**
* 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.base.service.interfaces;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.core.base.entity.BaseEntity;
import org.opsli.core.persistence.Page;
import java.util.Collection;
@ -21,7 +38,7 @@ import java.util.List;
* @param <T>
* @param <E>
*/
public interface CrudServiceInterface<T,E> extends BaseServiceInterface<T> {
public interface CrudServiceInterface<T extends BaseEntity,E extends ApiWrapper> extends BaseServiceInterface<T> {
/**

@ -1,25 +1,48 @@
/**
* 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.local;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.util.XmlUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.opsli.common.constants.CacheConstants;
import org.opsli.core.aspect.CacheDataAop;
import org.opsli.plugins.cache.EhCachePlugin;
import org.opsli.plugins.redis.RedisPlugin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.List;
import static org.opsli.common.constants.OrderConstants.UTIL_ORDER;
/**
* @BelongsProject: opsli-boot
@ -37,23 +60,27 @@ import java.util.List;
*
*/
@Slf4j
@Order(UTIL_ORDER)
@Component
@AutoConfigureAfter({RedisPlugin.class , EhCachePlugin.class})
public class CacheUtil {
private static final String JSON_KEY = "data";
public static final String JSON_KEY = "data";
/** 空状态 key 前缀 */
private static final String NIL_FLAG_PREFIX = "opsli:nil:";
/** 热点数据缓存时间 秒 */
private static int ttlHotData;
private static int ttlHotData = 60000;
/** Redis插件 */
private static RedisPlugin redisPlugin;
/** EhCache插件 */
private static EhCachePlugin ehCachePlugin;
static {
// 读取配置信息
CacheUtil.readPropertyXML();
try {
// 读取配置信息
CacheUtil.readPropertyXML();
}catch (Exception ignored){}
}
/**
@ -842,7 +869,7 @@ public class CacheUtil {
jsonObject.put(JSON_KEY, value);
// 存入EhCache
ehCachePlugin.put(CacheConstants.HOT_DATA,key, jsonObject);
ehCachePlugin.put(CacheConstants.HOT_DATA, key, jsonObject);
if(timeFlag){
@ -1057,8 +1084,10 @@ public class CacheUtil {
/**
*
*/
private static void readPropertyXML(){
Document document = XmlUtil.readXML("config/ehcache-opsli.xml");
private static void readPropertyXML() throws IOException {
// 有坑 读 xml
ClassPathResource resource = new ClassPathResource("config/ehcache-opsli.xml");
Document document = XmlUtil.readXML(resource.getInputStream());
NodeList nodeList = document.getElementsByTagName("cache");
if(nodeList != null){
for (int i = 0; i < nodeList.getLength(); i++) {

@ -1,3 +1,18 @@
/**
* 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.entity;
import lombok.Data;

@ -1,3 +1,18 @@
/**
* 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.enums;
/**

@ -1,3 +1,18 @@
/**
* 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.enums;
/**

@ -1,3 +1,18 @@
/**
* 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.enums;
/**
@ -27,6 +42,10 @@ public enum MsgArgsType {
/** 用户数据*/
USER_MODEL_DATA,
/** 菜单编号 */
MENU_CODE,
/** 菜单数据*/
MENU_MODEL_DATA,
/** 缓存数据Key */
CACHE_DATA_KEY,

@ -1,3 +1,18 @@
/**
* 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.enums;
/**
@ -15,6 +30,9 @@ public enum PushSubType {
/** 用户数据 */
USER,
/** 菜单数据 */
MENU,
/** 热点数据 */
HOT_DATA,

@ -1,3 +1,18 @@
/**
* 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.enums;
/**

@ -1,3 +1,18 @@
/**
* 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;

@ -1,3 +1,18 @@
/**
* 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;

@ -1,3 +1,18 @@
/**
* 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;

@ -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);
}
}

@ -1,3 +1,18 @@
/**
* 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;

@ -1,11 +1,24 @@
/**
* 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.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.wrapper.system.menu.MenuModel;
import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.constants.CacheConstants;
import org.opsli.core.cache.local.CacheUtil;
import org.opsli.core.cache.pushsub.enums.MsgArgsType;
@ -15,9 +28,6 @@ import org.opsli.core.utils.UserUtil;
import org.opsli.plugins.cache.EhCachePlugin;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.core.cache.pushsub.handler
@ -69,8 +79,6 @@ public class UserHandler implements RedisPushSubHandler{
// 数据为空则不执行
if(data == null) return;
// 获得数据
UserModel userModel = data.toJavaObject(UserModel.class);
// 获得用户ID 和 用户名
String userId = (String) msgJson.get(MsgArgsType.USER_ID.toString());
String username = (String) msgJson.get(MsgArgsType.USER_USERNAME.toString());
@ -81,12 +89,9 @@ public class UserHandler implements RedisPushSubHandler{
// 先删除
ehCachePlugin.delete(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID + userId);
ehCachePlugin.delete(CacheConstants.HOT_DATA, UserUtil.PREFIX_USERNAME + username);
// 再赋值
ehCachePlugin.put(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID + userId, userModel);
ehCachePlugin.put(CacheConstants.HOT_DATA,UserUtil.PREFIX_USERNAME + username, userModel);
// 清除空拦截
CacheUtil.putNilFlag(UserUtil.PREFIX_ID + userId);
CacheUtil.putNilFlag(UserUtil.PREFIX_USERNAME + username);
CacheUtil.delNilFlag(UserUtil.PREFIX_ID + userId);
CacheUtil.delNilFlag(UserUtil.PREFIX_USERNAME + username);
}
/**
@ -104,19 +109,10 @@ public class UserHandler implements RedisPushSubHandler{
return;
}
// 用户角色列表
List<String> roleCodes = dataArray.toJavaList(String.class);
if(roleCodes == null || roleCodes.isEmpty()){
return;
}
// 先删除
ehCachePlugin.delete(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID_ROLES + userId);
// 存入缓存
ehCachePlugin.put(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID_ROLES + userId, roleCodes);
// 清除空拦截
CacheUtil.putNilFlag(UserUtil.PREFIX_ID_ROLES + userId);
CacheUtil.delNilFlag(UserUtil.PREFIX_ID_ROLES + userId);
}
/**
@ -133,18 +129,11 @@ public class UserHandler implements RedisPushSubHandler{
if(StringUtils.isEmpty(userId)){
return;
}
// 用户权限列表
List<String> perms = dataArray.toJavaList(String.class);
if(perms == null || perms.isEmpty()){
return;
}
// 先删除
ehCachePlugin.delete(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID_PERMISSIONS + userId);
// 存入缓存
ehCachePlugin.put(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID_PERMISSIONS + userId, perms);
// 清除空拦截
CacheUtil.putNilFlag(UserUtil.PREFIX_ID_PERMISSIONS + userId);
CacheUtil.delNilFlag(UserUtil.PREFIX_ID_PERMISSIONS + userId);
}
/**
@ -161,18 +150,11 @@ public class UserHandler implements RedisPushSubHandler{
if(StringUtils.isEmpty(userId)){
return;
}
// 用户菜单列表
List<MenuModel> menus = dataArray.toJavaList(MenuModel.class);
if(menus == null || menus.isEmpty()){
return;
}
// 先删除
ehCachePlugin.delete(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID_MENUS + userId);
// 存入缓存
ehCachePlugin.put(CacheConstants.HOT_DATA, UserUtil.PREFIX_ID_MENUS + userId, menus);
// 清除空拦截
CacheUtil.putNilFlag(UserUtil.PREFIX_ID_MENUS + userId);
CacheUtil.delNilFlag(UserUtil.PREFIX_ID_MENUS + userId);
}

@ -1,3 +1,18 @@
/**
* 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;

@ -1,3 +1,18 @@
/**
* 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;

@ -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;
}
}

@ -1,3 +1,18 @@
/**
* 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;

@ -1,9 +1,25 @@
/**
* 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.receiver;
import cn.hutool.core.util.ClassUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.opsli.common.enums.SystemInfo;
import org.opsli.common.utils.PackageUtil;
import org.opsli.core.cache.pushsub.enums.PushSubType;
import org.opsli.core.cache.pushsub.handler.RedisPushSubHandler;
import org.opsli.core.msg.CoreMsg;
@ -53,10 +69,10 @@ public class RedisPushSubReceiver extends BaseReceiver {
@Bean
public void initRedisPushSubHandler(){
// 拿到state包下 实现了 SystemEventState 接口的,所有子类
Set<Class<?>> clazzSet = PackageUtil.listSubClazz(RedisPushSubHandler.class.getPackage().getName(),
true,
RedisPushSubHandler.class
Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(RedisPushSubHandler.class.getPackage().getName()
, RedisPushSubHandler.class
);
int count = 0;
@ -79,7 +95,7 @@ public class RedisPushSubReceiver extends BaseReceiver {
//自动注入依赖
beanFactory.autowireBean(obj);
} catch (Exception e){
log.error(CoreMsg.REDIS_EXCEPTION_PUSH_SUB.getMessage());
}
@ -100,10 +116,10 @@ public class RedisPushSubReceiver extends BaseReceiver {
JSONObject msgJson = JSONObject.parseObject(substring);
String type = (String) msgJson.get(BaseSubMessage.BASE_TYPE);
String identifier = (String) msgJson.get(BaseSubMessage.BASE_ID);
// TODO 本机不广播
// if(SystemInfo.INSTANCE.getSystemID().equals(identifier)){
// return;
// }
// 本机不广播
if(SystemInfo.INSTANCE.getSystemID().equals(identifier)){
return;
}
PushSubType pt = PushSubType.valueOf(type);
RedisPushSubHandler redisPushSubHandler = HANDLER_MAP.get(pt);
if(redisPushSubHandler == null){

@ -1,3 +1,18 @@
/**
* 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.conf;
import com.google.code.kaptcha.impl.DefaultKaptcha;

@ -1,3 +1,18 @@
/**
* 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.conf;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;

@ -1,3 +1,18 @@
/**
* 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.conf;
import lombok.extern.slf4j.Slf4j;
@ -33,7 +48,7 @@ public class RedisMessageListenerConfig {
*
* @return
*/
@Bean
public RedisMessageListenerContainer container(LettuceConnectionFactory lettuceConnectionFactory) {
RedisPushSubReceiver receiver = new RedisPushSubReceiver();

@ -1,3 +1,18 @@
/**
* 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.conf;
import org.apache.shiro.mgt.SecurityManager;
@ -62,6 +77,7 @@ public class ShiroConfig {
filterMap.put("/swagger-resources/**", "anon");
filterMap.put("/captcha.jpg", "anon");
filterMap.put("/ueditor/**", "anon");
filterMap.put("/static/file/**", "anon");
filterMap.put("/**", "oauth2");
shiroFilter.setFilterChainDefinitionMap(filterMap);

@ -1,10 +1,25 @@
/**
* 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.conf;
import com.fasterxml.classmate.TypeResolver;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiOperation;
import org.opsli.common.constants.TokenConstants;
import org.opsli.core.utils.UserTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -23,6 +38,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.List;
/**
* @author parker
*/
@Configuration
@EnableSwagger2
@EnableKnife4j
@ -100,7 +118,7 @@ public class SwaggerConfig {
private List<Parameter> defaultToken() {
ParameterBuilder parameterBuilder = new ParameterBuilder();
List<Parameter> parameters= Lists.newArrayList();
parameterBuilder.name(TokenConstants.ACCESS_TOKEN)
parameterBuilder.name(UserTokenUtil.TOKEN_NAME)
.description("Token 令牌")
.modelRef(new ModelRef("String"))
.parameterType("header")
@ -117,11 +135,11 @@ public class SwaggerConfig {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
return Lists.newArrayList(new SecurityReference(TokenConstants.ACCESS_TOKEN, authorizationScopes));
return Lists.newArrayList(new SecurityReference(UserTokenUtil.TOKEN_NAME, authorizationScopes));
}
private ApiKey apiKey() {
return new ApiKey(TokenConstants.ACCESS_TOKEN, TokenConstants.ACCESS_TOKEN, "header");
return new ApiKey(UserTokenUtil.TOKEN_NAME, UserTokenUtil.TOKEN_NAME, "header");
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save