diff --git a/README.md b/README.md index 0b2319e6..5827e91e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ Snowy谐音“小诺”,恰应小诺团队名称;意思为”下雪的、纯

+ + bootstrap + Gitee star diff --git a/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/enums/AuthExceptionEnum.java b/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/enums/AuthExceptionEnum.java index 7753b20f..37516593 100644 --- a/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/enums/AuthExceptionEnum.java +++ b/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/enums/AuthExceptionEnum.java @@ -29,6 +29,9 @@ public enum AuthExceptionEnum { /** 验证码请求号不能为空 */ VALID_CODE_REQ_NO_EMPTY("验证码请求号不能为空"), + /** 验证码过期 */ + VALID_CODE_EXPIRED("验证码过期"), + /** 验证码错误 */ VALID_CODE_ERROR("验证码错误"), diff --git a/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/service/impl/AuthServiceImpl.java b/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/service/impl/AuthServiceImpl.java index 9ab1f3d8..7a33d078 100644 --- a/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/service/impl/AuthServiceImpl.java +++ b/snowy-plugin/snowy-plugin-auth/src/main/java/vip/xiaonuo/auth/modular/login/service/impl/AuthServiceImpl.java @@ -327,11 +327,15 @@ public class AuthServiceImpl implements AuthService { // 手机或者邮箱验证码 existValidCode = commonCacheOperator.get(AUTH_VALID_CODE_CACHE_KEY + phoneOrEmail + StrUtil.UNDERLINE + validCodeReqNo); } - // 为空则直接验证码错误 - if(ObjectUtil.isEmpty(existValidCode)) { + // 缓存中不存在验证码则返回失效错误 + if (ObjectUtil.isEmpty(existValidCode)){ + throw new CommonException(AuthExceptionEnum.VALID_CODE_EXPIRED.getValue()); + } + // 不一致则直接验证码错误 + if (!validCode.equalsIgnoreCase(Convert.toStr(existValidCode))) { throw new CommonException(AuthExceptionEnum.VALID_CODE_ERROR.getValue()); } - // 移除该验证码 + // 验证成功,移除该验证码 if(ObjectUtil.isEmpty(phoneOrEmail)) { // 图形验证码 commonCacheOperator.remove(AUTH_VALID_CODE_CACHE_KEY + validCodeReqNo); @@ -339,10 +343,6 @@ public class AuthServiceImpl implements AuthService { // 手机或者邮箱验证码 commonCacheOperator.remove(AUTH_VALID_CODE_CACHE_KEY + phoneOrEmail + StrUtil.UNDERLINE + validCodeReqNo); } - // 不一致则直接验证码错误 - if (!validCode.equalsIgnoreCase(Convert.toStr(existValidCode))) { - throw new CommonException("验证码错误"); - } } /** diff --git a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/COMPLETED.png b/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/COMPLETED.png deleted file mode 100644 index 1ba0eb11..00000000 Binary files a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/COMPLETED.png and /dev/null differ diff --git a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/END.png b/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/END.png deleted file mode 100644 index 7877da5f..00000000 Binary files a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/END.png and /dev/null differ diff --git a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/REJECT.png b/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/REJECT.png deleted file mode 100644 index d0d9e28c..00000000 Binary files a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/REJECT.png and /dev/null differ diff --git a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/REVOKE.png b/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/REVOKE.png deleted file mode 100644 index dbdc08ac..00000000 Binary files a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/REVOKE.png and /dev/null differ diff --git a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/SUSPENDED.png b/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/SUSPENDED.png deleted file mode 100644 index 5ee4aec4..00000000 Binary files a/snowy-plugin/snowy-plugin-mobile/src/main/resources/static/mobile/flw/SUSPENDED.png and /dev/null differ diff --git a/snowy-web-app/src/main/java/vip/xiaonuo/core/config/JacksonConfig.java b/snowy-web-app/src/main/java/vip/xiaonuo/core/config/JacksonConfigure.java similarity index 97% rename from snowy-web-app/src/main/java/vip/xiaonuo/core/config/JacksonConfig.java rename to snowy-web-app/src/main/java/vip/xiaonuo/core/config/JacksonConfigure.java index 90164e26..14b4a29b 100644 --- a/snowy-web-app/src/main/java/vip/xiaonuo/core/config/JacksonConfig.java +++ b/snowy-web-app/src/main/java/vip/xiaonuo/core/config/JacksonConfigure.java @@ -1,165 +1,165 @@ -package vip.xiaonuo.core.config; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonStreamContext; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -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 org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Date; -import java.util.Map; - -/** - * Jackson序列化配置 - * 用于处理返回结果null值改为类型初始值等问题 - */ -@Configuration -public class JacksonConfig { - - private static final ThreadLocal IS_APP_REQUEST = ThreadLocal.withInitial(() -> false); - - @Bean - @Primary - @ConditionalOnMissingBean(ObjectMapper.class) - public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { - ObjectMapper objectMapper = builder.createXmlMapper(false).build(); - - objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer() { - @Override - public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { - // 若是APP端请求,则处理响应结果字段默认值 - if (IS_APP_REQUEST.get()) { - handleNullValue(gen); - } else { - gen.writeNull(); - } - } - - private void handleNullValue(JsonGenerator gen) throws IOException { - JsonStreamContext context = gen.getOutputContext(); - if (context.inObject()) { - String fieldName = context.getCurrentName(); - Object currentObj = context.getCurrentValue(); - if (currentObj != null) { - Class clazz = currentObj.getClass(); - Field field = getField(clazz, fieldName); - if (field != null) { - setDefaultByType(field.getType(), gen); - return; - } - } - } - // 默认处理 - gen.writeString(""); - } - - private Field getField(Class clazz, String fieldName) { - try { - Field field = clazz.getDeclaredField(fieldName); - field.setAccessible(true); - return field; - } catch (NoSuchFieldException e) { - // 查找父类字段 - Class superClass = clazz.getSuperclass(); - while (superClass != null) { - try { - Field field = superClass.getDeclaredField(fieldName); - field.setAccessible(true); - return field; - } catch (NoSuchFieldException ex) { - superClass = superClass.getSuperclass(); - } - } - } - return null; - } - - private void setDefaultByType(Class type, JsonGenerator gen) throws IOException { - if (type.isPrimitive()) { - handlePrimitive(type, gen); - } else if (type == String.class) { - gen.writeString(""); - } else if (Number.class.isAssignableFrom(type)) { - gen.writeNumber(0); - } else if (type == Boolean.class) { - gen.writeBoolean(false); - } else if (type == Date.class) { - gen.writeString(""); - } else if (type.isArray() || Collection.class.isAssignableFrom(type)) { - gen.writeStartArray(); - gen.writeEndArray(); - } else if (Map.class.isAssignableFrom(type)) { - gen.writeStartObject(); - gen.writeEndObject(); - } else { - gen.writeStartObject(); - gen.writeEndObject(); - } - } - - private void handlePrimitive(Class type, JsonGenerator gen) throws IOException { - if (type == int.class) { - gen.writeNumber(0); - } else if (type == long.class) { - gen.writeNumber(0L); - } else if (type == double.class) { - gen.writeNumber(0.0); - } else if (type == float.class) { - gen.writeNumber(0.0f); - } else if (type == boolean.class) { - gen.writeBoolean(false); - } else if (type == char.class) { - gen.writeString(String.valueOf('\0')); - } else { - gen.writeNull(); - } - } - }); - - return objectMapper; - } - - @Bean - public WebMvcConfigurer webMvcConfigurer() { - return new WebMvcConfigurer() { - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(new HandlerInterceptor() { - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { - IS_APP_REQUEST.set(isAppRequest(request)); - return true; - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { - IS_APP_REQUEST.remove(); - } - }); - } - }; - } - - /** - * 判断是否为移动端请求 - * path根据自己项目的实际路径进行判断 - */ - private boolean isAppRequest(HttpServletRequest request) { - String path = request.getRequestURI(); - String userAgent = request.getHeader("User-Agent"); - return path.startsWith("/client/c/app/") || path.startsWith("/auth/c/"); - } -} +package vip.xiaonuo.core.config; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonStreamContext; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +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 org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Date; +import java.util.Map; + +/** + * Jackson序列化配置 + * 用于处理返回结果null值改为类型初始值等问题 + */ +@Configuration +public class JacksonConfigure { + + private static final ThreadLocal IS_APP_REQUEST = ThreadLocal.withInitial(() -> false); + + @Bean + @Primary + @ConditionalOnMissingBean(ObjectMapper.class) + public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { + ObjectMapper objectMapper = builder.createXmlMapper(false).build(); + + objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer() { + @Override + public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { + // 若是APP端请求,则处理响应结果字段默认值 + if (IS_APP_REQUEST.get()) { + handleNullValue(gen); + } else { + gen.writeNull(); + } + } + + private void handleNullValue(JsonGenerator gen) throws IOException { + JsonStreamContext context = gen.getOutputContext(); + if (context.inObject()) { + String fieldName = context.getCurrentName(); + Object currentObj = context.getCurrentValue(); + if (currentObj != null) { + Class clazz = currentObj.getClass(); + Field field = getField(clazz, fieldName); + if (field != null) { + setDefaultByType(field.getType(), gen); + return; + } + } + } + // 默认处理 + gen.writeString(""); + } + + private Field getField(Class clazz, String fieldName) { + try { + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return field; + } catch (NoSuchFieldException e) { + // 查找父类字段 + Class superClass = clazz.getSuperclass(); + while (superClass != null) { + try { + Field field = superClass.getDeclaredField(fieldName); + field.setAccessible(true); + return field; + } catch (NoSuchFieldException ex) { + superClass = superClass.getSuperclass(); + } + } + } + return null; + } + + private void setDefaultByType(Class type, JsonGenerator gen) throws IOException { + if (type.isPrimitive()) { + handlePrimitive(type, gen); + } else if (type == String.class) { + gen.writeString(""); + } else if (Number.class.isAssignableFrom(type)) { + gen.writeNumber(0); + } else if (type == Boolean.class) { + gen.writeBoolean(false); + } else if (type == Date.class) { + gen.writeString(""); + } else if (type.isArray() || Collection.class.isAssignableFrom(type)) { + gen.writeStartArray(); + gen.writeEndArray(); + } else if (Map.class.isAssignableFrom(type)) { + gen.writeStartObject(); + gen.writeEndObject(); + } else { + gen.writeStartObject(); + gen.writeEndObject(); + } + } + + private void handlePrimitive(Class type, JsonGenerator gen) throws IOException { + if (type == int.class) { + gen.writeNumber(0); + } else if (type == long.class) { + gen.writeNumber(0L); + } else if (type == double.class) { + gen.writeNumber(0.0); + } else if (type == float.class) { + gen.writeNumber(0.0f); + } else if (type == boolean.class) { + gen.writeBoolean(false); + } else if (type == char.class) { + gen.writeString(String.valueOf('\0')); + } else { + gen.writeNull(); + } + } + }); + + return objectMapper; + } + + @Bean + public WebMvcConfigurer webMvcConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new HandlerInterceptor() { + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + IS_APP_REQUEST.set(isAppRequest(request)); + return true; + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { + IS_APP_REQUEST.remove(); + } + }); + } + }; + } + + /** + * 判断是否为移动端请求 + * path根据自己项目的实际路径进行判断 + */ + private boolean isAppRequest(HttpServletRequest request) { + String path = request.getRequestURI(); + String userAgent = request.getHeader("User-Agent"); + return path.startsWith("/client/c/app/") || path.startsWith("/auth/c/"); + } +} diff --git a/snowy-web-app/src/main/resources/_sql/snowy_mysql.sql b/snowy-web-app/src/main/resources/_sql/snowy_mysql.sql index f9533061..5d067fa4 100644 --- a/snowy-web-app/src/main/resources/_sql/snowy_mysql.sql +++ b/snowy-web-app/src/main/resources/_sql/snowy_mysql.sql @@ -895,7 +895,7 @@ CREATE TABLE `MOBILE_RESOURCE` ( INSERT INTO `MOBILE_RESOURCE` VALUES ('1623380023993298945', NULL, '业务', '217gcp9ifi', 'MODULE', NULL, NULL, NULL, 'container-outlined', '#1890ff', NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('1623380258656219138', '0', '机构管理', 'UJ3Iwy3jsW', 'MENU', '1623380023993298945', 'MENU', '/pages/biz/org/index', 'apartment-outlined', '#1890ff', 'YES', 'ENABLE', 0, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('1623380614295449601', '0', '岗位管理', 'sjIY9oGYir', 'MENU', '1623380023993298945', 'MENU', '/pages/biz/position/index', 'robot-outlined', '#9c28b1', 'YES', 'ENABLE', 2, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); -INSERT INTO `MOBILE_RESOURCE` VALUES ('1623380765202313218', '0', '人员管理', 'sjIY9oGYir', 'MENU', '1623380023993298945', 'MENU', '/pages/biz/user/index', 'team-outlined', '#fed835', 'YES', 'ENABLE', 4, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); +INSERT INTO `MOBILE_RESOURCE` VALUES ('1623380765202313218', '0', '人员管理', '2ppITl9dMw', 'MENU', '1623380023993298945', 'MENU', '/pages/biz/user/index', 'team-outlined', '#fed835', 'YES', 'ENABLE', 4, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('1623381127095250946', '0', '更多', 'mFVJNzE7gx', 'MENU', '1623380023993298945', 'CATALOG', '7029146815941316608', 'small-dash-outlined', '#f1627e', 'YES', 'ENABLE', 7, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('1623381298801668098', '1623380258656219138', '新增机构', 'mobileBizOrgAdd', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('1623381632131395586', '1623380258656219138', '编辑机构', 'mobileBizOrgEdit', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); diff --git a/snowy-web-app/src/main/resources/application.properties b/snowy-web-app/src/main/resources/application.properties index 7341fe54..35fa6054 100644 --- a/snowy-web-app/src/main/resources/application.properties +++ b/snowy-web-app/src/main/resources/application.properties @@ -84,6 +84,7 @@ spring.datasource.dynamic.druid.validation-query-timeout=2000 spring.datasource.dynamic.druid.test-on-borrow=false spring.datasource.dynamic.druid.test-on-return=false spring.datasource.dynamic.druid.test-while-idle=true +spring.datasource.dynamic.druid.validation-query=SELECT 1 spring.datasource.dynamic.druid.time-between-eviction-runs-millis=6000 spring.datasource.dynamic.druid.min-evictable-idle-time-millis=300000 spring.datasource.dynamic.druid.filters=stat