jtoms 4 vuotta sitten
vanhempi
commit
e44b791758

+ 6 - 1
pom.xml

@@ -37,7 +37,12 @@
         <dependency>
             <groupId>com.dliyun</groupId>
             <artifactId>framework-sprint-boot</artifactId>
-            <version>1.0.6</version>
+            <version>1.0.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.dliyun</groupId>
+            <artifactId>framework-docs</artifactId>
+            <version>1.0.7</version>
         </dependency>
         <dependency>
             <groupId>com.dliyun</groupId>

+ 0 - 82
src/main/java/com/zhiqiyun/open/config/BeanConfig.java

@@ -1,101 +1,19 @@
 package com.zhiqiyun.open.config;
 
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JacksonException;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonStreamContext;
-import com.fasterxml.jackson.databind.*;
-import com.fasterxml.jackson.databind.node.JsonNodeType;
 import com.zhiqiyun.open.Application;
-import com.zhiqiyun.open.enmus.IEnum;
-import io.netty.util.internal.StringUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
 import org.lionsoul.ip2region.DbConfig;
 import org.lionsoul.ip2region.DbSearcher;
-import org.springframework.beans.BeanUtils;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
 
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Collection;
 
 @Slf4j
 @Configuration
 public class BeanConfig {
     @Bean
-    public Jackson2ObjectMapperBuilderCustomizer enumCustomizer() {
-        return new Jackson2ObjectMapperBuilderCustomizer() {
-            @Override
-            public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
-                jacksonObjectMapperBuilder.serializerByType(IEnum.class, new JsonSerializer<IEnum>() {
-                    @Override
-                    public void serialize(IEnum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
-                        gen.writeStartObject();
-                        gen.writeNumberField("value", value.getValue());
-                        gen.writeStringField("text", value.getText());
-                        gen.writeStringField("name", value.getName());
-                        gen.writeEndObject();
-                    }
-                });
-//                jacksonObjectMapperBuilder.deserializerByType(IEnum.class, new JsonDeserializer<IEnum>() {
-//                    @Override
-//                    public IEnum deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JacksonException {
-//                        JsonNode node = jp.getCodec().readTree(jp);
-//                        String currentName = jp.currentName();
-//                        Object currentValue = jp.getCurrentValue();
-//                        Class findPropertyType = null;
-//                        if (currentValue instanceof Collection) {
-//
-//                            JsonStreamContext parsingContext = jp.getParsingContext();
-//
-//                            JsonStreamContext parent = parsingContext.getParent();
-//                            Object currentValue3 = parent.getCurrentValue();
-//                            String currentName3 = parent.getCurrentName();
-//                            try {
-//                                Field listField = currentValue3.getClass().getDeclaredField(currentName3);
-//                                ParameterizedType listGenericType = (ParameterizedType) listField.getGenericType();
-//                                Type listActualTypeArguments = listGenericType.getActualTypeArguments()[0];
-//                                findPropertyType = (Class<?>) listActualTypeArguments;
-//                            } catch (Exception e) {
-//                                e.printStackTrace();
-//                            }
-//                        } else {
-//                            findPropertyType = BeanUtils.findPropertyType(currentName, currentValue.getClass());
-//                        }
-//                        if (findPropertyType == null) {
-//                            throw new RuntimeException("数据格式异常");
-//                        }
-//                        String asText = null;
-//                        if (node.getNodeType() == JsonNodeType.STRING) {
-//                            asText = node.asText();
-//                        } else {
-//                            asText = node.get("code").asText();
-//                        }
-//                        IEnum valueOf = null;
-//                        if (StringUtils.isNotBlank(asText)) {
-//                            valueOf = IEnum.valueOf(asText, findPropertyType);
-//                        }
-//                        return valueOf;
-//                    }
-//                });
-
-                jacksonObjectMapperBuilder.serializationInclusion(JsonInclude.Include.NON_NULL);
-            }
-        };
-    }
-
-    @Bean
     public DbSearcher dbSearcher() throws Exception {
         DbConfig config = new DbConfig();
         InputStream inStream = Application.class.getResourceAsStream("/ip2region.db");

+ 35 - 0
src/main/java/com/zhiqiyun/open/config/WebMvcConfig.java

@@ -1,10 +1,19 @@
 package com.zhiqiyun.open.config;
 
 
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.zhiqiyun.open.enmus.EiEnum;
 import com.zhiqiyun.open.utils.ServletContext;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 import org.springframework.lang.NonNull;
 import org.springframework.web.servlet.HandlerInterceptor;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
@@ -13,6 +22,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
 
 /**
  * 系统启动配置
@@ -27,6 +38,30 @@ public class WebMvcConfig implements WebMvcConfigurer {
     private OauthInterceptor oauthInterceptor;
 
     @Override
+    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
+        converters.removeIf(converter -> converter instanceof MappingJackson2HttpMessageConverter);
+        ObjectMapper objectMapper = new ObjectMapper();
+        MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(objectMapper);
+        objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
+
+        SimpleModule module = new SimpleModule();
+        module.addSerializer(EiEnum.class, new JsonSerializer<EiEnum>() {
+            @Override
+            public void serialize(EiEnum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+                gen.writeStartObject();
+                gen.writeNumberField("value", value.getValue());
+                gen.writeStringField("text", value.getText());
+                gen.writeStringField("name", value.getName());
+                gen.writeEndObject();
+            }
+        });
+        objectMapper.registerModule(module);
+
+        converters.add(mappingJackson2HttpMessageConverter);
+    }
+
+
+    @Override
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(new HandlerInterceptor() {
             @Override

+ 2 - 1
src/main/java/com/zhiqiyun/open/enmus/AccountType.java

@@ -1,7 +1,7 @@
 package com.zhiqiyun.open.enmus;
 
 
-public enum AccountType implements IEnum {
+public enum AccountType implements EiEnum {
     /**
      *
      */
@@ -25,6 +25,7 @@ public enum AccountType implements IEnum {
         return null;
     }
 
+
     public String getText() {
         return text;
     }

+ 16 - 0
src/main/java/com/zhiqiyun/open/enmus/EiEnum.java

@@ -0,0 +1,16 @@
+package com.zhiqiyun.open.enmus;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+
+public interface EiEnum extends IEnum<Integer> {
+
+    Integer getValue();
+
+    String getText();
+
+    String getName();
+
+    static <E extends Enum<E>> EiEnum valueOf(String enumCode, Class<E> clazz) {
+        return (EiEnum) Enum.valueOf(clazz, enumCode);
+    }
+}

+ 1 - 1
src/main/java/com/zhiqiyun/open/enmus/Gender.java

@@ -5,7 +5,7 @@ package com.zhiqiyun.open.enmus;
  * @author jtoms
  */
 
-public enum Gender implements IEnum {
+public enum Gender implements EiEnum {
     /**
      *
      */

+ 0 - 14
src/main/java/com/zhiqiyun/open/enmus/IEnum.java

@@ -1,14 +0,0 @@
-package com.zhiqiyun.open.enmus;
-
-public interface IEnum {
-
-    Integer getValue();
-
-    String getText();
-
-    String getName();
-
-    static <E extends Enum<E>> IEnum valueOf(String enumCode, Class<E> clazz) {
-        return (IEnum) Enum.valueOf(clazz, enumCode);
-    }
-}

+ 1 - 1
src/main/java/com/zhiqiyun/open/enmus/PasswordType.java

@@ -5,7 +5,7 @@ package com.zhiqiyun.open.enmus;
  * @author jtoms
  */
 
-public enum PasswordType implements IEnum {
+public enum PasswordType implements EiEnum {
     /**
      *
      */

+ 1 - 1
src/main/java/com/zhiqiyun/open/enmus/UserLoginLogState.java

@@ -5,7 +5,7 @@ package com.zhiqiyun.open.enmus;
  * @author jtoms
  */
 
-public enum UserLoginLogState implements IEnum {
+public enum UserLoginLogState implements EiEnum {
     /**
      *
      */

+ 1 - 1
src/main/java/com/zhiqiyun/open/enmus/UserState.java

@@ -5,7 +5,7 @@ package com.zhiqiyun.open.enmus;
  * @author jtoms
  */
 
-public enum UserState implements IEnum {
+public enum UserState implements EiEnum {
     /**
      *
      */

+ 1 - 1
src/main/java/com/zhiqiyun/open/enmus/YN.java

@@ -5,7 +5,7 @@ package com.zhiqiyun.open.enmus;
  * @author jtoms
  */
 
-public enum YN implements IEnum {
+public enum YN implements EiEnum {
     /**
      *
      */

+ 8 - 1
src/main/java/com/zhiqiyun/open/models/AppKeyInfo.java

@@ -1,20 +1,27 @@
 package com.zhiqiyun.open.models;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import com.zhiqiyun.open.enmus.YN;
+import com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler;
 import lombok.Data;
 
 import java.util.Date;
 import java.util.List;
 
 @Data
-@TableName("app_key_info")
+@TableName(value = "app_key_info", autoResultMap = true)
 public class AppKeyInfo {
     @TableId(type = IdType.INPUT)
     private Long id;
     private String encryptKey;
     private String remark;
+    @TableField(typeHandler = JacksonTypeHandler.class)
     private List<String> permissions;
+    @TableField(typeHandler = IEnumTypeHandler.class)
+    private YN isEnable;
     private Date createdTime;
 }

+ 105 - 0
src/main/java/com/zhiqiyun/open/mvc/manager/controller/AppKeyInfoController.java

@@ -0,0 +1,105 @@
+package com.zhiqiyun.open.mvc.manager.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zhiqiyun.open.annotation.Permission;
+import com.zhiqiyun.open.enmus.YN;
+import com.zhiqiyun.open.models.AppKeyInfo;
+import com.zhiqiyun.open.mvc.Result;
+import com.zhiqiyun.open.mvc.manager.params.QueryAppKeyInfoParams;
+import com.zhiqiyun.open.mvc.manager.params.QueryPageParams;
+import com.zhiqiyun.open.mvc.manager.params.SaveAppKeyInfoParam;
+import com.zhiqiyun.open.service.AppKeyInfoService;
+import com.zhiqiyun.open.service.SequenceService;
+import com.zhiqiyun.open.utils.DateUtil;
+import com.zhiqiyun.open.utils.RandomUtil;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/appKey")
+public class AppKeyInfoController {
+
+    @Autowired
+    private AppKeyInfoService appKeyInfoService;
+
+    @Autowired
+    private SequenceService sequenceService;
+
+    @Permission(value = "app.key.find", tags = "查询AppKey")
+    @PostMapping("/findPage")
+    public Result findRolePage(@RequestBody QueryAppKeyInfoParams params) {
+
+        QueryWrapper<AppKeyInfo> queryWrapper = new QueryWrapper<>();
+        if (params.getId() != null) {
+            queryWrapper.eq("id", params.getId());
+        }
+        if (params.getIsEnable() != null) {
+            queryWrapper.eq("is_enable", params.getIsEnable());
+        }
+        if (StringUtils.isNotBlank(params.getRemark())) {
+            queryWrapper.like("remark", params.getRemark());
+        }
+        Page<AppKeyInfo> resultData = this.appKeyInfoService.page(params.getPage(), queryWrapper);
+
+        return Result.instance(Result.Code.SUCCESS).setData(resultData);
+    }
+
+    @Permission(value = "app.key.add", tags = "新建AppKey")
+    @PostMapping("/save")
+    public Result save(@RequestBody SaveAppKeyInfoParam param) {
+
+        AppKeyInfo appKeyInfo = new AppKeyInfo();
+        BeanUtils.copyProperties(param, appKeyInfo);
+
+        Long id = this.sequenceService.nextId();
+        String encryptKey = RandomUtil.get(64);
+        appKeyInfo.setId(id);
+        appKeyInfo.setEncryptKey(encryptKey);
+        appKeyInfo.setCreatedTime(DateUtil.current());
+        appKeyInfo.setIsEnable(YN.Y);
+        this.appKeyInfoService.save(appKeyInfo);
+
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+
+    @Permission(value = "app.key.add", tags = "更新AppKey")
+    @PostMapping("/updateById")
+    public Result updateById(Long id, @RequestBody SaveAppKeyInfoParam param) {
+        AppKeyInfo appKeyInfo = new AppKeyInfo();
+        BeanUtils.copyProperties(param, appKeyInfo);
+        appKeyInfo.setId(id);
+        this.appKeyInfoService.updateById(appKeyInfo);
+
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+
+    @Permission(value = "app.key.disable", tags = "禁用AppKey")
+    @PostMapping("/disableByIds")
+    public Result disableByIds(@RequestBody List<Long> ids) {
+        UpdateWrapper<AppKeyInfo> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.in("id", ids);
+        updateWrapper.set("is_enable", YN.N);
+        this.appKeyInfoService.update(updateWrapper);
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+
+    @Permission(value = "app.key.enable", tags = "启用AppKey")
+    @PostMapping("/enableByIds")
+    public Result enableByIds(@RequestBody List<Long> ids) {
+        UpdateWrapper<AppKeyInfo> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.in("id", ids);
+        updateWrapper.set("is_enable", YN.Y);
+        this.appKeyInfoService.update(updateWrapper);
+        return Result.instance(Result.Code.MESSAGE_SUCCESS);
+    }
+}

+ 15 - 0
src/main/java/com/zhiqiyun/open/mvc/manager/params/QueryAppKeyInfoParams.java

@@ -0,0 +1,15 @@
+package com.zhiqiyun.open.mvc.manager.params;
+
+import com.zhiqiyun.open.enmus.YN;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springframework.format.annotation.DateTimeFormat;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class QueryAppKeyInfoParams extends QueryPageParams {
+    private Long id;
+    @DateTimeFormat
+    private YN isEnable;
+    private String remark;
+}

+ 19 - 0
src/main/java/com/zhiqiyun/open/mvc/manager/params/QueryPageParams.java

@@ -1,9 +1,12 @@
 package com.zhiqiyun.open.mvc.manager.params;
 
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zhiqiyun.open.mybatis.paginator.domain.Order;
 import com.zhiqiyun.open.mybatis.paginator.domain.PageBounds;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 
 import java.lang.reflect.Field;
 import java.util.ArrayList;
@@ -37,6 +40,22 @@ public class QueryPageParams {
         return bounds;
     }
 
+    public <T> Page<T> getPage() {
+        Page<T> page = new Page<>(this.getCurrent(), this.getPageSize());
+
+        if (this.sorter != null && this.sorter.size() > 0) {
+            for (String key : this.sorter.keySet()) {
+                String directionString = this.sorter.get(key);
+                if (StringUtils.equalsIgnoreCase("ascend", directionString)) {
+                    page.addOrder(OrderItem.asc(key));
+                } else {
+                    page.addOrder(OrderItem.desc(key));
+                }
+            }
+        }
+        return page;
+    }
+
 
     public Map<String, Object> getQueryWrapper() {
         Map<String, Object> result = new HashMap<>();

+ 14 - 0
src/main/java/com/zhiqiyun/open/mvc/manager/params/SaveAppKeyInfoParam.java

@@ -0,0 +1,14 @@
+package com.zhiqiyun.open.mvc.manager.params;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.List;
+
+@Data
+public class SaveAppKeyInfoParam {
+    @NotBlank(message = "请输入AppKey名称")
+    private String name;
+    private String remark;
+    private List<String> permissions;
+}

+ 2 - 2
src/main/java/com/zhiqiyun/open/mybatis/typeHandler/IEnumTypeHandler.java

@@ -1,6 +1,6 @@
 package com.zhiqiyun.open.mybatis.typeHandler;
 
-import com.zhiqiyun.open.enmus.IEnum;
+import com.zhiqiyun.open.enmus.EiEnum;
 import org.apache.ibatis.type.BaseTypeHandler;
 import org.apache.ibatis.type.JdbcType;
 
@@ -12,7 +12,7 @@ import java.sql.SQLException;
 /**
  * @author jtoms
  */
-public class IEnumTypeHandler<E extends IEnum> extends BaseTypeHandler<E> {
+public class IEnumTypeHandler<E extends EiEnum> extends BaseTypeHandler<E> {
 
     private final Class<E> type;
 

+ 3 - 0
src/main/resources/application.properties

@@ -12,6 +12,9 @@ spring.datasource.password=liucheng123@
 #######################mybatis###############################
 mybatis-plus.config-location=classpath:mybatis/sqlMapConfig.xml
 mybatis-plus.mapper-locations=classpath:mybatis/mappers/*.xml
+mybatis-plus.type-enums-package=com.zhiqiyun.open.enmus
+#mybatis-plus.type-handlers-package=com.zhiqiyun.open.mybatis.typeHandler
+
 #######################redis###############################
 spring.redis.host=39.99.217.107
 spring.redis.password=hnylredis@

+ 145 - 123
src/main/resources/db/migration/V1.0.0__init_db.sql

@@ -1,141 +1,152 @@
 DROP TABLE IF EXISTS `authority_info`;
-CREATE TABLE IF NOT EXISTS `authority_info` (
-    `id` bigint(20) NOT NULL,
-    `parent_id` bigint(20) NOT NULL COMMENT '上级ID',
-    `name` varchar(32) NOT NULL COMMENT '权限名称',
-    `remark` varchar(255) NOT NULL COMMENT '权限说明',
+CREATE TABLE IF NOT EXISTS `authority_info`
+(
+    `id`        bigint(20)   NOT NULL,
+    `parent_id` bigint(20)   NOT NULL COMMENT '上级ID',
+    `name`      varchar(32)  NOT NULL COMMENT '权限名称',
+    `remark`    varchar(255) NOT NULL COMMENT '权限说明',
     PRIMARY KEY (`id`)
-    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='平台权限表';
-
-INSERT INTO `authority_info` (`id`, `parent_id`, `name`, `remark`) VALUES
-    (1000, 0, 'oauth.authority', '权限资源管理'),
-    (1001, 1000, 'oauth.authority.find', '查询'),
-    (1100, 0, 'oauth.role', '角色管理'),
-    (1101, 1100, 'oauth.role.find', '查询'),
-    (1102, 1100, 'oauth.role.add', '添加'),
-    (1103, 1100, 'oauth.role.edit', '编辑'),
-    (1104, 1100, 'oauth.role.delete', '删除'),
-    (1200, 0, 'oauth.user', '用户管理'),
-    (1201, 1200, 'oauth.user.find', '查询'),
-    (1202, 1200, 'oauth.user.add', '添加'),
-    (1203, 1200, 'oauth.user.edit', '编辑'),
-    (1204, 1200, 'oauth.user.disable', '禁用'),
-    (1205, 1200, 'oauth.user.enable', '启用'),
-    (1207, 1200, 'oauth.user.reset.login.password', '重置登录密码'),
-    (1208, 1200, 'oauth.user.find.login.log', '查询登录日志'),
-    (1209, 1200, 'oauth.user.find.operate.log', '查询操作日志'),
-    (1300, 0, 'system.config', '系统参数配置'),
-    (1301, 1300, 'system.config.find', '查询'),
-    (1302, 1300, 'system.config.edit', '修改');
+) ENGINE = InnoDB COMMENT ='平台权限表';
+
+INSERT INTO `authority_info` (`id`, `parent_id`, `name`, `remark`)
+VALUES (1000, 0, 'oauth.role', '角色管理'),
+       (1001, 1000, 'oauth.role.find', '查询'),
+       (1002, 1000, 'oauth.role.add', '添加'),
+       (1003, 1000, 'oauth.role.edit', '编辑'),
+       (1004, 1000, 'oauth.role.delete', '删除'),
+       (1100, 0, 'oauth.user', '用户管理'),
+       (1101, 1100, 'oauth.user.find', '查询'),
+       (1102, 1100, 'oauth.user.add', '添加'),
+       (1103, 1100, 'oauth.user.edit', '编辑'),
+       (1104, 1100, 'oauth.user.disable', '禁用'),
+       (1105, 1100, 'oauth.user.enable', '启用'),
+       (1106, 1100, 'oauth.user.reset.login.password', '重置登录密码'),
+       (1107, 1100, 'oauth.user.find.login.log', '查询登录日志'),
+       (1108, 1100, 'oauth.user.find.operate.log', '查询操作日志'),
+       (1200, 0, 'system.config', '系统参数配置'),
+       (1201, 1200, 'system.config.find', '查询'),
+       (1202, 1200, 'system.config.edit', '修改');
 
 DROP TABLE IF EXISTS `role_authority`;
-CREATE TABLE IF NOT EXISTS `role_authority` (
-    `id` bigint(20) NOT NULL AUTO_INCREMENT,
+CREATE TABLE IF NOT EXISTS `role_authority`
+(
+    `id`           bigint(20) NOT NULL AUTO_INCREMENT,
     `authority_id` bigint(20) NOT NULL COMMENT '权限ID',
-    `role_id` bigint(20) NOT NULL COMMENT '角色ID',
+    `role_id`      bigint(20) NOT NULL COMMENT '角色ID',
     PRIMARY KEY (`id`),
     KEY `authority_id_index` (`authority_id`),
     KEY `role_id_index` (`role_id`)
-    ) ENGINE=InnoDB AUTO_INCREMENT=801 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='平台角色权限关联表';
-
-INSERT INTO `role_authority` (`id`, `authority_id`, `role_id`) VALUES
-(783, 1001, 1000),
-(784, 1101, 1000),
-(785, 1102, 1000),
-(786, 1201, 1000),
-(787, 1202, 1000),
-(788, 1103, 1000),
-(789, 1203, 1000),
-(790, 1204, 1000),
-(791, 1104, 1000),
-(792, 1205, 1000),
-(793, 1209, 1000),
-(794, 1208, 1000),
-(795, 1207, 1000),
-(796, 1301, 1000),
-(797, 1302, 1000);
+) ENGINE = InnoDB
+  AUTO_INCREMENT = 801 COMMENT ='平台角色权限关联表';
+
+INSERT INTO `role_authority` (`id`, `authority_id`, `role_id`)
+VALUES (1, 1001, 1000),
+       (2, 1002, 1000),
+       (3, 1003, 1000),
+       (4, 1004, 1000),
+       (5, 1101, 1000),
+       (6, 1102, 1000),
+       (7, 1103, 1000),
+       (8, 1104, 1000),
+       (9, 1105, 1000),
+       (10, 1106, 1000),
+       (11, 1107, 1000),
+       (12, 1108, 1000),
+       (13, 1201, 1000),
+       (14, 1202, 1000);
 
 DROP TABLE IF EXISTS `role_info`;
-CREATE TABLE IF NOT EXISTS `role_info` (
-    `id` bigint(20) NOT NULL AUTO_INCREMENT,
-    `name` varchar(50) NOT NULL COMMENT '角色名称',
+CREATE TABLE IF NOT EXISTS `role_info`
+(
+    `id`     bigint(20)  NOT NULL AUTO_INCREMENT,
+    `name`   varchar(50) NOT NULL COMMENT '角色名称',
     `remark` varchar(100) DEFAULT NULL COMMENT '角色说明',
     PRIMARY KEY (`id`)
-    ) ENGINE=InnoDB AUTO_INCREMENT=1039 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='平台角色';
+) ENGINE = InnoDB
+  AUTO_INCREMENT = 1039 COMMENT ='平台角色';
 
 
-INSERT INTO `role_info` (`id`, `name`, `remark`) VALUES
-    (1000, '系统管理员', '管理网站的一切事务');
+INSERT INTO `role_info` (`id`, `name`, `remark`)
+VALUES (1000, '系统管理员', '管理网站的一切事务');
 
 
 DROP TABLE IF EXISTS `sequence`;
-CREATE TABLE IF NOT EXISTS `sequence` (
-    `id` bigint(20) NOT NULL AUTO_INCREMENT,
-    `salt_random` int(11) NOT NULL,
-    `created_time` datetime NOT NULL,
+CREATE TABLE IF NOT EXISTS `sequence`
+(
+    `id`           bigint(20) NOT NULL AUTO_INCREMENT,
+    `salt_random`  int(11)    NOT NULL,
+    `created_time` datetime   NOT NULL,
     PRIMARY KEY (`id`)
-    ) ENGINE=InnoDB AUTO_INCREMENT=1003 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统生成序列';
+) ENGINE = InnoDB COMMENT ='系统生成序列';
 
 
-INSERT INTO `sequence` (`id`, `salt_random`, `created_time`) VALUES
-(1000, 5, '2022-01-14 02:00:11'),
-(1001, 1, '2022-01-14 02:03:05'),
-(1002, 6, '2022-01-15 00:18:44');
+INSERT INTO `sequence` (`id`, `salt_random`, `created_time`)
+VALUES (1000, 5, '2022-01-14 02:00:11'),
+       (1001, 1, '2022-01-14 02:03:05'),
+       (1002, 6, '2022-01-15 00:18:44');
 
 
 DROP TABLE IF EXISTS `user_base_info`;
-CREATE TABLE IF NOT EXISTS `user_base_info` (
-    `id` bigint(20) NOT NULL AUTO_INCREMENT,
-    `nick_name` varchar(50) NOT NULL COMMENT '昵称',
-    `avatar` varchar(200) NOT NULL DEFAULT '' COMMENT '用户头像',
-    `gender` int(1) NOT NULL DEFAULT '0',
-    `state` int(1) NOT NULL COMMENT '用户状态',
-    `register_time` datetime NOT NULL,
-    `register_ip` varchar(50) NOT NULL,
+CREATE TABLE IF NOT EXISTS `user_base_info`
+(
+    `id`            bigint(20)   NOT NULL,
+    `nick_name`     varchar(50)  NOT NULL COMMENT '昵称',
+    `avatar`        varchar(200) NOT NULL DEFAULT '' COMMENT '用户头像',
+    `gender`        int(1)       NOT NULL DEFAULT '0',
+    `state`         int(1)       NOT NULL COMMENT '用户状态',
+    `register_time` datetime     NOT NULL,
+    `register_ip`   varchar(50)  NOT NULL,
     PRIMARY KEY (`id`),
     KEY `register_time_index` (`register_time`),
     KEY `state_index` (`state`),
     KEY `gender_index` (`gender`),
     KEY `nick_name_index` (`nick_name`)
-    ) ENGINE=InnoDB AUTO_INCREMENT=425782255161 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户基本信息表';
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8mb4
+  COLLATE = utf8mb4_0900_ai_ci COMMENT ='用户基本信息表';
 
 
 
-INSERT INTO `user_base_info` (`id`, `nick_name`, `avatar`, `gender`, `state`, `register_time`, `register_ip`) VALUES
-    (1000, 'admin11111', '/2020/11/15/4565685fb6a02e4fd04b0267b9f4932f.jpg', 0, 1, '2019-08-06 16:12:57', '127.0.0.1');
+INSERT INTO `user_base_info` (`id`, `nick_name`, `avatar`, `gender`, `state`, `register_time`, `register_ip`)
+VALUES (1000, 'admin11111', '/2020/11/15/4565685fb6a02e4fd04b0267b9f4932f.jpg', 0, 1, '2019-08-06 16:12:57',
+        '127.0.0.1');
 
 
 DROP TABLE IF EXISTS `user_login_account`;
-CREATE TABLE IF NOT EXISTS `user_login_account` (
-    `id` varchar(32) NOT NULL,
-    `uid` bigint(20) NOT NULL COMMENT '平台uid',
+CREATE TABLE IF NOT EXISTS `user_login_account`
+(
+    `id`            varchar(32) NOT NULL,
+    `uid`           bigint(20)  NOT NULL COMMENT '平台uid',
     `login_account` varchar(50) NOT NULL COMMENT '登录账号\n微信登录保存的为unionid',
-    `account_type` int(1) NOT NULL DEFAULT '1' COMMENT '账号类型',
+    `account_type`  int(1)      NOT NULL DEFAULT '1' COMMENT '账号类型',
     PRIMARY KEY (`id`),
-    UNIQUE KEY `uid_account_type_unique` (`uid`,`account_type`),
-    UNIQUE KEY `login_account_account_type_unique` (`login_account`,`account_type`),
+    UNIQUE KEY `uid_account_type_unique` (`uid`, `account_type`),
+    UNIQUE KEY `login_account_account_type_unique` (`login_account`, `account_type`),
     KEY `uid_index` (`uid`),
     KEY `login_account_index` (`login_account`)
-    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户基本信息表';
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8mb4
+  COLLATE = utf8mb4_0900_ai_ci COMMENT ='用户基本信息表';
 
 
 
-INSERT INTO `user_login_account` (`id`, `uid`, `login_account`, `account_type`) VALUES
-('13401bc84fcc27970a4dbc282d224333', 1000, 'admin@zhiqiyun.com', 1),
-('8604638900001fbee1de5551e67ea9e3', 1000, '18888888888', 2);
+INSERT INTO `user_login_account` (`id`, `uid`, `login_account`, `account_type`)
+VALUES ('13401bc84fcc27970a4dbc282d224333', 1000, 'admin@zhiqiyun.com', 1),
+       ('8604638900001fbee1de5551e67ea9e3', 1000, '18888888888', 2);
 
 
 DROP TABLE IF EXISTS `user_login_logs`;
-CREATE TABLE IF NOT EXISTS `user_login_logs` (
-    `id` bigint(20) NOT NULL AUTO_INCREMENT,
-    `login_account` varchar(50) NOT NULL,
-    `account_type` int(5) NOT NULL,
-    `login_ip` varchar(20) NOT NULL,
-    `login_local` varchar(100) NOT NULL,
-    `from_source` varchar(20) DEFAULT NULL,
-    `device_id` varchar(45) DEFAULT NULL COMMENT '登录的设备号',
-    `login_time` datetime NOT NULL,
-    `state` int(5) NOT NULL,
+CREATE TABLE IF NOT EXISTS `user_login_logs`
+(
+    `id`            bigint(20)   NOT NULL AUTO_INCREMENT,
+    `login_account` varchar(50)  NOT NULL,
+    `account_type`  int(5)       NOT NULL,
+    `login_ip`      varchar(20)  NOT NULL,
+    `login_local`   varchar(100) NOT NULL,
+    `from_source`   varchar(20) DEFAULT NULL,
+    `device_id`     varchar(45) DEFAULT NULL COMMENT '登录的设备号',
+    `login_time`    datetime     NOT NULL,
+    `state`         int(5)       NOT NULL,
     PRIMARY KEY (`id`),
     KEY `login_account_index` (`login_account`),
     KEY `account_type_index` (`account_type`),
@@ -143,55 +154,66 @@ CREATE TABLE IF NOT EXISTS `user_login_logs` (
     KEY `login_ip_index` (`login_ip`),
     KEY `login_time_index` (`login_time`),
     KEY `state_index` (`state`)
-    ) ENGINE=InnoDB AUTO_INCREMENT=406 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户登录日志';
+) ENGINE = InnoDB
+  AUTO_INCREMENT = 406
+  DEFAULT CHARSET = utf8mb4
+  COLLATE = utf8mb4_0900_ai_ci COMMENT ='用户登录日志';
 
 
 DROP TABLE IF EXISTS `user_operate_logs`;
-CREATE TABLE IF NOT EXISTS `user_operate_logs` (
-    `id` varchar(50) NOT NULL COMMENT '请请ID',
-    `uid` bigint(20) NOT NULL DEFAULT '0' COMMENT '用户ID',
-    `tags` varchar(100) DEFAULT NULL COMMENT '标签说明',
-    `from_source` varchar(20) DEFAULT NULL COMMENT '来源',
-    `request_url` varchar(200) NOT NULL COMMENT '请求地址',
-    `request_ip` varchar(50) NOT NULL COMMENT '请求IP地址',
-    `request_params` text NOT NULL COMMENT '请求参数',
-    `request_data` text NOT NULL COMMENT '请求主体参数',
-    `request_time` datetime NOT NULL COMMENT '请求时间',
-    `response_time` datetime DEFAULT NULL COMMENT '响应时间',
+CREATE TABLE IF NOT EXISTS `user_operate_logs`
+(
+    `id`             varchar(50)  NOT NULL COMMENT '请请ID',
+    `uid`            bigint(20)   NOT NULL DEFAULT '0' COMMENT '用户ID',
+    `tags`           varchar(100)          DEFAULT NULL COMMENT '标签说明',
+    `from_source`    varchar(20)           DEFAULT NULL COMMENT '来源',
+    `request_url`    varchar(200) NOT NULL COMMENT '请求地址',
+    `request_ip`     varchar(50)  NOT NULL COMMENT '请求IP地址',
+    `request_params` text         NOT NULL COMMENT '请求参数',
+    `request_data`   text         NOT NULL COMMENT '请求主体参数',
+    `request_time`   datetime     NOT NULL COMMENT '请求时间',
+    `response_time`  datetime              DEFAULT NULL COMMENT '响应时间',
     PRIMARY KEY (`id`),
     KEY `uid_index` (`uid`),
     KEY `request_time_index` (`request_time`),
     KEY `respone_time_index` (`response_time`)
-    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户操作日志';
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8mb4
+  COLLATE = utf8mb4_0900_ai_ci COMMENT ='用户操作日志';
 
 
 DROP TABLE IF EXISTS `user_password`;
-CREATE TABLE IF NOT EXISTS `user_password` (
-    `id` varchar(32) NOT NULL,
-    `uid` bigint(20) NOT NULL,
-    `passwd` varchar(50) NOT NULL,
-    `salt` varchar(8) NOT NULL,
-    `password_type` int(1) NOT NULL,
+CREATE TABLE IF NOT EXISTS `user_password`
+(
+    `id`            varchar(32) NOT NULL,
+    `uid`           bigint(20)  NOT NULL,
+    `passwd`        varchar(50) NOT NULL,
+    `salt`          varchar(8)  NOT NULL,
+    `password_type` int(1)      NOT NULL,
     PRIMARY KEY (`id`),
-    UNIQUE KEY `uid_type_unique` (`uid`,`password_type`),
+    UNIQUE KEY `uid_type_unique` (`uid`, `password_type`),
     KEY `uid_index` (`uid`),
     KEY `password_type_index` (`password_type`)
-    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户基本信息表';
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8mb4
+  COLLATE = utf8mb4_0900_ai_ci COMMENT ='用户基本信息表';
 
 
-INSERT INTO `user_password` (`id`, `uid`, `passwd`, `salt`, `password_type`) VALUES
-    ('f37011db6434955899ea64fb3ebe888f', 1000, '4257ff6ac1cd7c0dbb2f508efa6ebfc4', 'OcZII0zZ', 1);
+INSERT INTO `user_password` (`id`, `uid`, `passwd`, `salt`, `password_type`)
+VALUES ('f37011db6434955899ea64fb3ebe888f', 1000, '4257ff6ac1cd7c0dbb2f508efa6ebfc4', 'OcZII0zZ', 1);
 
 
 DROP TABLE IF EXISTS `user_role`;
-CREATE TABLE IF NOT EXISTS `user_role` (
-    `id` bigint(20) NOT NULL AUTO_INCREMENT,
-    `uid` bigint(20) NOT NULL,
+CREATE TABLE IF NOT EXISTS `user_role`
+(
+    `id`      bigint(20) NOT NULL AUTO_INCREMENT,
+    `uid`     bigint(20) NOT NULL,
     `role_id` bigint(20) NOT NULL,
     PRIMARY KEY (`id`),
     KEY `uid_index` (`uid`),
     KEY `role_id_index` (`role_id`)
-    ) ENGINE=InnoDB AUTO_INCREMENT=1040 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='管理平台用户与角色关联表';
+) ENGINE = InnoDB
+  AUTO_INCREMENT = 1040 COMMENT ='管理平台用户与角色关联表';
 
-INSERT INTO `user_role` (`id`, `uid`, `role_id`) VALUES
-    (1035, 1000, 1000);
+INSERT INTO `user_role` (`id`, `uid`, `role_id`)
+VALUES (1035, 1000, 1000);

+ 21 - 0
src/main/resources/db/migration/V1.0.1__app_key.sql

@@ -0,0 +1,21 @@
+REPLACE INTO `authority_info` (`id`, `parent_id`, `name`, `remark`)
+VALUES (1300, 0, 'app.key', 'AppKey管理'),
+       (1301, 1300, 'app.key.find', '查询'),
+       (1302, 1300, 'app.key.add', '添加'),
+       (1303, 1300, 'app.key.edit', '修改'),
+       (1304, 1300, 'app.key.disable', '禁用'),
+       (1305, 1300, 'app.key.enable', '启用');
+
+DROP TABLE IF EXISTS `app_key_info`;
+CREATE TABLE `app_key_info`
+(
+    `id`           VARCHAR(32)  NOT NULL,
+    `encrypt_key`  VARCHAR(64)  NOT NULL,
+    `remark`       VARCHAR(100) NOT NULL DEFAULT '',
+    `permissions`  TEXT         NULL     DEFAULT NULL,
+    `is_enable`    INT(1)       NOT NULL,
+    `created_time` DATETIME   NOT NULL,
+    PRIMARY KEY (`id`),
+    KEY `is_enable_index` (`is_enable`),
+    KEY `created_time_index` (`created_time`)
+) ENGINE = InnoDB;