Skip to content

Commit

Permalink
Merge pull request #14 from hiparker/development
Browse files Browse the repository at this point in the history
v 1.6.3 申请合并
  • Loading branch information
hiparker authored Apr 26, 2022
2 parents 9f1399b + 0327bed commit af9fdfc
Show file tree
Hide file tree
Showing 52 changed files with 1,400 additions and 633 deletions.
870 changes: 479 additions & 391 deletions db-file/opsli-boot.sql

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions db-file/升级SQL/1.6.2 =》1.6.3 .sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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.api.web.system.logs;

import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.logs.LogsModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;


/**
* 日志 API
*
* 对外 API 直接 暴露 @GetMapping 或者 @PostMapping
* 对内也推荐 单机版 不需要设置 Mapping 但是调用方法得从Controller写起
*
* 这样写法虽然比较绕,但是当单体项目想要改造微服务架构时 时非常容易的
*
* @author Parker
* @date 2020-09-13 17:40
*/
public interface LoginLogsApi {

/** 标题 */
String TITLE = "登录日志管理";
/** 子标题 */
String SUB_TITLE = "登录日志";


/**
* 日志 查询分页
* @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
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
public interface LogsApi {

/** 标题 */
String TITLE = "日志管理";
String TITLE = "操作日志管理";
/** 子标题 */
String SUB_TITLE = "日志";
String SUB_TITLE = "操作日志";

/**
* 日志 查一条
Expand All @@ -64,13 +64,6 @@ ResultVo<?> findPage(
HttpServletRequest request
);

/**
* 清空一个月前的日志
* @return ResultVo
*/
@PostMapping("/emptyByOneMonth")
ResultVo<?> emptyByOneMonth();


/**
* 日志 新增
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public interface UserApi {

/**
* 上传头像
* @param request 文件流 request
* @param userAvatarModel 图片地址
* @return ResultVo
*/
@PostMapping("/updateAvatar")
ResultVo<?> updateAvatar(MultipartHttpServletRequest request);
ResultVo<?> updateAvatar(@RequestBody UserAvatarModel userAvatarModel);


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* 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 io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper;

/**
* 登录 日志表
*
* @author Parker
* @date 2020-09-16 17:33
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class LoginLogsModel extends ApiWrapper {

/**
* 多租户字段
*/
private String tenantId;
/**
* 组织机构ID组 xxx,xxx
*/
private String orgIds;

/**
* 用户名称
*/
@ApiModelProperty(value = "用户名称")
private String username;

/**
* 真实姓名
*/
@ApiModelProperty(value = "真实姓名")
private String realName;

/**
* 日志类型
* 1 : 登录
* 2 : 登出
*/
@ApiModelProperty(value = "日志类型")
private String type;

/**
* 操作IP地址
*/
@ApiModelProperty(value = "操作IP地址")
private String remoteAddr;

/**
* 用户代理
*/
@ApiModelProperty(value = "用户代理")
private String userAgent;

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ public class LogsModel extends ApiWrapper {
public static final String TYPE_EXCEPTION = "2";


/**
* 多租户字段
*/
@ApiModelProperty(value = "租户ID")
private String tenantId;

/**
* 组织机构ID组 xxx,xxx
*/
@ApiModelProperty(value = "组织ID集合")
private String orgIds;

/** 日志类型(1:接入日志;2:错误日志) */
@ApiModelProperty(value = "日志类型")
private String type;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.api.wrapper.system.user;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.enums.ValidatorType;

/**
* 用户信息表
*
* @author Parker
* @date 2020-09-16 17:33
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class UserAvatarModel {

@ApiModelProperty(value = "图片地址")
@Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_URL})
private String imgUrl;

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public enum DictType {
DATA_SCOPE_DEPT_AND_UNDER("role_data_scope","2", "本部门及以下数据"),
DATA_SCOPE_ALL("role_data_scope","3", "全部数据"),

/** 登入登出日志类型 */
LOGIN_LOG_TYPE_LOGIN("login_log_type","1", "登入"),
LOGIN_LOG_TYPE_LOGOUT("login_log_type","2", "登出")


;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.common.thread.ThreadPoolFactory;

import java.util.concurrent.Callable;
import java.util.concurrent.RejectedExecutionException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.opsli.common.thread;


import com.alibaba.ttl.threadpool.TtlExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;

/**
* 线程池工厂
Expand Down Expand Up @@ -41,7 +39,7 @@ public final class ThreadPoolFactory {
* 创建默认的线程池
* @return ThreadPoolExecutor
*/
public static ThreadPoolExecutor createDefThreadPool(){
public static ExecutorService createDefThreadPool(){
return createInitThreadPool(DEFAULT_MAX_CONCURRENT, DEFAULT_MAX_CONCURRENT * 4, DEFAULT_KEEP_ALIVE,
TimeUnit.SECONDS, DEFAULT_SIZE, DEFAULT_THREAD_POOL_NAME, new ThreadPoolExecutor.CallerRunsPolicy());
}
Expand All @@ -53,7 +51,7 @@ public static ThreadPoolExecutor createDefThreadPool(){
* @param poolName 线程池名称
* @return ThreadPoolExecutor
*/
public static ThreadPoolExecutor createDefThreadPool(String poolName){
public static ExecutorService createDefThreadPool(String poolName){
return createInitThreadPool(DEFAULT_MAX_CONCURRENT, DEFAULT_MAX_CONCURRENT * 4, DEFAULT_KEEP_ALIVE,
TimeUnit.SECONDS, DEFAULT_SIZE, poolName, new ThreadPoolExecutor.CallerRunsPolicy());
}
Expand All @@ -65,7 +63,7 @@ public static ThreadPoolExecutor createDefThreadPool(String poolName){
* @param poolName 线程池名称
* @return ThreadPoolExecutor
*/
public static ThreadPoolExecutor createDefThreadPool(int maxConcurrent, String poolName){
public static ExecutorService createDefThreadPool(int maxConcurrent, String poolName){
return createInitThreadPool(maxConcurrent, maxConcurrent * 4, DEFAULT_KEEP_ALIVE,
TimeUnit.SECONDS, DEFAULT_SIZE, poolName, new ThreadPoolExecutor.CallerRunsPolicy());
}
Expand All @@ -81,19 +79,19 @@ public static ThreadPoolExecutor createDefThreadPool(int maxConcurrent, String p
* @param handler 拒绝处理策略
* @return ThreadPoolExecutor
*/
public static ThreadPoolExecutor createInitThreadPool(final int coreConcurrent,
public static ExecutorService createInitThreadPool(final int coreConcurrent,
final int maxConcurrent,
final long keepAlive,
final TimeUnit timeUnit,
final int queueSize,
final String poolName,
final RejectedExecutionHandler handler
){
return new ThreadPoolExecutor(coreConcurrent, maxConcurrent, keepAlive, timeUnit,
return TtlExecutors.getTtlExecutorService(new ThreadPoolExecutor(coreConcurrent, maxConcurrent, keepAlive, timeUnit,
new LinkedBlockingDeque<>(queueSize),
new ThreadFactoryBuilder().setNameFormat(poolName).build(),
handler
);
));
}

private ThreadPoolFactory(){}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import org.opsli.common.annotation.ApiRestController;
import org.opsli.core.api.ApiRequestMappingHandlerMapping;
import org.opsli.core.autoconfigure.properties.ApiPathProperties;
import org.opsli.core.filters.interceptor.UserAuthInterceptor;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
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.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
Expand Down Expand Up @@ -83,4 +85,10 @@ public CorsFilter corsFilter() {
return new CorsFilter(urlBasedCorsConfigurationSource);
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
// 加载特定拦截器
registry.addInterceptor(new UserAuthInterceptor());
WebMvcConfigurer.super.addInterceptors(registry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
import org.opsli.plugins.excel.exception.ExcelPluginException;
import org.opsli.plugins.excel.listener.BatchExcelListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
Expand Down Expand Up @@ -92,6 +94,18 @@ public abstract class BaseRestController <T extends BaseEntity, E extends ApiWra
@Autowired(required = false)
protected S IService;

/**
* 默认 直接设置 传入数据的
* 根据id 从缓存 直接查询 数据对象
*
* @param id id
* @return E
*/
@ModelAttribute
public E get(@RequestParam(required=false) String id) {
return IService.get(id);
}

/**
* Excel 导入
* @param request request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,11 @@ public List<T> findAllList() {

@Override
public Page<T,E> findPage(Page<T,E> page) {
// 数据处理责任链
QueryWrapper<T> qWrapper = this.addHandler(entityClazz, page.getQueryWrapper());
page.pageHelperBegin();
try{
List<T> list = this.findList(page.getQueryWrapper());
List<T> list = super.list(qWrapper);
PageInfo<T> pageInfo = new PageInfo<>(list);
List<E> es = transformTs2Ms(pageInfo.getList());
page.instance(pageInfo, es);
Expand All @@ -242,9 +244,11 @@ public Page<T,E> findPage(Page<T,E> page) {

@Override
public Page<T,E> findPageNotCount(Page<T,E> page) {
// 数据处理责任链
QueryWrapper<T> qWrapper = this.addHandler(entityClazz, page.getQueryWrapper());
page.pageHelperBegin(false);
try{
List<T> list = this.findList(page.getQueryWrapper());
List<T> list = super.list(qWrapper);
PageInfo<T> pageInfo = new PageInfo<>(list);
List<E> es = transformTs2Ms(pageInfo.getList());
page.instance(pageInfo, es);
Expand Down
Loading

0 comments on commit af9fdfc

Please sign in to comment.