Compare commits
No commits in common. "90a52ac3422aa67b74435650bf4f0ead5a7b1622" and "1ab1d7f27d8e12b5337229a3fb53288e1c842f7f" have entirely different histories.
90a52ac342
...
1ab1d7f27d
|
@ -13,7 +13,6 @@
|
|||
<file url="file://$PROJECT_DIR$/spzx-service-client/service-user-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/spzx-service-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/spzx-service-client/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/spzx-service/service-cart/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/spzx-service/service-order/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/spzx-service/service-order/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/spzx-service/service-order/src/main/resources-filtered" charset="UTF-8" />
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Deprecation" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="IncorrectHttpHeaderInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="customHeaders">
|
||||
<set>
|
||||
<option value="token" />
|
||||
</set>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="RawUseOfParameterizedType" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ThrowablePrintStackTrace" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UNCHECKED_WARNING" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
|
|
|
@ -4,20 +4,17 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="6ee93b58-a7e0-45a0-9e98-4c363b192afb" name="Changes" comment="添加购物车">
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service-client/service-product-client/src/main/java/cn/bunny/web/ProductFeignClient.java" afterDir="false" />
|
||||
<list default="true" id="6ee93b58-a7e0-45a0-9e98-4c363b192afb" name="Changes" comment="修改不用的引用">
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/mapper/ProductDetailsMapper.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/mapper/ProductMapper.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/mapper/product/ProductDetailsMapper.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/mapper/product/ProductMapper.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-server-gateway/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-server-gateway/src/main/resources/application-dev.yml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service-client/service-product-client/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service-client/service-product-client/pom.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service-client/service-product-client/src/main/java/cn/bunny/web/App.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-cart/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-cart/pom.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/CartApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/CartApplication.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/controller/CartController.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/controller/CartController.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/service/CartService.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/service/CartService.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/service/impl/CartServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/service/impl/CartServiceImpl.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/controller/ProductController.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/controller/ProductController.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/mapper/ProductSkuMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/mapper/ProductSkuMapper.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/ProductService.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/ProductService.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/imp/ProductServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/imp/ProductServiceImpl.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/mapper/product/ProductSkuMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/mapper/product/ProductSkuMapper.xml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -27,9 +24,9 @@
|
|||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="mybatis-mapper" />
|
||||
<option value="Class" />
|
||||
<option value="Interface" />
|
||||
<option value="mybatis-mapper" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -68,48 +65,46 @@
|
|||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RequestMappingsPanelOrder0": "0",
|
||||
"RequestMappingsPanelOrder1": "1",
|
||||
"RequestMappingsPanelWidth0": "75",
|
||||
"RequestMappingsPanelWidth1": "75",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"code.cleanup.on.save": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"jdk.selected.JAVA_MODULE": "corretto-17",
|
||||
"last_opened_file_path": "F:/File/Java/spzx-parent/spzx-service/service-cart/src/main/resources",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"project.structure.last.edited": "Project",
|
||||
"project.structure.proportion": "0.15",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"rearrange.code.on.save": "true",
|
||||
"settings.editor.selected.configurable": "MavenSettings",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RequestMappingsPanelOrder0": "0",
|
||||
"RequestMappingsPanelOrder1": "1",
|
||||
"RequestMappingsPanelWidth0": "75",
|
||||
"RequestMappingsPanelWidth1": "75",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"code.cleanup.on.save": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"jdk.selected.JAVA_MODULE": "21",
|
||||
"last_opened_file_path": "F:/File/Java/spzx-parent/spzx-service/service-product/src/main/java/cn/bunny/web/product",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"project.structure.last.edited": "Project",
|
||||
"project.structure.proportion": "0.15",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"rearrange.code.on.save": "true",
|
||||
"settings.editor.selected.configurable": "actions.on.save",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"DatabaseDriversLRU": [
|
||||
"mysql"
|
||||
"keyToStringList": {
|
||||
"DatabaseDriversLRU": [
|
||||
"mysql"
|
||||
]
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="ReactorSettings">
|
||||
<option name="notificationShown" value="true" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="F:\File\Java\spzx-parent\spzx-service\service-cart\src\main\resources" />
|
||||
<recent name="F:\File\Java\spzx-parent\spzx-service\service-user\src\main\resources" />
|
||||
<recent name="F:\File\Java\spzx-parent\spzx-service\service-user\src\main\java\cn\bunny\user" />
|
||||
<recent name="F:\File\Java\spzx-parent\spzx-service\service-product\src\main\java\cn\bunny\web\product" />
|
||||
<recent name="F:\File\Java\spzx-parent\spzx-server-gateway\src\main\resources" />
|
||||
<recent name="F:\File\Java\spzx-parent\spzx-service\service-product\src\main\resources" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="F:\File\Java\spzx-parent\spzx-service\service-product\src\main\resources" />
|
||||
|
@ -124,13 +119,13 @@
|
|||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Spring Boot.CartApplication">
|
||||
<configuration name="CartApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
|
||||
<module name="service-cart" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="cn.bunny.web.CartApplication" />
|
||||
<component name="RunManager" selected="Spring Boot.ProductApplication">
|
||||
<configuration name="MangerApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
|
||||
<module name="spzx-manager" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="cn.bunny.MangerApplication" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="cn.bunny.web.*" />
|
||||
<option name="PATTERN" value="cn.bunny.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
|
@ -151,38 +146,10 @@
|
|||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="ServerGetWayApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
|
||||
<module name="spzx-server-gateway" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="cn.bunny.getway.ServerGetWayApplication" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="cn.bunny.getway.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="User" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
|
||||
<module name="service-user" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="cn.bunny.user.User" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="cn.bunny.user.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Spring Boot.ServerGetWayApplication" />
|
||||
<item itemvalue="Spring Boot.ProductApplication" />
|
||||
<item itemvalue="Spring Boot.CartApplication" />
|
||||
<item itemvalue="Spring Boot.User" />
|
||||
<item itemvalue="Spring Boot.MangerApplication" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
|
@ -196,10 +163,7 @@
|
|||
<updated>1703487755445</updated>
|
||||
<workItem from="1703487757122" duration="903000" />
|
||||
<workItem from="1703488670206" duration="5932000" />
|
||||
<workItem from="1703549556395" duration="26425000" />
|
||||
<workItem from="1703654409796" duration="10591000" />
|
||||
<workItem from="1703684112039" duration="2403000" />
|
||||
<workItem from="1703722925328" duration="13331000" />
|
||||
<workItem from="1703549556395" duration="13968000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="前端接口初始化;显示商品页面">
|
||||
<option name="closed" value="true" />
|
||||
|
@ -257,103 +221,12 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1703559306235</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00008" summary="商品详情">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703567148967</created>
|
||||
<option name="number" value="00008" />
|
||||
<option name="presentableId" value="LOCAL-00008" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703567148967</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00009" summary="发送验证码">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703574739774</created>
|
||||
<option name="number" value="00009" />
|
||||
<option name="presentableId" value="LOCAL-00009" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703574739774</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00010" summary="用户注册">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703578711882</created>
|
||||
<option name="number" value="00010" />
|
||||
<option name="presentableId" value="LOCAL-00010" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703578711882</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00011" summary="会员登录">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703580114862</created>
|
||||
<option name="number" value="00011" />
|
||||
<option name="presentableId" value="LOCAL-00011" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703580114862</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00012" summary="获取用户信息-未测试">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703581022155</created>
|
||||
<option name="number" value="00012" />
|
||||
<option name="presentableId" value="LOCAL-00012" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703581022155</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00013" summary="获取用户信息-未测试">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703581032554</created>
|
||||
<option name="number" value="00013" />
|
||||
<option name="presentableId" value="LOCAL-00013" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703581032554</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00014" summary="获取用户信息-未测试">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703581061973</created>
|
||||
<option name="number" value="00014" />
|
||||
<option name="presentableId" value="LOCAL-00014" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703581061973</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00015" summary="获取用户信息并跳转">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703664991364</created>
|
||||
<option name="number" value="00015" />
|
||||
<option name="presentableId" value="LOCAL-00015" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703664991364</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00016" summary="创建购物车">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703667374773</created>
|
||||
<option name="number" value="00016" />
|
||||
<option name="presentableId" value="LOCAL-00016" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703667374773</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00017" summary="添加购物车">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703738845213</created>
|
||||
<option name="number" value="00017" />
|
||||
<option name="presentableId" value="LOCAL-00017" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703738845213</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="18" />
|
||||
<option name="localTasksCounter" value="8" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="前端接口初始化;显示商品页面" />
|
||||
<MESSAGE value="解决跨域;修改MySQL语法错误;获取分类树形数据" />
|
||||
|
@ -361,17 +234,18 @@
|
|||
<MESSAGE value="将首页数据存放在redis中作为缓存" />
|
||||
<MESSAGE value="根据品牌进行查询" />
|
||||
<MESSAGE value="修改不用的引用" />
|
||||
<MESSAGE value="商品详情" />
|
||||
<MESSAGE value="发送验证码" />
|
||||
<MESSAGE value="用户注册" />
|
||||
<MESSAGE value="会员登录" />
|
||||
<MESSAGE value="获取用户信息-未测试" />
|
||||
<MESSAGE value="获取用户信息并跳转" />
|
||||
<MESSAGE value="创建购物车" />
|
||||
<MESSAGE value="添加购物车" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="添加购物车" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="修改不用的引用" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/config/RedisConfig.java</url>
|
||||
<line>33</line>
|
||||
<option name="timeStamp" value="15" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
<pin-to-top-manager>
|
||||
<pinned-members>
|
||||
<PinnedItemInfo parentTag="java.lang.String" memberName="value" />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
<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>
|
||||
|
@ -44,23 +44,6 @@
|
|||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- spring boot web开发所需要的起步依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- openfeign依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.anno;
|
||||
|
||||
import cn.bunny.config.UserWebMvcConfiguration;
|
||||
import cn.bunny.interceptor.UserLoginAuthInterceptor;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = ElementType.TYPE)
|
||||
@Import(value = {UserLoginAuthInterceptor.class, UserWebMvcConfiguration.class})
|
||||
public @interface EnableUserWebMvcConfiguration {
|
||||
}
|
|
@ -13,19 +13,11 @@ public class Knife4jConfig {
|
|||
@Bean
|
||||
public GroupedOpenApi adminApi() {// 创建API分组
|
||||
return GroupedOpenApi.builder()
|
||||
.group("后端接口")
|
||||
.group("admin-api111")
|
||||
.pathsToMatch("/admin/**")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi UserApi() {// 创建API分组
|
||||
return GroupedOpenApi.builder()
|
||||
.group("前端用户")
|
||||
.pathsToMatch("/api/**")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OpenAPI customerOpenApi() {
|
||||
return new OpenAPI().info(new Info().title("接口文档").version("1.0").contact(new Contact()
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package cn.bunny.config;
|
||||
|
||||
import cn.bunny.interceptor.UserLoginAuthInterceptor;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
public class UserWebMvcConfiguration implements WebMvcConfigurer {
|
||||
@Resource
|
||||
private UserLoginAuthInterceptor userLoginAuthInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(userLoginAuthInterceptor)
|
||||
.addPathPatterns("/api/**");
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package cn.bunny.interceptor;
|
||||
|
||||
import cn.bunny.common.AuthContextUtil;
|
||||
import cn.bunny.common.spzx.model.entity.user.UserInfo;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
|
||||
public class UserLoginAuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 如果token不为空,那么此时验证token的合法性
|
||||
String userInfoJSON = redisTemplate.opsForValue().get("user:spzx:" + request.getHeader("token"));
|
||||
AuthContextUtil.setUserInfo(JSON.parseObject(userInfoJSON, UserInfo.class));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -41,32 +41,5 @@
|
|||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>9.3.7.v20160115</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,10 +1,8 @@
|
|||
package cn.bunny.common;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.system.SysUser;
|
||||
import cn.bunny.common.spzx.model.entity.user.UserInfo;
|
||||
|
||||
public class AuthContextUtil {
|
||||
private static final ThreadLocal<UserInfo> userInfoThreadLocal = new ThreadLocal<>();
|
||||
|
||||
// 创建一个ThreadLocal对象
|
||||
private static final ThreadLocal<SysUser> threadLocal = new ThreadLocal<>();
|
||||
|
@ -23,19 +21,4 @@ public class AuthContextUtil {
|
|||
public static void remove() {
|
||||
threadLocal.remove();
|
||||
}
|
||||
|
||||
// 定义获取数据的方法
|
||||
public static UserInfo getUserInfo() {
|
||||
return userInfoThreadLocal.get();
|
||||
}
|
||||
|
||||
// 定义存储数据的静态方法
|
||||
public static void setUserInfo(UserInfo userInfo) {
|
||||
userInfoThreadLocal.set(userInfo);
|
||||
}
|
||||
|
||||
// 删除数据的方法
|
||||
public static void removeUserInfo() {
|
||||
userInfoThreadLocal.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,238 +0,0 @@
|
|||
package cn.bunny.common;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpUtils {
|
||||
public static HttpResponse doGet(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpGet request = new HttpGet(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
Map<String, String> bodys)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (bodys != null) {
|
||||
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
|
||||
|
||||
for (String key : bodys.keySet()) {
|
||||
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
|
||||
}
|
||||
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
|
||||
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
|
||||
request.setEntity(formEntity);
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
String body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
request.setEntity(new StringEntity(body, "utf-8"));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
byte[] body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (body != null) {
|
||||
request.setEntity(new ByteArrayEntity(body));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
|
||||
public static HttpResponse doPut(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
String body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
request.setEntity(new StringEntity(body, "utf-8"));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
|
||||
public static HttpResponse doPut(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
byte[] body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (body != null) {
|
||||
request.setEntity(new ByteArrayEntity(body));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
|
||||
public static HttpResponse doDelete(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
|
||||
StringBuilder sbUrl = new StringBuilder();
|
||||
sbUrl.append(host);
|
||||
if (!StringUtils.isBlank(path)) {
|
||||
sbUrl.append(path);
|
||||
}
|
||||
if (null != querys) {
|
||||
StringBuilder sbQuery = new StringBuilder();
|
||||
for (Map.Entry<String, String> query : querys.entrySet()) {
|
||||
if (0 < sbQuery.length()) {
|
||||
sbQuery.append("&");
|
||||
}
|
||||
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
|
||||
sbQuery.append(query.getValue());
|
||||
}
|
||||
if (!StringUtils.isBlank(query.getKey())) {
|
||||
sbQuery.append(query.getKey());
|
||||
if (!StringUtils.isBlank(query.getValue())) {
|
||||
sbQuery.append("=");
|
||||
sbQuery.append(URLEncoder.encode(query.getValue(), StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0 < sbQuery.length()) {
|
||||
sbUrl.append("?").append(sbQuery);
|
||||
}
|
||||
}
|
||||
|
||||
return sbUrl.toString();
|
||||
}
|
||||
|
||||
private static HttpClient wrapClient(String host) {
|
||||
HttpClient httpClient = new DefaultHttpClient();
|
||||
if (host.startsWith("https://")) {
|
||||
sslClient(httpClient);
|
||||
}
|
||||
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
private static void sslClient(HttpClient httpClient) {
|
||||
try {
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
X509TrustManager tm = new X509TrustManager() {
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] xcs, String str) {
|
||||
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] xcs, String str) {
|
||||
|
||||
}
|
||||
};
|
||||
ctx.init(null, new TrustManager[]{tm}, null);
|
||||
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
|
||||
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
ClientConnectionManager ccm = httpClient.getConnectionManager();
|
||||
SchemeRegistry registry = ccm.getSchemeRegistry();
|
||||
registry.register(new Scheme("https", 443, ssf));
|
||||
} catch (KeyManagementException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
<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>
|
||||
|
@ -19,10 +19,6 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package cn.bunny.getway.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
|
||||
// String的序列化方式
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
|
||||
// 序列号key value
|
||||
redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||
redisTemplate.setValueSerializer(genericJackson2JsonRedisSerializer);
|
||||
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
package cn.bunny.getway.filter;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.user.UserInfo;
|
||||
import cn.bunny.common.spzx.model.vo.common.Result;
|
||||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||
|
||||
private final AntPathMatcher antPathMatcher = new AntPathMatcher();
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
String path = request.getURI().getPath();
|
||||
UserInfo userInfo = this.getUserInfo(request);
|
||||
|
||||
// api接口,异步请求,校验用户必须登录
|
||||
if (antPathMatcher.match("/api/**/auth/**", path)) {
|
||||
if (null == userInfo) {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
return out(response, ResultCodeEnum.LOGIN_AUTH);
|
||||
}
|
||||
}
|
||||
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private Mono<Void> out(ServerHttpResponse response, ResultCodeEnum resultCodeEnum) {
|
||||
Result result = Result.build(null, resultCodeEnum);
|
||||
byte[] bits = JSONObject.toJSONString(result).getBytes(StandardCharsets.UTF_8);
|
||||
DataBuffer buffer = response.bufferFactory().wrap(bits);
|
||||
// 指定编码,否则在浏览器中会中文乱码
|
||||
response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
|
||||
return response.writeWith(Mono.just(buffer));
|
||||
}
|
||||
|
||||
private UserInfo getUserInfo(ServerHttpRequest request) {
|
||||
String token = "";
|
||||
List<String> tokenList = request.getHeaders().get("token");
|
||||
if (null != tokenList) {
|
||||
token = tokenList.get(0);
|
||||
}
|
||||
if (!StringUtils.isEmpty(token)) {
|
||||
String userInfoJSON = redisTemplate.opsForValue().get("user:spzx:" + token);
|
||||
if (StringUtils.isEmpty(userInfoJSON)) {
|
||||
return null;
|
||||
} else {
|
||||
return JSON.parseObject(userInfoJSON, UserInfo.class);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -6,8 +6,7 @@ spring:
|
|||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.2.82:8848
|
||||
# server-addr: 192.168.31.202:8848
|
||||
server-addr: 192.168.2.156:8848
|
||||
gateway:
|
||||
discovery:
|
||||
locator:
|
||||
|
@ -27,14 +26,6 @@ spring:
|
|||
uri: lb://service-product
|
||||
predicates:
|
||||
- Path=/*/product/**
|
||||
- id: service-user
|
||||
uri: lb://service-user
|
||||
predicates:
|
||||
- Path=/*/user/**
|
||||
- id: service-cart
|
||||
uri: lb://service-cart
|
||||
predicates:
|
||||
- Path=/api/order/cart/**
|
||||
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
|
@ -42,11 +33,7 @@ spring:
|
|||
url: jdbc:mysql://60.204.230.80:3306/db_spzx?characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: "02120212"
|
||||
data:
|
||||
redis:
|
||||
host: 192.168.2.82
|
||||
# host: 192.168.31.202
|
||||
port: 6379
|
||||
|
||||
mybatis:
|
||||
config-location: classpath:mybatis-config.xml
|
||||
mapper-locations: classpath:/mapper/*/*.xml
|
||||
mapper-locations: classpath:/mapper/*/*.xml
|
|
@ -1,4 +1,4 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
<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>
|
||||
|
@ -24,30 +24,5 @@
|
|||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>common-util</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>spzx-model</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- openfeign依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- loadbalancer依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package cn.bunny.web;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package cn.bunny.web;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.product.ProductSku;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@FeignClient(value = "service-product")
|
||||
public interface ProductFeignClient {
|
||||
|
||||
@GetMapping("/api/product/getBySkuId/{skuId}")
|
||||
ProductSku getBySkuId(@PathVariable("skuId") Long skuId);
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
<module>service-order</module>
|
||||
<module>service-product</module>
|
||||
<module>service-user</module>
|
||||
<module>service-cart</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>cn.bunny</groupId>
|
||||
<artifactId>spzx-service</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>cn.bunny.web</groupId>
|
||||
<artifactId>service-cart</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>service-cart</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.bunny.web</groupId>
|
||||
<artifactId>service-product-client</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.web;
|
||||
|
||||
import cn.bunny.anno.EnableUserWebMvcConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) // 排除数据库的自动化配置,Cart微服务不需要访问数据库
|
||||
@EnableFeignClients(basePackages = {"cn.bunny"})
|
||||
@EnableUserWebMvcConfiguration
|
||||
public class CartApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CartApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package cn.bunny.web.controller;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.h5.CartInfo;
|
||||
import cn.bunny.common.spzx.model.vo.common.Result;
|
||||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import cn.bunny.web.service.CartService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/order/cart")
|
||||
public class CartController {
|
||||
|
||||
@Resource
|
||||
private CartService cartService;
|
||||
|
||||
@Operation(summary = "添加购物车")
|
||||
@GetMapping("auth/addToCart/{skuId}/{skuNum}")
|
||||
public Result addToCart(@PathVariable Long skuId,
|
||||
@PathVariable Integer skuNum) {
|
||||
cartService.addToCart(skuId, skuNum);
|
||||
return Result.build(null, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询购物车")
|
||||
@GetMapping("auth/cartList")
|
||||
public Result<List<CartInfo>> cartList() {
|
||||
List<CartInfo> cartInfoList = cartService.getCartList();
|
||||
return Result.build(cartInfoList, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package cn.bunny.web.service;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.h5.CartInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CartService {
|
||||
// 添加购物车
|
||||
void addToCart(Long skuId, Integer skuNum);
|
||||
|
||||
// 查询购物车
|
||||
List<CartInfo> getCartList();
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package cn.bunny.web.service.impl;
|
||||
|
||||
import cn.bunny.common.AuthContextUtil;
|
||||
import cn.bunny.common.spzx.model.entity.h5.CartInfo;
|
||||
import cn.bunny.common.spzx.model.entity.product.ProductSku;
|
||||
import cn.bunny.web.ProductFeignClient;
|
||||
import cn.bunny.web.service.CartService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class CartServiceImpl implements CartService {
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private ProductFeignClient productFeignClient;
|
||||
|
||||
// 定义key user:cart:userId
|
||||
private String getCartKey(Long userId) {
|
||||
return "user:cart:" + userId;
|
||||
}
|
||||
|
||||
// 添加购物车
|
||||
@Override
|
||||
public void addToCart(Long skuId, Integer skuNum) {
|
||||
// 1.必须是登录状态,获取当前登录用户id,从ThreadLocal获取用户信息就可以了
|
||||
Long userId = AuthContextUtil.getUserInfo().getId();
|
||||
String cartKey = this.getCartKey(userId);
|
||||
|
||||
// 2.因为购物车放到Redis里面,从Redis里面获取购物车数据,根据key值 + skuId获取(hash类型key+field)
|
||||
// hash类型 key:useId fileId:skuId value:sku信息CartInfo
|
||||
Object cartInfoObj = redisTemplate.opsForHash().get(cartKey, String.valueOf(skuId));
|
||||
|
||||
// 3.如果购物车存在添加商品,把商品数量相加
|
||||
CartInfo cartInfo = null;
|
||||
if (cartInfoObj != null) {
|
||||
cartInfo = JSON.parseObject(cartInfoObj.toString(), CartInfo.class);
|
||||
// 数量相加
|
||||
cartInfo.setSkuNum(cartInfo.getSkuNum() + skuNum);
|
||||
// 购物车商品是选中状态
|
||||
cartInfo.setIsChecked(1);
|
||||
cartInfo.setUpdateTime(new Date());
|
||||
} else {
|
||||
// 4.如果购物车没有商品,直接商品添加购物车(添加到Redis里面)
|
||||
// 远程调用实现:通过nacos + openFeign 实现,根据skuId获取商品sku信息
|
||||
cartInfo = new CartInfo();
|
||||
// 远程调用实现:根据skuId获取商品sku信息
|
||||
// ProductSku productSku = productFeignClient.getBySkuId(skuId).getData();
|
||||
ProductSku productSku = productFeignClient.getBySkuId(skuId);
|
||||
cartInfo.setCartPrice(productSku.getSalePrice());
|
||||
cartInfo.setSkuNum(skuNum);
|
||||
cartInfo.setSkuId(skuId);
|
||||
cartInfo.setUserId(userId);
|
||||
cartInfo.setImgUrl(productSku.getThumbImg());
|
||||
cartInfo.setSkuName(productSku.getSkuName());
|
||||
cartInfo.setIsChecked(1);
|
||||
cartInfo.setCreateTime(new Date());
|
||||
cartInfo.setUpdateTime(new Date());
|
||||
}
|
||||
|
||||
redisTemplate.opsForHash().put(cartKey, String.valueOf(skuId), JSON.toJSONString(cartInfo));
|
||||
}
|
||||
|
||||
// 查询购物车
|
||||
@Override
|
||||
public List<CartInfo> getCartList() {
|
||||
// 1. 构建查询的Redis里面的key值,根据当前userId
|
||||
Long userId = AuthContextUtil.getUserInfo().getId();
|
||||
String cartKey = this.getCartKey(userId);
|
||||
// 2. 根据key从Redis里面hash类型获取所有value值 cartInfo
|
||||
List valueList = redisTemplate.opsForHash().values(cartKey);
|
||||
// List<Object> ---> List<cartInfo>
|
||||
if (CollectionUtils.isEmpty(valueList)) {
|
||||
return (List<CartInfo>) valueList.stream().map(cartInfoJSON -> JSON.parseObject(cartInfoJSON.toString(), CartInfo.class))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
server:
|
||||
port: 8513
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: service-cart
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.2.82:8848
|
||||
data:
|
||||
redis:
|
||||
host: 192.168.2.82
|
||||
# host: 192.168.31.202
|
||||
port: 6379
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
|
@ -1,3 +0,0 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: dev
|
|
@ -1,56 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<contextName>logback</contextName>
|
||||
|
||||
<!-- 日志的输出目录 -->
|
||||
<property name="log.path" value="D://logs//service-product//logs" />
|
||||
|
||||
<!--控制台日志格式:彩色日志-->
|
||||
<!-- magenta:洋红 -->
|
||||
<!-- boldMagenta:粗红-->
|
||||
<!-- cyan:青色 -->
|
||||
<!-- white:白色 -->
|
||||
<!-- magenta:洋红 -->
|
||||
<property name="CONSOLE_LOG_PATTERN" value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) %highlight([%-5level]) %green(%logger) %msg%n"/>
|
||||
|
||||
<!--文件日志格式-->
|
||||
<property name="FILE_LOG_PATTERN" value="%date{yyyy-MM-dd HH:mm:ss} [%-5level] %thread %file:%line %logger %msg%n" />
|
||||
|
||||
<!--编码-->
|
||||
<property name="ENCODING" value="UTF-8" />
|
||||
|
||||
<!-- 控制台日志 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- 临界值过滤器 -->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 文件日志 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>${log.path}//log.log</file>
|
||||
<append>true</append>
|
||||
<encoder>
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 开发环境 -->
|
||||
<springProfile name="dev">
|
||||
<!-- com.atguigu日志记录器:业务程序INFO级别 -->
|
||||
<logger name="com.atguigu" level="INFO" />
|
||||
<!-- 根日志记录器:INFO级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
|
@ -1,38 +0,0 @@
|
|||
package cn.bunny.web;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
|
@ -34,13 +34,14 @@ public class RedisConfig {
|
|||
@Bean
|
||||
public CacheManager cacheManager(LettuceConnectionFactory connectionFactory) {
|
||||
|
||||
// 定义序列化器
|
||||
//定义序列化器
|
||||
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
|
||||
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
|
||||
// 过期时间600秒
|
||||
.entryTtl(Duration.ofSeconds(604800))
|
||||
//过期时间600秒
|
||||
.entryTtl(Duration.ofSeconds(600))
|
||||
// 配置序列化
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(stringRedisSerializer))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(genericJackson2JsonRedisSerializer));
|
||||
|
|
|
@ -5,7 +5,6 @@ import cn.bunny.common.spzx.model.vo.common.Result;
|
|||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import cn.bunny.web.product.service.BrandService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -13,9 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "品牌接口")
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/product/brand")
|
||||
@RequestMapping(value="/api/product/brand")
|
||||
public class BrandController {
|
||||
@Resource
|
||||
private BrandService brandService;
|
||||
|
|
|
@ -13,18 +13,18 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "分类接口管理")
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/product/category")
|
||||
@Tag(name = "分类接口管理")
|
||||
@RequestMapping(value="/api/product/category")
|
||||
// @CrossOrigin
|
||||
public class CategoryController {
|
||||
@Resource
|
||||
private CategoryService categoryService;
|
||||
|
||||
@Operation(summary = "获取分类树形数据", description = "按照树型方式进行封装")
|
||||
@Operation(summary = "获取分类树形数据",description = "按照树型方式进行封装")
|
||||
@GetMapping("findCategoryTree")
|
||||
public Result findCategoryTree() {
|
||||
List<Category> categoryList = categoryService.findCategoryTree();
|
||||
List<Category> categoryList= categoryService.findCategoryTree();
|
||||
return Result.build(categoryList, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,12 @@ import cn.bunny.web.product.service.ProductService;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "商品接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/product")
|
||||
public class ProductController {
|
||||
|
@ -39,10 +37,4 @@ public class ProductController {
|
|||
ProductItemVo productItemVo = productService.itemBySkuId(skuId);
|
||||
return Result.build(productItemVo, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "远程调用:根据skuId返回sku信息")
|
||||
@GetMapping("getBySkuId/{skuId}")
|
||||
public ProductSku getBySkuId(@PathVariable Long skuId) {
|
||||
return productService.getBySkuId(skuId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,4 @@ public interface ProductService {
|
|||
|
||||
// 商品详情
|
||||
ProductItemVo itemBySkuId(Long skuId);
|
||||
|
||||
// 远程调用:根据skuId返回sku信息
|
||||
ProductSku getBySkuId(Long skuId);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,10 @@ import java.util.*;
|
|||
public class ProductServiceImpl implements ProductService {
|
||||
@Resource
|
||||
private ProductSkuMapper productSkuMapper;
|
||||
|
||||
@Resource
|
||||
private ProductMapper productMapper;
|
||||
|
||||
@Resource
|
||||
private ProductDetailsMapper productDetailsMapper;
|
||||
@Resource
|
||||
|
@ -33,8 +35,8 @@ public class ProductServiceImpl implements ProductService {
|
|||
@Cacheable(value = "productSku", key = "'one'")
|
||||
@Override
|
||||
public List<ProductSku> selectProductSkuBySal() {
|
||||
// 1. 查询redis是否有一级分类
|
||||
Object productSkuJson = redisTemplate.opsForValue().get("productSku::one");
|
||||
/* // 1. 查询redis是否有一级分类
|
||||
Object productSkuJson = redisTemplate.opsForValue().get("productSku:one");
|
||||
String productSkuJsonString = JSON.toJSONString(productSkuJson);
|
||||
|
||||
// 2. 如果存在一级分类直接返回即可
|
||||
|
@ -42,10 +44,15 @@ public class ProductServiceImpl implements ProductService {
|
|||
return JSON.parseArray(productSkuJsonString);
|
||||
}
|
||||
// 3. 如果redis没有一级分类,查询数据库,把数据库内容返回,并且查询放到redis中
|
||||
// List<ProductSku> productSkuList = productSkuMapper.selectProductSkuBySale();
|
||||
// redisTemplate.opsForValue()
|
||||
// .set("productSku::one", JSON.toJSON(productSkuList), 7, TimeUnit.DAYS);
|
||||
// return productSkuList;
|
||||
List<ProductSku> productSkuList = productSkuMapper.selectProductSkuBySale();
|
||||
redisTemplate.opsForValue()
|
||||
.set("productSku:one", JSON.toJSON(productSkuList), 7, TimeUnit.DAYS);
|
||||
return productSkuList; */
|
||||
Object productSkuJson = redisTemplate.opsForValue().get("productSku:one");
|
||||
String productSkuJsonString = JSON.toJSONString(productSkuJson);
|
||||
if (!Objects.equals(productSkuJsonString, "null")) {
|
||||
return JSON.parseArray(productSkuJsonString);
|
||||
}
|
||||
return productSkuMapper.selectProductSkuBySale();
|
||||
}
|
||||
|
||||
|
@ -89,10 +96,4 @@ public class ProductServiceImpl implements ProductService {
|
|||
|
||||
return productItemVo;
|
||||
}
|
||||
|
||||
// 远程调用:根据skuId返回sku信息
|
||||
@Override
|
||||
public ProductSku getBySkuId(Long skuId) {
|
||||
return productSkuMapper.getById(skuId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@ spring:
|
|||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.2.82:8848
|
||||
# server-addr: 192.168.31.202:8848
|
||||
server-addr: 192.168.2.156:8848
|
||||
|
||||
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
@ -18,8 +19,7 @@ spring:
|
|||
data:
|
||||
redis:
|
||||
port: 6379
|
||||
host: 192.168.2.82
|
||||
# host: 192.168.31.202
|
||||
host: 192.168.2.156
|
||||
|
||||
mybatis:
|
||||
config-location: classpath:mybatis-config.xml
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
<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>cn.bunny</groupId>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>spzx-service</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package cn.bunny.user;
|
||||
|
||||
import cn.bunny.anno.EnableUserWebMvcConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"cn.bunny"})
|
||||
@EnableUserWebMvcConfiguration
|
||||
public class User {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(User.class, args);
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package cn.bunny.user.config;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(lettuceConnectionFactory);
|
||||
|
||||
// 设置key序列化为String
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
// 设置value序列化方式为JSON,使用GenericJackson2JsonRedisSerializer替换为默认序列化
|
||||
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager(LettuceConnectionFactory connectionFactory) {
|
||||
|
||||
// 定义序列化器
|
||||
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
|
||||
// 过期时间600秒
|
||||
.entryTtl(Duration.ofSeconds(600))
|
||||
// 配置序列化
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(stringRedisSerializer))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(genericJackson2JsonRedisSerializer));
|
||||
|
||||
return RedisCacheManager.builder(connectionFactory)
|
||||
.cacheDefaults(config)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package cn.bunny.user.controller;
|
||||
|
||||
import cn.bunny.common.spzx.model.vo.common.Result;
|
||||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import cn.bunny.user.service.SmsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "发送验证码")
|
||||
@RestController
|
||||
@RequestMapping("/api/user/sms")
|
||||
public class SmsController {
|
||||
@Resource
|
||||
private SmsService smsService;
|
||||
|
||||
@GetMapping(value = "/sendCode/{phone}")
|
||||
@Operation(summary = "短信验证码", operationId = "发送短信验证码")
|
||||
public Result sendValidateCode(@PathVariable("phone") String phone) {
|
||||
return Result.build(smsService.sendCode(phone), ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package cn.bunny.user.controller;
|
||||
|
||||
import cn.bunny.common.spzx.model.dto.h5.UserLoginDto;
|
||||
import cn.bunny.common.spzx.model.dto.h5.UserRegisterDto;
|
||||
import cn.bunny.common.spzx.model.vo.common.Result;
|
||||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import cn.bunny.common.spzx.model.vo.h5.UserInfoVo;
|
||||
import cn.bunny.user.service.UserinfoService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Tag(name = "会员用户接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/user/userInfo")
|
||||
public class UserinfoController {
|
||||
@Resource
|
||||
private UserinfoService userinfoService;
|
||||
|
||||
@Operation(summary = "获取当前登录用户信息")
|
||||
@GetMapping("auth/getCurrentUserInfo")
|
||||
public Result getCurrentUserInfo(HttpServletRequest request) {
|
||||
String token = request.getHeader("token");
|
||||
UserInfoVo userInfoVo = userinfoService.getCurrentUserInfo(token);
|
||||
return Result.build(userInfoVo, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "会员登录")
|
||||
@PostMapping("login")
|
||||
public Result login(@RequestBody UserLoginDto userLoginDto) {
|
||||
String token = userinfoService.login(userLoginDto);
|
||||
return Result.build(token, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "会员注册")
|
||||
@PostMapping("register")
|
||||
public Result register(@RequestBody UserRegisterDto userRegisterDto) {
|
||||
userinfoService.register(userRegisterDto);
|
||||
return Result.build(null, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.bunny.user.mapper;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.user.UserInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface UserinfoMapper {
|
||||
|
||||
// 校验用户名不重复
|
||||
UserInfo getByUsername(@Param("username") String username);
|
||||
|
||||
// 封装添加数据,调用方法调用添加数据
|
||||
void save(UserInfo userInfo);
|
||||
|
||||
// 根据用户名查询数据库,得到用户信息
|
||||
UserInfo selectByUsername(String username);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
package cn.bunny.user.service;
|
||||
|
||||
public interface SmsService {
|
||||
// 短信验证码
|
||||
Object sendCode(String phone);
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package cn.bunny.user.service;
|
||||
|
||||
import cn.bunny.common.spzx.model.dto.h5.UserLoginDto;
|
||||
import cn.bunny.common.spzx.model.dto.h5.UserRegisterDto;
|
||||
import cn.bunny.common.spzx.model.vo.h5.UserInfoVo;
|
||||
|
||||
public interface UserinfoService {
|
||||
UserInfoVo getCurrentUserInfo(String token);
|
||||
|
||||
// 会员注册
|
||||
void register(UserRegisterDto userLoginDto);
|
||||
|
||||
// 会员登录
|
||||
String login(UserLoginDto userLoginDto);
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package cn.bunny.user.service.impl;
|
||||
|
||||
import cn.bunny.common.HttpUtils;
|
||||
import cn.bunny.user.service.SmsService;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class SmsServiceImpl implements SmsService {
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
// 短信验证码
|
||||
@Override
|
||||
public Object sendCode(String phone) {
|
||||
Object code = redisTemplate.opsForValue().get(phone);
|
||||
if (StringUtils.hasText((String) code)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// 1.生成短信验证码
|
||||
code = RandomStringUtils.randomNumeric(4);
|
||||
// 2.放入Redis中,设置过期时间
|
||||
redisTemplate.opsForValue().set(phone, code, 5, TimeUnit.MINUTES);
|
||||
// 3. 向手机号发送短信验证码
|
||||
sendMessage(phone, (String) code);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
// 发送验证码
|
||||
private void sendMessage(String phone, String code) {
|
||||
String host = "https://dfsns.market.alicloudapi.com";
|
||||
String path = "/data/send_sms";
|
||||
String method = "POST";
|
||||
String appcode = "5a4cb12374904a7fa2975ec5a1a9d50f";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("Authorization", "APPCODE " + appcode);
|
||||
// 根据API的要求,定义相对应的Content-Type
|
||||
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
Map<String, String> querys = new HashMap<String, String>();
|
||||
Map<String, String> bodys = new HashMap<String, String>();
|
||||
bodys.put("content", "code:" + code);
|
||||
bodys.put("template_id", "CST_ptdie100"); // 该模板为调试接口专用,短信下发有受限制,调试成功后请联系客服报备专属模板
|
||||
bodys.put("phone_number", phone);
|
||||
|
||||
|
||||
try {
|
||||
HttpResponse httpResponse = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||
System.out.println(httpResponse.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
package cn.bunny.user.service.impl;
|
||||
|
||||
import cn.bunny.common.AuthContextUtil;
|
||||
import cn.bunny.common.exception.BunnyException;
|
||||
import cn.bunny.common.spzx.model.dto.h5.UserLoginDto;
|
||||
import cn.bunny.common.spzx.model.dto.h5.UserRegisterDto;
|
||||
import cn.bunny.common.spzx.model.entity.user.UserInfo;
|
||||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import cn.bunny.common.spzx.model.vo.h5.UserInfoVo;
|
||||
import cn.bunny.user.mapper.UserinfoMapper;
|
||||
import cn.bunny.user.service.UserinfoService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class UserinfoServiceImpl implements UserinfoService {
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private UserinfoMapper userinfoMapper;
|
||||
|
||||
// 获取当前登录用户信息
|
||||
@Override
|
||||
public UserInfoVo getCurrentUserInfo(String token) {
|
||||
/* // 从Redis根据token获取用户信息
|
||||
String userJson = (String) redisTemplate.opsForValue().get("user:spzx" + token);
|
||||
if (!StringUtils.hasText(userJson)) {
|
||||
throw new BunnyException(ResultCodeEnum.LOGIN_ERROR);
|
||||
}
|
||||
|
||||
UserInfo userinfo = JSON.parseObject(userJson, UserInfo.class);
|
||||
assert userinfo != null;
|
||||
UserInfoVo userInfoVo = new UserInfoVo();
|
||||
BeanUtils.copyProperties(userinfo, userInfoVo);
|
||||
|
||||
return userInfoVo; */
|
||||
UserInfo userInfo = AuthContextUtil.getUserInfo();
|
||||
UserInfoVo userInfoVo = new UserInfoVo();
|
||||
BeanUtils.copyProperties(userInfo, userInfoVo);
|
||||
return userInfoVo;
|
||||
}
|
||||
|
||||
// 会员注册
|
||||
@Override
|
||||
public void register(UserRegisterDto userRegisterDto) {
|
||||
// 1. userLoginDto获取数据
|
||||
String username = userRegisterDto.getUsername();
|
||||
String password = userRegisterDto.getPassword();
|
||||
String nickName = userRegisterDto.getNickName();
|
||||
String code = userRegisterDto.getCode();
|
||||
// 2. 从Redis获取发送验证码
|
||||
String redisCode = (String) redisTemplate.opsForValue().get(username);
|
||||
// 3. 获取输入验证码,进行对比
|
||||
if (!redisCode.equals(code)) {
|
||||
throw new BunnyException(ResultCodeEnum.VALIDATECODE_ERROR);
|
||||
}
|
||||
// 4. 校验用户名不重复
|
||||
UserInfo userInfo = userinfoMapper.getByUsername(username);
|
||||
if (userInfo != null) {
|
||||
throw new BunnyException(ResultCodeEnum.USER_NAME_IS_EXISTS);
|
||||
}
|
||||
// 5. 封装添加数据,调用方法调用添加数据
|
||||
userInfo = new UserInfo();
|
||||
userInfo.setUsername(username);
|
||||
userInfo.setNickName(nickName);
|
||||
userInfo.setPassword(DigestUtils.md5DigestAsHex(password.getBytes()));
|
||||
userInfo.setPhone(username);
|
||||
userInfo.setStatus(1);
|
||||
userInfo.setSex(0);
|
||||
userInfo.setAvatar("http://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eoj0hHXhgJNOTSOFsS4uZs8x1ConecaVOB8eIl115xmJZcT4oCicvia7wMEufibKtTLqiaJeanU2Lpg3w/132");
|
||||
userinfoMapper.save(userInfo);
|
||||
// 6. 从Redis中删除发送验证码
|
||||
redisTemplate.delete(username);
|
||||
}
|
||||
|
||||
// 会员登录
|
||||
@Override
|
||||
public String login(UserLoginDto userLoginDto) {
|
||||
// 1. dto获取用户名和密码
|
||||
String username = userLoginDto.getUsername();
|
||||
String password = userLoginDto.getPassword();
|
||||
// 2. 根据用户名查询数据库,得到用户信息
|
||||
UserInfo userInfo = userinfoMapper.selectByUsername(username);
|
||||
// 3. 比较密码是否一致
|
||||
String database_password = userInfo.getPassword();
|
||||
String md5_password = DigestUtils.md5DigestAsHex(password.getBytes());
|
||||
if (!database_password.equals(md5_password)) {
|
||||
throw new BunnyException(ResultCodeEnum.LOGIN_ERROR);
|
||||
}
|
||||
// 4. 校验用户名是否禁用
|
||||
if (userInfo.getStatus() == 0) {
|
||||
throw new BunnyException(ResultCodeEnum.ACCOUNT_STOP);
|
||||
}
|
||||
// 5. 生成token
|
||||
String token = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
// 6. 把用户名信息放到redis中
|
||||
redisTemplate.opsForValue().set("user:spzx" + token,
|
||||
JSON.toJSONString(userInfo), 30, TimeUnit.DAYS);
|
||||
// 7. 返回token
|
||||
return token;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package cn.bunny.web;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
server:
|
||||
port: 8512
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: service-user
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.2.82:8848
|
||||
# server-addr: 192.168.31.202:8848
|
||||
|
||||
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://60.204.230.80:3306/db_spzx?characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: "02120212"
|
||||
data:
|
||||
redis:
|
||||
port: 6379
|
||||
host: 192.168.2.82
|
||||
# host: 192.168.31.202
|
||||
|
||||
mybatis:
|
||||
config-location: classpath:mybatis-config.xml
|
||||
mapper-locations: classpath:/mapper/*.xml
|
|
@ -1,3 +0,0 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: dev
|
|
@ -1,56 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<contextName>logback</contextName>
|
||||
|
||||
<!-- 日志的输出目录 -->
|
||||
<property name="log.path" value="D://logs//service-product//logs" />
|
||||
|
||||
<!--控制台日志格式:彩色日志-->
|
||||
<!-- magenta:洋红 -->
|
||||
<!-- boldMagenta:粗红-->
|
||||
<!-- cyan:青色 -->
|
||||
<!-- white:白色 -->
|
||||
<!-- magenta:洋红 -->
|
||||
<property name="CONSOLE_LOG_PATTERN" value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) %highlight([%-5level]) %green(%logger) %msg%n"/>
|
||||
|
||||
<!--文件日志格式-->
|
||||
<property name="FILE_LOG_PATTERN" value="%date{yyyy-MM-dd HH:mm:ss} [%-5level] %thread %file:%line %logger %msg%n" />
|
||||
|
||||
<!--编码-->
|
||||
<property name="ENCODING" value="UTF-8" />
|
||||
|
||||
<!-- 控制台日志 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- 临界值过滤器 -->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 文件日志 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>${log.path}//log.log</file>
|
||||
<append>true</append>
|
||||
<encoder>
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 开发环境 -->
|
||||
<springProfile name="dev">
|
||||
<!-- com.atguigu日志记录器:业务程序INFO级别 -->
|
||||
<logger name="com.atguigu" level="INFO" />
|
||||
<!-- 根日志记录器:INFO级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
|
@ -1,55 +0,0 @@
|
|||
<?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="cn.bunny.user.mapper.UserinfoMapper">
|
||||
<resultMap id="userInfoMap" type="cn.bunny.common.spzx.model.entity.user.UserInfo" autoMapping="true"/>
|
||||
|
||||
<!-- 用于select查询公用抽取的列 -->
|
||||
<sql id="columns">
|
||||
id,username,password,nick_name,avatar,sex,phone,memo,open_id,union_id,last_login_ip,last_login_time,status,create_time,update_time,is_deleted
|
||||
</sql>
|
||||
|
||||
<!-- 校验用户名不重复 -->
|
||||
<select id="selectByUsername" resultMap="userInfoMap">
|
||||
select *
|
||||
from user_info
|
||||
where username = #{username}
|
||||
</select>
|
||||
<select id="getByUsername" resultType="cn.bunny.common.spzx.model.entity.user.UserInfo">
|
||||
select
|
||||
<include refid="columns"/>
|
||||
from user_info
|
||||
where
|
||||
username = #{username}
|
||||
</select>
|
||||
|
||||
<!-- 封装添加数据,调用方法调用添加数据 -->
|
||||
<insert id="save" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into user_info (id,
|
||||
username,
|
||||
password,
|
||||
nick_name,
|
||||
avatar,
|
||||
sex,
|
||||
phone,
|
||||
memo,
|
||||
open_id,
|
||||
union_id,
|
||||
last_login_ip,
|
||||
last_login_time,
|
||||
status)
|
||||
values (#{id},
|
||||
#{username},
|
||||
#{password},
|
||||
#{nickName},
|
||||
#{avatar},
|
||||
#{sex},
|
||||
#{phone},
|
||||
#{memo},
|
||||
#{openId},
|
||||
#{unionId},
|
||||
#{lastLoginIp},
|
||||
#{lastLoginTime},
|
||||
#{status})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration PUBLIC
|
||||
"-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<settings>
|
||||
<!-- 设置驼峰标识 -->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
<!-- 打印SQL语句 -->
|
||||
<setting name="logImpl" value="STDOUT_LOGGING"/>
|
||||
</settings>
|
||||
<plugins>
|
||||
<!-- 分页插件 -->
|
||||
<plugin interceptor="com.github.pagehelper.PageInterceptor"/>
|
||||
</plugins>
|
||||
</configuration>
|
Loading…
Reference in New Issue