master
WeiRan 2024-08-12 19:19:25 +08:00
commit b7196964a0
108 changed files with 5764 additions and 0 deletions

38
.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AnalysisProjectProfileManager">
<option name="PROJECT_PROFILE" />
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
<list size="0" />
</component>
<component name="SuppressionsComponent">
<option name="suppComments" value="[]" />
</component>
</project>

8
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-modules/bwie-coupon/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-modules/bwie-es/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-modules/bwie-mq/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-modules/bwie-user/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-modules/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-modules/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,46 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AbstractBeanReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="ConfigurationProperties" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="ContextComponentScanInconsistencyInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="ContextJavaBeanUnresolvedMethodsInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="InjectionValueTypeInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="JdkProxiedBeanTypeInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="RequiredBeanTypeInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringAopErrorsInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringAopPointcutExpressionInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringBeanConstructorArgInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringBeanInstantiationInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringBeanLookupMethodInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringBootAdditionalConfig" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringBootApplicationSetup" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringBootBootstrapConfigurationInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringCacheableComponentsInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringComponentScan" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringConfigurationProxyMethods" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringContextConfigurationInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringDataMongoDBJsonFieldInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringDependsOnUnresolvedBeanInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringFacetProgrammaticInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringFactoryMethodInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringHandlersSchemasHighlighting" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringIncorrectResourceTypeInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringInjectionValueConsistencyInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringIntegrationModel" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringJavaAutowiredFieldsWarningInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringJavaInjectionPointsAutowiringInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringLookupInjectionInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringMVCInitBinder" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringProfileExpression" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringRequiredAnnotationInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringRequiredPropertyInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringScopesInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringSecurityAnnotationBeanPointersResolveInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringSecurityModelInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringTransactionalComponentInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringXmlAutowiringInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="SpringXmlModelInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="UtilSchemaInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
</profile>
</component>

23
.idea/misc.xml 100644
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FindBugsConfigurable">
<option name="make" value="true" />
<option name="effort" value="default" />
<option name="priority" value="Medium" />
<option name="excludeFilter" value="" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SuppressionsComponent">
<option name="suppComments" value="[]" />
</component>
</project>

View File

@ -0,0 +1,465 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AnalysisProjectProfileManager">
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
<scopes />
<profiles>
<profile profile_name="Project Default" version="1.0" is_locked="false">
<coding_rule class="AM_CREATES_EMPTY_JAR_FILE_ENTRY" level="MAJOR" enabled="true" />
<coding_rule class="AM_CREATES_EMPTY_ZIP_FILE_ENTRY" level="MAJOR" enabled="true" />
<coding_rule class="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION" level="CRITICAL" enabled="false" />
<coding_rule class="BAC_BAD_APPLET_CONSTRUCTOR" level="MAJOR" enabled="false" />
<coding_rule class="BC_BAD_CAST_TO_ABSTRACT_COLLECTION" level="MAJOR" enabled="true" />
<coding_rule class="BC_BAD_CAST_TO_CONCRETE_COLLECTION" level="CRITICAL" enabled="true" />
<coding_rule class="BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS" level="CRITICAL" enabled="true" />
<coding_rule class="BC_IMPOSSIBLE_CAST" level="BLOCKER" enabled="true" />
<coding_rule class="BC_IMPOSSIBLE_DOWNCAST" level="MAJOR" enabled="false" />
<coding_rule class="BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY" level="MAJOR" enabled="false" />
<coding_rule class="BC_IMPOSSIBLE_INSTANCEOF" level="CRITICAL" enabled="true" />
<coding_rule class="BC_UNCONFIRMED_CAST" level="CRITICAL" enabled="true" />
<coding_rule class="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" level="CRITICAL" enabled="false" />
<coding_rule class="BC_VACUOUS_INSTANCEOF" level="CRITICAL" enabled="true" />
<coding_rule class="BIT_ADD_OF_SIGNED_BYTE" level="CRITICAL" enabled="true" />
<coding_rule class="BIT_AND" level="CRITICAL" enabled="true" />
<coding_rule class="BIT_AND_ZZ" level="CRITICAL" enabled="true" />
<coding_rule class="BIT_IOR" level="CRITICAL" enabled="true" />
<coding_rule class="BIT_IOR_OF_SIGNED_BYTE" level="CRITICAL" enabled="true" />
<coding_rule class="BIT_SIGNED_CHECK" level="CRITICAL" enabled="true" />
<coding_rule class="BIT_SIGNED_CHECK_HIGH_BIT" level="CRITICAL" enabled="true" />
<coding_rule class="BOA_BADLY_OVERRIDDEN_ADAPTER" level="CRITICAL" enabled="true" />
<coding_rule class="BSHIFT_WRONG_ADD_PRIORITY" level="MAJOR" enabled="false" />
<coding_rule class="BX_BOXING_IMMEDIATELY_UNBOXED" level="MAJOR" enabled="true" />
<coding_rule class="BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION" level="MAJOR" enabled="true" />
<coding_rule class="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR" level="MAJOR" enabled="true" />
<coding_rule class="BX_UNBOXING_IMMEDIATELY_REBOXED" level="CRITICAL" enabled="false" />
<coding_rule class="CAA_COVARIANT_ARRAY_ELEMENT_STORE" level="MAJOR" enabled="false" />
<coding_rule class="CAA_COVARIANT_ARRAY_FIELD" level="MAJOR" enabled="false" />
<coding_rule class="CAA_COVARIANT_ARRAY_LOCAL" level="MAJOR" enabled="false" />
<coding_rule class="CAA_COVARIANT_ARRAY_RETURN" level="MAJOR" enabled="false" />
<coding_rule class="CD_CIRCULAR_DEPENDENCY" level="MAJOR" enabled="false" />
<coding_rule class="CI_CONFUSED_INHERITANCE" level="MINOR" enabled="true" />
<coding_rule class="CNT_ROUGH_CONSTANT_VALUE" level="MAJOR" enabled="false" />
<coding_rule class="CN_IDIOM" level="MAJOR" enabled="true" />
<coding_rule class="CN_IDIOM_NO_SUPER_CALL" level="MAJOR" enabled="true" />
<coding_rule class="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE" level="MAJOR" enabled="true" />
<coding_rule class="CO_ABSTRACT_SELF" level="MAJOR" enabled="true" />
<coding_rule class="CO_COMPARETO_INCORRECT_FLOATING" level="MAJOR" enabled="false" />
<coding_rule class="CO_COMPARETO_RESULTS_MIN_VALUE" level="CRITICAL" enabled="false" />
<coding_rule class="CO_SELF_NO_OBJECT" level="MAJOR" enabled="true" />
<coding_rule class="DB_DUPLICATE_BRANCHES" level="CRITICAL" enabled="true" />
<coding_rule class="DB_DUPLICATE_SWITCH_CLAUSES" level="CRITICAL" enabled="true" />
<coding_rule class="DC_DOUBLECHECK" level="MAJOR" enabled="true" />
<coding_rule class="DC_PARTIALLY_CONSTRUCTED" level="MAJOR" enabled="false" />
<coding_rule class="DE_MIGHT_DROP" level="MAJOR" enabled="true" />
<coding_rule class="DE_MIGHT_IGNORE" level="MAJOR" enabled="true" />
<coding_rule class="DLS_DEAD_LOCAL_INCREMENT_IN_RETURN" level="MAJOR" enabled="false" />
<coding_rule class="DLS_DEAD_LOCAL_STORE" level="CRITICAL" enabled="true" />
<coding_rule class="DLS_DEAD_LOCAL_STORE_IN_RETURN" level="CRITICAL" enabled="true" />
<coding_rule class="DLS_DEAD_LOCAL_STORE_OF_NULL" level="CRITICAL" enabled="true" />
<coding_rule class="DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD" level="CRITICAL" enabled="false" />
<coding_rule class="DLS_DEAD_STORE_OF_CLASS_LITERAL" level="CRITICAL" enabled="true" />
<coding_rule class="DLS_OVERWRITTEN_INCREMENT" level="CRITICAL" enabled="true" />
<coding_rule class="DL_SYNCHRONIZATION_ON_BOOLEAN" level="CRITICAL" enabled="true" />
<coding_rule class="DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE" level="CRITICAL" enabled="true" />
<coding_rule class="DL_SYNCHRONIZATION_ON_SHARED_CONSTANT" level="CRITICAL" enabled="true" />
<coding_rule class="DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION" level="MAJOR" enabled="true" />
<coding_rule class="DMI_ARGUMENTS_WRONG_ORDER" level="CRITICAL" enabled="false" />
<coding_rule class="DMI_BAD_MONTH" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE" level="CRITICAL" enabled="false" />
<coding_rule class="DMI_BLOCKING_METHODS_ON_URL" level="BLOCKER" enabled="true" />
<coding_rule class="DMI_CALLING_NEXT_FROM_HASNEXT" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_COLLECTION_OF_URLS" level="BLOCKER" enabled="true" />
<coding_rule class="DMI_CONSTANT_DB_PASSWORD" level="BLOCKER" enabled="true" />
<coding_rule class="DMI_DOH" level="CRITICAL" enabled="false" />
<coding_rule class="DMI_EMPTY_DB_PASSWORD" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS" level="CRITICAL" enabled="false" />
<coding_rule class="DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR" level="MINOR" enabled="true" />
<coding_rule class="DMI_HARDCODED_ABSOLUTE_FILENAME" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_INVOKING_HASHCODE_ON_ARRAY" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_INVOKING_TOSTRING_ON_ARRAY" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_NONSERIALIZABLE_OBJECT_WRITTEN" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_RANDOM_USED_ONLY_ONCE" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS" level="MINOR" enabled="true" />
<coding_rule class="DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED" level="MAJOR" enabled="true" />
<coding_rule class="DMI_UNSUPPORTED_METHOD" level="MAJOR" enabled="true" />
<coding_rule class="DMI_USELESS_SUBSTRING" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION" level="CRITICAL" enabled="true" />
<coding_rule class="DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD" level="MINOR" enabled="true" />
<coding_rule class="DMI_VACUOUS_SELF_COLLECTION_CALL" level="CRITICAL" enabled="true" />
<coding_rule class="DM_BOOLEAN_CTOR" level="MAJOR" enabled="true" />
<coding_rule class="DM_BOXED_PRIMITIVE_FOR_COMPARE" level="MAJOR" enabled="false" />
<coding_rule class="DM_BOXED_PRIMITIVE_FOR_PARSING" level="MAJOR" enabled="false" />
<coding_rule class="DM_BOXED_PRIMITIVE_TOSTRING" level="MAJOR" enabled="true" />
<coding_rule class="DM_CONVERT_CASE" level="INFO" enabled="true" />
<coding_rule class="DM_DEFAULT_ENCODING" level="CRITICAL" enabled="false" />
<coding_rule class="DM_EXIT" level="MAJOR" enabled="true" />
<coding_rule class="DM_FP_NUMBER_CTOR" level="MAJOR" enabled="true" />
<coding_rule class="DM_GC" level="MAJOR" enabled="true" />
<coding_rule class="DM_INVALID_MIN_MAX" level="MAJOR" enabled="false" />
<coding_rule class="DM_MONITOR_WAIT_ON_CONDITION" level="MAJOR" enabled="true" />
<coding_rule class="DM_NEW_FOR_GETCLASS" level="MAJOR" enabled="true" />
<coding_rule class="DM_NEXTINT_VIA_NEXTDOUBLE" level="MAJOR" enabled="true" />
<coding_rule class="DM_NUMBER_CTOR" level="CRITICAL" enabled="true" />
<coding_rule class="DM_RUN_FINALIZERS_ON_EXIT" level="MAJOR" enabled="true" />
<coding_rule class="DM_STRING_CTOR" level="MAJOR" enabled="true" />
<coding_rule class="DM_STRING_TOSTRING" level="INFO" enabled="true" />
<coding_rule class="DM_STRING_VOID_CTOR" level="MAJOR" enabled="true" />
<coding_rule class="DM_USELESS_THREAD" level="MAJOR" enabled="true" />
<coding_rule class="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED" level="MAJOR" enabled="true" />
<coding_rule class="DP_DO_INSIDE_DO_PRIVILEGED" level="MAJOR" enabled="true" />
<coding_rule class="EC_ARRAY_AND_NONARRAY" level="CRITICAL" enabled="true" />
<coding_rule class="EC_BAD_ARRAY_COMPARE" level="CRITICAL" enabled="true" />
<coding_rule class="EC_INCOMPATIBLE_ARRAY_COMPARE" level="MAJOR" enabled="false" />
<coding_rule class="EC_NULL_ARG" level="CRITICAL" enabled="true" />
<coding_rule class="EC_UNRELATED_CLASS_AND_INTERFACE" level="CRITICAL" enabled="true" />
<coding_rule class="EC_UNRELATED_INTERFACES" level="CRITICAL" enabled="true" />
<coding_rule class="EC_UNRELATED_TYPES" level="CRITICAL" enabled="true" />
<coding_rule class="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY" level="CRITICAL" enabled="true" />
<coding_rule class="EI_EXPOSE_REP" level="MAJOR" enabled="true" />
<coding_rule class="EI_EXPOSE_REP2" level="MAJOR" enabled="true" />
<coding_rule class="EI_EXPOSE_STATIC_REP2" level="MAJOR" enabled="true" />
<coding_rule class="EQ_ABSTRACT_SELF" level="MAJOR" enabled="true" />
<coding_rule class="EQ_ALWAYS_FALSE" level="BLOCKER" enabled="true" />
<coding_rule class="EQ_ALWAYS_TRUE" level="BLOCKER" enabled="true" />
<coding_rule class="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS" level="MAJOR" enabled="true" />
<coding_rule class="EQ_COMPARETO_USE_OBJECT_EQUALS" level="CRITICAL" enabled="true" />
<coding_rule class="EQ_COMPARING_CLASS_NAMES" level="MAJOR" enabled="true" />
<coding_rule class="EQ_DOESNT_OVERRIDE_EQUALS" level="MAJOR" enabled="false" />
<coding_rule class="EQ_DONT_DEFINE_EQUALS_FOR_ENUM" level="MAJOR" enabled="true" />
<coding_rule class="EQ_GETCLASS_AND_CLASS_CONSTANT" level="CRITICAL" enabled="true" />
<coding_rule class="EQ_OTHER_NO_OBJECT" level="MAJOR" enabled="true" />
<coding_rule class="EQ_OTHER_USE_OBJECT" level="MAJOR" enabled="true" />
<coding_rule class="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC" level="MAJOR" enabled="true" />
<coding_rule class="EQ_SELF_NO_OBJECT" level="MAJOR" enabled="true" />
<coding_rule class="EQ_SELF_USE_OBJECT" level="MAJOR" enabled="true" />
<coding_rule class="EQ_UNUSUAL" level="MINOR" enabled="true" />
<coding_rule class="ES_COMPARING_PARAMETER_STRING_WITH_EQ" level="MAJOR" enabled="true" />
<coding_rule class="ES_COMPARING_STRINGS_WITH_EQ" level="MAJOR" enabled="true" />
<coding_rule class="ESync_EMPTY_SYNC" level="MAJOR" enabled="true" />
<coding_rule class="FB_MISSING_EXPECTED_WARNING" level="CRITICAL" enabled="false" />
<coding_rule class="FB_UNEXPECTED_WARNING" level="CRITICAL" enabled="false" />
<coding_rule class="FE_FLOATING_POINT_EQUALITY" level="CRITICAL" enabled="true" />
<coding_rule class="FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER" level="CRITICAL" enabled="true" />
<coding_rule class="FI_EMPTY" level="MAJOR" enabled="true" />
<coding_rule class="FI_EXPLICIT_INVOCATION" level="MAJOR" enabled="true" />
<coding_rule class="FI_FINALIZER_NULLS_FIELDS" level="MAJOR" enabled="true" />
<coding_rule class="FI_FINALIZER_ONLY_NULLS_FIELDS" level="MAJOR" enabled="true" />
<coding_rule class="FI_MISSING_SUPER_CALL" level="MAJOR" enabled="true" />
<coding_rule class="FI_NULLIFY_SUPER" level="CRITICAL" enabled="true" />
<coding_rule class="FI_PUBLIC_SHOULD_BE_PROTECTED" level="MAJOR" enabled="true" />
<coding_rule class="FI_USELESS" level="MINOR" enabled="true" />
<coding_rule class="FL_MATH_USING_FLOAT_PRECISION" level="CRITICAL" enabled="true" />
<coding_rule class="GC_UNCHECKED_TYPE_IN_GENERIC_CALL" level="CRITICAL" enabled="true" />
<coding_rule class="GC_UNRELATED_TYPES" level="CRITICAL" enabled="true" />
<coding_rule class="HE_EQUALS_NO_HASHCODE" level="MAJOR" enabled="true" />
<coding_rule class="HE_EQUALS_USE_HASHCODE" level="CRITICAL" enabled="true" />
<coding_rule class="HE_HASHCODE_NO_EQUALS" level="CRITICAL" enabled="true" />
<coding_rule class="HE_HASHCODE_USE_OBJECT_EQUALS" level="CRITICAL" enabled="true" />
<coding_rule class="HE_INHERITS_EQUALS_USE_HASHCODE" level="CRITICAL" enabled="true" />
<coding_rule class="HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS" level="CRITICAL" enabled="true" />
<coding_rule class="HE_USE_OF_UNHASHABLE_CLASS" level="CRITICAL" enabled="true" />
<coding_rule class="HRS_REQUEST_PARAMETER_TO_COOKIE" level="MAJOR" enabled="true" />
<coding_rule class="HRS_REQUEST_PARAMETER_TO_HTTP_HEADER" level="MAJOR" enabled="true" />
<coding_rule class="HSC_HUGE_SHARED_STRING_CONSTANT" level="CRITICAL" enabled="true" />
<coding_rule class="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD" level="MAJOR" enabled="true" />
<coding_rule class="ICAST_BAD_SHIFT_AMOUNT" level="CRITICAL" enabled="true" />
<coding_rule class="ICAST_IDIV_CAST_TO_DOUBLE" level="CRITICAL" enabled="true" />
<coding_rule class="ICAST_INTEGER_MULTIPLY_CAST_TO_LONG" level="CRITICAL" enabled="true" />
<coding_rule class="ICAST_INT_2_LONG_AS_INSTANT" level="CRITICAL" enabled="false" />
<coding_rule class="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL" level="CRITICAL" enabled="true" />
<coding_rule class="ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND" level="CRITICAL" enabled="true" />
<coding_rule class="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT" level="CRITICAL" enabled="true" />
<coding_rule class="IC_INIT_CIRCULARITY" level="CRITICAL" enabled="true" />
<coding_rule class="IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION" level="MAJOR" enabled="true" />
<coding_rule class="IIL_ELEMENTS_GET_LENGTH_IN_LOOP" level="MAJOR" enabled="false" />
<coding_rule class="IIL_PATTERN_COMPILE_IN_LOOP" level="MAJOR" enabled="false" />
<coding_rule class="IIL_PATTERN_COMPILE_IN_LOOP_INDIRECT" level="MAJOR" enabled="false" />
<coding_rule class="IIL_PREPARE_STATEMENT_IN_LOOP" level="MAJOR" enabled="false" />
<coding_rule class="IIO_INEFFICIENT_INDEX_OF" level="MAJOR" enabled="false" />
<coding_rule class="IIO_INEFFICIENT_LAST_INDEX_OF" level="MAJOR" enabled="false" />
<coding_rule class="IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD" level="CRITICAL" enabled="true" />
<coding_rule class="IJU_BAD_SUITE_METHOD" level="CRITICAL" enabled="true" />
<coding_rule class="IJU_NO_TESTS" level="CRITICAL" enabled="true" />
<coding_rule class="IJU_SETUP_NO_SUPER" level="CRITICAL" enabled="true" />
<coding_rule class="IJU_SUITE_NOT_STATIC" level="CRITICAL" enabled="true" />
<coding_rule class="IJU_TEARDOWN_NO_SUPER" level="CRITICAL" enabled="true" />
<coding_rule class="IL_CONTAINER_ADDED_TO_ITSELF" level="CRITICAL" enabled="true" />
<coding_rule class="IL_INFINITE_LOOP" level="CRITICAL" enabled="true" />
<coding_rule class="IL_INFINITE_RECURSIVE_LOOP" level="CRITICAL" enabled="true" />
<coding_rule class="IMA_INEFFICIENT_MEMBER_ACCESS" level="MAJOR" enabled="false" />
<coding_rule class="IMSE_DONT_CATCH_IMSE" level="MAJOR" enabled="true" />
<coding_rule class="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW" level="CRITICAL" enabled="true" />
<coding_rule class="IM_BAD_CHECK_FOR_ODD" level="CRITICAL" enabled="true" />
<coding_rule class="IM_MULTIPLYING_RESULT_OF_IREM" level="CRITICAL" enabled="true" />
<coding_rule class="INT_BAD_COMPARISON_WITH_INT_VALUE" level="CRITICAL" enabled="false" />
<coding_rule class="INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE" level="CRITICAL" enabled="true" />
<coding_rule class="INT_BAD_COMPARISON_WITH_SIGNED_BYTE" level="CRITICAL" enabled="true" />
<coding_rule class="INT_BAD_REM_BY_1" level="CRITICAL" enabled="true" />
<coding_rule class="INT_VACUOUS_BIT_OPERATION" level="CRITICAL" enabled="true" />
<coding_rule class="INT_VACUOUS_COMPARISON" level="CRITICAL" enabled="true" />
<coding_rule class="IO_APPENDING_TO_OBJECT_OUTPUT_STREAM" level="CRITICAL" enabled="true" />
<coding_rule class="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN" level="CRITICAL" enabled="true" />
<coding_rule class="IS2_INCONSISTENT_SYNC" level="CRITICAL" enabled="true" />
<coding_rule class="ISC_INSTANTIATE_STATIC_CLASS" level="MAJOR" enabled="true" />
<coding_rule class="IS_FIELD_NOT_GUARDED" level="CRITICAL" enabled="true" />
<coding_rule class="ITA_INEFFICIENT_TO_ARRAY" level="CRITICAL" enabled="true" />
<coding_rule class="IT_NO_SUCH_ELEMENT" level="MINOR" enabled="true" />
<coding_rule class="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION" level="CRITICAL" enabled="true" />
<coding_rule class="JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS" level="MINOR" enabled="true" />
<coding_rule class="JLM_JSR166_LOCK_MONITORENTER" level="CRITICAL" enabled="true" />
<coding_rule class="JLM_JSR166_UTILCONCURRENT_MONITORENTER" level="CRITICAL" enabled="false" />
<coding_rule class="JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT" level="CRITICAL" enabled="false" />
<coding_rule class="LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE" level="MAJOR" enabled="false" />
<coding_rule class="LI_LAZY_INIT_STATIC" level="CRITICAL" enabled="true" />
<coding_rule class="LI_LAZY_INIT_UPDATE_STATIC" level="CRITICAL" enabled="true" />
<coding_rule class="ME_ENUM_FIELD_SETTER" level="MAJOR" enabled="false" />
<coding_rule class="ME_MUTABLE_ENUM_FIELD" level="MAJOR" enabled="false" />
<coding_rule class="MF_CLASS_MASKS_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="MF_METHOD_MASKS_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="ML_SYNC_ON_UPDATED_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="MSF_MUTABLE_SERVLET_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="MS_CANNOT_BE_FINAL" level="MAJOR" enabled="true" />
<coding_rule class="MS_EXPOSE_REP" level="CRITICAL" enabled="true" />
<coding_rule class="MS_FINAL_PKGPROTECT" level="MAJOR" enabled="true" />
<coding_rule class="MS_MUTABLE_ARRAY" level="MAJOR" enabled="true" />
<coding_rule class="MS_MUTABLE_COLLECTION" level="MAJOR" enabled="false" />
<coding_rule class="MS_MUTABLE_COLLECTION_PKGPROTECT" level="MAJOR" enabled="false" />
<coding_rule class="MS_MUTABLE_HASHTABLE" level="MAJOR" enabled="true" />
<coding_rule class="MS_OOI_PKGPROTECT" level="MAJOR" enabled="true" />
<coding_rule class="MS_PKGPROTECT" level="MAJOR" enabled="true" />
<coding_rule class="MS_SHOULD_BE_FINAL" level="MAJOR" enabled="true" />
<coding_rule class="MS_SHOULD_BE_REFACTORED_TO_BE_FINAL" level="CRITICAL" enabled="false" />
<coding_rule class="MTIA_SUSPECT_SERVLET_INSTANCE_FIELD" level="CRITICAL" enabled="true" />
<coding_rule class="MTIA_SUSPECT_STRUTS_INSTANCE_FIELD" level="CRITICAL" enabled="true" />
<coding_rule class="MWN_MISMATCHED_NOTIFY" level="CRITICAL" enabled="true" />
<coding_rule class="MWN_MISMATCHED_WAIT" level="CRITICAL" enabled="true" />
<coding_rule class="NM_BAD_EQUAL" level="MAJOR" enabled="false" />
<coding_rule class="NM_CLASS_NAMING_CONVENTION" level="MAJOR" enabled="false" />
<coding_rule class="NM_CLASS_NOT_EXCEPTION" level="MAJOR" enabled="true" />
<coding_rule class="NM_CONFUSING" level="MAJOR" enabled="true" />
<coding_rule class="NM_FIELD_NAMING_CONVENTION" level="MAJOR" enabled="false" />
<coding_rule class="NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER" level="MAJOR" enabled="true" />
<coding_rule class="NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER" level="MAJOR" enabled="true" />
<coding_rule class="NM_LCASE_HASHCODE" level="MAJOR" enabled="false" />
<coding_rule class="NM_LCASE_TOSTRING" level="MAJOR" enabled="false" />
<coding_rule class="NM_METHOD_CONSTRUCTOR_CONFUSION" level="MAJOR" enabled="true" />
<coding_rule class="NM_METHOD_NAMING_CONVENTION" level="MAJOR" enabled="false" />
<coding_rule class="NM_SAME_SIMPLE_NAME_AS_INTERFACE" level="MAJOR" enabled="true" />
<coding_rule class="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" level="MAJOR" enabled="true" />
<coding_rule class="NM_VERY_CONFUSING" level="MAJOR" enabled="true" />
<coding_rule class="NM_VERY_CONFUSING_INTENTIONAL" level="MAJOR" enabled="true" />
<coding_rule class="NM_WRONG_PACKAGE" level="MAJOR" enabled="true" />
<coding_rule class="NM_WRONG_PACKAGE_INTENTIONAL" level="MAJOR" enabled="true" />
<coding_rule class="NN_NAKED_NOTIFY" level="CRITICAL" enabled="true" />
<coding_rule class="NOISE_FIELD_REFERENCE" level="MAJOR" enabled="false" />
<coding_rule class="NOISE_METHOD_CALL" level="MAJOR" enabled="false" />
<coding_rule class="NOISE_NULL_DEREFERENCE" level="MAJOR" enabled="false" />
<coding_rule class="NOISE_OPERATION" level="MAJOR" enabled="false" />
<coding_rule class="NO_NOTIFY_NOT_NOTIFYALL" level="CRITICAL" enabled="true" />
<coding_rule class="NP_ALWAYS_NULL" level="CRITICAL" enabled="true" />
<coding_rule class="NP_ALWAYS_NULL_EXCEPTION" level="CRITICAL" enabled="true" />
<coding_rule class="NP_ARGUMENT_MIGHT_BE_NULL" level="MAJOR" enabled="true" />
<coding_rule class="NP_BOOLEAN_RETURN_NULL" level="MAJOR" enabled="true" />
<coding_rule class="NP_CLONE_COULD_RETURN_NULL" level="CRITICAL" enabled="true" />
<coding_rule class="NP_CLOSING_NULL" level="MAJOR" enabled="false" />
<coding_rule class="NP_DEREFERENCE_OF_READLINE_VALUE" level="CRITICAL" enabled="true" />
<coding_rule class="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT" level="CRITICAL" enabled="true" />
<coding_rule class="NP_GUARANTEED_DEREF" level="BLOCKER" enabled="true" />
<coding_rule class="NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH" level="CRITICAL" enabled="true" />
<coding_rule class="NP_IMMEDIATE_DEREFERENCE_OF_READLINE" level="CRITICAL" enabled="true" />
<coding_rule class="NP_LOAD_OF_KNOWN_NULL_VALUE" level="CRITICAL" enabled="true" />
<coding_rule class="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION" level="MAJOR" enabled="false" />
<coding_rule class="NP_METHOD_RETURN_RELAXING_ANNOTATION" level="MAJOR" enabled="false" />
<coding_rule class="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" level="CRITICAL" enabled="false" />
<coding_rule class="NP_NONNULL_PARAM_VIOLATION" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NONNULL_RETURN_VIOLATION" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NULL_INSTANCEOF" level="BLOCKER" enabled="true" />
<coding_rule class="NP_NULL_ON_SOME_PATH" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NULL_ON_SOME_PATH_EXCEPTION" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NULL_PARAM_DEREF" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS" level="CRITICAL" enabled="true" />
<coding_rule class="NP_NULL_PARAM_DEREF_NONVIRTUAL" level="CRITICAL" enabled="true" />
<coding_rule class="NP_OPTIONAL_RETURN_NULL" level="MAJOR" enabled="false" />
<coding_rule class="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" level="CRITICAL" enabled="true" />
<coding_rule class="NP_STORE_INTO_NONNULL_FIELD" level="CRITICAL" enabled="true" />
<coding_rule class="NP_SYNC_AND_NULL_CHECK_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="NP_TOSTRING_COULD_RETURN_NULL" level="CRITICAL" enabled="true" />
<coding_rule class="NP_UNWRITTEN_FIELD" level="MAJOR" enabled="false" />
<coding_rule class="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" level="CRITICAL" enabled="false" />
<coding_rule class="NS_DANGEROUS_NON_SHORT_CIRCUIT" level="CRITICAL" enabled="true" />
<coding_rule class="NS_NON_SHORT_CIRCUIT" level="MAJOR" enabled="true" />
<coding_rule class="OBL_UNSATISFIED_OBLIGATION" level="CRITICAL" enabled="false" />
<coding_rule class="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE" level="CRITICAL" enabled="false" />
<coding_rule class="ODR_OPEN_DATABASE_RESOURCE" level="CRITICAL" enabled="true" />
<coding_rule class="ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH" level="CRITICAL" enabled="true" />
<coding_rule class="OS_OPEN_STREAM" level="CRITICAL" enabled="true" />
<coding_rule class="OS_OPEN_STREAM_EXCEPTION_PATH" level="CRITICAL" enabled="true" />
<coding_rule class="PS_PUBLIC_SEMAPHORES" level="CRITICAL" enabled="true" />
<coding_rule class="PT_ABSOLUTE_PATH_TRAVERSAL" level="CRITICAL" enabled="false" />
<coding_rule class="PT_RELATIVE_PATH_TRAVERSAL" level="CRITICAL" enabled="false" />
<coding_rule class="PZLA_PREFER_ZERO_LENGTH_ARRAYS" level="MAJOR" enabled="true" />
<coding_rule class="PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS" level="CRITICAL" enabled="false" />
<coding_rule class="QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT" level="CRITICAL" enabled="true" />
<coding_rule class="QF_QUESTIONABLE_FOR_LOOP" level="CRITICAL" enabled="true" />
<coding_rule class="RANGE_ARRAY_INDEX" level="MAJOR" enabled="false" />
<coding_rule class="RANGE_ARRAY_LENGTH" level="MAJOR" enabled="false" />
<coding_rule class="RANGE_ARRAY_OFFSET" level="MAJOR" enabled="false" />
<coding_rule class="RANGE_STRING_INDEX" level="MAJOR" enabled="false" />
<coding_rule class="RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE" level="CRITICAL" enabled="true" />
<coding_rule class="RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES" level="CRITICAL" enabled="true" />
<coding_rule class="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" level="CRITICAL" enabled="true" />
<coding_rule class="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE" level="CRITICAL" enabled="true" />
<coding_rule class="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" level="CRITICAL" enabled="true" />
<coding_rule class="RC_REF_COMPARISON" level="CRITICAL" enabled="true" />
<coding_rule class="RC_REF_COMPARISON_BAD_PRACTICE" level="MAJOR" enabled="false" />
<coding_rule class="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN" level="MAJOR" enabled="false" />
<coding_rule class="REC_CATCH_EXCEPTION" level="MAJOR" enabled="true" />
<coding_rule class="RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION" level="CRITICAL" enabled="true" />
<coding_rule class="RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION" level="CRITICAL" enabled="true" />
<coding_rule class="RE_POSSIBLE_UNINTENDED_PATTERN" level="CRITICAL" enabled="true" />
<coding_rule class="RI_REDUNDANT_INTERFACES" level="MAJOR" enabled="true" />
<coding_rule class="RR_NOT_CHECKED" level="MAJOR" enabled="true" />
<coding_rule class="RS_READOBJECT_SYNC" level="CRITICAL" enabled="true" />
<coding_rule class="RU_INVOKE_RUN" level="MAJOR" enabled="true" />
<coding_rule class="RV_01_TO_INT" level="MAJOR" enabled="true" />
<coding_rule class="RV_ABSOLUTE_VALUE_OF_HASHCODE" level="CRITICAL" enabled="true" />
<coding_rule class="RV_ABSOLUTE_VALUE_OF_RANDOM_INT" level="CRITICAL" enabled="true" />
<coding_rule class="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE" level="CRITICAL" enabled="false" />
<coding_rule class="RV_CHECK_FOR_POSITIVE_INDEXOF" level="MINOR" enabled="true" />
<coding_rule class="RV_DONT_JUST_NULL_CHECK_READLINE" level="MAJOR" enabled="true" />
<coding_rule class="RV_EXCEPTION_NOT_THROWN" level="CRITICAL" enabled="true" />
<coding_rule class="RV_NEGATING_RESULT_OF_COMPARETO" level="CRITICAL" enabled="false" />
<coding_rule class="RV_REM_OF_HASHCODE" level="CRITICAL" enabled="true" />
<coding_rule class="RV_REM_OF_RANDOM_INT" level="CRITICAL" enabled="true" />
<coding_rule class="RV_RETURN_VALUE_IGNORED" level="MINOR" enabled="true" />
<coding_rule class="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" level="MAJOR" enabled="true" />
<coding_rule class="RV_RETURN_VALUE_IGNORED_INFERRED" level="CRITICAL" enabled="false" />
<coding_rule class="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" level="MAJOR" enabled="false" />
<coding_rule class="RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED" level="MAJOR" enabled="false" />
<coding_rule class="RpC_REPEATED_CONDITIONAL_TEST" level="MAJOR" enabled="true" />
<coding_rule class="SA_FIELD_DOUBLE_ASSIGNMENT" level="CRITICAL" enabled="true" />
<coding_rule class="SA_FIELD_SELF_ASSIGNMENT" level="CRITICAL" enabled="true" />
<coding_rule class="SA_FIELD_SELF_COMPARISON" level="CRITICAL" enabled="true" />
<coding_rule class="SA_FIELD_SELF_COMPUTATION" level="CRITICAL" enabled="true" />
<coding_rule class="SA_LOCAL_DOUBLE_ASSIGNMENT" level="CRITICAL" enabled="true" />
<coding_rule class="SA_LOCAL_SELF_ASSIGNMENT" level="CRITICAL" enabled="true" />
<coding_rule class="SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD" level="CRITICAL" enabled="false" />
<coding_rule class="SA_LOCAL_SELF_COMPARISON" level="CRITICAL" enabled="true" />
<coding_rule class="SA_LOCAL_SELF_COMPUTATION" level="CRITICAL" enabled="true" />
<coding_rule class="SBSC_USE_STRINGBUFFER_CONCATENATION" level="CRITICAL" enabled="true" />
<coding_rule class="SC_START_IN_CTOR" level="CRITICAL" enabled="true" />
<coding_rule class="SE_BAD_FIELD" level="MINOR" enabled="false" />
<coding_rule class="SE_BAD_FIELD_INNER_CLASS" level="MINOR" enabled="true" />
<coding_rule class="SE_BAD_FIELD_STORE" level="CRITICAL" enabled="true" />
<coding_rule class="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE" level="MAJOR" enabled="true" />
<coding_rule class="SE_INNER_CLASS" level="MAJOR" enabled="true" />
<coding_rule class="SE_METHOD_MUST_BE_PRIVATE" level="MAJOR" enabled="true" />
<coding_rule class="SE_NONFINAL_SERIALVERSIONID" level="CRITICAL" enabled="true" />
<coding_rule class="SE_NONLONG_SERIALVERSIONID" level="MAJOR" enabled="true" />
<coding_rule class="SE_NONSTATIC_SERIALVERSIONID" level="MAJOR" enabled="true" />
<coding_rule class="SE_NO_SERIALVERSIONID" level="MAJOR" enabled="true" />
<coding_rule class="SE_NO_SUITABLE_CONSTRUCTOR" level="MAJOR" enabled="true" />
<coding_rule class="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION" level="MAJOR" enabled="true" />
<coding_rule class="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED" level="MAJOR" enabled="true" />
<coding_rule class="SE_READ_RESOLVE_IS_STATIC" level="MAJOR" enabled="true" />
<coding_rule class="SE_READ_RESOLVE_MUST_RETURN_OBJECT" level="MAJOR" enabled="true" />
<coding_rule class="SE_TRANSIENT_FIELD_NOT_RESTORED" level="MAJOR" enabled="true" />
<coding_rule class="SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS" level="MAJOR" enabled="true" />
<coding_rule class="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH" level="MAJOR" enabled="false" />
<coding_rule class="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW" level="MAJOR" enabled="false" />
<coding_rule class="SF_SWITCH_FALLTHROUGH" level="MAJOR" enabled="false" />
<coding_rule class="SF_SWITCH_NO_DEFAULT" level="MAJOR" enabled="false" />
<coding_rule class="SIC_INNER_SHOULD_BE_STATIC" level="MAJOR" enabled="true" />
<coding_rule class="SIC_INNER_SHOULD_BE_STATIC_ANON" level="MAJOR" enabled="true" />
<coding_rule class="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS" level="MAJOR" enabled="true" />
<coding_rule class="SIC_THREADLOCAL_DEADLY_EMBRACE" level="MAJOR" enabled="false" />
<coding_rule class="SIO_SUPERFLUOUS_INSTANCEOF" level="CRITICAL" enabled="true" />
<coding_rule class="SI_INSTANCE_BEFORE_FINALS_ASSIGNED" level="CRITICAL" enabled="true" />
<coding_rule class="SP_SPIN_ON_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="SQL_BAD_PREPARED_STATEMENT_ACCESS" level="CRITICAL" enabled="true" />
<coding_rule class="SQL_BAD_RESULTSET_ACCESS" level="CRITICAL" enabled="true" />
<coding_rule class="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE" level="CRITICAL" enabled="true" />
<coding_rule class="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" level="CRITICAL" enabled="true" />
<coding_rule class="SR_NOT_CHECKED" level="MAJOR" enabled="true" />
<coding_rule class="SS_SHOULD_BE_STATIC" level="MAJOR" enabled="true" />
<coding_rule class="STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE" level="CRITICAL" enabled="true" />
<coding_rule class="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE" level="CRITICAL" enabled="true" />
<coding_rule class="STCAL_STATIC_CALENDAR_INSTANCE" level="CRITICAL" enabled="true" />
<coding_rule class="STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE" level="CRITICAL" enabled="true" />
<coding_rule class="STI_INTERRUPTED_ON_CURRENTTHREAD" level="CRITICAL" enabled="true" />
<coding_rule class="STI_INTERRUPTED_ON_UNKNOWNTHREAD" level="CRITICAL" enabled="true" />
<coding_rule class="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" level="CRITICAL" enabled="true" />
<coding_rule class="SWL_SLEEP_WITH_LOCK_HELD" level="CRITICAL" enabled="true" />
<coding_rule class="SW_SWING_METHODS_INVOKED_IN_SWING_THREAD" level="MAJOR" enabled="true" />
<coding_rule class="TLW_TWO_LOCK_WAIT" level="MAJOR" enabled="true" />
<coding_rule class="TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED" level="CRITICAL" enabled="true" />
<coding_rule class="TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS" level="CRITICAL" enabled="false" />
<coding_rule class="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK" level="CRITICAL" enabled="true" />
<coding_rule class="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK" level="CRITICAL" enabled="true" />
<coding_rule class="TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK" level="CRITICAL" enabled="true" />
<coding_rule class="TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK" level="CRITICAL" enabled="true" />
<coding_rule class="TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED" level="CRITICAL" enabled="true" />
<coding_rule class="TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED" level="CRITICAL" enabled="false" />
<coding_rule class="UCF_USELESS_CONTROL_FLOW" level="CRITICAL" enabled="true" />
<coding_rule class="UCF_USELESS_CONTROL_FLOW_NEXT_LINE" level="CRITICAL" enabled="true" />
<coding_rule class="UC_USELESS_CONDITION" level="MAJOR" enabled="false" />
<coding_rule class="UC_USELESS_CONDITION_TYPE" level="MAJOR" enabled="false" />
<coding_rule class="UC_USELESS_OBJECT" level="MAJOR" enabled="false" />
<coding_rule class="UC_USELESS_OBJECT_STACK" level="MAJOR" enabled="false" />
<coding_rule class="UC_USELESS_VOID_METHOD" level="MAJOR" enabled="false" />
<coding_rule class="UG_SYNC_SET_UNSYNC_GET" level="MAJOR" enabled="true" />
<coding_rule class="UI_INHERITANCE_UNSAFE_GETRESOURCE" level="MAJOR" enabled="true" />
<coding_rule class="UL_UNRELEASED_LOCK" level="CRITICAL" enabled="true" />
<coding_rule class="UL_UNRELEASED_LOCK_EXCEPTION_PATH" level="CRITICAL" enabled="true" />
<coding_rule class="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS" level="CRITICAL" enabled="true" />
<coding_rule class="UM_UNNECESSARY_MATH" level="CRITICAL" enabled="true" />
<coding_rule class="UPM_UNCALLED_PRIVATE_METHOD" level="CRITICAL" enabled="true" />
<coding_rule class="URF_UNREAD_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" level="CRITICAL" enabled="false" />
<coding_rule class="UR_UNINIT_READ" level="MAJOR" enabled="true" />
<coding_rule class="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR" level="MAJOR" enabled="false" />
<coding_rule class="USM_USELESS_ABSTRACT_METHOD" level="MAJOR" enabled="false" />
<coding_rule class="USM_USELESS_SUBCLASS_METHOD" level="MAJOR" enabled="false" />
<coding_rule class="UUF_UNUSED_FIELD" level="MAJOR" enabled="true" />
<coding_rule class="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD" level="CRITICAL" enabled="false" />
<coding_rule class="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" level="MAJOR" enabled="false" />
<coding_rule class="UWF_NULL_FIELD" level="CRITICAL" enabled="true" />
<coding_rule class="UWF_UNWRITTEN_FIELD" level="MAJOR" enabled="false" />
<coding_rule class="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" level="CRITICAL" enabled="false" />
<coding_rule class="UW_UNCOND_WAIT" level="MAJOR" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_BAD_ARGUMENT" level="CRITICAL" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_BAD_CONVERSION" level="CRITICAL" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY" level="MAJOR" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN" level="MAJOR" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED" level="MAJOR" enabled="false" />
<coding_rule class="VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED" level="MAJOR" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_ILLEGAL" level="CRITICAL" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_MISSING_ARGUMENT" level="CRITICAL" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT" level="CRITICAL" enabled="true" />
<coding_rule class="VA_FORMAT_STRING_USES_NEWLINE" level="CRITICAL" enabled="false" />
<coding_rule class="VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG" level="CRITICAL" enabled="true" />
<coding_rule class="VO_VOLATILE_INCREMENT" level="CRITICAL" enabled="false" />
<coding_rule class="VO_VOLATILE_REFERENCE_TO_ARRAY" level="MAJOR" enabled="true" />
<coding_rule class="VR_UNRESOLVABLE_REFERENCE" level="MAJOR" enabled="false" />
<coding_rule class="WA_AWAIT_NOT_IN_LOOP" level="CRITICAL" enabled="true" />
<coding_rule class="WA_NOT_IN_LOOP" level="CRITICAL" enabled="true" />
<coding_rule class="WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL" level="CRITICAL" enabled="true" />
<coding_rule class="WMI_WRONG_MAP_ITERATOR" level="CRITICAL" enabled="true" />
<coding_rule class="WS_WRITEOBJECT_SYNC" level="CRITICAL" enabled="true" />
<coding_rule class="XFB_XML_FACTORY_BYPASS" level="CRITICAL" enabled="true" />
<coding_rule class="XSS_REQUEST_PARAMETER_TO_JSP_WRITER" level="CRITICAL" enabled="true" />
<coding_rule class="XSS_REQUEST_PARAMETER_TO_SEND_ERROR" level="CRITICAL" enabled="true" />
<coding_rule class="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER" level="CRITICAL" enabled="true" />
</profile>
</profiles>
<list size="0" />
</component>
</project>

6
.idea/vcs.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

38
bwie-auth/.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

49
bwie-auth/pom.xml 100644
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>monthA8.12</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-auth</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 项目公共 依赖 -->
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
</dependency>
<!-- SpringBoot Web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<!-- kafka -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,20 @@
package com.bwie.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @Authorweiran
* @Packagecom.bwie.auth
* @ProjectmonthA8.12
* @nameAuthApplication
* @Date2024/8/12 9:11
*/
@SpringBootApplication
@EnableFeignClients
public class AuthApplication {
public static void main(String[] args) {
SpringApplication.run(AuthApplication.class, args);
}
}

View File

@ -0,0 +1,14 @@
package com.bwie.auth.config;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
@Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
return new RabbitAdmin(connectionFactory);
}
}

View File

@ -0,0 +1,15 @@
package com.bwie.auth.config;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitmqConfig {
// 消息转换配置
@Bean
public MessageConverter jsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
}

View File

@ -0,0 +1,55 @@
package com.bwie.auth.controller;
import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.UserReq;
import com.bwie.common.domain.response.JwtResp;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Authorweiran
* @Packagecom.bwie.auth.controller
* @ProjectmonthA8.12
* @nameAuthController
* @Date2024/8/12 9:23
*/
@RestController
@RequestMapping("/auth")
public class AuthController {
@Autowired
private AuthService authService;
/**
*
*/
@PostMapping("/sendcode/{userPhone}")
public Result sendcode(@PathVariable String userPhone){
return Result.success(authService.sendcode(userPhone),"发送成功");
}
/**
*
* @param userReq
* @return
*/
@PostMapping("/login")
public Result<JwtResp> login(@RequestBody UserReq userReq){
return Result.success(authService.login(userReq),"登录成功");
}
/**
*
* @return
*/
@GetMapping("/info")
public Result<User> getInfo(){
return Result.success(authService.getInfo());
}
}

View File

@ -0,0 +1,26 @@
package com.bwie.auth.feign;
import com.bwie.auth.feign.factory.AuthFieignFactory;
import com.bwie.common.domain.User;
import com.bwie.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @Authorweiran
* @Packagecom.bwie.auth.feign
* @ProjectmonthA8.12
* @nameAuthFieign
* @Date2024/8/12 9:24
*/
@FeignClient(value = "bwie-user",fallback = AuthFieignFactory.class)
public interface AuthFieign {
@PostMapping("/user/user/findByuserPhone/{userPhone}")
Result<User> findByuserPhone(@PathVariable String userPhone);
@PostMapping("/user/user/adduser")
Result adduser(@RequestBody User user);
}

View File

@ -0,0 +1,32 @@
package com.bwie.auth.feign.factory;
import com.bwie.auth.feign.AuthFieign;
import com.bwie.common.domain.User;
import com.bwie.common.result.Result;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* @Authorweiran
* @Packagecom.bwie.auth.feign.factory
* @ProjectmonthA8.12
* @nameAuthFieignFactory
* @Date2024/8/12 9:25
*/
@Component
public class AuthFieignFactory implements FallbackFactory<AuthFieign> {
@Override
public AuthFieign create(Throwable cause) {
return new AuthFieign() {
@Override
public Result<User> findByuserPhone(String userPhone) {
return Result.error("网络异常,已进入熔断状态");
}
@Override
public Result adduser(User user) {
return Result.error("网络异常,已进入熔断状态");
}
};
}
}

View File

@ -0,0 +1,29 @@
package com.bwie.auth.service;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.UserReq;
import com.bwie.common.domain.response.JwtResp;
/**
* @Authorweiran
* @Packagecom.bwie.auth.service
* @ProjectmonthA8.12
* @nameAuthService
* @Date2024/8/12 9:23
*/
public interface AuthService {
/**
*
*/
String sendcode(String userPhone);
/**
*
* @param userReq
* @return
*/
JwtResp login(UserReq userReq);
User getInfo();
}

View File

@ -0,0 +1,128 @@
package com.bwie.auth.service.impl;
import ch.qos.logback.core.util.TimeUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.RandomUtils;
import com.bwie.auth.feign.AuthFieign;
import com.bwie.auth.service.AuthService;
import com.bwie.common.constants.JwtConstants;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.UserReq;
import com.bwie.common.domain.response.JwtResp;
import com.bwie.common.exception.ProductException;
import com.bwie.common.result.Result;
import com.bwie.common.utils.JwtUtils;
import com.bwie.common.utils.StringUtils;
import com.bwie.common.utils.TelSmsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
/**
* @Authorweiran
* @Packagecom.bwie.auth.service.impl
* @ProjectmonthA8.12
* @nameAuthServiceImpl
* @Date2024/8/12 9:24
*/
@Service
public class AuthServiceImpl implements AuthService {
@Autowired
private AuthFieign authFieign;
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private HttpServletRequest request;
/**
*
*/
@Override
public String sendcode(String userPhone) {
//判断手机号是否为空
if(StringUtils.isBlank(userPhone)){
throw new ProductException("手机号不能为空");
}
//手机号是否存在
Result<User> result = authFieign.findByuserPhone(userPhone);
User login = result.getData();
if (login==null){
throw new ProductException("手机号不存在");
}
//创建验证码
String code = RandomUtil.randomNumbers(4);
//将验证码存入redis
redisTemplate.opsForValue().set(userPhone, code,5, TimeUnit.MINUTES);
//发送验证码
HashMap<String, String> map = new HashMap<>();
map.put(userPhone,code);
TelSmsUtils.sendSms(userPhone, code, map);
//返回code
return code;
}
/**
*
* @param userReq
* @return
*/
@Override
public JwtResp login(UserReq userReq) {
//判断手机号或验证码是否为空
String userPhone = userReq.getUserPhone();
String code = userReq.getCode();
if (StringUtils.isAnyBlank(userPhone,code)){
throw new ProductException("手机号或验证码不能为空");
}
//判断手机号是否存在 用户点击登录后,若系统中无此账号则需要先录入到系统用户表当中
Result<User> result = authFieign.findByuserPhone(userPhone);
User login = result.getData();
if (login==null){
String num = RandomUtil.randomNumbers(4);
User user = new User();
user.setUserName("游客"+num);
user.setUserPhone(userPhone);
authFieign.adduser(user);
throw new ProductException("手机号不存在,已经以"+user.getUserName()+"的身份帮您录入,请重新登录");
}
//判断验证码是否过期
Boolean aBoolean = redisTemplate.hasKey(userPhone);
if (!aBoolean){
throw new ProductException("验证码已过期");
}
//判断验证码是否正确
String code1 = redisTemplate.opsForValue().get(userPhone);
if (!code1.equals(code)){
throw new ProductException("验证码错误");
}
//登录
HashMap<String, Object> map = new HashMap<>();
map.put(JwtConstants.USER_KEY, login.getUserId());
String token = JwtUtils.createToken(map);
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+login.getUserId(), JSONObject.toJSONString(login),30, TimeUnit.MINUTES);
JwtResp jwtResp = new JwtResp(token, "30MIN");
return jwtResp;
}
/**
*
* @return
*/
@Override
public User getInfo() {
String token = request.getHeader(TokenConstants.TOKEN);
String userKey = JwtUtils.getUserKey(token);
String code = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
return JSONObject.parseObject(code, User.class);
}
}

View File

@ -0,0 +1,77 @@
package com.bwie.auth.utils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Component
public class DLXQueue {
// routingKey
private static final String DEAD_ROUTING_KEY = "dead.routingkey";
private static final String ROUTING_KEY = "routingkey";
private static final String DEAD_EXCHANGE = "dead.exchange";
private static final String EXCHANGE = "common.exchange";
@Autowired
RabbitTemplate rabbitTemplate;
@Resource
RabbitAdmin rabbitAdmin;
/**
*
*
* @param queueName
* @param deadQueueName
* @param params
* @param expiration
*/
public void sendDLXQueue(String queueName, String deadQueueName, Object params, Integer expiration) {
/**
* ----------------------------------ttl--------------------------------------------
*/
Map<String, Object> map = new HashMap<>();
// 队列设置存活时间单位ms, 必须是整形数据。
map.put("x-message-ttl", expiration);
// 设置死信交换机
map.put("x-dead-letter-exchange", DEAD_EXCHANGE);
// 设置死信交换器路由
map.put("x-dead-letter-routing-key", DEAD_ROUTING_KEY);
/*参数1队列名称 参数2持久化 参数3是否排他 参数4自动删除队列 参数5队列参数*/
Queue queue = new Queue(queueName, true, false, false, map);
rabbitAdmin.declareQueue(queue);
/**
* ------------------------------------------------------------------------------
*/
DirectExchange directExchange = new DirectExchange(EXCHANGE, true, false);
rabbitAdmin.declareExchange(directExchange);
/**
* ------------------------------------------------------------------------------
*/
Binding binding = BindingBuilder.bind(queue).to(directExchange).with(ROUTING_KEY);
rabbitAdmin.declareBinding(binding);
/**
* ------------------------------------------------------------------------------
*/
DirectExchange deadExchange = new DirectExchange(DEAD_EXCHANGE, true, false);
rabbitAdmin.declareExchange(deadExchange);
Queue deadQueue = new Queue(deadQueueName, true, false, false);
rabbitAdmin.declareQueue(deadQueue);
/**
* ------------------------------------------------------------------------------
*/
// 将队列和交换机绑定
Binding deadbinding = BindingBuilder.bind(deadQueue).to(deadExchange).with(DEAD_ROUTING_KEY);
rabbitAdmin.declareBinding(deadbinding);
// 发送消息
rabbitTemplate.convertAndSend(EXCHANGE, ROUTING_KEY, params);
}
}

View File

@ -0,0 +1,79 @@
package com.bwie.auth.utils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
*/
@Component
public class DelayedQueue {
// routingKey
private static final String DELAYED_ROUTING_KEY = "delayed.routingkey";
// 延迟队列交换机
private static final String DELAYED_EXCHANGE = "delayed.exchange";
@Autowired
RabbitTemplate rabbitTemplate;
@Resource
RabbitAdmin rabbitAdmin;
/**
*
*
* @param queueName
* @param params
* @param expiration
*/
public void sendDelayedQueue(String queueName, Object params, Integer expiration) {
// 先创建一个队列
Queue queue = new Queue(queueName);
rabbitAdmin.declareQueue(queue);
// 创建延迟队列交换机
CustomExchange customExchange = createCustomExchange();
rabbitAdmin.declareExchange(customExchange);
// 将队列和交换机绑定
Binding binding = BindingBuilder.bind(queue).to(customExchange).with(DELAYED_ROUTING_KEY).noargs();
rabbitAdmin.declareBinding(binding);
// 发送延迟消息
rabbitTemplate.convertAndSend(DELAYED_EXCHANGE, DELAYED_ROUTING_KEY, params, msg -> {
// 发送消息的时候 延迟时长
msg.getMessageProperties().setMessageId(UUID.randomUUID().toString().replaceAll("-", ""));
msg.getMessageProperties().setDelay(expiration);
return msg;
});
}
private CustomExchange createCustomExchange() {
Map<String, Object> arguments = new HashMap<>();
/**
*
* 1.
* 2.
* 3.
* 4.
* 5.
*/
arguments.put("x-delayed-type", "direct");
return new CustomExchange(DELAYED_EXCHANGE, "x-delayed-message", true, false, arguments);
}
}

View File

@ -0,0 +1,66 @@
package com.bwie.auth.utils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* TTL
*
*/
@Component
public class TtlQueue {
// routingKey
private static final String TTL_KEY = "ttl.routingkey";
private static final String TTL_EXCHANGE = "ttl.exchange";
@Autowired
RabbitTemplate rabbitTemplate;
@Resource
RabbitAdmin rabbitAdmin;
/**
* TTL
*
* @param queueName
* @param params
* @param expiration
*/
public void sendTtlQueue(String queueName, Object params, Integer expiration) {
/**
* ----------------------------------ttl--------------------------------------------
*/
Map<String, Object> map = new HashMap<>();
// 队列设置存活时间单位ms,必须是整形数据。
map.put("x-message-ttl", expiration);
/*参数1队列名称 参数2持久化 参数3是否排他 参数4自动删除队列 参数5队列参数*/
Queue queue = new Queue(queueName, true, false, false, map);
rabbitAdmin.declareQueue(queue);
/**
* ------------------------------------------------------------------------------
*/
DirectExchange directExchange = new DirectExchange(TTL_EXCHANGE, true, false);
rabbitAdmin.declareExchange(directExchange);
/**
* ------------------------------------------------------------------------------
*/
// 将队列和交换机绑定
Binding binding = BindingBuilder.bind(queue).to(directExchange).with(TTL_KEY);
rabbitAdmin.declareBinding(binding);
// 发送消息
rabbitTemplate.convertAndSend(TTL_EXCHANGE, TTL_KEY, params);
}
}

View File

@ -0,0 +1,114 @@
# Tomcat
server:
port: 9001
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-auth
kafka:
producer:
# Kafka服务器
bootstrap-servers: 122.51.12.81:9092
# 开启事务,必须在开启了事务的方法中发送,否则报错
transaction-id-prefix: kafkaTx-
# 发生错误后消息重发的次数开启事务必须设置大于0。
retries: 3
# acks=0 生产者在成功写入消息之前不会等待任何来自服务器的响应。
# acks=1 只要集群的首领节点收到消息,生产者就会收到一个来自服务器成功响应。
# acks=all :只有当所有参与复制的节点全部收到消息时,生产者才会收到一个来自服务器的成功响应。
# 开启事务时必须设置为all
acks: all
# 当有多个消息需要被发送到同一个分区时,生产者会把它们放在同一个批次里。该参数指定了一个批次可以使用的内存大小,按照字节数计算。
batch-size: 16384
# 生产者内存缓冲区的大小。
buffer-memory: 1024000
# 键的序列化方式
key-serializer: org.springframework.kafka.support.serializer.JsonSerializer
# 值的序列化方式建议使用Json这种序列化方式可以无需额外配置传输实体类
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
consumer:
# Kafka服务器
bootstrap-servers: 122.51.12.81:9092
group-id: firstGroup
# 自动提交的时间间隔 在spring boot 2.X 版本中这里采用的是值的类型为Duration 需要符合特定的格式如1S,1M,2H,5D
#auto-commit-interval: 2s
# 该属性指定了消费者在读取一个没有偏移量的分区或者偏移量无效的情况下该作何处理:
# earliest当各分区下有已提交的offset时从提交的offset开始消费无提交的offset时从头开始消费分区的记录
# latest当各分区下有已提交的offset时从提交的offset开始消费无提交的offset时消费新产生的该分区下的数据在消费者启动之后生成的记录
# none当各分区都存在已提交的offset时从提交的offset开始消费只要有一个分区不存在已提交的offset则抛出异常
auto-offset-reset: latest
# 是否自动提交偏移量默认值是true为了避免出现重复数据和数据丢失可以把它设置为false然后手动提交偏移量
enable-auto-commit: false
# 键的反序列化方式
#key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
key-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
# 值的反序列化方式建议使用Json这种序列化方式可以无需额外配置传输实体类
value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
# 配置消费者的 Json 反序列化的可信赖包,反序列化实体类需要
properties:
spring:
json:
trusted:
packages: "*"
# 这个参数定义了poll方法最多可以拉取多少条消息默认值为500。如果在拉取消息的时候新消息不足500条那有多少返回多少如果超过500条每次只返回500。
# 这个默认值在有些场景下太大有些场景很难保证能够在5min内处理完500条消息
# 如果消费者无法在5分钟内处理完500条消息的话就会触发reBalance,
# 然后这批消息会被分配到另一个消费者中,还是会处理不完,这样这批消息就永远也处理不完。
# 要避免出现上述问题提前评估好处理一条消息最长需要多少时间然后覆盖默认的max.poll.records参数
# 注需要开启BatchListener批量监听才会生效如果不开启BatchListener则不会出现reBalance情况
max-poll-records: 3
properties:
# 两次poll之间的最大间隔默认值为5分钟。如果超过这个间隔会触发reBalance
max:
poll:
interval:
ms: 600000
# 当broker多久没有收到consumer的心跳请求后就触发reBalance默认值是10s
session:
timeout:
ms: 10000
listener:
# 在侦听器容器中运行的线程数,一般设置为 机器数*分区数
concurrency: 4
# 自动提交关闭,需要设置手动消息确认
ack-mode: manual_immediate
# 消费监听接口监听的主题不存在时默认会报错所以设置为false忽略错误
missing-topics-fatal: false
# 两次poll之间的最大间隔默认值为5分钟。如果超过这个间隔会触发reBalance
poll-timeout: 600000
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 122.51.12.81:8848
namespace: nacos
config:
# 配置中心地址
server-addr: 122.51.12.81:8848
namespace: nacos
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
rabbitmq:
username: guest
password: guest
virtualHost: /
port: 5672
host: 122.51.12.81
listener:
simple:
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
publisher-returns: true #确认消息已发送到队列(Queue)

38
bwie-common/.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

107
bwie-common/pom.xml 100644
View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>monthA8.12</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-common</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- bootstrap 启动器 -->
<!-- Java Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- 负载均衡-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<!-- SpringCloud Openfeign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<!-- Alibaba Fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.80</version>
</dependency>
<!-- SpringBoot Boot Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- Hibernate Validator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- Apache Lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- lombok依赖 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- hutool -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.3</version>
</dependency>
<!-- 阿里大鱼 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>2.0.1</version>
</dependency>
<!-- rabbitMQ -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,18 @@
package com.bwie.common.constants;
/**
* @description:
* @author DongZl
*/
public class Constants {
/**
*
*/
public static final Integer SUCCESS = 200;
public static final String SUCCESS_MSG = "操作成功";
/**
*
*/
public static final Integer ERROR = 500;
public static final String ERROR_MSG = "操作异常";
}

View File

@ -0,0 +1,29 @@
package com.bwie.common.constants;
/**
* @author DongZl
* @description: Jwt
*/
public class JwtConstants {
/**
* ID
*/
public static final String DETAILS_USER_ID = "user_id";
/**
*
*/
public static final String DETAILS_USERNAME = "username";
/**
*
*/
public static final String USER_KEY = "user_key";
/**
*
*/
public final static String SECRET = "abcdefghijklmnopqrstuvwxyz";
}

View File

@ -0,0 +1,15 @@
package com.bwie.common.constants;
/**
* @Project boot-month
* @Author
* @Date 2023/9/6 10:06-+
* @Description
*/
public class QueueConstants {
public static final String SEND_CODE_QUEUE = "send_code_queue";
public static final String SEND_CODE_PREVENT_REPEAT_ID = "send_code_prevent_repeat_id:";
public static final String BLOG_UPDATE_QUEUE = "blog_update_queue";
public static final String BLOG_UPDATE_PREVENT_REPEAT_ID = "blog_update_prevent_repeat_id:";
}

View File

@ -0,0 +1,18 @@
package com.bwie.common.constants;
/**
* Clazz:2103A
* Name :FYSN
* Desc :--·
* Date :2023-08-20 20:37:02
*/
public class RabbitMQOneConstants {
//发送短消息队列名称
public static final String SEND_SHORT_MESSAGE_QUEUE_NAME = "send_short_message";
//查看的日志队列名称
public static final String QUERY_LOG_QUEUE_NAME = "query_log_message";
}

View File

@ -0,0 +1,18 @@
package com.bwie.common.constants;
/**
* Clazz:2103A
* Name :FYSN
* Desc :--·
* Date :2023-08-20 20:37:02
*/
public class RabbitMQTwoConstants {
//发送消息队列名称
public static final String SEND_SMS_QUEUE = "send_sms_queue";
//添加消息队列名称日志
public static final String ADD_MESSAGE_QUEUE_NAME_LOG = "add_message_log";
}

View File

@ -0,0 +1,24 @@
package com.bwie.common.constants;
/**
* @author DongZl
* @description:
*/
public class TokenConstants {
/**
* 720
*/
public final static long EXPIRATION = 720;
/**
* 120
*/
public final static long REFRESH_TIME = 120;
/**
*
*/
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
/**
* token
*/
public static final String TOKEN = "token";
}

View File

@ -0,0 +1,29 @@
package com.bwie.common.controlleradvice;
import com.bwie.common.exception.ProductException;
import com.bwie.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* @Authorweiran
*
*
*/
@RestControllerAdvice
@Slf4j
public class ProductControllerAdvice {
@ExceptionHandler(value = ProductException.class)
public Result productExceptionHandler(Throwable e){
StackTraceElement stackTraceElement = e.getStackTrace()[0];
String className = stackTraceElement.getClassName();
String fileName = stackTraceElement.getFileName();
int lineNumber = stackTraceElement.getLineNumber();
String methodName = stackTraceElement.getMethodName();
log.error("该方法报错的位置是类:{},文件:{},报错行数:{},方法名称:{}",className,fileName,lineNumber,methodName);
return Result.error(e.getMessage()+"该方法报错的位置是类:{"+className+"},文件:{"+fileName+"},报错行数:{"+lineNumber+"},方法名称:{"+methodName+"}");
}
}

View File

@ -0,0 +1,51 @@
package com.bwie.common.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain
* @ProjectmonthA8.12
* @nameCoupon
* @Date2024/8/12 10:57
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Coupon {
/**
* Id
*/
private String couponId;
/**
*
*/
private String couponName;
/**
*
*/
private String couponNum;
/**
*
*/
private String couponPrice;
/**
*
*/
private String couponStatus;
/**
* Id
*/
private String typeId;
}

View File

@ -0,0 +1,56 @@
package com.bwie.common.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain
* @ProjectmonthA8.12
* @nameCoupon
* @Date2024/8/12 10:57
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MyCoupon {
/**
* Id
*/
private String couponId;
/**
*
*/
private String couponName;
/**
*
*/
private String couponNum;
/**
*
*/
private String couponPrice;
/**
*
*/
private String couponStatus;
/**
* Id
*/
private String typeId;
/**
*
*/
private String typeName;
}

View File

@ -0,0 +1,27 @@
package com.bwie.common.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain
* @ProjectmonthA8.12
* @nameOrder
* @Date2024/8/12 15:27
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Order {
private Integer orderId;
private Integer couponId;
private String couponName;
private String exchangeNum;
private Double orderMoney;
private String orderTime;
private Integer orderStatus;
}

View File

@ -0,0 +1,21 @@
package com.bwie.common.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain
* @ProjectmonthA8.12
* @nameType
* @Date2024/8/12 13:49
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Type {
private Integer typeId;
private String typeName;
private String typeGroupname;
}

View File

@ -0,0 +1,35 @@
package com.bwie.common.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain
* @ProjectmonthA8.12
* @nameUser
* @Date2024/8/12 9:18
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
/**
* Id
*/
private Integer userId;
/**
*
*/
private String userName;
/**
*
*/
private String userPhone;
/**
*
*/
private Double userMoney;
}

View File

@ -0,0 +1,65 @@
package com.bwie.common.domain.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain.request
* @ProjectmonthA8.12
* @nameCouponBuyReq
* @Date2024/8/12 15:21
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CouponBuyReq {
/**
* Id
*/
private Integer couponId;
/**
*
*/
private String couponName;
/**
*
*/
private Integer couponNum;
/**
*
*/
private Double couponPrice;
/**
*
*/
private Integer couponStatus;
/**
* Id
*/
private Integer typeId;
/**
*
*/
private String exchangeNum;
/**
*
*/
private Double money;
}

View File

@ -0,0 +1,41 @@
package com.bwie.common.domain.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain.request
* @ProjectmonthA8.12
* @nameCouponReq
* @Date2024/8/12 11:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CouponReq {
/**
*
*/
private String couponName;
/**
* Id
*/
private Integer typeId;
/**
*
*/
private String typeName;
/**
*
*/
private String typeGroupname;
}

View File

@ -0,0 +1,70 @@
package com.bwie.common.domain.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain.request
* @ProjectmonthA8.12
* @nameCouponBuyReq
* @Date2024/8/12 15:21
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CouponSellReq {
/**
* Id
*/
private Integer couponId;
/**
*
*/
private String couponName;
/**
*
*/
private Integer couponNum;
/**
*
*/
private Double couponPrice;
/**
*
*/
private Integer couponStatus;
/**
* Id
*/
private Integer typeId;
/**
*
*/
private String exchangeNum;
/**
*
*/
private Double money;
/**
*
*/
private String time;
}

View File

@ -0,0 +1,45 @@
package com.bwie.common.domain.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain.request
* @ProjectmonthA8.12
* @nameReduceMoneyReq
* @Date2024/8/12 16:26
*/
@Data
@NoArgsConstructor
public class ReduceMoneyReq {
private Integer userId;
private Double couponPrice;
public ReduceMoneyReq(Integer userId, Double couponPrice) {
this.userId = userId;
this.couponPrice = couponPrice;
}
public ReduceMoneyReq(Integer userId, String couponPrice) {
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Double getCouponPrice() {
return couponPrice;
}
public void setCouponPrice(Double couponPrice) {
this.couponPrice = couponPrice;
}
}

View File

@ -0,0 +1,29 @@
package com.bwie.common.domain.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain.request
* @ProjectmonthA8.12
* @nameUserReq
* @Date2024/8/12 9:20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserReq {
/**
*
*/
private String userPhone;
/**
*
*/
private String code;
}

View File

@ -0,0 +1,57 @@
package com.bwie.common.domain.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain.response
* @ProjectmonthA8.12
* @nameCouponResp
* @Date2024/8/12 11:01
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CouponResp {
/**
* Id
*/
private String couponId;
/**
*
*/
private String couponName;
/**
*
*/
private String couponNum;
/**
*
*/
private String couponPrice;
/**
*
*/
private String couponStatus;
/**
* Id
*/
private String typeId;
/**
*
*/
private String typeName;
/**
*
*/
private String typeRroup;
}

View File

@ -0,0 +1,28 @@
package com.bwie.common.domain.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.common.domain.response
* @ProjectmonthA8.12
* @nameJwtResp
* @Date2024/8/12 9:21
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class JwtResp {
/**
* token
*/
private String token;
/**
*
*/
private String expireTime;
}

View File

@ -0,0 +1,29 @@
package com.bwie.common.exception;
/**
* @Authorweiran
*
*
*/
public class ProductException extends RuntimeException{
public ProductException() {
super();
}
public ProductException(String message) {
super(message);
}
public ProductException(String message, Throwable cause) {
super(message, cause);
}
public ProductException(Throwable cause) {
super(cause);
}
protected ProductException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -0,0 +1,34 @@
package com.bwie.common.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author DongZl
* @description:
*/
@Data
public class PageResult<T> implements Serializable {
/**
*
*/
private long total;
/**
*
*/
private List<T> list;
public PageResult() {
}
public PageResult(long total, List<T> list) {
this.total = total;
this.list = list;
}
public static <T> PageResult<T> toPageResult(long total, List<T> list){
return new PageResult(total , list);
}
public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
return Result.success(PageResult.toPageResult(total,list));
}
}

View File

@ -0,0 +1,76 @@
package com.bwie.common.result;
import com.bwie.common.constants.Constants;
import lombok.Data;
import java.io.Serializable;
/**
* @author DongZl
* @description:
*/
@Data
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
public static final int SUCCESS = Constants.SUCCESS;
/**
*
*/
public static final int FAIL = Constants.ERROR;
/**
*
*/
private int code;
/**
*
*/
private String msg;
/**
*
*/
private T data;
public static <T> Result<T> success() {
return restResult(null, SUCCESS, Constants.SUCCESS_MSG);
}
public static <T> Result<T> success(T data) {
return restResult(data, SUCCESS, Constants.SUCCESS_MSG);
}
public static <T> Result<T> success(T data, String msg) {
return restResult(data, SUCCESS, msg);
}
public static <T> Result<T> error() {
return restResult(null, FAIL, Constants.ERROR_MSG);
}
public static <T> Result<T> error(String msg) {
return restResult(null, FAIL, msg);
}
public static <T> Result<T> error(T data) {
return restResult(data, FAIL, Constants.ERROR_MSG);
}
public static <T> Result<T> error(T data, String msg) {
return restResult(data, FAIL, msg);
}
public static <T> Result<T> error(int code, String msg) {
return restResult(null, code, msg);
}
private static <T> Result<T> restResult(T data, int code, String msg) {
Result<T> apiResult = new Result<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
}

View File

@ -0,0 +1,312 @@
package com.bwie.common.utils;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* IP
*
* @author ruoyi
*/
public class IpUtils {
public final static String REGX_0_255 = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)";
// 匹配 ip
public final static String REGX_IP = "((" + REGX_0_255 + "\\.){3}" + REGX_0_255 + ")";
public final static String REGX_IP_WILDCARD = "(((\\*\\.){3}\\*)|(" + REGX_0_255 + "(\\.\\*){3})|(" + REGX_0_255 + "\\." + REGX_0_255 + ")(\\.\\*){2}" + "|((" + REGX_0_255 + "\\.){3}\\*))";
// 匹配网段
public final static String REGX_IP_SEG = "(" + REGX_IP + "\\-" + REGX_IP + ")";
/**
* IP
*
* @param request
* @return IP
*/
public static String getIpAddr(HttpServletRequest request) {
if (request == null) {
return "unknown";
}
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("X-Forwarded-For");
}
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("X-Real-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip);
}
/**
* IP
*
* @param ip IP
* @return
*/
public static boolean internalIp(String ip) {
byte[] addr = textToNumericFormatV4(ip);
return internalIp(addr) || "127.0.0.1".equals(ip);
}
/**
* IP
*
* @param addr byte
* @return
*/
private static boolean internalIp(byte[] addr) {
if (StringUtils.isNull(addr) || addr.length < 2) {
return true;
}
final byte b0 = addr[0];
final byte b1 = addr[1];
// 10.x.x.x/8
final byte SECTION_1 = 0x0A;
// 172.16.x.x/12
final byte SECTION_2 = (byte) 0xAC;
final byte SECTION_3 = (byte) 0x10;
final byte SECTION_4 = (byte) 0x1F;
// 192.168.x.x/16
final byte SECTION_5 = (byte) 0xC0;
final byte SECTION_6 = (byte) 0xA8;
switch (b0) {
case SECTION_1:
return true;
case SECTION_2:
if (b1 >= SECTION_3 && b1 <= SECTION_4) {
return true;
}
case SECTION_5:
switch (b1) {
case SECTION_6:
return true;
}
default:
return false;
}
}
/**
* IPv4
*
* @param text IPv4
* @return byte
*/
public static byte[] textToNumericFormatV4(String text) {
if (text.length() == 0) {
return null;
}
byte[] bytes = new byte[4];
String[] elements = text.split("\\.", -1);
try {
long l;
int i;
switch (elements.length) {
case 1:
l = Long.parseLong(elements[0]);
if ((l < 0L) || (l > 4294967295L)) {
return null;
}
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 2:
l = Integer.parseInt(elements[0]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[0] = (byte) (int) (l & 0xFF);
l = Integer.parseInt(elements[1]);
if ((l < 0L) || (l > 16777215L)) {
return null;
}
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 3:
for (i = 0; i < 2; ++i) {
l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[i] = (byte) (int) (l & 0xFF);
}
l = Integer.parseInt(elements[2]);
if ((l < 0L) || (l > 65535L)) {
return null;
}
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 4:
for (i = 0; i < 4; ++i) {
l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[i] = (byte) (int) (l & 0xFF);
}
break;
default:
return null;
}
} catch (NumberFormatException e) {
return null;
}
return bytes;
}
/**
* IP
*
* @return IP
*/
public static String getHostIp() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
}
return "127.0.0.1";
}
/**
*
*
* @return
*/
public static String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
}
return "未知";
}
/**
* unknown IP
*
* @param ip IP
* @return unknown IP
*/
public static String getMultistageReverseProxyIp(String ip) {
// 多级反向代理检测
if (ip != null && ip.indexOf(",") > 0) {
final String[] ips = ip.trim().split(",");
for (String subIp : ips) {
if (false == isUnknown(subIp)) {
ip = subIp;
break;
}
}
}
return StringUtils.substring(ip, 0, 255);
}
/**
* HTTP
*
* @param checkString
* @return
*/
public static boolean isUnknown(String checkString) {
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
}
/**
* IP
*/
public static boolean isIP(String ip) {
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
}
/**
* IP *
*/
public static boolean isIpWildCard(String ip) {
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP_WILDCARD);
}
/**
* ip
*/
public static boolean ipIsInWildCardNoCheck(String ipWildCard, String ip) {
String[] s1 = ipWildCard.split("\\.");
String[] s2 = ip.split("\\.");
boolean isMatchedSeg = true;
for (int i = 0; i < s1.length && !s1[i].equals("*"); i++) {
if (!s1[i].equals(s2[i])) {
isMatchedSeg = false;
break;
}
}
return isMatchedSeg;
}
/**
* :10.10.10.1-10.10.10.99ip
*/
public static boolean isIPSegment(String ipSeg) {
return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
}
/**
* ip
*/
public static boolean ipIsInNetNoCheck(String iparea, String ip) {
int idx = iparea.indexOf('-');
String[] sips = iparea.substring(0, idx).split("\\.");
String[] sipe = iparea.substring(idx + 1).split("\\.");
String[] sipt = ip.split("\\.");
long ips = 0L, ipe = 0L, ipt = 0L;
for (int i = 0; i < 4; ++i) {
ips = ips << 8 | Integer.parseInt(sips[i]);
ipe = ipe << 8 | Integer.parseInt(sipe[i]);
ipt = ipt << 8 | Integer.parseInt(sipt[i]);
}
if (ips > ipe) {
long t = ips;
ips = ipe;
ipe = t;
}
return ips <= ipt && ipt <= ipe;
}
/**
* ip
*
* @param filter IP,'*',:`10.10.10.1-10.10.10.99`
* @param ip IP
* @return boolean
*/
public static boolean isMatchedIp(String filter, String ip) {
if (StringUtils.isEmpty(filter) || StringUtils.isEmpty(ip)) {
return false;
}
String[] ips = filter.split(";");
for (String iStr : ips) {
if (isIP(iStr) && iStr.equals(ip)) {
return true;
} else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip)) {
return true;
} else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,109 @@
package com.bwie.common.utils;
import com.bwie.common.constants.JwtConstants;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Map;
/**
* @description: Jwt
* @author DongZl
*/
public class JwtUtils {
/**
*
*/
public static String secret = JwtConstants.SECRET;
/**
*
*
* @param claims
* @return
*/
public static String createToken(Map<String, Object> claims){
String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
return token;
}
/**
*
*
* @param token
* @return
*/
public static Claims parseToken(String token){
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
}
/**
*
*
* @param token
* @return ID
*/
public static String getUserKey(String token){
Claims claims = parseToken(token);
return getValue(claims, JwtConstants.USER_KEY);
}
/**
*
*
* @param claims
* @return ID
*/
public static String getUserKey(Claims claims){
return getValue(claims, JwtConstants.USER_KEY);
}
/**
* ID
*
* @param token
* @return ID
*/
public static String getUserId(String token){
Claims claims = parseToken(token);
return getValue(claims, JwtConstants.DETAILS_USER_ID);
}
/**
* ID
*
* @param claims
* @return ID
*/
public static String getUserId(Claims claims){
return getValue(claims, JwtConstants.DETAILS_USER_ID);
}
/**
*
*
* @param token
* @return
*/
public static String getUserName(String token){
Claims claims = parseToken(token);
return getValue(claims, JwtConstants.DETAILS_USERNAME);
}
/**
*
*
* @param claims
* @return
*/
public static String getUserName(Claims claims){
return getValue(claims, JwtConstants.DETAILS_USERNAME);
}
/**
*
*
* @param claims
* @param key
* @return
*/
public static String getValue(Claims claims, String key){
Object obj = claims.get(key);
return obj == null ? "" : obj.toString();
}
}

View File

@ -0,0 +1,68 @@
package com.bwie.common.utils;
import org.springframework.util.AntPathMatcher;
import java.util.Collection;
import java.util.List;
/**
* @author DongZl
* @description:
*/
public class StringUtils extends org.apache.commons.lang3.StringUtils {
/**
* *
*
* @param object Object
* @return true false
*/
public static boolean isNull(Object object) {
return object == null;
}
/**
* * Collection ListSetQueue
*
* @param coll Collection
* @return true false
*/
public static boolean isEmpty(Collection<?> coll) {
return isNull(coll) || coll.isEmpty();
}
/**
*
*
* @param str
* @param strs
* @return
*/
public static boolean matches(String str, List<String> strs) {
if (isEmpty(str) || isEmpty(strs)) {
return false;
}
for (String pattern : strs) {
if (isMatch(pattern, str))
{
return true;
}
}
return false;
}
/**
* url:
* ? ;
* * ;
* ** ;
*
* @param pattern
* @param url url
* @return
*/
public static boolean isMatch(String pattern, String url) {
AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url);
}
}

View File

@ -0,0 +1,88 @@
package com.bwie.common.utils;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.teaopenapi.models.Config;
import lombok.extern.log4j.Log4j2;
import java.util.Map;
/**
*
*/
@Log4j2
public class TelSmsUtils {
/**
* AccessKeyaccessKeySecretAPI访
*/
private static String accessKeyId = "LTAI5tQWdAodc1EJ1doShoW4";
private static String accessKeySecret = "9MbfDBJ3Efqc6iN5yPFX0zq3ZErsII";
private static String templateCode = "SMS0001";
/**
* 访
*/
private static String endpoint = "dysmsapi.aliyuncs.com";
/**
*
*/
private static String signName = "登录验证";
/**
*
*/
private static Client client;
static {
log.info("初始化短信服务开始");
long startTime = System.currentTimeMillis();
try {
client = initClient();
log.info("初始化短信成功:{}",signName);
} catch (Exception e) {
e.printStackTrace();
}
log.info("初始化短信服务结束:耗时:{}MS",(System.currentTimeMillis()-startTime));
}
/**
*
* @return
* @throws Exception
*/
private static Client initClient() throws Exception{
Config config = new Config()
// 您的AccessKey ID
.setAccessKeyId(accessKeyId)
// 您的AccessKey Secret
.setAccessKeySecret(accessKeySecret);
// 访问的域名
config.endpoint = endpoint;
return new Client(config);
}
/**
*
* @param tel
* @param templateCode SMS_153991546
* @param sendDataMap
*/
public static String sendSms(String tel, String templateCode,Map<String,String> sendDataMap){
SendSmsRequest sendSmsRequest = new SendSmsRequest()
.setPhoneNumbers(tel)
.setSignName(signName)
.setTemplateCode(templateCode)
.setTemplateParam(JSONObject.toJSONString(sendDataMap));
SendSmsResponse sendSmsResponse = null;
try {
log.info("发送短信验证码:消息内容是:【{}】", JSONObject.toJSONString(sendDataMap));
sendSmsResponse = client.sendSms(sendSmsRequest);
} catch (Exception e) {
log.error("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", tel, sendDataMap, e);
}
return JSONObject.toJSONString(sendSmsResponse.getBody());
}
}

38
bwie-gateway/.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>monthA8.12</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-gateway</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 公共模块 -->
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
</dependency>
<!-- 网关依赖 -->
<!-- SpringCloud Gateway -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel Gateway -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<!-- 引入阿里巴巴sentinel限流 依赖-->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,18 @@
package com.bwie.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @Authorweiran
* @Packagecom.bwie.gateway
* @ProjectmonthA8.12
* @nameGateWayApplication
* @Date2024/8/12 9:10
*/
@SpringBootApplication
public class GateWayApplication {
public static void main(String[] args) {
SpringApplication.run(GateWayApplication.class, args);
}
}

View File

@ -0,0 +1,32 @@
package com.bwie.gateway.config;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @author DongZl
*/
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "ignore")
@Data
@Log4j2
public class IgnoreWhiteConfig {
/**
*
*/
private List<String> whites = new ArrayList<>();
public void setWhites(List<String> whites) {
log.info("加载网关路径白名单:{}", JSONObject.toJSONString(whites));
this.whites = whites;
}
}

View File

@ -0,0 +1,82 @@
package com.bwie.gateway.filters;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.utils.JwtUtils;
import com.bwie.common.utils.StringUtils;
import com.bwie.gateway.config.IgnoreWhiteConfig;
import com.bwie.gateway.utils.GatewayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.*;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Component
public class AuthFilter implements GlobalFilter, Ordered {
@Autowired
private IgnoreWhiteConfig ignoreWhiteConfig;
@Autowired
private StringRedisTemplate redisTemplate;
/**
*
* @name:weiran
* @param exchange
* @param chain
* @return
*/
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
// 验证请求是否是白名单请求
// 加载系统白名单请求
List<String> whites = ignoreWhiteConfig.getWhites();
// 判断当前请求的 URI 是否是白名单
ServerHttpRequest request = exchange.getRequest();
String path = request.getURI().getPath();
if (StringUtils.matches(path, whites)) {
// 是白名单请求直接放行
return chain.filter(exchange);
}
// 验证 token 获取 token
String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
// 非空验证
if (StringUtils.isBlank(token)) {
return GatewayUtils.errorResponse(exchange, "无权访问");
}
// 合法性验证
try {
JwtUtils.parseToken(token);
} catch (Exception ex) {
return GatewayUtils.errorResponse(exchange, "token不合法");
}
// 有效性验证 判断 Redis中存储的响应的用户是否过期
String userKey = JwtUtils.getUserKey(token);
if (!redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY + userKey)) {
return GatewayUtils.errorResponse(exchange, "token过期");
} else {
// 续期
redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY + userKey, 30, TimeUnit.MINUTES);
}
// 方形
return chain.filter(exchange);
}
/**
*
* @return
*/
@Override
public int getOrder() {
return 0;
}
}

View File

@ -0,0 +1,98 @@
package com.bwie.gateway.utils;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.result.Result;
import com.bwie.common.utils.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
/**
* @author weiran
* @description:
*/
@Log4j2
public class GatewayUtils {
/**
*
* @param mutate
* @param key
* @param value
*/
public static void addHeader(ServerHttpRequest.Builder mutate, String key, Object value) {
if (StringUtils.isEmpty(key)){
log.warn("添加请求头参数键不可以为空");
return;
}
if (value == null) {
log.warn("添加请求头参数:[{}]值为空",key);
return;
}
String valueStr = value.toString();
mutate.header(key, valueStr);
log.info("添加请求头参数成功 - 键:[{}] , 值:[{}]", key , value);
}
/**
*
* @param mutate
* @param key
*/
public static void removeHeader(ServerHttpRequest.Builder mutate, String key) {
if (StringUtils.isEmpty(key)){
log.warn("删除请求头参数键不可以为空");
return;
}
mutate.headers(httpHeaders -> httpHeaders.remove(key)).build();
log.info("删除请求头参数 - 键:[{}]",key);
}
/**
*
* @param exchange
* @param msg
* @return
*/
public static Mono<Void> errorResponse(ServerWebExchange exchange, String msg, HttpStatus httpStatus) {
ServerHttpResponse response = exchange.getResponse();
//设置HTTP响应头状态
response.setStatusCode(httpStatus);
//设置HTTP响应头文本格式
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
//定义响应内容
Result<?> result = Result.error(msg);
String resultJson = JSONObject.toJSONString(result);
log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
//进行响应
return response.writeWith(Mono.just(dataBuffer));
}
/**
*
* @param exchange
* @param msg
* @return
*/
public static Mono<Void> errorResponse(ServerWebExchange exchange, String msg) {
ServerHttpResponse response = exchange.getResponse();
//设置HTTP响应头状态
response.setStatusCode(HttpStatus.OK);
//设置HTTP响应头文本格式
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
//定义响应内容
Result<?> result = Result.error(msg);
String resultJson = JSONObject.toJSONString(result);
log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
//进行响应
return response.writeWith(Mono.just(dataBuffer));
}
}

View File

@ -0,0 +1,31 @@
# Tomcat
server:
port: 18080
# Spring
spring:
application:
# 应用名称
name: bwie-gateway
profiles:
# 环境配置
active: dev
main:
# 允许使用循环引用
allow-circular-references: true
# 允许定义相同的bean对象 去覆盖原有的
allow-bean-definition-overriding: true
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 122.51.12.81:8848
namespace: nacos
config:
# 配置中心地址
server-addr: 122.51.12.81:8848
namespace: nacos
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

38
bwie-modules/.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>bwie-modules</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-coupon</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 系统公共 依赖 -->
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
</dependency>
<!-- SpringBoot Web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Mybatis 依赖配置 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.26.5</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,36 @@
package com.bwie.coupon;
import com.bwie.coupon.service.CouponService;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import javax.annotation.PostConstruct;
/**
* @Authorweiran
* @Packagecom.bwie.coupon
* @ProjectmonthA8.12
* @nameCouponApplication
* @Date2024/8/12 11:11
*/
@SpringBootApplication
@EnableFeignClients
public class CouponApplication {
public static void main(String[] args) {
SpringApplication.run(CouponApplication.class,args);
}
@Bean
public Queue initQueue(){
return new Queue("updatemoney");
}
}

View File

@ -0,0 +1,90 @@
package com.bwie.coupon.controller;
import com.bwie.common.domain.request.CouponBuyReq;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.exception.ProductException;
import com.bwie.common.result.Result;
import com.bwie.coupon.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.controller
* @ProjectmonthA8.12
* @nameCouponController
* @Date2024/8/12 11:04
*/
@RestController
@RequestMapping("/coupon")
public class CouponController {
@Autowired
private CouponService couponService;
/**
*
* @param couponReq
* @return
*/
@PostMapping("/getList")
public Result getList(@RequestBody CouponReq couponReq){
return Result.success(couponService.getList(couponReq));
}
/**
*
*/
@PostMapping("/getTypeList")
public Result getTypeList(){
return Result.success(couponService.getTypeList());
}
/**
*
*/
@PostMapping("/gettypeListBytypeGroupname")
public Result gettypeListBytypeGroupname(){
return Result.success(couponService.gettypeListBytypeGroupname());
}
/**
*
* @param couponBuyReq
* @return
*/
@PostMapping("/buyyes")
public Result buyyes(@RequestBody CouponBuyReq couponBuyReq){
Integer buy = couponService.buy(couponBuyReq);
if (buy>0){
return Result.success();
}
throw new ProductException("生成订单出现异常");
}
/**
*
*/
@PostMapping("/getmycouponList")
public Result getmycouponList(){
return Result.success(couponService.findMycoupon()) ;
}
/**
* MQES
*/
@PostMapping("/updes")
public void updes(){
couponService.updes();
}
/**
*
*/
@PostMapping("/choosetypeRroup/{typeGroupname}")
public Result choosetypeRroup(@PathVariable String typeGroupname){
return Result.success(couponService.choosetypeRroup(typeGroupname));
}
}

View File

@ -0,0 +1,76 @@
package com.bwie.coupon.controller;
import com.bwie.common.domain.Order;
import com.bwie.common.domain.request.CouponSellReq;
import com.bwie.common.exception.ProductException;
import com.bwie.common.result.Result;
import com.bwie.coupon.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
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;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.controller
* @ProjectmonthA8.12
* @nameOrderController
* @Date2024/8/12 15:54
*/
@RestController
@RequestMapping("/order")
public class OrderController {
@Autowired
private OrderService orderService;
/**
*
* @return
*/
@PostMapping("/getList")
public Result getList(){
return Result.success(orderService.getList());
}
/**
*
* @param order
* @return
*/
@PostMapping("/updateorderstatus")
public Result updateorderstatus(@RequestBody Order order){
Integer updateorderstatus = orderService.updateorderstatus(order);
if (updateorderstatus>0){
return Result.success();
}
throw new ProductException("确认收货异常,请稍后再试");
}
/**
* 48
*/
@Scheduled(cron = "* * 0/48 * * *")
@PostMapping("/receive")
public void receive(){
orderService.receive();
}
/**
*
* @param couponSellReq
* @return
*/
@PostMapping("/sellyes")
public Result sellyes(@RequestBody CouponSellReq couponSellReq){
Integer sellyes = orderService.sellyes(couponSellReq);
if (sellyes>0){
return Result.success();
}
throw new ProductException("售卖异常,请稍后再试");
}
}

View File

@ -0,0 +1,21 @@
package com.bwie.coupon.feign;
import com.bwie.common.domain.request.ReduceMoneyReq;
import com.bwie.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.feign
* @ProjectmonthA8.12
* @nameCouponFeign
* @Date2024/8/12 17:34
*/
@FeignClient("bwie-user")
public interface CouponFeign {
@PostMapping("/user/user/addmoney")
Result addmoney(@RequestBody ReduceMoneyReq reduceMoneyReq);
}

View File

@ -0,0 +1,47 @@
package com.bwie.coupon.mapper;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.MyCoupon;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.CouponBuyReq;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.domain.request.CouponSellReq;
import com.bwie.common.domain.response.CouponResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.mapper
* @ProjectmonthA8.12
* @nameCouponMapper
* @Date2024/8/12 11:03
*/
@Mapper
public interface CouponMapper {
List<CouponResp> getList(CouponReq couponReq);
List<Type> getTypeList();
List<Type> gettypeListBytypeGroupname();
Integer addorder(CouponBuyReq couponBuyReq);
void reducecouponNum(@Param("couponId") Integer couponId);
void addmycoupon(CouponBuyReq couponBuyReq);
List<MyCoupon> findMycoupon();
void del(CouponSellReq couponSellReq);
List<Coupon> findall();
MyCoupon findByname(@Param("couponName") String couponName);
List<CouponResp> choosetypeRroup(@Param("typeGroupname") String typeGroupname);
}

View File

@ -0,0 +1,29 @@
package com.bwie.coupon.mapper;
import com.bwie.common.domain.Order;
import com.bwie.common.domain.request.CouponSellReq;
import org.apache.ibatis.annotations.Mapper;
import org.aspectj.weaver.ast.Or;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.mapper
* @ProjectmonthA8.12
* @nameOrderMapper
* @Date2024/8/12 15:54
*/
@Mapper
public interface OrderMapper {
List<Order> getList();
Integer updateorderstatus(Order order);
List<Order> findBytime();
Integer add(CouponSellReq couponSellReq);
List<Order> findorder();
}

View File

@ -0,0 +1,48 @@
package com.bwie.coupon.service;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.MyCoupon;
import com.bwie.common.domain.Order;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.CouponBuyReq;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.domain.request.CouponSellReq;
import com.bwie.common.domain.response.CouponResp;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.service
* @ProjectmonthA8.12
* @nameCouponService
* @Date2024/8/12 11:04
*/
public interface CouponService {
/**
*
* @param couponReq
* @return
*/
List<CouponResp> getList(CouponReq couponReq);
/**
*
*/
List<Type> getTypeList();
List<Type> gettypeListBytypeGroupname();
Integer buy(CouponBuyReq couponBuyReq);
List<MyCoupon> findMycoupon();
void del(CouponSellReq couponSellReq);
void updes();
List<CouponResp> choosetypeRroup(String typeGroupname);
}

View File

@ -0,0 +1,24 @@
package com.bwie.coupon.service;
import com.bwie.common.domain.Order;
import com.bwie.common.domain.request.CouponSellReq;
import com.bwie.common.result.Result;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.service
* @ProjectmonthA8.12
* @nameOrderService
* @Date2024/8/12 15:54
*/
public interface OrderService {
List<Order> getList();
Integer updateorderstatus(Order order);
void receive();
Integer sellyes(CouponSellReq couponSellReq);
}

View File

@ -0,0 +1,135 @@
package com.bwie.coupon.service.impl;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.common.utils.RandomUtils;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.MyCoupon;
import com.bwie.common.domain.Order;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.CouponBuyReq;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.domain.request.CouponSellReq;
import com.bwie.common.domain.response.CouponResp;
import com.bwie.common.exception.ProductException;
import com.bwie.coupon.mapper.CouponMapper;
import com.bwie.coupon.service.CouponService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.service.impl
* @ProjectmonthA8.12
* @nameCouponServiceImpl
* @Date2024/8/12 11:04
*/
@Service
public class CouponServiceImpl implements CouponService {
@Autowired
private CouponMapper couponMapper;
@Autowired
private RabbitTemplate rabbitTemplate;
/**
*
* @param couponReq
* @return
*/
@Override
public List<CouponResp> getList(CouponReq couponReq) {
List<CouponResp> list = couponMapper.getList(couponReq);
return list;
}
/**
*
*/
@Override
public List<Type> getTypeList() {
List<Type> typeList = couponMapper.getTypeList();
return typeList;
}
/**
*
*/
@Override
public List<Type> gettypeListBytypeGroupname() {
List<Type> types = couponMapper.gettypeListBytypeGroupname();
return types;
}
/**
*
* @param couponBuyReq
* @return
*/
@Override
public Integer buy(CouponBuyReq couponBuyReq) {
MyCoupon byname = couponMapper.findByname(couponBuyReq.getCouponName());
if (byname!=null){
throw new ProductException("您已购买完成,无法再次进行购买");
}
//生成兑换码
String code = RandomUtil.randomNumbers(10);
couponBuyReq.setExchangeNum(code);
//生成订单
Integer addorder = couponMapper.addorder(couponBuyReq);
if (addorder>0){
//自己的仓库中添加购买的券
couponMapper.addmycoupon(couponBuyReq);
//异步给客户扣款
rabbitTemplate.convertAndSend("updatemoney", JSON.toJSONString(couponBuyReq), message->{
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
return message;
});
//生成订单成功后,库存-1
couponMapper.reducecouponNum(couponBuyReq.getCouponId());
}
return addorder;
}
@Override
public List<MyCoupon> findMycoupon() {
return couponMapper.findMycoupon();
}
@Override
public void del(CouponSellReq couponSellReq) {
couponMapper.del(couponSellReq);
}
/**
* MQES
*/
@Override
public void updes() {
List<Coupon> findall = couponMapper.findall();
//MQ进行异步更新ES索引库
rabbitTemplate.convertAndSend("updatees",findall, message->{
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
return message;
});
}
@Override
public List<CouponResp> choosetypeRroup(String typeGroupname) {
return couponMapper.choosetypeRroup(typeGroupname);
}
}

View File

@ -0,0 +1,122 @@
package com.bwie.coupon.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.domain.Order;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.CouponSellReq;
import com.bwie.common.domain.request.ReduceMoneyReq;
import com.bwie.common.utils.JwtUtils;
import com.bwie.coupon.feign.CouponFeign;
import com.bwie.coupon.mapper.OrderMapper;
import com.bwie.coupon.service.CouponService;
import com.bwie.coupon.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Objects;
/**
* @Authorweiran
* @Packagecom.bwie.coupon.service.impl
* @ProjectmonthA8.12
* @nameOrderServiceImpl
* @Date2024/8/12 15:54
*/
@Service
public class OrderServiceImpl implements OrderService {
@Autowired
private OrderMapper orderMapper;
@Autowired
private HttpServletRequest request;
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private CouponFeign couponFeign;
@Autowired
private CouponService couponService;
@Autowired
private RedisTemplate<Object,Object> redisTemplate1;
/**
*
* @return
*/
@Override
public List<Order> getList() {
return orderMapper.getList();
}
/**
*
* @param order
* @return
*/
@Override
public Integer updateorderstatus(Order order) {
return orderMapper.updateorderstatus(order);
}
/**
* 48
*/
@Override
public void receive() {
//查询出48小时之后还未收到的信息
List<Order> list = orderMapper.findBytime();
for (Order order : list) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime parse = LocalDateTime.parse(order.getOrderTime(), dateTimeFormatter);
LocalDateTime now = LocalDateTime.now();
long between = ChronoUnit.HOURS.between(parse, now);
if (between>24){
orderMapper.updateorderstatus(order);
}
}
}
/**
*
* @param couponSellReq
* @return
*/
@Override
public Integer sellyes(CouponSellReq couponSellReq) {
//生成订单
Integer add = orderMapper.add(couponSellReq);
if (add>0){
//用户余额加款
String token = request.getHeader("token");
String userKey = JwtUtils.getUserKey(token);
String code = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
User user = JSONObject.parseObject(code, User.class);
ReduceMoneyReq reduceMoneyReq = new ReduceMoneyReq(user.getUserId(), couponSellReq.getMoney());
couponFeign.addmoney(reduceMoneyReq);
//把售卖的券码删除
couponService.del(couponSellReq);
}
List<Order> findorder = orderMapper.findorder();
for (Order order : findorder) {
List<Object> range = redisTemplate1.opsForList().range(order.getOrderId(), 0, -1);
if (range==null){
redisTemplate1.opsForSet().add(order.getOrderId(), order);
}
}
return add;
}
}

View File

@ -0,0 +1,55 @@
package com.bwie.coupon.utils;
import org.springframework.stereotype.Component;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
/**
* @BelongsProject: 0107day02
* @BelongsPackage: com.bw.config
* @Author: zhupengfei
* @CreateTime: 2023-02-01 08:52
*/
@Component
public class FastUtil {
private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
@Resource
private FastFileStorageClient storageClient ;
/**
*
*/
public String upload(MultipartFile multipartFile) throws Exception{
String originalFilename = multipartFile.getOriginalFilename().
substring(multipartFile.getOriginalFilename().
lastIndexOf(".") + 1);
StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
multipartFile.getInputStream(),
multipartFile.getSize(),originalFilename , null);
return storePath.getFullPath() ;
}
/**
*
*/
public String deleteFile(String fileUrl) {
if (StringUtils.isEmpty(fileUrl)) {
log.info("fileUrl == >>文件路径为空...");
return "文件路径不能为空";
}
try {
StorePath storePath = StorePath.parseFromUrl(fileUrl);
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
} catch (Exception e) {
log.error(e.getMessage());
}
return "删除成功";
}
}

View File

@ -0,0 +1,31 @@
# Tomcat
server:
port: 9003
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-coupon
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 122.51.12.81:8848
namespace: nacos
config:
# 配置中心地址
server-addr: 122.51.12.81:8848
namespace: nacos
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bwie.coupon.mapper.CouponMapper">
<select id="getList" resultType="com.bwie.common.domain.response.CouponResp">
SELECT
coupon.*,
type.type_name,
type.type_groupname
FROM
coupon
LEFT JOIN type ON coupon.type_id = type.type_id
<where>
<if test="couponName!=null and couponName!=''">
and coupon_name like '%${couponName}%'
</if>
<if test="typeId!=null and typeId!=''">
and typeId=#{typeId}
</if>
<if test="typeGroupname!=null and typeGroupname!=''">
and type.type_groupname=#{typeGroupname}
</if>
<if test="typeName!=null and typeName!=''">
and type.type_name=#{typeName}
</if>
</where>
</select>
<select id="getTypeList" resultType="com.bwie.common.domain.Type">
select * from type
</select>
<select id="gettypeListBytypeGroupname" resultType="com.bwie.common.domain.Type">
select * from type GROUP BY type_groupname
</select>
<select id="findMycoupon" resultType="com.bwie.common.domain.MyCoupon">
select * from mycoupon
</select>
<select id="findall" resultType="com.bwie.common.domain.Coupon">
SELECT
coupon.*,
type.type_name,
type.type_groupname
FROM
coupon
LEFT JOIN type ON coupon.type_id = type.type_id
</select>
<select id="findByname" resultType="com.bwie.common.domain.MyCoupon">
select * from mycoupon where coupon_name=#{couponName}
</select>
<select id="choosetypeRroup" resultType="com.bwie.common.domain.response.CouponResp">
SELECT
coupon.*,
type.type_name,
type.type_groupname
FROM
coupon
LEFT JOIN type ON coupon.type_id = type.type_id
<where>
and type.type_groupname=#{typeGroupname}
</where>
</select>
<insert id="addorder">
INSERT INTO `month8.12`.`order1`
(`order_id`, `coupon_id`, `coupon_name`, `exchange_num`, `order_money`, `order_time`, `order_status`) VALUES
(0, #{couponId}, #{couponName}, #{exchangeNum}, #{money}, now(), 0);
</insert>
<insert id="addmycoupon">
INSERT INTO `month8.12`.`mycoupon`
(`coupon_id`, `coupon_name`, `coupon_num`, `coupon_price`, `coupon_status`, `type_id`) VALUES
(0, #{couponName},1, #{couponPrice}, 0, #{typeId});
</insert>
<update id="reducecouponNum">
update coupon set coupon_num=coupon_num-1 where coupon_id=#{couponId}
</update>
<delete id="del">
delete from mycoupon where coupon_id=#{couponId}
</delete>
</mapper>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bwie.coupon.mapper.OrderMapper">
<select id="getList" resultType="com.bwie.common.domain.Order">
select * from order1
</select>
<select id="findBytime" resultType="com.bwie.common.domain.Order">
select * from order1
</select>
<select id="findorder" resultType="com.bwie.common.domain.Order">
select * from order1
</select>
<update id="updateorderstatus">
update order1 set order_status=1 where order_id=#{orderId}
</update>
<insert id="add">
INSERT INTO `month8.12`.`order1`
(`order_id`, `coupon_id`, `coupon_name`, `exchange_num`, `order_money`, `order_time`, `order_status`) VALUES
(0, #{couponId}, #{couponName}, #{exchangeNum}, #{money}, #{time}, 2);
</insert>
</mapper>

38
bwie-modules/bwie-es/.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>bwie-modules</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-es</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>
</dependencies>
<!-- es:-->
<!-- hostname: 106.54.222.192-->
<!-- port: 9200-->
<!-- scheme: http-->
</project>

View File

@ -0,0 +1,30 @@
package com.bwie.es;
import com.bwie.es.controller.EsController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import javax.annotation.PostConstruct;
/**
* @Authorweiran
* @Packagecom.bwie.es
* @ProjectmonthA8.12
* @nameEsApplication
* @Date2024/8/12 11:45
*/
@SpringBootApplication
public class EsApplication {
public static void main(String[] args) {
SpringApplication.run(EsApplication.class, args);
}
@Autowired
private EsController esController;
// @PostConstruct
// public void toES(){
// esController.bathadd();
// }
}

View File

@ -0,0 +1,25 @@
package com.bwie.es.config;
import lombok.Data;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "es")
@Data
public class InitEsRes {
private String host;
private int port;
private String scheme;
@Bean
public RestHighLevelClient restHighLevelClient(){
return new RestHighLevelClient(
RestClient.builder(new HttpHost(host,port,scheme))
);
}
}

View File

@ -0,0 +1,49 @@
package com.bwie.es.controller;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.result.Result;
import com.bwie.es.service.EsService;
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;
/**
* @Authorweiran
* @Packagecom.bwie.es.controller
* @ProjectmonthA8.12
* @nameEsController
* @Date2024/8/12 11:49
*/
@RestController
@RequestMapping("/es")
public class EsController {
@Autowired
private EsService esService;
/**
*
* @param coupons
*/
@PostMapping("/bathadd")
public Result bathadd(@RequestBody List<Coupon> coupons){
esService.bathadd(coupons);
return Result.success();
}
/**
*
*/
@PostMapping("/search")
public Result search(@RequestBody CouponReq couponReq){
return Result.success(esService.search(couponReq));
}
}

View File

@ -0,0 +1,20 @@
package com.bwie.es.service;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.domain.response.CouponResp;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.es.service
* @ProjectmonthA8.12
* @nameEsService
* @Date2024/8/12 11:49
*/
public interface EsService {
void bathadd(List<Coupon> coupons);
List<CouponResp> search(CouponReq couponReq);
}

View File

@ -0,0 +1,121 @@
package com.bwie.es.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.domain.response.CouponResp;
import com.bwie.common.utils.StringUtils;
import com.bwie.es.service.EsService;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Authorweiran
* @Packagecom.bwie.es.service.impl
* @ProjectmonthA8.12
* @nameEsServiceImpl
* @Date2024/8/12 11:49
*/
@Service
public class EsServiceImpl implements EsService {
@Autowired
private RestHighLevelClient restHighLevelClient;
private static final String INDEX_NAME="coupon";
/**
*
* @param coupons
*/
@Override
public void bathadd(List<Coupon> coupons) {
BulkRequest bulkRequest = new BulkRequest();
for (Coupon coupon : coupons) {
bulkRequest.add(new IndexRequest(INDEX_NAME)
.id(coupon.getCouponId()+"")
.source(JSONObject.toJSONString(coupon), XContentType.JSON));
}
try {
restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
*
*/
@Override
public List<CouponResp> search(CouponReq couponReq) {
ArrayList<CouponResp> couponResps = new ArrayList<>();
try {
SearchRequest searchRequest = new SearchRequest(INDEX_NAME);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if (StringUtils.isNotBlank(couponReq.getCouponName())){
boolQueryBuilder.must(QueryBuilders.matchQuery("couponName", couponReq.getCouponName()));
}
if (couponReq.getTypeId()!=null){
boolQueryBuilder.must(QueryBuilders.matchQuery("typeId", couponReq.getTypeId()));
}
searchSourceBuilder.query(boolQueryBuilder);
searchSourceBuilder.highlighter(
new HighlightBuilder()
.field("couponName")
.preTags("<span style=\"color:red;\">")
.postTags("</span>")
);
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
SearchHits hits = searchResponse.getHits();
SearchHit[] searchHits = hits.getHits();
for (SearchHit searchHit : searchHits) {
if (searchHit!=null){
String sourceAsString = searchHit.getSourceAsString();
CouponResp couponResp = JSONObject.parseObject(sourceAsString, CouponResp.class);
Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
HighlightField highlightField = highlightFields.get("couponName");
Text[] fragments = highlightField.fragments();
String str="";
for (Text fragment : fragments) {
str+=fragment;
couponResp.setCouponName(str);
}
couponResps.add(couponResp);
}
}
return couponResps;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,35 @@
# Tomcat
server:
port: 9005
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-es
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 122.51.12.81:8848
namespace: nacos
config:
# 配置中心地址
server-addr: 122.51.12.81:8848
namespace: nacos
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
es:
host: 122.51.12.81
port: 9200
scheme: http

38
bwie-modules/bwie-mq/.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>bwie-modules</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-mq</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- rabbitMQ -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,20 @@
package com.bwie.mq;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @Authorweiran
* @Packagecom.bwie.mq
* @ProjectmonthA8.12
* @nameMqApplication
* @Date2024/8/12 9:09
*/
@SpringBootApplication
@EnableFeignClients
public class MqApplication {
public static void main(String[] args) {
SpringApplication.run(MqApplication.class,args);
}
}

View File

@ -0,0 +1,45 @@
package com.bwie.mq.config;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* @ClassName:
* @Description: broker
* @Author: zhuwenqiang
* @Date: 2024/3/29
*/
@Component
public class ConfirmCallbackConfig implements RabbitTemplate.ConfirmCallback {
@Autowired
private RabbitTemplate rabbitTemplate;
/**
* ConfirmCallbackConfig
*/
@PostConstruct
public void init() {
this.rabbitTemplate.setConfirmCallback(this);
}
/**
* broker
* @param correlationData correlation data for the callback.
* @param ack true for ack, false for nack
* @param cause An optional cause, for nack, when available, otherwise null.
*/
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
if (ack) {
System.out.println("消息发送到broker成功");
} else {
System.out.println("消息发送到broker失败失败的原因" + cause);
}
}
}

View File

@ -0,0 +1,47 @@
package com.bwie.mq.config;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* rabbitAdmin RabbitAdmin
*/
@Configuration
public class RabbitAdminConfig {
@Value("${spring.rabbitmq.host}")
private String host;
@Value("${spring.rabbitmq.username}")
private String username;
@Value("${spring.rabbitmq.password}")
private String password;
@Value("${spring.rabbitmq.virtualhost}")
private String virtualhost;
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setAddresses(host);
connectionFactory.setUsername(username);
connectionFactory.setPassword(password);
connectionFactory.setVirtualHost(virtualhost);
// 设置消息发送确认
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
connectionFactory.setPublisherReturns(true);
//我们将填充好的 cachingConnectionFactory 实例进行返回,以初始化完成 RabbitMQ 客户端连接
return connectionFactory;
}
@Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
rabbitAdmin.setAutoStartup(true);
return rabbitAdmin;
}
}

View File

@ -0,0 +1,15 @@
package com.bwie.mq.config;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitmqConfig {
// 消息转换配置
@Bean
public MessageConverter jsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
}

View File

@ -0,0 +1,34 @@
package com.bwie.mq.config;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
*
*/
@Component
public class ReturnCallbackConfig implements RabbitTemplate.ReturnsCallback {
@Autowired
private RabbitTemplate rabbitTemplate;
@PostConstruct // @PostContruct是spring框架的注解在⽅法上加该注解会在项⽬启动的时候执⾏该⽅法也可以理解为在spring容器初始化的时候执
public void init() {
rabbitTemplate.setReturnsCallback(this);
}
/**
*
* @param returnedMessage the returned message and metadata.
*/
@Override
public void returnedMessage(ReturnedMessage returnedMessage) {
System.out.println("消息" + returnedMessage.getMessage().toString() + "被交换机" + returnedMessage.getExchange() + "回退!"
+ "退回原因为:" + returnedMessage.getReplyText());
// TODO 回退了所有的信息,可做补偿机制
}
}

View File

@ -0,0 +1,67 @@
package com.bwie.mq.consumer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.CouponBuyReq;
import com.bwie.common.domain.request.ReduceMoneyReq;
import com.bwie.common.result.Result;
import com.bwie.common.utils.JwtUtils;
import com.bwie.mq.feign.MqFeign;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* @Authorweiran
* @Packagecom.bwie.mq.consumer
* @ProjectmonthA8.12
* @nameUpdateMoney
* @Date2024/8/12 16:18
*/
@Component
public class UpdateMoney {
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private HttpServletRequest request;
@Autowired
private MqFeign mqFeign;
@RabbitListener(queuesToDeclare = @Queue("updatemoney"))
public void UpdateMoney(String coupons , Message message, Channel channel){
CouponBuyReq couponBuyReq = JSON.parseObject(coupons, CouponBuyReq.class);
String messageId = message.getMessageProperties().getMessageId();
Long userKey1 = redisTemplate.opsForSet().add("UPDATEMONEY", messageId);
if (userKey1>0 && userKey1==1){
String token = request.getHeader("token");
String userKey = JwtUtils.getUserKey(token);
String code = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
User user = JSONObject.parseObject(code, User.class);
ReduceMoneyReq reduceMoneyReq = new ReduceMoneyReq(user.getUserId(), couponBuyReq.getCouponPrice());
Result changemoney = mqFeign.changemoney(reduceMoneyReq);
try {
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
try {
redisTemplate.opsForSet().remove("UPDATEMONEY", messageId);
channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
throw new RuntimeException(e);
}
}
}
}

View File

@ -0,0 +1,60 @@
package com.bwie.mq.consumer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.CouponBuyReq;
import com.bwie.common.domain.request.ReduceMoneyReq;
import com.bwie.common.result.Result;
import com.bwie.common.utils.JwtUtils;
import com.bwie.mq.feign.MqFeign;
import com.bwie.mq.feign.ToEsFeign;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.mq.consumer
* @ProjectmonthA8.12
* @nameupdatees
* @Date2024/8/12 18:00
*/
public class updatees {
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private HttpServletRequest request;
@Autowired
private ToEsFeign toEsFeign;
@RabbitListener(queuesToDeclare = @Queue("updatees"))
public void updatees(List<Coupon> couponList, Message message, Channel channel){
String messageId = message.getMessageProperties().getMessageId();
toEsFeign.bathadd(couponList);
try {
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
try {
redisTemplate.opsForSet().remove("UPDATEES", messageId);
channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,21 @@
package com.bwie.mq.feign;
import com.bwie.common.domain.request.ReduceMoneyReq;
import com.bwie.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @Authorweiran
* @Packagecom.bwie.mq.feign
* @ProjectmonthA8.12
* @nameMqFeign
* @Date2024/8/12 16:24
*/
@FeignClient("bwie-user")
public interface MqFeign {
@PostMapping("/user/user/changemoney")
Result changemoney(@RequestBody ReduceMoneyReq reduceMoneyReq);
}

View File

@ -0,0 +1,36 @@
package com.bwie.mq.feign;
import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.request.CouponReq;
import com.bwie.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.mq.feign
* @ProjectmonthA8.12
* @nameToEsFeign
* @Date2024/8/12 18:02
*/
@FeignClient("bwie-es")
public interface ToEsFeign {
/**
*
* @param coupons
*/
@PostMapping("/es/es/bathadd")
public Result bathadd(@RequestBody List<Coupon> coupons);
/**
*
*/
@PostMapping("/es/es/search")
public Result search(@RequestBody CouponReq couponReq);
}

View File

@ -0,0 +1,95 @@
package com.bwie.mq.utils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* normalqueue
*/
@Component
public class DLXQueue {
/**
*
*/
private static final String DEAD_ROUTING_KEY = "dead.routingkey";
/**
* ttl
*/
private static final String ROUTING_KEY = "routingkey";
/**
*
*/
private static final String DEAD_EXCHANGE = "dead.exchange";
/**
* ttl
*/
private static final String EXCHANGE = "common.exchange";
@Autowired
RabbitTemplate rabbitTemplate;
@Resource
RabbitAdmin rabbitAdmin;
/**
*
*
* @param queueName
* @param deadQueueName
* @param params
* @param expiration
*/
public void sendDLXQueue(String queueName, String deadQueueName, Object params, Integer expiration) {
/**
* ----------------------------------ttl--------------------------------------------
*/
Map<String, Object> map = new HashMap<>();
// 队列设置存活时间单位ms, 必须是整形数据。
map.put("x-message-ttl", expiration);
// 设置死信交换机
map.put("x-dead-letter-exchange", DEAD_EXCHANGE);
// 设置死信交换器路由
map.put("x-dead-letter-routing-key", DEAD_ROUTING_KEY);
/*参数1队列名称 参数2持久化 参数3是否排他 参数4自动删除队列 参数5队列参数*/
Queue queue = new Queue(queueName, true, false, false, map);
rabbitAdmin.declareQueue(queue);
/**
* ------------------------------------------------------------------------------
*/
DirectExchange directExchange = new DirectExchange(EXCHANGE, true, false);
rabbitAdmin.declareExchange(directExchange);
/**
* ------------------------------------------------------------------------------
*/
Binding binding = BindingBuilder.bind(queue).to(directExchange).with(ROUTING_KEY);
rabbitAdmin.declareBinding(binding);
/**
* ------------------------------------------------------------------------------
*/
DirectExchange deadExchange = new DirectExchange(DEAD_EXCHANGE, true, false);
rabbitAdmin.declareExchange(deadExchange);
Queue deadQueue = new Queue(deadQueueName, true, false, false);
rabbitAdmin.declareQueue(deadQueue);
/**
* ------------------------------------------------------------------------------
*/
// 将队列和交换机绑定
Binding deadbinding = BindingBuilder.bind(deadQueue).to(deadExchange).with(DEAD_ROUTING_KEY);
rabbitAdmin.declareBinding(deadbinding);
// 发送消息
rabbitTemplate.convertAndSend(EXCHANGE, ROUTING_KEY, params);
}
}

View File

@ -0,0 +1,83 @@
package com.bwie.mq.utils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author Administrator
*/
@Component
public class DelayedQueue {
/**
* routingKey
*/
private static final String DELAYED_ROUTING_KEY = "delayed.routingkey";
/**
*
*/
private static final String DELAYED_EXCHANGE = "delayed.exchange";
@Autowired
RabbitTemplate rabbitTemplate;
@Resource
RabbitAdmin rabbitAdmin;
/**
*
*
* @param queueName
* @param params
* @param delayedTime
*/
public void sendDelayedQueue(String queueName, Object params, Integer delayedTime) {
// 先创建一个队列
Queue queue = new Queue(queueName);
rabbitAdmin.declareQueue(queue);
// 创建延迟队列交换机
CustomExchange customExchange = createCustomExchange();
rabbitAdmin.declareExchange(customExchange);
// 将队列和交换机绑定
Binding binding = BindingBuilder.bind(queue).to(customExchange).with(DELAYED_ROUTING_KEY).noargs();
rabbitAdmin.declareBinding(binding);
// 发送延迟消息 方法的参数是一个接口 那么传入 他的实现类 MessagePostProcessor
rabbitTemplate.convertAndSend(DELAYED_EXCHANGE, DELAYED_ROUTING_KEY, params, message -> {
// 设置消息的延迟时间
message.getMessageProperties().setDelay(delayedTime);
return message;
});
}
public CustomExchange createCustomExchange() {
Map<String, Object> arguments = new HashMap<>();
/**
*
* 1.
* 2.
* 3.
* 4.
* 5.
*/
arguments.put("x-delayed-type", "direct");
return new CustomExchange(DELAYED_EXCHANGE, "x-delayed-message", true, false, arguments);
}
}

View File

@ -0,0 +1,72 @@
package com.bwie.mq.utils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* TTL
*/
@Component
public class TtlQueue {
/**
* routingKey
*/
private static final String TTL_KEY = "ttl.routingkey";
/**
* ttl
*/
private static final String TTL_EXCHANGE = "ttl.exchange";
@Autowired
RabbitTemplate rabbitTemplate;
@Resource
RabbitAdmin rabbitAdmin;
/**
* TTL
*
* @param queueName
* @param params
* @param expiration
*/
public void sendTtlQueue(String queueName, Object params, Integer expiration) {
/**
* ----------------------------------ttl--------------------------------------------
*/
Map<String, Object> map = new HashMap<>();
// 队列设置存活时间单位ms,必须是整形数据。
map.put("x-message-ttl", expiration);
/*参数1队列名称 参数2持久化 参数3是否排他 参数4自动删除队列 参数5队列参数*/
Queue queue = new Queue(queueName, true, false, false, map);
rabbitAdmin.declareQueue(queue);
/**
* ------------------------------------------------------------------------------
*/
DirectExchange directExchange = new DirectExchange(TTL_EXCHANGE, true, false);
rabbitAdmin.declareExchange(directExchange);
/**
* ------------------------------------------------------------------------------
*/
// 将队列和交换机绑定
Binding binding = BindingBuilder.bind(queue).to(directExchange).with(TTL_KEY);
rabbitAdmin.declareBinding(binding);
// 发送消息
rabbitTemplate.convertAndSend(TTL_EXCHANGE, TTL_KEY, params);
}
}

View File

@ -0,0 +1,42 @@
# Tomcat
server:
port: 9010
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-mq
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 122.51.12.81:8848
namespace: nacos
config:
# 配置中心地址
server-addr: 122.51.12.81:8848
namespace: nacos
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
rabbitmq:
username: guest
password: guest
virtualHost: /
port: 5672
host: 122.51.12.81
listener:
simple:
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
publisher-returns: true #确认消息已发送到队列(Queue)

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>bwie-modules</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bwie-user</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 系统公共 依赖 -->
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
</dependency>
<!-- SpringBoot Web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Mybatis 依赖配置 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,18 @@
package com.bwie.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @Authorweiran
* @Packagecom.bwie.user
* @ProjectmonthA8.12
* @nameUserApplication
* @Date2024/8/12 9:10
*/
@SpringBootApplication
public class UserApplication {
public static void main(String[] args) {
SpringApplication.run(UserApplication.class, args);
}
}

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