u
This commit is contained in:
1 parent
4dcac7b5a0
commit
59d3be2299
25 files changed
+369
-114
No files matched your search
@@ -7,6 +7,7 @@ import { IconQq, IconWeixin, IconZhiwen } from '@/components/iconfont'
|
|||||||
import { Divider } from '@/components/ui/divider'
|
import { Divider } from '@/components/ui/divider'
|
||||||
import useFormValidation from '@/hooks/useFormValidation'
|
import useFormValidation from '@/hooks/useFormValidation'
|
||||||
import { loginDefaultApi } from '@/request/api/auth'
|
import { loginDefaultApi } from '@/request/api/auth'
|
||||||
|
import { useMoneyCategoryStore } from '@/store/moneyCategory'
|
||||||
import { useUserStore } from '@/store/user'
|
import { useUserStore } from '@/store/user'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ interface LoginForm {
|
|||||||
export default function AuthLogin() {
|
export default function AuthLogin() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
const moneyCategoryStore = useMoneyCategoryStore()
|
||||||
|
|
||||||
const [loading, setLoading] = useState<boolean>(false)
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
const [form, setForm] = useState<LoginForm>({
|
const [form, setForm] = useState<LoginForm>({
|
||||||
@@ -60,6 +62,7 @@ export default function AuthLogin() {
|
|||||||
refreshToken: res.data.refreshToken,
|
refreshToken: res.data.refreshToken,
|
||||||
rememberMe: form.rememberMe,
|
rememberMe: form.rememberMe,
|
||||||
})
|
})
|
||||||
|
moneyCategoryStore.init()
|
||||||
|
|
||||||
router.replace('/user')
|
router.replace('/user')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import { Link, LinkText } from '@/components/ui/link'
|
|||||||
|
|
||||||
interface JoinSpaceProps {
|
interface JoinSpaceProps {
|
||||||
onBack?: () => void
|
onBack?: () => void
|
||||||
|
onJoin?: (code: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function JoinSpace({
|
export default function JoinSpace({
|
||||||
onBack,
|
onBack,
|
||||||
|
onJoin,
|
||||||
}: JoinSpaceProps) {
|
}: JoinSpaceProps) {
|
||||||
const formRef = useRef<AFormRef>(null)
|
const formRef = useRef<AFormRef>(null)
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
@@ -22,11 +24,32 @@ export default function JoinSpace({
|
|||||||
name="username"
|
name="username"
|
||||||
label="邀请码"
|
label="邀请码"
|
||||||
>
|
>
|
||||||
<AInput placeholder="请输入邀请码"></AInput>
|
<AInput
|
||||||
|
placeholder="请输入邀请码"
|
||||||
|
value={form.code}
|
||||||
|
onChangeText={text => setForm({
|
||||||
|
...form,
|
||||||
|
code: text,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
</AInput>
|
||||||
</AFormItem>
|
</AFormItem>
|
||||||
</AForm>
|
</AForm>
|
||||||
|
|
||||||
<AButton className="w-full">加入空间</AButton>
|
<AButton
|
||||||
|
className="w-full"
|
||||||
|
onPress={() => {
|
||||||
|
if (form.code === '') {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
onJoin?.(form.code)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
加入空间
|
||||||
|
</AButton>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
className="flex-row items-center w-full"
|
className="flex-row items-center w-full"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { UserSpace } from '@/types/space/spaceUser'
|
||||||
import { Text, View } from 'react-native'
|
import { Text, View } from 'react-native'
|
||||||
import { AButton, ADivider, LucideIcon } from '@/components/common/ao'
|
import { AButton, ADivider, LucideIcon } from '@/components/common/ao'
|
||||||
|
|
||||||
|
|||||||
+44
-18
@@ -1,9 +1,10 @@
|
|||||||
|
import type { SpaceUser, UserSpace } from '@/types/space/spaceUser'
|
||||||
import * as Clipboard from 'expo-clipboard'
|
import * as Clipboard from 'expo-clipboard'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { FlatList, Pressable, TouchableOpacity, View } from 'react-native'
|
import { FlatList, Pressable, TouchableOpacity, View } from 'react-native'
|
||||||
import QRCode from 'react-native-qrcode-svg'
|
import QRCode from 'react-native-qrcode-svg'
|
||||||
import { AButton, ADivider, LucideIcon } from '@/components/common/ao'
|
|
||||||
|
|
||||||
|
import { AButton, ADivider, LucideIcon } from '@/components/common/ao'
|
||||||
import {
|
import {
|
||||||
Accordion,
|
Accordion,
|
||||||
AccordionContent,
|
AccordionContent,
|
||||||
@@ -25,16 +26,22 @@ import { ChevronDownIcon, ChevronUpIcon } from '@/components/ui/icon'
|
|||||||
import { Menu, MenuItem, MenuItemLabel } from '@/components/ui/menu'
|
import { Menu, MenuItem, MenuItemLabel } from '@/components/ui/menu'
|
||||||
import { Text } from '@/components/ui/text'
|
import { Text } from '@/components/ui/text'
|
||||||
import { VStack } from '@/components/ui/vstack'
|
import { VStack } from '@/components/ui/vstack'
|
||||||
|
import { useUserStore } from '@/store/user'
|
||||||
|
import { formatRelativeTime } from '@/utils/time'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
export default function SpaceInviteAndMembers() {
|
interface SpaceInviteProps {
|
||||||
const [accordion, setAccordion] = useState(['a'])
|
userSpace: UserSpace | null
|
||||||
|
spaceUsers: SpaceUser[]
|
||||||
|
}
|
||||||
|
|
||||||
const members = [
|
export default function SpaceInvite({
|
||||||
{ id: 1, name: '张三' },
|
userSpace,
|
||||||
{ id: 2, name: '李四' },
|
spaceUsers,
|
||||||
{ id: 3, name: '王五' },
|
}: SpaceInviteProps) {
|
||||||
]
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
const [accordion, setAccordion] = useState(['a'])
|
||||||
|
|
||||||
async function copyInviteCode() {
|
async function copyInviteCode() {
|
||||||
await Clipboard.setStringAsync('hello world')
|
await Clipboard.setStringAsync('hello world')
|
||||||
@@ -94,7 +101,7 @@ export default function SpaceInviteAndMembers() {
|
|||||||
copyInviteCode()
|
copyInviteCode()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text className="font-bold text-3xl tracking-[4px] mr-3">123456</Text>
|
<Text className="font-bold text-3xl tracking-[4px] mr-3">{userSpace?.invite_code}</Text>
|
||||||
<LucideIcon icon="Copy" size={16} color="blue" clickable={false} />
|
<LucideIcon icon="Copy" size={16} color="blue" clickable={false} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
@@ -102,7 +109,7 @@ export default function SpaceInviteAndMembers() {
|
|||||||
<ADivider direction="horizontal" text="扫描二维码" />
|
<ADivider direction="horizontal" text="扫描二维码" />
|
||||||
<QRCode
|
<QRCode
|
||||||
size={120}
|
size={120}
|
||||||
value="http://awesome.link.qr"
|
value={userSpace?.invite_code}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</AccordionContent>
|
</AccordionContent>
|
||||||
@@ -112,31 +119,50 @@ export default function SpaceInviteAndMembers() {
|
|||||||
<View className="flex flex-row items-center justify-between">
|
<View className="flex flex-row items-center justify-between">
|
||||||
<Text className="font-semibold text-lg">空间成员</Text>
|
<Text className="font-semibold text-lg">空间成员</Text>
|
||||||
<Badge size="lg" variant="solid" action="muted">
|
<Badge size="lg" variant="solid" action="muted">
|
||||||
<BadgeText>3 人</BadgeText>
|
<BadgeText>
|
||||||
|
{spaceUsers.length}
|
||||||
|
{' '}
|
||||||
|
人
|
||||||
|
</BadgeText>
|
||||||
</Badge>
|
</Badge>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View>
|
<View>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={members}
|
data={spaceUsers}
|
||||||
keyExtractor={item => item.id.toString()}
|
keyExtractor={item => item.user_id.toString()}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<TouchableOpacity>
|
<TouchableOpacity>
|
||||||
<HStack space="md" className="my-2 items-center">
|
<HStack space="md" className="my-2 items-center">
|
||||||
<Avatar className="bg-indigo-600">
|
<Avatar className="bg-indigo-600">
|
||||||
<AvatarFallbackText className="text-white text-lg">
|
<AvatarFallbackText className="text-white text-2xl">
|
||||||
{item.name}
|
{item.username}
|
||||||
</AvatarFallbackText>
|
</AvatarFallbackText>
|
||||||
<AvatarBadge />
|
<AvatarBadge />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<VStack>
|
<VStack>
|
||||||
<HStack space="sm">
|
<HStack space="sm">
|
||||||
<Heading size="sm">{item.name}</Heading>
|
<Heading size="sm">{item.username}</Heading>
|
||||||
|
{[0, 1].includes(item.space_role) && (
|
||||||
<Badge size="sm" variant="solid" action="muted">
|
<Badge size="sm" variant="solid" action="muted">
|
||||||
<BadgeText>管理员</BadgeText>
|
<BadgeText>
|
||||||
|
{item.space_role === 0 ? '创建者' : '管理员'}
|
||||||
|
</BadgeText>
|
||||||
</Badge>
|
</Badge>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{
|
||||||
|
(userStore.userInfo?.id === item.user_id) && (
|
||||||
|
<Badge size="sm" variant="solid" action='info'>
|
||||||
|
<BadgeText>
|
||||||
|
我
|
||||||
|
</BadgeText>
|
||||||
|
</Badge>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
</HStack>
|
</HStack>
|
||||||
<Text size="sm">Marketing Coordinator</Text>
|
<Text size="sm" className="mt-1">{formatRelativeTime(item.active_time)}</Text>
|
||||||
</VStack>
|
</VStack>
|
||||||
|
|
||||||
<View className="ml-auto">
|
<View className="ml-auto">
|
||||||
@@ -1,18 +1,87 @@
|
|||||||
|
import type { SpaceUser, UserSpace } from '@/types/space/spaceUser'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import CustomHeader from '@/components/custom/Header'
|
import CustomHeader from '@/components/custom/Header'
|
||||||
|
import { createSpaceApi } from '@/request/api/space/space'
|
||||||
|
import { getUserSpaceApi, joinSpaceApi, listSpaceUsersApi } from '@/request/api/space/spaceUser'
|
||||||
import JoinSpace from './components/JoinSpace'
|
import JoinSpace from './components/JoinSpace'
|
||||||
import SpaceHome from './components/SpaceHome'
|
import SpaceHome from './components/SpaceHome'
|
||||||
import SpaceInviteAndMembers from './components/SpaceInviteAndMembers'
|
import SpaceInviteAndMembers from './components/SpaceInvite'
|
||||||
|
|
||||||
import StepFade from './components/StepFade'
|
import StepFade from './components/StepFade'
|
||||||
|
|
||||||
export default function PagerWithTab() {
|
export default function PagerWithTab() {
|
||||||
const [step, setStep] = useState<'join' | 'invite' | 'home'>('home')
|
const [step, setStep] = useState<'join' | 'invite' | 'home'>('home')
|
||||||
|
const [userSpace, setUserSpace] = useState<UserSpace | null>(null)
|
||||||
|
const [spaceUsers, setSpaceUsers] = useState<SpaceUser[]>([])
|
||||||
|
|
||||||
|
const fetchData = async () => {
|
||||||
|
await Promise.all([
|
||||||
|
getUserSpaceApi({})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.isSuccess) {
|
||||||
|
if (res.data === null) {
|
||||||
|
setUserSpace(null)
|
||||||
|
setStep('home')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setUserSpace({
|
||||||
|
space_id: res.data.space_id,
|
||||||
|
space_name: res.data.space_name,
|
||||||
|
role: res.data.role,
|
||||||
|
invite_code: res.data.invite_code,
|
||||||
|
})
|
||||||
|
setStep('invite')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 提示
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error('getUserSpaceApi error:', err)),
|
||||||
|
|
||||||
|
listSpaceUsersApi({})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.isSuccess) {
|
||||||
|
setSpaceUsers(res.data.users)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 提示
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error('listSpaceUsersApi error:', err)),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
fetchData()
|
||||||
|
}, [])
|
||||||
|
|
||||||
function createSpace() {
|
function createSpace() {
|
||||||
|
createSpaceApi({}).then((res) => {
|
||||||
|
if (res.isSuccess) {
|
||||||
|
setUserSpace({
|
||||||
|
space_id: res.data.id,
|
||||||
|
space_name: '',
|
||||||
|
role: 0,
|
||||||
|
invite_code: res.data.invite_code,
|
||||||
|
})
|
||||||
|
|
||||||
|
setStep('invite')
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function joinSpace(code: string) {
|
||||||
|
joinSpaceApi({
|
||||||
|
invite_code: code,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.isSuccess) {
|
||||||
|
fetchData()
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -21,9 +90,7 @@ export default function PagerWithTab() {
|
|||||||
<View className="flex-1">
|
<View className="flex-1">
|
||||||
<StepFade visible={step === 'home'}>
|
<StepFade visible={step === 'home'}>
|
||||||
<SpaceHome
|
<SpaceHome
|
||||||
onCreate={() => {
|
onCreate={createSpace}
|
||||||
setStep('invite')
|
|
||||||
}}
|
|
||||||
onJoin={() => {
|
onJoin={() => {
|
||||||
setStep('join')
|
setStep('join')
|
||||||
}}
|
}}
|
||||||
@@ -35,11 +102,16 @@ export default function PagerWithTab() {
|
|||||||
onBack={() => {
|
onBack={() => {
|
||||||
setStep('home')
|
setStep('home')
|
||||||
}}
|
}}
|
||||||
|
onJoin={(code) => {
|
||||||
|
if (code !== '') {
|
||||||
|
joinSpace(code)
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</StepFade>
|
</StepFade>
|
||||||
|
|
||||||
<StepFade visible={step === 'invite'}>
|
<StepFade visible={step === 'invite'}>
|
||||||
<SpaceInviteAndMembers />
|
<SpaceInviteAndMembers userSpace={userSpace} spaceUsers={spaceUsers} />
|
||||||
</StepFade>
|
</StepFade>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export default function CustomHeader(props: CustomHeaderProps) {
|
|||||||
{...screenProps}
|
{...screenProps}
|
||||||
options={{
|
options={{
|
||||||
...screenProps?.options,
|
...screenProps?.options,
|
||||||
headerShown: true,
|
headerShown: false,
|
||||||
header: () => (
|
header: () => (
|
||||||
<SafeAreaView
|
<SafeAreaView
|
||||||
className={`${className}`}
|
className={`${className}`}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ function isWhiteListed(url: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const alovaInstance = createAlova({
|
const alovaInstance = createAlova({
|
||||||
baseURL: 'http://192.168.5.6:8086/app',
|
// baseURL: 'http://192.168.5.6:8086/app',
|
||||||
// baseURL: 'http://192.168.1.136:8086/app',
|
baseURL: 'http://192.168.1.136:8086/app',
|
||||||
requestAdapter: axiosRequestAdapter(),
|
requestAdapter: axiosRequestAdapter(),
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
cacheFor: null,
|
cacheFor: null,
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
export interface UserSpace {
|
||||||
|
space_id: number
|
||||||
|
space_name: string
|
||||||
|
role: number
|
||||||
|
invite_code: string
|
||||||
|
}
|
||||||
|
|
||||||
// 获取用户的空间
|
// 获取用户的空间
|
||||||
export interface GetUserSpaceParams {
|
export interface GetUserSpaceParams {
|
||||||
|
|
||||||
@@ -22,6 +29,7 @@ export interface SpaceUser {
|
|||||||
user_id: number
|
user_id: number
|
||||||
username: string
|
username: string
|
||||||
space_role: number
|
space_role: number
|
||||||
|
active_time: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListSpaceUsersParams {
|
export interface ListSpaceUsersParams {
|
||||||
|
|||||||
@@ -68,3 +68,40 @@ export function isInMonth(date: string, month: string): boolean {
|
|||||||
// month 形如 "2025-01"
|
// month 形如 "2025-01"
|
||||||
return dayjs(date).format('YYYY-MM') === month
|
return dayjs(date).format('YYYY-MM') === month
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatRelativeTime(date: string | Date | number): string {
|
||||||
|
if (typeof date === 'string' && !date.trim()) {
|
||||||
|
return '暂无活跃'
|
||||||
|
}
|
||||||
|
|
||||||
|
const d = dayjs(date)
|
||||||
|
if (!d.isValid())
|
||||||
|
return '暂无活跃'
|
||||||
|
|
||||||
|
const now = dayjs()
|
||||||
|
const diff = now.diff(d, 'second') // 相差秒数
|
||||||
|
|
||||||
|
if (diff < 60) {
|
||||||
|
return '刚刚'
|
||||||
|
}
|
||||||
|
else if (diff < 3600) {
|
||||||
|
const minutes = Math.floor(diff / 60)
|
||||||
|
return `${minutes}分钟前`
|
||||||
|
}
|
||||||
|
else if (diff < 86400) {
|
||||||
|
const hours = Math.floor(diff / 3600)
|
||||||
|
return `${hours}小时前`
|
||||||
|
}
|
||||||
|
else if (diff < 2592000) { // 30天以内
|
||||||
|
const days = Math.floor(diff / 86400)
|
||||||
|
return `${days}天前`
|
||||||
|
}
|
||||||
|
else if (diff < 31536000) { // 1年以内
|
||||||
|
const months = Math.floor(diff / 2592000)
|
||||||
|
return `${months}个月前`
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const years = Math.floor(diff / 31536000)
|
||||||
|
return `${years}年前`
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,8 +44,8 @@ func LoginDefault(ctx context.Context, c *app.RequestContext) {
|
|||||||
|
|
||||||
// 异步更新登录事件
|
// 异步更新登录事件
|
||||||
go func(userID int64) {
|
go func(userID int64) {
|
||||||
time, err := db.Queries.UpdateUserLoginLastTime(ctx, userID)
|
err = db.Queries.UpdateUserLoginLastTime(ctx, userID)
|
||||||
if err != nil || time == 0 {
|
if err != nil {
|
||||||
logx.CtxError(ctx, "更新用户登录时间失败,UserID=%d, err=%v", loginUser.ID, err)
|
logx.CtxError(ctx, "更新用户登录时间失败,UserID=%d, err=%v", loginUser.ID, err)
|
||||||
}
|
}
|
||||||
}(loginUser.ID)
|
}(loginUser.ID)
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import (
|
|||||||
auth "cn/oneao/base-go/biz/model/auth"
|
auth "cn/oneao/base-go/biz/model/auth"
|
||||||
"cn/oneao/base-go/db"
|
"cn/oneao/base-go/db"
|
||||||
"cn/oneao/base-go/db/repo"
|
"cn/oneao/base-go/db/repo"
|
||||||
|
"cn/oneao/base-go/utils"
|
||||||
"cn/oneao/base-go/utils/errorx"
|
"cn/oneao/base-go/utils/errorx"
|
||||||
"cn/oneao/base-go/utils/idgen"
|
"cn/oneao/base-go/utils/idgen"
|
||||||
|
"cn/oneao/base-go/utils/pgtypex"
|
||||||
"cn/oneao/base-go/utils/response"
|
"cn/oneao/base-go/utils/response"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -64,11 +66,18 @@ func RegisterDefault(ctx context.Context, c *app.RequestContext) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
generateCode, err := utils.GenerateCode(8)
|
||||||
|
if err != nil {
|
||||||
|
errorx.AddError(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 插入用户
|
// 插入用户
|
||||||
params := repo.InsertUserParams{
|
params := repo.InsertUserParams{
|
||||||
ID: idgen.NextId(),
|
ID: idgen.NextId(),
|
||||||
Account: account,
|
Account: account,
|
||||||
Password: password,
|
Password: password,
|
||||||
|
Username: pgtypex.StringToText("a_" + generateCode),
|
||||||
}
|
}
|
||||||
|
|
||||||
insert, err := db.Queries.WithTx(tx).InsertUser(ctx, params)
|
insert, err := db.Queries.WithTx(tx).InsertUser(ctx, params)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"cn/oneao/base-go/db/repo"
|
"cn/oneao/base-go/db/repo"
|
||||||
"cn/oneao/base-go/utils/errorx"
|
"cn/oneao/base-go/utils/errorx"
|
||||||
"cn/oneao/base-go/utils/idgen"
|
"cn/oneao/base-go/utils/idgen"
|
||||||
|
"cn/oneao/base-go/utils/pgtypex"
|
||||||
"cn/oneao/base-go/utils/response"
|
"cn/oneao/base-go/utils/response"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -81,6 +82,7 @@ func ListSpaceUsers(ctx context.Context, c *app.RequestContext) {
|
|||||||
UserId: u.UserID,
|
UserId: u.UserID,
|
||||||
Username: u.Username.String,
|
Username: u.Username.String,
|
||||||
SpaceRole: u.Role,
|
SpaceRole: u.Role,
|
||||||
|
ActiveTime: pgtypex.TimestampToDateTimeString(u.ActiveTime),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.28.0
|
// protoc-gen-go v1.28.0
|
||||||
// protoc v6.33.1
|
// protoc v4.25.3
|
||||||
// source: api.proto
|
// source: api.proto
|
||||||
|
|
||||||
package api
|
package api
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.28.0
|
// protoc-gen-go v1.28.0
|
||||||
// protoc v6.33.1
|
// protoc v4.25.3
|
||||||
// source: space.proto
|
// source: space.proto
|
||||||
|
|
||||||
package space
|
package space
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.28.0
|
// protoc-gen-go v1.28.0
|
||||||
// protoc v6.33.1
|
// protoc v4.25.3
|
||||||
// source: space/space_types.proto
|
// source: space/space_types.proto
|
||||||
|
|
||||||
package space
|
package space
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.28.0
|
// protoc-gen-go v1.28.0
|
||||||
// protoc v6.33.1
|
// protoc v4.25.3
|
||||||
// source: space/space_user_types.proto
|
// source: space/space_user_types.proto
|
||||||
|
|
||||||
package space
|
package space
|
||||||
@@ -67,7 +67,8 @@ type SpaceUser struct {
|
|||||||
|
|
||||||
UserId int64 `protobuf:"varint,1,opt,name=UserId,proto3" form:"user_id" json:"user_id"`
|
UserId int64 `protobuf:"varint,1,opt,name=UserId,proto3" form:"user_id" json:"user_id"`
|
||||||
Username string `protobuf:"bytes,2,opt,name=Username,proto3" form:"username" json:"username"`
|
Username string `protobuf:"bytes,2,opt,name=Username,proto3" form:"username" json:"username"`
|
||||||
SpaceRole int32 `protobuf:"varint,4,opt,name=SpaceRole,proto3" form:"space_role" json:"space_role"`
|
SpaceRole int32 `protobuf:"varint,3,opt,name=SpaceRole,proto3" form:"space_role" json:"space_role"`
|
||||||
|
ActiveTime string `protobuf:"bytes,4,opt,name=ActiveTime,proto3" form:"active_time" json:"active_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SpaceUser) Reset() {
|
func (x *SpaceUser) Reset() {
|
||||||
@@ -123,6 +124,13 @@ func (x *SpaceUser) GetSpaceRole() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *SpaceUser) GetActiveTime() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.ActiveTime
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
type ListSpaceUsersResult struct {
|
type ListSpaceUsersResult struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@@ -646,66 +654,69 @@ var file_space_space_user_types_proto_rawDesc = []byte{
|
|||||||
0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
|
0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
|
||||||
0x73, 0x70, 0x61, 0x63, 0x65, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x73, 0x70, 0x61, 0x63, 0x65, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
0x22, 0x16, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65,
|
0x22, 0x16, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65,
|
||||||
0x72, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x88, 0x01, 0x0a, 0x09, 0x53, 0x70, 0x61,
|
0x72, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0xb9, 0x01, 0x0a, 0x09, 0x53, 0x70, 0x61,
|
||||||
0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
|
0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72,
|
||||||
0x5f, 0x69, 0x64, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x55,
|
0x5f, 0x69, 0x64, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x55,
|
||||||
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xca,
|
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xca,
|
||||||
0xbb, 0x18, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x08, 0x55, 0x73, 0x65,
|
0xbb, 0x18, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x08, 0x55, 0x73, 0x65,
|
||||||
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x6f,
|
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x6f,
|
||||||
0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x0a, 0x73, 0x70,
|
0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x0a, 0x73, 0x70,
|
||||||
0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52,
|
0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52,
|
||||||
0x6f, 0x6c, 0x65, 0x22, 0x3e, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65,
|
0x6f, 0x6c, 0x65, 0x12, 0x2f, 0x0a, 0x0a, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d,
|
||||||
0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x75,
|
0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x61, 0x63, 0x74,
|
||||||
0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x73, 0x70, 0x61,
|
0x69, 0x76, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65,
|
||||||
0x63, 0x65, 0x2e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73,
|
0x54, 0x69, 0x6d, 0x65, 0x22, 0x3e, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63,
|
||||||
0x65, 0x72, 0x73, 0x22, 0x4d, 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65,
|
0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x05,
|
||||||
0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65,
|
0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x73, 0x70,
|
||||||
0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1a, 0xca, 0xbb, 0x18, 0x0b,
|
0x61, 0x63, 0x65, 0x2e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75,
|
||||||
0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0xda, 0xbb, 0x18, 0x07, 0x24,
|
0x73, 0x65, 0x72, 0x73, 0x22, 0x4d, 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63,
|
||||||
0x20, 0x21, 0x3d, 0x20, 0x27, 0x27, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f,
|
0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74,
|
||||||
0x64, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52,
|
0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1a, 0xca, 0xbb, 0x18,
|
||||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x69, 0x74, 0x53, 0x70, 0x61,
|
0x0b, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0xda, 0xbb, 0x18, 0x07,
|
||||||
0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x69, 0x74,
|
0x24, 0x20, 0x21, 0x3d, 0x20, 0x27, 0x27, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43,
|
||||||
0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x78, 0x0a, 0x15, 0x52,
|
0x6f, 0x64, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65,
|
||||||
0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61,
|
0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x69, 0x74, 0x53, 0x70,
|
||||||
0x72, 0x61, 0x6d, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x18,
|
0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x69,
|
||||||
0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x16, 0xca, 0xbb, 0x18, 0x08, 0x73, 0x70, 0x61, 0x63, 0x65,
|
0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x78, 0x0a, 0x15,
|
||||||
0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06, 0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x07, 0x53,
|
0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50,
|
||||||
0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
|
0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64,
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x15, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x16, 0xca, 0xbb, 0x18, 0x08, 0x73, 0x70, 0x61, 0x63,
|
||||||
0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06, 0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x06, 0x55,
|
0x65, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06, 0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x07,
|
||||||
0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x17, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53,
|
0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
|
||||||
0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0xae,
|
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x15, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65,
|
||||||
0x01, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73,
|
0x72, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06, 0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x06,
|
||||||
0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x30, 0x0a, 0x07,
|
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x17, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
|
||||||
0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x16, 0xca,
|
0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22,
|
||||||
0xbb, 0x18, 0x08, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06, 0x24,
|
0xae, 0x01, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55,
|
||||||
0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x2d,
|
0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x30, 0x0a,
|
||||||
0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x15,
|
0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x16,
|
||||||
0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06, 0x24,
|
0xca, 0xbb, 0x18, 0x08, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06,
|
||||||
0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x30, 0x0a,
|
0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12,
|
||||||
0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x1c, 0xca, 0xbb, 0x18,
|
0x2d, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42,
|
||||||
0x04, 0x72, 0x6f, 0x6c, 0x65, 0xda, 0xbb, 0x18, 0x10, 0x24, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20,
|
0x15, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06,
|
||||||
0x7c, 0x7c, 0x20, 0x24, 0x20, 0x3d, 0x3d, 0x20, 0x32, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x22,
|
0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x30,
|
||||||
0x1b, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73,
|
0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x1c, 0xca, 0xbb,
|
||||||
0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x14, 0x0a, 0x12,
|
0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0xda, 0xbb, 0x18, 0x10, 0x24, 0x20, 0x3d, 0x3d, 0x20, 0x31,
|
||||||
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61,
|
0x20, 0x7c, 0x7c, 0x20, 0x24, 0x20, 0x3d, 0x3d, 0x20, 0x32, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65,
|
||||||
0x6d, 0x73, 0x22, 0xb9, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70,
|
0x22, 0x1b, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55,
|
||||||
0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x53, 0x70, 0x61,
|
0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x14, 0x0a,
|
||||||
0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, 0xca, 0xbb, 0x18, 0x08,
|
0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72,
|
||||||
0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49,
|
0x61, 0x6d, 0x73, 0x22, 0xb9, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53,
|
||||||
0x64, 0x12, 0x2c, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02,
|
0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x53, 0x70,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x0a, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f,
|
0x61, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, 0xca, 0xbb, 0x18,
|
||||||
0x6e, 0x61, 0x6d, 0x65, 0x52, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12,
|
0x08, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65,
|
||||||
0x2f, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20,
|
0x49, 0x64, 0x12, 0x2c, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18,
|
||||||
0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x5f,
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x0a, 0x73, 0x70, 0x61, 0x63, 0x65,
|
||||||
0x63, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65,
|
0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65,
|
||||||
0x12, 0x1c, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x42, 0x08,
|
0x12, 0x2f, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03,
|
||||||
0xca, 0xbb, 0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x22,
|
0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65,
|
||||||
0x5a, 0x20, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2d,
|
0x5f, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64,
|
||||||
0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70, 0x61,
|
0x65, 0x12, 0x1c, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x42,
|
||||||
0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x08, 0xca, 0xbb, 0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x42,
|
||||||
|
0x22, 0x5a, 0x20, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65,
|
||||||
|
0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70,
|
||||||
|
0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"cn/oneao/base-go/db"
|
||||||
|
"cn/oneao/base-go/logx"
|
||||||
|
"context"
|
||||||
|
"github.com/cloudwego/hertz/pkg/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RefreshActive() app.HandlerFunc {
|
||||||
|
return func(c context.Context, ctx *app.RequestContext) {
|
||||||
|
// 先执行后续 handler
|
||||||
|
ctx.Next(c)
|
||||||
|
|
||||||
|
userID := GetUserID(c)
|
||||||
|
if userID == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 异步刷新活跃时间
|
||||||
|
go func() {
|
||||||
|
if err := db.Queries.UpdateUserActiveTime(c, userID); err != nil {
|
||||||
|
logx.CtxError(c, "刷新用户活跃时间失败, userID=%d, err=%v", userID, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,19 +18,21 @@ SET role = $1
|
|||||||
WHERE user_id = $2
|
WHERE user_id = $2
|
||||||
AND space_id = $3;
|
AND space_id = $3;
|
||||||
|
|
||||||
-- 获取空间下的所有用户信息
|
-- 获取空间下的所有用户信息(按 role, active_time, username 排序)
|
||||||
-- name: ListSpaceUsers :many
|
-- name: ListSpaceUsers :many
|
||||||
SELECT
|
SELECT
|
||||||
u.id as user_id,
|
u.id AS user_id,
|
||||||
u.username,
|
u.username,
|
||||||
|
u.active_time,
|
||||||
su.role,
|
su.role,
|
||||||
su.join_time
|
su.join_time
|
||||||
FROM space_user su
|
FROM space_user su
|
||||||
JOIN space s ON su.space_id = s.id
|
JOIN space s ON su.space_id = s.id
|
||||||
JOIN user_info u ON su.user_id = u.id
|
JOIN user_info u ON su.user_id = u.id
|
||||||
WHERE s.id = $1
|
WHERE s.id = $1
|
||||||
ORDER BY su.join_time ASC;
|
ORDER BY su.role ASC,
|
||||||
|
u.active_time DESC,
|
||||||
|
u.username ASC;
|
||||||
|
|
||||||
-- name: GetSpaceUserByUserId :one
|
-- name: GetSpaceUserByUserId :one
|
||||||
SELECT * FROM space_user WHERE user_id = $1;
|
SELECT * FROM space_user WHERE user_id = $1;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
-- 插入用户并返回刚创建的记录
|
-- 插入用户并返回刚创建的记录
|
||||||
-- name: InsertUser :execrows
|
-- name: InsertUser :execrows
|
||||||
INSERT INTO user_info (id, account, password)
|
INSERT INTO user_info (id, account, password,username)
|
||||||
VALUES ($1, $2, $3);
|
VALUES ($1, $2, $3,$4);
|
||||||
|
|
||||||
-- 根据 ID 查询单条用户记录
|
-- 根据 ID 查询单条用户记录
|
||||||
-- name: GetUserById :one
|
-- name: GetUserById :one
|
||||||
@@ -23,8 +23,13 @@ WHERE account = $1
|
|||||||
AND password = $2;
|
AND password = $2;
|
||||||
|
|
||||||
-- 更新用户最后登录时间,并返回更新后的记录
|
-- 更新用户最后登录时间,并返回更新后的记录
|
||||||
-- name: UpdateUserLoginLastTime :execrows
|
-- name: UpdateUserLoginLastTime :exec
|
||||||
UPDATE user_info
|
UPDATE user_info
|
||||||
SET last_login_time = now()
|
SET last_login_time = now()
|
||||||
WHERE id = $1;
|
WHERE id = $1;
|
||||||
|
|
||||||
|
-- 更新用户活跃时间
|
||||||
|
-- name: UpdateUserActiveTime :exec
|
||||||
|
UPDATE user_info
|
||||||
|
SET active_time = now()
|
||||||
|
WHERE id = $1;
|
||||||
@@ -76,5 +76,6 @@ type UserInfo struct {
|
|||||||
Gender pgtype.Int4
|
Gender pgtype.Int4
|
||||||
CreateTime pgtype.Timestamp
|
CreateTime pgtype.Timestamp
|
||||||
UpdateTime pgtype.Timestamp
|
UpdateTime pgtype.Timestamp
|
||||||
|
ActiveTime pgtype.Timestamp
|
||||||
LastLoginTime pgtype.Timestamp
|
LastLoginTime pgtype.Timestamp
|
||||||
}
|
}
|
||||||
@@ -109,25 +109,29 @@ func (q *Queries) InsertSpaceUser(ctx context.Context, arg InsertSpaceUserParams
|
|||||||
|
|
||||||
const listSpaceUsers = `-- name: ListSpaceUsers :many
|
const listSpaceUsers = `-- name: ListSpaceUsers :many
|
||||||
SELECT
|
SELECT
|
||||||
u.id as user_id,
|
u.id AS user_id,
|
||||||
u.username,
|
u.username,
|
||||||
|
u.active_time,
|
||||||
su.role,
|
su.role,
|
||||||
su.join_time
|
su.join_time
|
||||||
FROM space_user su
|
FROM space_user su
|
||||||
JOIN space s ON su.space_id = s.id
|
JOIN space s ON su.space_id = s.id
|
||||||
JOIN user_info u ON su.user_id = u.id
|
JOIN user_info u ON su.user_id = u.id
|
||||||
WHERE s.id = $1
|
WHERE s.id = $1
|
||||||
ORDER BY su.join_time ASC
|
ORDER BY su.role ASC,
|
||||||
|
u.active_time DESC,
|
||||||
|
u.username ASC
|
||||||
`
|
`
|
||||||
|
|
||||||
type ListSpaceUsersRow struct {
|
type ListSpaceUsersRow struct {
|
||||||
UserID int64
|
UserID int64
|
||||||
Username pgtype.Text
|
Username pgtype.Text
|
||||||
|
ActiveTime pgtype.Timestamp
|
||||||
Role int32
|
Role int32
|
||||||
JoinTime pgtype.Timestamp
|
JoinTime pgtype.Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取空间下的所有用户信息
|
// 获取空间下的所有用户信息(按 role, active_time, username 排序)
|
||||||
func (q *Queries) ListSpaceUsers(ctx context.Context, id int64) ([]ListSpaceUsersRow, error) {
|
func (q *Queries) ListSpaceUsers(ctx context.Context, id int64) ([]ListSpaceUsersRow, error) {
|
||||||
rows, err := q.db.Query(ctx, listSpaceUsers, id)
|
rows, err := q.db.Query(ctx, listSpaceUsers, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -140,6 +144,7 @@ func (q *Queries) ListSpaceUsers(ctx context.Context, id int64) ([]ListSpaceUser
|
|||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&i.UserID,
|
&i.UserID,
|
||||||
&i.Username,
|
&i.Username,
|
||||||
|
&i.ActiveTime,
|
||||||
&i.Role,
|
&i.Role,
|
||||||
&i.JoinTime,
|
&i.JoinTime,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ package repo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|
||||||
const getUserByAccount = `-- name: GetUserByAccount :one
|
const getUserByAccount = `-- name: GetUserByAccount :one
|
||||||
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, last_login_time
|
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, active_time, last_login_time
|
||||||
FROM user_info
|
FROM user_info
|
||||||
WHERE account = $1
|
WHERE account = $1
|
||||||
`
|
`
|
||||||
@@ -29,13 +31,14 @@ func (q *Queries) GetUserByAccount(ctx context.Context, account string) (UserInf
|
|||||||
&i.Gender,
|
&i.Gender,
|
||||||
&i.CreateTime,
|
&i.CreateTime,
|
||||||
&i.UpdateTime,
|
&i.UpdateTime,
|
||||||
|
&i.ActiveTime,
|
||||||
&i.LastLoginTime,
|
&i.LastLoginTime,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const getUserById = `-- name: GetUserById :one
|
const getUserById = `-- name: GetUserById :one
|
||||||
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, last_login_time
|
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, active_time, last_login_time
|
||||||
FROM user_info
|
FROM user_info
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
`
|
`
|
||||||
@@ -54,13 +57,14 @@ func (q *Queries) GetUserById(ctx context.Context, id int64) (UserInfo, error) {
|
|||||||
&i.Gender,
|
&i.Gender,
|
||||||
&i.CreateTime,
|
&i.CreateTime,
|
||||||
&i.UpdateTime,
|
&i.UpdateTime,
|
||||||
|
&i.ActiveTime,
|
||||||
&i.LastLoginTime,
|
&i.LastLoginTime,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const getUserForLogin = `-- name: GetUserForLogin :one
|
const getUserForLogin = `-- name: GetUserForLogin :one
|
||||||
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, last_login_time
|
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, active_time, last_login_time
|
||||||
FROM user_info
|
FROM user_info
|
||||||
WHERE account = $1
|
WHERE account = $1
|
||||||
AND password = $2
|
AND password = $2
|
||||||
@@ -85,42 +89,58 @@ func (q *Queries) GetUserForLogin(ctx context.Context, arg GetUserForLoginParams
|
|||||||
&i.Gender,
|
&i.Gender,
|
||||||
&i.CreateTime,
|
&i.CreateTime,
|
||||||
&i.UpdateTime,
|
&i.UpdateTime,
|
||||||
|
&i.ActiveTime,
|
||||||
&i.LastLoginTime,
|
&i.LastLoginTime,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const insertUser = `-- name: InsertUser :execrows
|
const insertUser = `-- name: InsertUser :execrows
|
||||||
INSERT INTO user_info (id, account, password)
|
INSERT INTO user_info (id, account, password,username)
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, $3,$4)
|
||||||
`
|
`
|
||||||
|
|
||||||
type InsertUserParams struct {
|
type InsertUserParams struct {
|
||||||
ID int64
|
ID int64
|
||||||
Account string
|
Account string
|
||||||
Password string
|
Password string
|
||||||
|
Username pgtype.Text
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插入用户并返回刚创建的记录
|
// 插入用户并返回刚创建的记录
|
||||||
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (int64, error) {
|
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (int64, error) {
|
||||||
result, err := q.db.Exec(ctx, insertUser, arg.ID, arg.Account, arg.Password)
|
result, err := q.db.Exec(ctx, insertUser,
|
||||||
|
arg.ID,
|
||||||
|
arg.Account,
|
||||||
|
arg.Password,
|
||||||
|
arg.Username,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return result.RowsAffected(), nil
|
return result.RowsAffected(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateUserLoginLastTime = `-- name: UpdateUserLoginLastTime :execrows
|
const updateUserActiveTime = `-- name: UpdateUserActiveTime :exec
|
||||||
|
UPDATE user_info
|
||||||
|
SET active_time = now()
|
||||||
|
WHERE id = $1
|
||||||
|
`
|
||||||
|
|
||||||
|
// 更新用户活跃时间
|
||||||
|
func (q *Queries) UpdateUserActiveTime(ctx context.Context, id int64) error {
|
||||||
|
_, err := q.db.Exec(ctx, updateUserActiveTime, id)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateUserLoginLastTime = `-- name: UpdateUserLoginLastTime :exec
|
||||||
UPDATE user_info
|
UPDATE user_info
|
||||||
SET last_login_time = now()
|
SET last_login_time = now()
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
`
|
`
|
||||||
|
|
||||||
// 更新用户最后登录时间,并返回更新后的记录
|
// 更新用户最后登录时间,并返回更新后的记录
|
||||||
func (q *Queries) UpdateUserLoginLastTime(ctx context.Context, id int64) (int64, error) {
|
func (q *Queries) UpdateUserLoginLastTime(ctx context.Context, id int64) error {
|
||||||
result, err := q.db.Exec(ctx, updateUserLoginLastTime, id)
|
_, err := q.db.Exec(ctx, updateUserLoginLastTime, id)
|
||||||
if err != nil {
|
return err
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return result.RowsAffected(), nil
|
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ CREATE TABLE user_info (
|
|||||||
gender INT DEFAULT 0,
|
gender INT DEFAULT 0,
|
||||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
active_time TIMESTAMP,
|
||||||
last_login_time TIMESTAMP
|
last_login_time TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ message ListSpaceUsersParams {
|
|||||||
message SpaceUser {
|
message SpaceUser {
|
||||||
int64 UserId = 1 [(api.body)="user_id"];
|
int64 UserId = 1 [(api.body)="user_id"];
|
||||||
string Username = 2 [(api.body)="username"];
|
string Username = 2 [(api.body)="username"];
|
||||||
int32 SpaceRole = 4 [(api.body)="space_role"];
|
int32 SpaceRole = 3 [(api.body)="space_role"];
|
||||||
|
string ActiveTime = 4 [(api.body)="active_time"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListSpaceUsersResult {
|
message ListSpaceUsersResult {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ func main() {
|
|||||||
h.Use(middleware.Log())
|
h.Use(middleware.Log())
|
||||||
h.Use(middleware.Error())
|
h.Use(middleware.Error())
|
||||||
h.Use(middleware.Auth())
|
h.Use(middleware.Auth())
|
||||||
|
h.Use(middleware.RefreshActive())
|
||||||
|
|
||||||
register(h)
|
register(h)
|
||||||
h.Spin()
|
h.Spin()
|
||||||
|
|||||||
Reference in new issue
Block a user