From 3210eb3779068bb755cd26d4e93c82da5e3d17e5 Mon Sep 17 00:00:00 2001 From: lijiantao Date: Mon, 19 Aug 2019 17:56:23 +0800 Subject: [PATCH] =?UTF-8?q?shiro=20=E5=A4=9Arealm=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- antd-ova/config/router.config.js | 52 ++---------- antd-ova/src/OvaConfig.js | 8 +- .../components/GlobalHeader/RightContent.js | 4 +- antd-ova/src/custom/ReactQuillWrapper.js | 6 +- antd-ova/src/custom/UnipicUpload.js | 6 +- antd-ova/src/models/menu.js | 6 +- .../pages/{System => Seller}/Menu/Index.js | 0 .../{System => Seller}/Menu/models/menu.js | 0 .../pages/{System => Seller}/Role/Index.js | 0 .../pages/{System => Seller}/Role/MenuTree.js | 0 .../{System => Seller}/Role/models/role.js | 0 .../pages/{System => Seller}/User/Index.js | 4 +- .../{System => Seller}/User/models/user.js | 0 antd-ova/src/services/system.js | 82 +------------------ antd-ova/src/services/user.js | 2 +- .../java/cn/ova/core/shiro/LoginType.java | 19 +++++ .../core}/shiro/OvaShiroSessionManager.java | 4 +- .../OvaUserModularRealmAuthenticator.java | 48 +++++++++++ .../java/cn/ova/core/shiro/OvaUserToken.java | 21 +++++ .../java/cn/ova/dao/OvCommCategoryDao.java | 11 --- .../main/java/cn/ova/dao/OvCommPicDao.java | 11 --- .../main/java/cn/ova/dao/OvCommodityDao.java | 11 --- .../main/java/cn/ova/dao/OvOrderCommDao.java | 11 --- .../java/cn/ova/dao/OvUserAddressDao.java | 11 --- .../{OvOrdersDao.java => OvaCategoryDao.java} | 5 +- ...erInfoDao.java => OvaCommCategoryDao.java} | 5 +- .../{OvCommentDao.java => OvaCommPicDao.java} | 5 +- .../main/java/cn/ova/dao/OvaCommentDao.java | 10 +++ .../main/java/cn/ova/dao/OvaCommodityDao.java | 10 +++ .../main/java/cn/ova/dao/OvaOrderCommDao.java | 10 +++ .../{OvCategoryDao.java => OvaOrdersDao.java} | 4 +- .../java/cn/ova/dao/OvaSellerUserDao.java | 15 ++++ .../java/cn/ova/dao/OvaUserAddressDao.java | 10 +++ .../dao/{OvUserDao.java => OvaUserDao.java} | 8 +- .../OvaCategoryEntity.java} | 6 +- .../OvaCommCategoryEntity.java} | 6 +- .../OvaCommPicEntity.java} | 6 +- .../OvaCommentEntity.java} | 6 +- .../OvaCommodityEntity.java} | 14 ++-- .../OvaOrderCommEntity.java} | 6 +- .../OvaOrdersEntity.java} | 6 +- .../OvaSellerUserEntity.java} | 9 +- .../OvaUserAddressEntity.java} | 9 +- .../OvaUserEntity.java} | 9 +- ova-boot/ova-seller/pom.xml | 4 +- .../java/cn/ova/dto/OvaSellerUserDto.java | 12 +++ .../main/java/cn/ova/dto/OvaUserInfoDto.java | 5 -- .../cn/ova/shiro/OvaSellerShiroRealm.java} | 51 ++++++++---- .../src/main/java/cn/ova/web/LoginRest.java | 9 +- .../main/java/cn/ova/web/OvUserInfoRest.java | 20 ----- ...OvUserRest.java => OvaSellerUserRest.java} | 38 ++++----- ova-boot/ova-web/pom.xml | 2 +- .../cn/ova}/config/CorsConfiguration.java | 2 +- .../cn/ova/config}/ShiroConfiguration.java | 41 ++++++++-- ova-boot/ova-wechat/pom.xml | 4 +- ova-boot/pom.xml | 18 ++-- 56 files changed, 346 insertions(+), 336 deletions(-) rename antd-ova/src/pages/{System => Seller}/Menu/Index.js (100%) rename antd-ova/src/pages/{System => Seller}/Menu/models/menu.js (100%) rename antd-ova/src/pages/{System => Seller}/Role/Index.js (100%) rename antd-ova/src/pages/{System => Seller}/Role/MenuTree.js (100%) rename antd-ova/src/pages/{System => Seller}/Role/models/role.js (100%) rename antd-ova/src/pages/{System => Seller}/User/Index.js (98%) rename antd-ova/src/pages/{System => Seller}/User/models/user.js (100%) create mode 100644 ova-boot/ova-core/src/main/java/cn/ova/core/shiro/LoginType.java rename ova-boot/{ova-dao/src/main/java/cn/ova => ova-core/src/main/java/cn/ova/core}/shiro/OvaShiroSessionManager.java (92%) create mode 100644 ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserModularRealmAuthenticator.java create mode 100644 ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserToken.java delete mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommCategoryDao.java delete mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommPicDao.java delete mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommodityDao.java delete mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvOrderCommDao.java delete mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserAddressDao.java rename ova-boot/ova-dao/src/main/java/cn/ova/dao/{OvOrdersDao.java => OvaCategoryDao.java} (46%) rename ova-boot/ova-dao/src/main/java/cn/ova/dao/{OvUserInfoDao.java => OvaCommCategoryDao.java} (46%) rename ova-boot/ova-dao/src/main/java/cn/ova/dao/{OvCommentDao.java => OvaCommPicDao.java} (46%) create mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommentDao.java create mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommodityDao.java create mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaOrderCommDao.java rename ova-boot/ova-dao/src/main/java/cn/ova/dao/{OvCategoryDao.java => OvaOrdersDao.java} (52%) create mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaSellerUserDao.java create mode 100644 ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaUserAddressDao.java rename ova-boot/ova-dao/src/main/java/cn/ova/dao/{OvUserDao.java => OvaUserDao.java} (49%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvCategoryEntity.java => commodity/OvaCategoryEntity.java} (70%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvCommCategoryEntity.java => commodity/OvaCommCategoryEntity.java} (80%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvCommPicEntity.java => commodity/OvaCommPicEntity.java} (80%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvCommentEntity.java => commodity/OvaCommentEntity.java} (81%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvCommodityEntity.java => commodity/OvaCommodityEntity.java} (87%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvOrderCommEntity.java => order/OvaOrderCommEntity.java} (80%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvOrdersEntity.java => order/OvaOrdersEntity.java} (93%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvUserInfoEntity.java => user/OvaSellerUserEntity.java} (90%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvUserAddressEntity.java => user/OvaUserAddressEntity.java} (87%) rename ova-boot/ova-dao/src/main/java/cn/ova/entity/{OvUserEntity.java => user/OvaUserEntity.java} (88%) create mode 100644 ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaSellerUserDto.java delete mode 100644 ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaUserInfoDto.java rename ova-boot/{ova-dao/src/main/java/cn/ova/shiro/OvaShiroRealm.java => ova-seller/src/main/java/cn/ova/shiro/OvaSellerShiroRealm.java} (35%) delete mode 100644 ova-boot/ova-seller/src/main/java/cn/ova/web/OvUserInfoRest.java rename ova-boot/ova-seller/src/main/java/cn/ova/web/{OvUserRest.java => OvaSellerUserRest.java} (30%) rename ova-boot/{ova-core/src/main/java/cn/ova/core => ova-web/src/main/java/cn/ova}/config/CorsConfiguration.java (96%) rename ova-boot/{ova-dao/src/main/java/cn/ova/shiro => ova-web/src/main/java/cn/ova/config}/ShiroConfiguration.java (70%) diff --git a/antd-ova/config/router.config.js b/antd-ova/config/router.config.js index 46a8329..01d3066 100644 --- a/antd-ova/config/router.config.js +++ b/antd-ova/config/router.config.js @@ -20,58 +20,18 @@ export default [ routes: [ { path: '/', - redirect: '/system/user', + redirect: '/seller/user', }, { - path: '/system', - name: 'system', + path: '/seller', + name: 'seller', routes: [ { - path: '/system/user', + path: '/seller/user', name: 'user', - component: './System/User/Index', - }, - { - path: '/system/menu', - name: 'menu', - component: './System/Menu/Index', - }, - { - path: '/system/role', - name: 'role', - component: './System/Role/Index', - }, - ], - }, - { - path: '/operation', - name: 'operation', - routes:[ - { - path: '/operation/log', - name: 'log', - component: './Operation/Log/Index' - }, - { - path: '/operation/article', - name: 'article', - routes:[ - { - path: '/operation/article', - component: './Operation/Article/Index' - },{ - path: '/operation/article/:id', - name: 'edit', - component: './Operation/Article/Edit' - } - ] - }, - { - path: '/operation/sqlmonitor', - name: 'sqlmonitor', - component: './Operation/SqlMonitor/Index' + component: './Seller/User/Index', } - ] + ], }, { component: '404', diff --git a/antd-ova/src/OvaConfig.js b/antd-ova/src/OvaConfig.js index 5501709..f07e9c3 100644 --- a/antd-ova/src/OvaConfig.js +++ b/antd-ova/src/OvaConfig.js @@ -1,7 +1,7 @@ module.exports = { - AntdspBase: '/ova', - AntdspServiceApi: 'http://localhost:8088/ova-api', - AntdspUploadApi: '/ova-api/fileupload', - AntdspDownloadApi: 'http://www.qiniuimage.jt-lee.cn', + OvaBase: '/ova', + OvaServiceApi: 'http://localhost:8088/ova-api', + OvaUploadApi: '/ova-api/fileupload', + // OvaDownloadApi: 'http://www.qiniuimage.jt-lee.cn', } \ No newline at end of file diff --git a/antd-ova/src/components/GlobalHeader/RightContent.js b/antd-ova/src/components/GlobalHeader/RightContent.js index 55fe5eb..318ee39 100644 --- a/antd-ova/src/components/GlobalHeader/RightContent.js +++ b/antd-ova/src/components/GlobalHeader/RightContent.js @@ -8,7 +8,7 @@ import HeaderSearch from '../HeaderSearch'; import HeaderDropdown from '../HeaderDropdown'; import SelectLang from '../SelectLang'; import styles from './index.less'; -import AntdspConfig from '@/AntdspConfig'; +import OvaConfig from '@/OvaConfig'; export default class GlobalHeaderRight extends PureComponent { getNoticeData() { @@ -115,7 +115,7 @@ export default class GlobalHeaderRight extends PureComponent { {currentUser.realname} diff --git a/antd-ova/src/custom/ReactQuillWrapper.js b/antd-ova/src/custom/ReactQuillWrapper.js index 5449cfa..87005d2 100644 --- a/antd-ova/src/custom/ReactQuillWrapper.js +++ b/antd-ova/src/custom/ReactQuillWrapper.js @@ -3,7 +3,7 @@ import 'react-quill/dist/quill.snow.css'; import ReactQuill from 'react-quill'; import fetch from 'dva/fetch'; -import AntdspConfig from '@/AntdspConfig' +import OvaConfig from '@/OvaConfig' import { Input } from "antd"; let uploadGroup = ""; @@ -68,12 +68,12 @@ export default class ReactQuillWrapper extends PureComponent{ let formData = new FormData(); formData.append('file', fileInput.files[0]); - fetch(`${AntdspConfig.AntdspUploadApi}/${uploadGroup}`,{ + fetch(`${OvaConfig.OvaUploadApi}/${uploadGroup}`,{ method: 'POST', body: formData, }).then((response)=>response.json()).then((data)=>{ if(data.success){ - _this3.quill.insertEmbed(range.index, 'image', `${AntdspConfig.AntdspDownloadApi}/${ data.message}`); + _this3.quill.insertEmbed(range.index, 'image', `${OvaConfig.OvaDownloadApi}/${ data.message}`); } }) } diff --git a/antd-ova/src/custom/UnipicUpload.js b/antd-ova/src/custom/UnipicUpload.js index 797e436..c988554 100644 --- a/antd-ova/src/custom/UnipicUpload.js +++ b/antd-ova/src/custom/UnipicUpload.js @@ -1,6 +1,6 @@ import { PureComponent } from "react"; import { Upload, Icon, message } from "antd"; -import AntdspConfig from "@/AntdspConfig"; +import OvaConfig from "@/OvaConfig"; export default class UnipicUpload extends PureComponent{ @@ -17,7 +17,7 @@ export default class UnipicUpload extends PureComponent{ } uploadUrl(group){ - return `${AntdspConfig.AntdspUploadApi}/${group}`; + return `${OvaConfig.OvaUploadApi}/${group}`; } handlerBeforeUpload=(file)=>{ @@ -64,7 +64,7 @@ export default class UnipicUpload extends PureComponent{ > { !this.state.loading && imgUrl ? - + :
diff --git a/antd-ova/src/models/menu.js b/antd-ova/src/models/menu.js index 9459ff1..35e91a4 100644 --- a/antd-ova/src/models/menu.js +++ b/antd-ova/src/models/menu.js @@ -112,9 +112,9 @@ export default { *getMenuData({ payload }, {call , put }) { const { routes, authority, path } = payload; const originalMenuData = memoizeOneFormatter(routes, authority, path); - // const menuData = filterMenuData(originalMenuData); - const roleMenus = yield call(queryRoleMenus); - const menuData = roleMenus.children || []; + const menuData = filterMenuData(originalMenuData); + // const roleMenus = yield call(queryRoleMenus); + // const menuData = roleMenus.children || []; const breadcrumbNameMap = memoizeOneGetBreadcrumbNameMap(originalMenuData); yield put({ type: 'save', diff --git a/antd-ova/src/pages/System/Menu/Index.js b/antd-ova/src/pages/Seller/Menu/Index.js similarity index 100% rename from antd-ova/src/pages/System/Menu/Index.js rename to antd-ova/src/pages/Seller/Menu/Index.js diff --git a/antd-ova/src/pages/System/Menu/models/menu.js b/antd-ova/src/pages/Seller/Menu/models/menu.js similarity index 100% rename from antd-ova/src/pages/System/Menu/models/menu.js rename to antd-ova/src/pages/Seller/Menu/models/menu.js diff --git a/antd-ova/src/pages/System/Role/Index.js b/antd-ova/src/pages/Seller/Role/Index.js similarity index 100% rename from antd-ova/src/pages/System/Role/Index.js rename to antd-ova/src/pages/Seller/Role/Index.js diff --git a/antd-ova/src/pages/System/Role/MenuTree.js b/antd-ova/src/pages/Seller/Role/MenuTree.js similarity index 100% rename from antd-ova/src/pages/System/Role/MenuTree.js rename to antd-ova/src/pages/Seller/Role/MenuTree.js diff --git a/antd-ova/src/pages/System/Role/models/role.js b/antd-ova/src/pages/Seller/Role/models/role.js similarity index 100% rename from antd-ova/src/pages/System/Role/models/role.js rename to antd-ova/src/pages/Seller/Role/models/role.js diff --git a/antd-ova/src/pages/System/User/Index.js b/antd-ova/src/pages/Seller/User/Index.js similarity index 98% rename from antd-ova/src/pages/System/User/Index.js rename to antd-ova/src/pages/Seller/User/Index.js index b0aaa50..8487774 100644 --- a/antd-ova/src/pages/System/User/Index.js +++ b/antd-ova/src/pages/Seller/User/Index.js @@ -19,7 +19,7 @@ import { } from 'antd'; import md5 from 'js-md5' import UnipicUpload from '@/custom/UnipicUpload'; -import AntdspConfig from '@/AntdspConfig' +import OvaConfig from '@/OvaConfig' const FormItem = Form.Item; @@ -227,7 +227,7 @@ export default class extends PureComponent { dataIndex: 'avatar', render:(val)=>{ if(val){ - return
+ return
} } }, diff --git a/antd-ova/src/pages/System/User/models/user.js b/antd-ova/src/pages/Seller/User/models/user.js similarity index 100% rename from antd-ova/src/pages/System/User/models/user.js rename to antd-ova/src/pages/Seller/User/models/user.js diff --git a/antd-ova/src/services/system.js b/antd-ova/src/services/system.js index 86639dc..f110065 100644 --- a/antd-ova/src/services/system.js +++ b/antd-ova/src/services/system.js @@ -2,10 +2,8 @@ import { async } from "q"; import request, { download } from '@/utils/request'; import qs from 'qs'; -const API_BASE = "/antdsp-api"; -const USER_API = API_BASE + "/system/user"; -const MENU_API = API_BASE + "/system/menu"; -const ROLE_API = API_BASE + "/system/role"; +const API_BASE = "/ova-api"; +const USER_API = API_BASE + "/seller/user"; export async function fetchAllUser(params){ return request(`${USER_API}?${qs.stringify(params, { indices: false })}`); @@ -40,80 +38,4 @@ export async function fetchUser(params){ return request(`${USER_API}/${params.id}`,{ method: 'GET' }); -} - -export async function fetchAllMenu(){ - return request(`${MENU_API}`) -} - -export async function addMenu(params){ - - return request(`${MENU_API}`,{ - method: 'POST', - data:{ - ...params - } - }); -} -export async function updateMenu(params){ - return request(`${MENU_API}`,{ - method: 'PUT', - data:{ - ...params - } - }); -} - -export async function delMenuById(param){ - return request(`${MENU_API}/${param.id}`,{ - method: 'DELETE', - }) -} - -export async function fetchAllRole(param){ - return request(`${ROLE_API}?${qs.stringify(param, { indices: false })}`) -} - - -export async function addRole(params){ - return request(`${ROLE_API}`,{ - method: 'POST', - data: { - ...params - }, - }) -} -export async function updateRole(params){ - return request(`${ROLE_API}`,{ - method: 'PUT', - data: { - ...params - } - }); -} - -export async function delRoleById(param){ - return request(`${ROLE_API}/${param.id}`,{ - method: 'DELETE' - }) -} - -export async function fetchRoleById(param){ - return request(`${ROLE_API}/${param.id}`); -} - -export async function queryRoles(){ - return request(`${ROLE_API}/queryRoleNameAndIds`); -} - -export async function queryRoleMenus(){ - return request(`${MENU_API}/route`); -} - -export async function fetchAllLog(param){ - return request(`${API_BASE}/operation/log?${qs.stringify(param, { indices: false })}`); -} - -export async function exportLog(params){ - return download(`${API_BASE}/operation/log/export?${qs.stringify(params, { indices: false })}`) } \ No newline at end of file diff --git a/antd-ova/src/services/user.js b/antd-ova/src/services/user.js index bc16023..15d5093 100644 --- a/antd-ova/src/services/user.js +++ b/antd-ova/src/services/user.js @@ -5,5 +5,5 @@ export async function query() { } export async function queryCurrent() { - return request('/antdsp-api/system/user/current'); + return request('/ova-api/seller/user/current'); } diff --git a/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/LoginType.java b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/LoginType.java new file mode 100644 index 0000000..49d4b64 --- /dev/null +++ b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/LoginType.java @@ -0,0 +1,19 @@ +package cn.ova.core.shiro; + +public enum LoginType { + + SELLER("Seller"), + WECHAT("Wechat"); + + private String type; + + private LoginType(String type){ + this.type = type; + } + + + @Override + public String toString() { + return this.type; + } +} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/shiro/OvaShiroSessionManager.java b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaShiroSessionManager.java similarity index 92% rename from ova-boot/ova-dao/src/main/java/cn/ova/shiro/OvaShiroSessionManager.java rename to ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaShiroSessionManager.java index 59c6c55..6bea810 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/shiro/OvaShiroSessionManager.java +++ b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaShiroSessionManager.java @@ -1,4 +1,4 @@ -package cn.ova.shiro; +package cn.ova.core.shiro; import cn.ova.core.util.Constants; import org.apache.shiro.web.servlet.ShiroHttpServletRequest; @@ -12,7 +12,7 @@ import javax.servlet.http.HttpServletRequest; import java.io.Serializable; public class OvaShiroSessionManager extends DefaultWebSessionManager{ -private static final String REFERENCED_SESSION_ID_SOURCE = "Stateless request"; + private static final String REFERENCED_SESSION_ID_SOURCE = "Stateless request"; public OvaShiroSessionManager() { super(); diff --git a/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserModularRealmAuthenticator.java b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserModularRealmAuthenticator.java new file mode 100644 index 0000000..71501e5 --- /dev/null +++ b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserModularRealmAuthenticator.java @@ -0,0 +1,48 @@ +package cn.ova.core.shiro; + +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationInfo; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.pam.ModularRealmAuthenticator; +import org.apache.shiro.realm.Realm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class OvaUserModularRealmAuthenticator extends ModularRealmAuthenticator { + + private static final Logger logger = LoggerFactory.getLogger(OvaUserModularRealmAuthenticator.class); + + @Override + protected AuthenticationInfo doAuthenticate(AuthenticationToken authenticationToken) throws AuthenticationException { + + logger.info("OvaUserModularRealmAuthenticator.doAuthenticate 开始执行..."); + + assertRealmsConfigured(); + OvaUserToken userToken = (OvaUserToken) authenticationToken ; + + LoginType loginType = userToken.getLoginType(); + + Collection realms = getRealms(); + List typeRealms = new ArrayList<>(); + + for (Realm realm : realms){ + //realm.getName() realm的全类名 + if(realm.getName().contains(loginType.toString())){ + typeRealms.add(realm); + } + } + + if (typeRealms.size() == 1){ + logger.info("doSingleRealmAuthentication() execute "); + return doSingleRealmAuthentication(typeRealms.get(0), userToken); + } + else{ + logger.info("doMultiRealmAuthentication() execute "); + return doMultiRealmAuthentication(typeRealms, userToken); + } + } +} diff --git a/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserToken.java b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserToken.java new file mode 100644 index 0000000..5df0472 --- /dev/null +++ b/ova-boot/ova-core/src/main/java/cn/ova/core/shiro/OvaUserToken.java @@ -0,0 +1,21 @@ +package cn.ova.core.shiro; + +import lombok.Data; +import org.apache.shiro.authc.UsernamePasswordToken; + +@Data +public class OvaUserToken extends UsernamePasswordToken { + + //登录类型,判断是seller端或者是wecht端登录 + private LoginType loginType; + + public OvaUserToken(final String username, final String password, LoginType type){ + + super(username, password); + this.loginType = type; + } + + + + +} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommCategoryDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommCategoryDao.java deleted file mode 100644 index 28351fb..0000000 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommCategoryDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.ova.dao; - -import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvCategoryEntity; -import cn.ova.entity.OvCommCategoryEntity; -import org.springframework.stereotype.Repository; - -@Repository -public interface OvCommCategoryDao extends OvaBaseRepository { - -} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommPicDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommPicDao.java deleted file mode 100644 index 0ef54c5..0000000 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommPicDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.ova.dao; - -import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvCommPicEntity; -import cn.ova.entity.OvCommodityEntity; -import org.springframework.stereotype.Repository; - -@Repository -public interface OvCommPicDao extends OvaBaseRepository { - -} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommodityDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommodityDao.java deleted file mode 100644 index 971e0f9..0000000 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommodityDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.ova.dao; - -import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvCommentEntity; -import cn.ova.entity.OvCommodityEntity; -import org.springframework.stereotype.Repository; - -@Repository -public interface OvCommodityDao extends OvaBaseRepository { - -} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvOrderCommDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvOrderCommDao.java deleted file mode 100644 index 35a8b25..0000000 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvOrderCommDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.ova.dao; - -import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvCommPicEntity; -import cn.ova.entity.OvOrderCommEntity; -import org.springframework.stereotype.Repository; - -@Repository -public interface OvOrderCommDao extends OvaBaseRepository { - -} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserAddressDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserAddressDao.java deleted file mode 100644 index 46d4b7a..0000000 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserAddressDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.ova.dao; - -import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvUserAddressEntity; -import cn.ova.entity.OvUserEntity; -import org.springframework.stereotype.Repository; - -@Repository -public interface OvUserAddressDao extends OvaBaseRepository { - -} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvOrdersDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCategoryDao.java similarity index 46% rename from ova-boot/ova-dao/src/main/java/cn/ova/dao/OvOrdersDao.java rename to ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCategoryDao.java index 8a11057..0a1ce10 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvOrdersDao.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCategoryDao.java @@ -1,11 +1,10 @@ package cn.ova.dao; import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvOrderCommEntity; -import cn.ova.entity.OvOrdersEntity; +import cn.ova.entity.commodity.OvaCategoryEntity; import org.springframework.stereotype.Repository; @Repository -public interface OvOrdersDao extends OvaBaseRepository { +public interface OvaCategoryDao extends OvaBaseRepository { } diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserInfoDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommCategoryDao.java similarity index 46% rename from ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserInfoDao.java rename to ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommCategoryDao.java index d068e1b..f011ee3 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserInfoDao.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommCategoryDao.java @@ -1,11 +1,10 @@ package cn.ova.dao; import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvUserEntity; -import cn.ova.entity.OvUserInfoEntity; +import cn.ova.entity.commodity.OvaCommCategoryEntity; import org.springframework.stereotype.Repository; @Repository -public interface OvUserInfoDao extends OvaBaseRepository { +public interface OvaCommCategoryDao extends OvaBaseRepository { } diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommentDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommPicDao.java similarity index 46% rename from ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommentDao.java rename to ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommPicDao.java index 98af680..b4f146a 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCommentDao.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommPicDao.java @@ -1,11 +1,10 @@ package cn.ova.dao; import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvCategoryEntity; -import cn.ova.entity.OvCommentEntity; +import cn.ova.entity.commodity.OvaCommPicEntity; import org.springframework.stereotype.Repository; @Repository -public interface OvCommentDao extends OvaBaseRepository { +public interface OvaCommPicDao extends OvaBaseRepository { } diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommentDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommentDao.java new file mode 100644 index 0000000..0beda90 --- /dev/null +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommentDao.java @@ -0,0 +1,10 @@ +package cn.ova.dao; + +import cn.ova.core.repository.OvaBaseRepository; +import cn.ova.entity.commodity.OvaCommentEntity; +import org.springframework.stereotype.Repository; + +@Repository +public interface OvaCommentDao extends OvaBaseRepository { + +} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommodityDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommodityDao.java new file mode 100644 index 0000000..236fc58 --- /dev/null +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaCommodityDao.java @@ -0,0 +1,10 @@ +package cn.ova.dao; + +import cn.ova.core.repository.OvaBaseRepository; +import cn.ova.entity.commodity.OvaCommodityEntity; +import org.springframework.stereotype.Repository; + +@Repository +public interface OvaCommodityDao extends OvaBaseRepository { + +} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaOrderCommDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaOrderCommDao.java new file mode 100644 index 0000000..78f19f0 --- /dev/null +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaOrderCommDao.java @@ -0,0 +1,10 @@ +package cn.ova.dao; + +import cn.ova.core.repository.OvaBaseRepository; +import cn.ova.entity.order.OvaOrderCommEntity; +import org.springframework.stereotype.Repository; + +@Repository +public interface OvaOrderCommDao extends OvaBaseRepository { + +} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCategoryDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaOrdersDao.java similarity index 52% rename from ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCategoryDao.java rename to ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaOrdersDao.java index 8934085..ae46b7a 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvCategoryDao.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaOrdersDao.java @@ -1,10 +1,10 @@ package cn.ova.dao; import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvCategoryEntity; +import cn.ova.entity.order.OvaOrdersEntity; import org.springframework.stereotype.Repository; @Repository -public interface OvCategoryDao extends OvaBaseRepository { +public interface OvaOrdersDao extends OvaBaseRepository { } diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaSellerUserDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaSellerUserDao.java new file mode 100644 index 0000000..f9d6345 --- /dev/null +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaSellerUserDao.java @@ -0,0 +1,15 @@ +package cn.ova.dao; + +import cn.ova.core.repository.OvaBaseRepository; +import cn.ova.entity.user.OvaSellerUserEntity; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface OvaSellerUserDao extends OvaBaseRepository { + + @Query("From OvaSellerUserEntity WHERE username= :username") + OvaSellerUserEntity querySellerUserByLoginName(@Param("username") String username); + +} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaUserAddressDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaUserAddressDao.java new file mode 100644 index 0000000..ca2606c --- /dev/null +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaUserAddressDao.java @@ -0,0 +1,10 @@ +package cn.ova.dao; + +import cn.ova.core.repository.OvaBaseRepository; +import cn.ova.entity.user.OvaUserAddressEntity; +import org.springframework.stereotype.Repository; + +@Repository +public interface OvaUserAddressDao extends OvaBaseRepository { + +} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserDao.java b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaUserDao.java similarity index 49% rename from ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserDao.java rename to ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaUserDao.java index 5de4d4a..06f672e 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvUserDao.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/dao/OvaUserDao.java @@ -1,15 +1,15 @@ package cn.ova.dao; import cn.ova.core.repository.OvaBaseRepository; -import cn.ova.entity.OvUserEntity; +import cn.ova.entity.user.OvaUserEntity; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository -public interface OvUserDao extends OvaBaseRepository { +public interface OvaUserDao extends OvaBaseRepository { - @Query("From OvUserEntity WHERE username = :username") - OvUserEntity queryUserByLoginName(@Param("username") String username); + @Query("From OvaUserEntity WHERE username = :username") + OvaUserEntity queryUserByLoginName(@Param("username") String username); } diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCategoryEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCategoryEntity.java similarity index 70% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCategoryEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCategoryEntity.java index 0e13e64..107ffe1 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCategoryEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCategoryEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.commodity; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -8,9 +8,9 @@ import javax.persistence.Entity; import javax.persistence.Table; @Data -@Table(name = "ov_category") +@Table(name = "ova_category") @Entity -public class OvCategoryEntity extends AbstractEntity { +public class OvaCategoryEntity extends AbstractEntity { /** * 类别名称 diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommCategoryEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommCategoryEntity.java similarity index 80% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommCategoryEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommCategoryEntity.java index 359cce3..d45d22a 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommCategoryEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommCategoryEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.commodity; import lombok.Data; @@ -8,9 +8,9 @@ import javax.persistence.*; * 商品分类关联表 */ @Data -@Table(name = "ov_comm_category") +@Table(name = "ova_comm_category") @Entity -public class OvCommCategoryEntity { +public class OvaCommCategoryEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommPicEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommPicEntity.java similarity index 80% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommPicEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommPicEntity.java index b0dbfcd..afabf01 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommPicEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommPicEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.commodity; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -8,9 +8,9 @@ import javax.persistence.Entity; import javax.persistence.Table; @Data -@Table(name = "ov_comm_pic") +@Table(name = "ova_comm_pic") @Entity -public class OvCommPicEntity extends AbstractEntity { +public class OvaCommPicEntity extends AbstractEntity { @Column(name = "comm_id", length = 20, nullable = false) private Long commId; diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommentEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommentEntity.java similarity index 81% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommentEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommentEntity.java index 30fe9ab..02c3381 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommentEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommentEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.commodity; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -8,9 +8,9 @@ import javax.persistence.Entity; import javax.persistence.Table; @Data -@Table(name = "ov_comment") +@Table(name = "ova_comment") @Entity -public class OvCommentEntity extends AbstractEntity { +public class OvaCommentEntity extends AbstractEntity { @Column(name = "comm_id", length = 20, nullable = false) private Long commId; diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommodityEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommodityEntity.java similarity index 87% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommodityEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommodityEntity.java index 411b2dd..e6b6150 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvCommodityEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/commodity/OvaCommodityEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.commodity; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -10,9 +10,9 @@ import java.math.BigDecimal; import java.sql.Time; @Data -@Table(name = "ov_commodity") +@Table(name = "ova_commodity") @Entity -public class OvCommodityEntity extends AbstractEntity { +public class OvaCommodityEntity extends AbstractEntity { /** * 商品编号 @@ -23,8 +23,8 @@ public class OvCommodityEntity extends AbstractEntity { /** * 商品名称 */ - @Column(name = "name", length = 64, nullable = false) - private String name; + @Column(name = "c_name", length = 64, nullable = false) + private String cname; /** * 市场价 @@ -89,8 +89,8 @@ public class OvCommodityEntity extends AbstractEntity { /** * 商品介绍 */ - @Column(name = "describe") - private String describe; + @Column(name = "description", length = 10240) + private String description; /** * 是否上架 0 是 1 否 diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvOrderCommEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/order/OvaOrderCommEntity.java similarity index 80% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvOrderCommEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/order/OvaOrderCommEntity.java index ae62a3d..de7db92 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvOrderCommEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/order/OvaOrderCommEntity.java @@ -1,13 +1,13 @@ -package cn.ova.entity; +package cn.ova.entity.order; import lombok.Data; import javax.persistence.*; @Data -@Table(name = "ov_order_comm") +@Table(name = "ova_order_comm") @Entity -public class OvOrderCommEntity { +public class OvaOrderCommEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvOrdersEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/order/OvaOrdersEntity.java similarity index 93% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvOrdersEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/order/OvaOrdersEntity.java index 4dca6ce..35ed2e4 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvOrdersEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/order/OvaOrdersEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.order; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -10,9 +10,9 @@ import java.math.BigDecimal; import java.sql.Time; @Data -@Table(name = "ov_orders") +@Table(name = "ova_orders") @Entity -public class OvOrdersEntity extends AbstractEntity { +public class OvaOrdersEntity extends AbstractEntity { /** * 编码 diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserInfoEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaSellerUserEntity.java similarity index 90% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserInfoEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaSellerUserEntity.java index 2823672..2176870 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserInfoEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaSellerUserEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.user; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -8,10 +8,13 @@ import javax.persistence.Entity; import javax.persistence.Table; import java.sql.Time; +/** + * 商户后台登录账号实体类 + */ @Data -@Table(name = "ov_user_info") +@Table(name = "ova_seller_user") @Entity -public class OvUserInfoEntity extends AbstractEntity { +public class OvaSellerUserEntity extends AbstractEntity { @Column(name = "username", length = 64, nullable = false) diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserAddressEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaUserAddressEntity.java similarity index 87% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserAddressEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaUserAddressEntity.java index 5f4230e..66bc126 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserAddressEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaUserAddressEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.user; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -8,10 +8,13 @@ import javax.persistence.Entity; import javax.persistence.Table; import java.sql.Time; +/** + * 收货地址 + */ @Data -@Table(name = "user_address") +@Table(name = "ova_user_address") @Entity -public class OvUserAddressEntity extends AbstractEntity { +public class OvaUserAddressEntity extends AbstractEntity { @Column(name = "user_id", length = 64, nullable = false) diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserEntity.java b/ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaUserEntity.java similarity index 88% rename from ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserEntity.java rename to ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaUserEntity.java index 6030a90..dd54a86 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/entity/OvUserEntity.java +++ b/ova-boot/ova-dao/src/main/java/cn/ova/entity/user/OvaUserEntity.java @@ -1,4 +1,4 @@ -package cn.ova.entity; +package cn.ova.entity.user; import cn.ova.core.base.AbstractEntity; import lombok.Data; @@ -8,10 +8,13 @@ import javax.persistence.Entity; import javax.persistence.Table; import java.sql.Time; +/** + * 微信小程序登录账号实体类 + */ @Data -@Table(name = "ov_user") +@Table(name = "ova_user") @Entity -public class OvUserEntity extends AbstractEntity { +public class OvaUserEntity extends AbstractEntity { /** diff --git a/ova-boot/ova-seller/pom.xml b/ova-boot/ova-seller/pom.xml index 963d057..8ba5e4f 100644 --- a/ova-boot/ova-seller/pom.xml +++ b/ova-boot/ova-seller/pom.xml @@ -9,9 +9,9 @@ 4.0.0 - ova-store + ova-seller - ova-store + ova-seller http://www.example.com diff --git a/ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaSellerUserDto.java b/ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaSellerUserDto.java new file mode 100644 index 0000000..24a9426 --- /dev/null +++ b/ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaSellerUserDto.java @@ -0,0 +1,12 @@ +package cn.ova.dto; + +import lombok.Data; + +@Data +public class OvaSellerUserDto { + + private String username; + + private String avatar; + +} diff --git a/ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaUserInfoDto.java b/ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaUserInfoDto.java deleted file mode 100644 index 27f188a..0000000 --- a/ova-boot/ova-seller/src/main/java/cn/ova/dto/OvaUserInfoDto.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.ova.dto; - -public class OvaUserInfoDto { - -} diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/shiro/OvaShiroRealm.java b/ova-boot/ova-seller/src/main/java/cn/ova/shiro/OvaSellerShiroRealm.java similarity index 35% rename from ova-boot/ova-dao/src/main/java/cn/ova/shiro/OvaShiroRealm.java rename to ova-boot/ova-seller/src/main/java/cn/ova/shiro/OvaSellerShiroRealm.java index 183293b..4a99b72 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/shiro/OvaShiroRealm.java +++ b/ova-boot/ova-seller/src/main/java/cn/ova/shiro/OvaSellerShiroRealm.java @@ -1,44 +1,65 @@ package cn.ova.shiro; -import cn.ova.dao.OvUserDao; -import cn.ova.entity.OvUserEntity; +import cn.ova.core.shiro.OvaUserToken; +import cn.ova.dao.OvaSellerUserDao; +import cn.ova.entity.user.OvaSellerUserEntity; import org.apache.shiro.authc.*; import org.apache.shiro.authz.AuthorizationInfo; import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.subject.PrincipalCollection; import org.apache.shiro.util.ByteSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; /** - *

title: OvaShiroRealm

- *

Description: 用户登录鉴权和获取用户授权

+ *

title: OvaSellerShiroRealm

+ *

Description: Seller端用户登录鉴权和获取用户授权

*

Copyright: Copyright (c) 2019

* * @author jt-lee * @date 2019年8月16日 * @email a496401006@qq.com */ -@Service -public class OvaShiroRealm extends AuthorizingRealm { +public class OvaSellerShiroRealm extends AuthorizingRealm { + + private static final Logger logger = LoggerFactory.getLogger(OvaSellerShiroRealm.class); @Autowired - OvUserDao userDao; + OvaSellerUserDao ovaSellerUserDao; @Override - protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { + protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { return null; } @Override - protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { - String username = (String) token.getPrincipal(); - OvUserEntity user = userDao.queryUserByLoginName(username); - if (user == null) { + protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { + + logger.info("OvaSellerShiroRealm.doGetAuthenticationInfo 开始执行..."); + + OvaUserToken userToken = (OvaUserToken) authenticationToken; + + String username = userToken.getUsername(); + String password = new String(userToken.getPassword()); + + OvaSellerUserEntity entity = ovaSellerUserDao.querySellerUserByLoginName(username); + if(entity == null){ + if(logger.isDebugEnabled()){ + + logger.error("未找到用户名: {}", username); + } throw new UnknownAccountException("用户名/密码错误"); } + if(!entity.getPassword().equals(password)){ + if(logger.isDebugEnabled()){ + + logger.error("用户名: {}, 密码错误", username); + } + throw new UnknownAccountException("用户名/密码错误"); + } + ByteSource byteSource = ByteSource.Util.bytes(username); - return new SimpleAuthenticationInfo(user, user.getPassword(), byteSource, getName()); + return new SimpleAuthenticationInfo(entity, entity.getPassword(), byteSource, getName()); } - } diff --git a/ova-boot/ova-seller/src/main/java/cn/ova/web/LoginRest.java b/ova-boot/ova-seller/src/main/java/cn/ova/web/LoginRest.java index 4a02a84..aac1103 100644 --- a/ova-boot/ova-seller/src/main/java/cn/ova/web/LoginRest.java +++ b/ova-boot/ova-seller/src/main/java/cn/ova/web/LoginRest.java @@ -1,6 +1,8 @@ package cn.ova.web; import cn.ova.core.response.OvaResponse; +import cn.ova.core.shiro.LoginType; +import cn.ova.core.shiro.OvaUserToken; import cn.ova.dto.OvaUserDto; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.IncorrectCredentialsException; @@ -9,6 +11,7 @@ import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.session.Session; import org.apache.shiro.subject.Subject; 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; @@ -17,9 +20,11 @@ import org.springframework.web.bind.annotation.RestController; public class LoginRest { @PostMapping("/login") - public OvaResponse login(OvaUserDto userDto) { + public OvaResponse login(@RequestBody OvaUserDto userDto) { Subject subject = SecurityUtils.getSubject(); - UsernamePasswordToken token = new UsernamePasswordToken(userDto.getUsername(), userDto.getPassword()); + + OvaUserToken token = new OvaUserToken(userDto.getUsername(), userDto.getPassword(), LoginType.SELLER); + try { subject.login(token); Session session = subject.getSession(); diff --git a/ova-boot/ova-seller/src/main/java/cn/ova/web/OvUserInfoRest.java b/ova-boot/ova-seller/src/main/java/cn/ova/web/OvUserInfoRest.java deleted file mode 100644 index e553392..0000000 --- a/ova-boot/ova-seller/src/main/java/cn/ova/web/OvUserInfoRest.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.ova.web; - -import cn.ova.dao.OvUserDao; -import cn.ova.dao.OvUserInfoDao; -import cn.ova.entity.OvUserEntity; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -@RequestMapping("/userinfo") -public class OvUserInfoRest { - - @Autowired - OvUserInfoDao userInfoDao; - -} diff --git a/ova-boot/ova-seller/src/main/java/cn/ova/web/OvUserRest.java b/ova-boot/ova-seller/src/main/java/cn/ova/web/OvaSellerUserRest.java similarity index 30% rename from ova-boot/ova-seller/src/main/java/cn/ova/web/OvUserRest.java rename to ova-boot/ova-seller/src/main/java/cn/ova/web/OvaSellerUserRest.java index b8ee245..6a06114 100644 --- a/ova-boot/ova-seller/src/main/java/cn/ova/web/OvUserRest.java +++ b/ova-boot/ova-seller/src/main/java/cn/ova/web/OvaSellerUserRest.java @@ -1,36 +1,34 @@ package cn.ova.web; -import cn.ova.dao.OvUserDao; -import cn.ova.entity.OvUserEntity; +import cn.ova.core.response.OvaResponse; +import cn.ova.dao.OvaSellerUserDao; +import cn.ova.dto.OvaSellerUserDto; +import cn.ova.entity.user.OvaSellerUserEntity; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/user") -public class OvUserRest { +@RequestMapping("/seller/user") +public class OvaSellerUserRest { @Autowired - OvUserDao ovaUserDao; + OvaSellerUserDao sellerUserDao; - @GetMapping("/t") - @Transactional - public String test() { + @GetMapping("/current") + public OvaSellerUserDto current(){ + Subject subject = SecurityUtils.getSubject(); + OvaSellerUserEntity sellerUser = (OvaSellerUserEntity) subject.getPrincipal(); - OvUserEntity userEntity = new OvUserEntity(); - userEntity.setUsername("张三"); - userEntity.setPassword("8415230"); - userEntity.setGender((byte) 0); - userEntity.setNickName("睿智"); - userEntity.setCreator("1"); - userEntity.setModifier("1"); - userEntity.onPreInsert(); + OvaSellerUserDto dto = new OvaSellerUserDto(); + dto.setAvatar(sellerUser.getAvatar()); + dto.setUsername(sellerUser.getUsername()); - Long id = ovaUserDao.save(userEntity).getId(); - - return String.valueOf(id); + return dto; } + } diff --git a/ova-boot/ova-web/pom.xml b/ova-boot/ova-web/pom.xml index fb396b8..5a6047b 100644 --- a/ova-boot/ova-web/pom.xml +++ b/ova-boot/ova-web/pom.xml @@ -22,7 +22,7 @@ cn.ova - ova-store + ova-seller 0.0.1-SNAPSHOT diff --git a/ova-boot/ova-core/src/main/java/cn/ova/core/config/CorsConfiguration.java b/ova-boot/ova-web/src/main/java/cn/ova/config/CorsConfiguration.java similarity index 96% rename from ova-boot/ova-core/src/main/java/cn/ova/core/config/CorsConfiguration.java rename to ova-boot/ova-web/src/main/java/cn/ova/config/CorsConfiguration.java index 3800341..30e0fa0 100644 --- a/ova-boot/ova-core/src/main/java/cn/ova/core/config/CorsConfiguration.java +++ b/ova-boot/ova-web/src/main/java/cn/ova/config/CorsConfiguration.java @@ -1,4 +1,4 @@ -package cn.ova.core.config; +package cn.ova.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; diff --git a/ova-boot/ova-dao/src/main/java/cn/ova/shiro/ShiroConfiguration.java b/ova-boot/ova-web/src/main/java/cn/ova/config/ShiroConfiguration.java similarity index 70% rename from ova-boot/ova-dao/src/main/java/cn/ova/shiro/ShiroConfiguration.java rename to ova-boot/ova-web/src/main/java/cn/ova/config/ShiroConfiguration.java index 9b0a14a..05379a4 100644 --- a/ova-boot/ova-dao/src/main/java/cn/ova/shiro/ShiroConfiguration.java +++ b/ova-boot/ova-web/src/main/java/cn/ova/config/ShiroConfiguration.java @@ -1,6 +1,11 @@ -package cn.ova.shiro; +package cn.ova.config; +import cn.ova.core.shiro.OvaShiroSessionManager; +import cn.ova.core.shiro.OvaUserModularRealmAuthenticator; +import cn.ova.shiro.OvaSellerShiroRealm; import org.apache.shiro.authc.credential.HashedCredentialsMatcher; +import org.apache.shiro.authc.pam.AtLeastOneSuccessfulStrategy; +import org.apache.shiro.authc.pam.ModularRealmAuthenticator; import org.apache.shiro.mgt.SecurityManager; import org.apache.shiro.realm.Realm; import org.apache.shiro.session.mgt.SessionManager; @@ -10,7 +15,9 @@ import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @@ -34,17 +41,17 @@ public class ShiroConfiguration { return matcher; } - @Bean - public Realm shiroRealm() { - OvaShiroRealm realm = new OvaShiroRealm(); - realm.setCredentialsMatcher(credentialsMatcher()); - return realm; - } - @Bean("securityManager") public SecurityManager securityManager() { DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); - securityManager.setRealm(shiroRealm()); + + //设置Realm + securityManager.setAuthenticator(modularRealmAuthenticator()); + + List realms = new ArrayList<>(); + realms.add(sellerShiroRealm()); + securityManager.setRealms(realms); + securityManager.setSessionManager(shiroSessionManager()); return securityManager; } @@ -83,4 +90,20 @@ public class ShiroConfiguration { return authorizationAttributeSourceAdvisor; } + + //系统自带的Realm管理,主要针对多realm + @Bean + public ModularRealmAuthenticator modularRealmAuthenticator(){ + OvaUserModularRealmAuthenticator modularRealmAuthenticator = new OvaUserModularRealmAuthenticator(); + modularRealmAuthenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy()); + return modularRealmAuthenticator; + } + + @Bean + public Realm sellerShiroRealm(){ + OvaSellerShiroRealm sellerShiroRealm = new OvaSellerShiroRealm(); + sellerShiroRealm.setCredentialsMatcher(credentialsMatcher()); + return sellerShiroRealm; + } + } diff --git a/ova-boot/ova-wechat/pom.xml b/ova-boot/ova-wechat/pom.xml index cd2f441..2cee76f 100644 --- a/ova-boot/ova-wechat/pom.xml +++ b/ova-boot/ova-wechat/pom.xml @@ -9,9 +9,9 @@ 4.0.0 - ova-customer + ova-wechat - ova-customer + ova-wechat http://www.example.com diff --git a/ova-boot/pom.xml b/ova-boot/pom.xml index 10f4d04..cfbd935 100644 --- a/ova-boot/pom.xml +++ b/ova-boot/pom.xml @@ -89,14 +89,14 @@ spring-boot-maven-plugin 1.8 - 1.8 - UTF-8 - true - true - - cn.ova.AppBootStarter - ZIP - + 1.8 + UTF-8 + true + true + + cn.ova.AppBootStarter + ZIP + @@ -115,7 +115,7 @@ true - jdbc:mysql://localhost:3306/ova?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + jdbc:mysql://192.168.1.231:3306/ova?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai root 123456 com.mysql.cj.jdbc.Driver -- Gitee