Browse Source

chore: extraction userVo merge kiccUser

master
wangxiang 2 years ago
parent
commit
d604c5a990
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 25
      src/api/common/base/entity/index.ts
  2. 5
      src/api/platform/core/controller/user.ts
  3. 29
      src/api/platform/core/entity/user.ts
  4. 4
      src/api/platform/system/controller/ssoUser.ts
  5. 5
      src/api/platform/system/controller/user.ts
  6. 4
      src/api/platform/system/entity/user.ts
  7. 4
      src/layouts/default/header/components/user-dropdown/index.vue
  8. 2
      src/store/modules/lock.ts
  9. 17
      src/store/modules/user.ts
  10. 4
      src/utils/cache/persistent.ts
  11. 4
      src/views/core/lock/LockPage.vue
  12. 4
      src/views/system/user/account/setting/UserInfo.vue
  13. 4
      src/views/system/user/user.data.ts

25
src/api/common/base/entity/index.ts

@ -38,9 +38,30 @@ export interface CasUser { @@ -38,9 +38,30 @@ export interface CasUser {
/** SSO扩展用户模型 */
export interface KiccUser extends CasUser {
deptId: string;
// 扩展用户ID
id: string;
// CAS用户ID
casUserId: string;
// 用户类型
userType: string;
exPermissions: string[];
// 所属部门ID
deptId: string;
// 所属部门名称
deptName: string;
// 地图标记点位置图片旋转值
mapOrientation: number;
// 地图设计器默认中心点位置
mapCenter: string;
// 用户状态
status: string;
// 指定登录后首页跳转
homePath?: string;
// 角色ID权限
roleIds: string[];
// 菜单按钮权限
permissions: string[];
// 多租户ID集合
tenantIds: string[];
[key: string]: any;
}

5
src/api/platform/core/controller/user.ts

@ -4,7 +4,8 @@ @@ -4,7 +4,8 @@
* author wangxiang4
*/
import type { Captcha, LoginParams, TokenEnhancer, UserVo } from '../entity/user';
import type { Captcha, LoginParams, TokenEnhancer } from '../entity/user';
import { KiccUser } from '/@/api/common/base/entity';
import { encryptionLogin } from '/@/utils/cipher';
import { defHttp } from '/@/utils/http/axios';
import qs from 'qs';
@ -45,7 +46,7 @@ export const login = (params: LoginParams) => { @@ -45,7 +46,7 @@ export const login = (params: LoginParams) => {
};
/** 获取当前用户信息 */
export const getUserInfo = () => defHttp.get<UserVo>({ url: Api.getUserInfo });
export const getUserInfo = () => defHttp.get<KiccUser>({ url: Api.getUserInfo });
/** 登出 */
export const logout = () => defHttp.delete({ url: Api.logout }, { errorMessageMode: 'none'});

29
src/api/platform/core/entity/user.ts

@ -32,35 +32,6 @@ export interface TokenEnhancer { @@ -32,35 +32,6 @@ export interface TokenEnhancer {
user_info: CasUser;
}
/** 用户VO对象 */
export interface UserVo extends SsoUser {
// 系统用户id
id: string;
// CAS用户ID
casUserId: string;
// 用户类型
userType: string;
// 所属部门ID
deptId: string;
// 所属部门名称
deptName: string;
// 地图标记点位置图片旋转值
mapOrientation: number;
// 地图设计器默认中心点位置
mapCenter: string;
// 用户状态
status: string;
// 指定登录后首页跳转
homePath?: string;
// 前端项目配置多租户选择集合
tenantIds: string[];
// 角色ID权限
roleIds: string[];
// 菜单按钮权限
permissions: string[];
[key: string]: any;
}
/** 验证码对象 */
export interface Captcha {
// 验证码地址

4
src/api/platform/system/controller/ssoUser.ts

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
*/
import type { SsoUserParams, SsoUser ,SsoUserResult } from '/@/api/platform/system/entity/ssoUser';
import { defHttp } from '/@/utils/http/axios';
import { UserVo } from '/@/api/platform/core/entity/user';
import { KiccUser } from '/@/api/common/base/entity';
enum Api {
list = '/system_proxy/system/ssoUser/list',
@ -35,4 +35,4 @@ export const updatePwd = (params: Partial<SsoUser>) => defHttp.put({ url: Api.up @@ -35,4 +35,4 @@ export const updatePwd = (params: Partial<SsoUser>) => defHttp.put({ url: Api.up
export const resetPwd = (params: Partial<SsoUser>) => defHttp.put({ url: Api.resetPwd, data: params });
export const updateSsoUserAndExUser = (params: Partial<UserVo>) => defHttp.put({ url: Api.updateSsoUserAndExUser, data: params });
export const updateSsoUserAndExUser = (params: Partial<KiccUser>) => defHttp.put({ url: Api.updateSsoUserAndExUser, data: params });

5
src/api/platform/system/controller/user.ts

@ -4,8 +4,7 @@ @@ -4,8 +4,7 @@
* author wangxiang4
*/
import type { UserParams, User, UserResult } from '/@/api/platform/system/entity/user';
import type { UserVo } from '/@/api/platform/core/entity/user';
import type { ResultVo } from '/@/api/common/base/entity';
import type { KiccUser, ResultVo } from '/@/api/common/base/entity';
import { defHttp } from '/@/utils/http/axios';
enum Api {
@ -46,7 +45,7 @@ export const changeTenant = (tenantIds: string[]) => defHttp.get({ url: `${Api.c @@ -46,7 +45,7 @@ export const changeTenant = (tenantIds: string[]) => defHttp.get({ url: `${Api.c
export const resetTenant = () => defHttp.get({ url: Api.resetTenant });
/** 获取全部快递员集合 */
export const getCourierUserList = () => defHttp.get<UserVo[]>({ url: Api.getCourierUserList });
export const getCourierUserList = () => defHttp.get<KiccUser[]>({ url: Api.getCourierUserList });
/** 获取用户类型集合 */
export const getUserTypeList = () => defHttp.get({ url: Api.getUserTypeList });

4
src/api/platform/system/entity/user.ts

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
*/
import type { R } from '/#/axios';
import type { CommonEntity, Page } from '/@/api/common/data/entity';
import { UserVo } from '/@/api/platform/core/entity/user';
import { KiccUser } from '/@/api/common/base/entity';
/** 用户查询参数 */
export type UserParams = Page & User;
@ -36,4 +36,4 @@ export interface User extends CommonEntity { @@ -36,4 +36,4 @@ export interface User extends CommonEntity {
}
/** 用户响应对象 */
export type UserResult = R<UserVo[]>;
export type UserResult = R<KiccUser[]>;

4
src/layouts/default/header/components/user-dropdown/index.vue

@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
import { useRouter } from 'vue-router';
type MenuEvent = 'logout' | 'doc' | 'lock' | 'accountSettings' | 'userCenter';
import type { UserVo } from '/@/api/platform/core/entity/user';
import { KiccUser } from '/@/api/common/base/entity';
import DropMenuItem from './DropMenuItem.vue';
export default defineComponent({
@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
const { getUseLockPage } = useHeaderSetting();
const userStore = useUserStore();
const getUserInfo = computed((): UserVo => userStore.getUserInfo || {});
const getUserInfo = computed((): KiccUser => userStore.getUserInfo || {});
const { push } = useRouter();
const [register, { openModal }] = useModal();

2
src/store/modules/lock.ts

@ -47,7 +47,7 @@ export const useLockStore = defineStore({ @@ -47,7 +47,7 @@ export const useLockStore = defineStore({
// 浏览器缓存已经清空,需要重新登录验证当前用户密码
const tryLogin = async () => {
try {
const username = userStore.getUserInfo.userName;
const username = userStore.getUserInfo.username;
const res = await userStore.login({
username,
password: password,

17
src/store/modules/user.ts

@ -10,7 +10,8 @@ import { store } from '/@/store'; @@ -10,7 +10,8 @@ import { store } from '/@/store';
import { PageEnum } from '/@/enums/pageEnum';
import { ACCESS_TOKEN_KEY, PERMISSIONS_KEY, REFRESH_TOKEN_KEY, ROLE_IDS_KEY, USER_INFO_KEY } from '/@/enums/cacheEnum';
import { getAuthCache, setAuthCache } from '/@/utils/auth';
import { UserVo, LoginParams } from '/@/api/platform/core/entity/user';
import { KiccUser } from '/@/api/common/base/entity';
import { LoginParams } from '/@/api/platform/core/entity/user';
import { logout, getUserInfo, login } from '/@/api/platform/core/controller/user';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMessage } from '/@/hooks/web/useMessage';
@ -27,7 +28,7 @@ import { merge } from 'lodash-es'; @@ -27,7 +28,7 @@ import { merge } from 'lodash-es';
import { RequestOptions } from '/#/axios';
interface UserState {
userInfo: Nullable<UserVo>;
userInfo: Nullable<KiccUser>;
sessionTimeout?: boolean;
lastUpdateTime: number;
roleIds: string[];
@ -40,7 +41,7 @@ export const useUserStore = defineStore({ @@ -40,7 +41,7 @@ export const useUserStore = defineStore({
id: 'app-user',
state: (): UserState => ({
// 用户信息
userInfo: getAuthCache<UserVo>(USER_INFO_KEY),
userInfo: getAuthCache<KiccUser>(USER_INFO_KEY),
// 登录是否过期记录(确保下次登陆不刷新路由直接还原)
sessionTimeout: false,
// 最后一次性更新用户信息时间(用于页面刷新更新用户数据)
@ -55,7 +56,7 @@ export const useUserStore = defineStore({ @@ -55,7 +56,7 @@ export const useUserStore = defineStore({
refresh_token: getAuthCache<string>(REFRESH_TOKEN_KEY),
}),
getters: {
getUserInfo(): UserVo {
getUserInfo(): KiccUser {
return this.userInfo || {};
},
getAccessToken(): string {
@ -94,7 +95,7 @@ export const useUserStore = defineStore({ @@ -94,7 +95,7 @@ export const useUserStore = defineStore({
this.refresh_token = refreshToken;
setAuthCache(REFRESH_TOKEN_KEY, refreshToken);
},
setUserInfo(userInfo: Nullable<UserVo>) {
setUserInfo(userInfo: Nullable<KiccUser>) {
this.userInfo = userInfo;
this.lastUpdateTime = new Date().getTime();
setAuthCache(USER_INFO_KEY, userInfo);
@ -111,7 +112,7 @@ export const useUserStore = defineStore({ @@ -111,7 +112,7 @@ export const useUserStore = defineStore({
this.setPermissions([]);
},
/** 登录 */
async login(params: LoginParams): Promise<UserVo | null> {
async login(params: LoginParams): Promise<KiccUser | null> {
try {
const { goHome = true, clientId = '', ...loginParams } = params;
// 处理自定义授权客户端
@ -134,7 +135,7 @@ export const useUserStore = defineStore({ @@ -134,7 +135,7 @@ export const useUserStore = defineStore({
}
},
/** 登录成功后动作 */
async afterLoginAction(goHome?: boolean): Promise<UserVo | null> {
async afterLoginAction(goHome?: boolean): Promise<KiccUser | null> {
if (!this.getAccessToken) return null;
// 获取用户信息
const userInfo = await this.getUserInfoAction();
@ -157,7 +158,7 @@ export const useUserStore = defineStore({ @@ -157,7 +158,7 @@ export const useUserStore = defineStore({
return userInfo;
},
/** 获取用户信息 */
async getUserInfoAction(): Promise<UserVo> {
async getUserInfoAction(): Promise<KiccUser> {
const { apiUrl } = useGlobSetting();
const { t } = useI18n();
try {

4
src/utils/cache/persistent.ts vendored

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
*/
import type { LockInfo } from '/#/store';
import type { UserVo } from '/@/api/platform/core/entity/user';
import { KiccUser } from '/@/api/common/base/entity';
import type { ProjectConfig } from '/#/config';
import type { RouteLocationNormalized } from 'vue-router';
import { createLocalStorage, createSessionStorage } from '/@/utils/cache';
@ -34,7 +34,7 @@ interface BasicStore { @@ -34,7 +34,7 @@ interface BasicStore {
[REFRESH_TOKEN_KEY]: string | number | null | undefined;
[ROLE_IDS_KEY]: string[];
[PERMISSIONS_KEY]: string[];
[USER_INFO_KEY]: UserVo;
[USER_INFO_KEY]: KiccUser;
[LOCK_INFO_KEY]: LockInfo;
[PROJ_CFG_KEY]: ProjectConfig;
[MULTIPLE_TABS_KEY]: RouteLocationNormalized[];

4
src/views/core/lock/LockPage.vue

@ -88,7 +88,7 @@ @@ -88,7 +88,7 @@
import { useNow } from './useNow';
import { useDesign } from '/@/hooks/web/useDesign';
import { LockOutlined } from '@ant-design/icons-vue';
import { UserVo } from '/@/api/platform/core/entity/user';
import { KiccUser } from '/@/api/common/base/entity';
import defaultAvatar from '/@/assets/images/defaultAvatar.svg';
const InputPassword = Input.Password;
@ -101,7 +101,7 @@ @@ -101,7 +101,7 @@
const userStore = useUserStore();
const { hour, month, minute, meridiem, year, day, week } = useNow(true);
const { t } = useI18n();
const userInfo = computed<UserVo>(() => {
const userInfo = computed<KiccUser>(() => {
return userStore.getUserInfo || {};
});

4
src/views/system/user/account/setting/UserInfo.vue

@ -35,12 +35,12 @@ @@ -35,12 +35,12 @@
import { useUserStore } from '/@/store/modules/user';
import { commonUpload } from '/@/api/platform/core/controller/upload';
import { useContentHeight } from '/@/hooks/web/useContentHeight';
import { UserVo } from '/@/api/platform/core/entity/user';
import { KiccUser } from '/@/api/common/base/entity';
import { isBase64image } from '/@/utils/is';
interface State {
baseInfoBtnLoading: boolean;
userInfo: UserVo | any;
userInfo: KiccUser | any;
}
export default defineComponent({
components: {

4
src/views/system/user/user.data.ts

@ -22,7 +22,7 @@ const { createConfirm } = useMessage(); @@ -22,7 +22,7 @@ const { createConfirm } = useMessage();
export const columns: BasicColumn[] = [
{
title: '用户名称',
dataIndex: 'userName',
dataIndex: 'username',
width: 120
},
{
@ -59,7 +59,7 @@ export const columns: BasicColumn[] = [ @@ -59,7 +59,7 @@ export const columns: BasicColumn[] = [
createConfirm({
iconType: 'warning',
title: '警告',
content: `确认要"${text}${record.userName}用户吗?`,
content: `确认要"${text}${record.username}用户吗?`,
onOk: async () => {
record.pendingStatus = true;
const newStatus = checked ? '0' : '1';

Loading…
Cancel
Save