切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
郑周
2 years ago
提交
5cb7d590afcdbf4eee23071d667cf3b9151e0349
2 个父辈
b32f1e60
d2f82565
Merge remote-tracking branch 'origin/test' into test
隐藏空白字符变更
内嵌
并排对比
正在显示
10 个修改的文件
包含
103 行增加
和
13 行删除
go_build_main_go
pkg/application/department/sync_data_service.go
pkg/application/user/command/save_user.go
pkg/application/user/query/list_user_query.go
pkg/application/user/sync_data_service.go
pkg/application/user/user.go
pkg/domain/user.go
pkg/infrastructure/pg/models/user.go
pkg/port/beego/controllers/user_controller.go
pkg/port/beego/routers/user_router.go
go_build_main_go
查看文件 @
5cb7d59
不能预览此文件类型
pkg/application/department/sync_data_service.go
查看文件 @
5cb7d59
...
...
@@ -142,6 +142,8 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen
}
if
len
(
param
.
ChargeUserIds
)
>
0
{
departmentList
[
i
]
.
ChargeUserIds
=
param
.
ChargeUserIds
}
else
{
departmentList
[
i
]
.
ChargeUserIds
=
make
([]
int64
,
0
)
}
continue
}
...
...
pkg/application/user/command/save_user.go
查看文件 @
5cb7d59
...
...
@@ -8,6 +8,7 @@ type SaveUserCommand struct {
AdminType
int
`json:"admin_type"`
// 1普通员工 2 主管理员
Name
string
`json:"name"`
// 用户姓名
Status
int
`json:"status"`
// 用户状态(1正常 2禁用)
EntryTime
string
`json:"entryTime"`
//入职日期
Email
string
`json:"email"`
// 邮箱
UserDepartments
[]
struct
{
DepartmentId
int
`json:"department_id" `
...
...
pkg/application/user/query/list_user_query.go
0 → 100644
查看文件 @
5cb7d59
package
query
type
ListUserQuery
struct
{
CompanyId
int64
`json:"companyId"`
// 公司ID
Name
string
`json:"name"`
// 用户姓名
}
...
...
pkg/application/user/sync_data_service.go
查看文件 @
5cb7d59
...
...
@@ -102,6 +102,7 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error {
Name
:
param
.
Name
,
Email
:
param
.
Email
,
Status
:
param
.
Status
,
EntryTime
:
param
.
EntryTime
,
UpdatedAt
:
nowTime
,
CreatedAt
:
nowTime
,
}
...
...
@@ -160,6 +161,7 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error
newUser
.
AdminType
=
param
.
AdminType
newUser
.
Name
=
param
.
Name
newUser
.
Status
=
param
.
Status
newUser
.
EntryTime
=
param
.
EntryTime
newUser
.
PositionId
=
param
.
PositionIds
()
newUser
.
DepartmentId
=
param
.
DepartmentIds
()
...
...
@@ -294,6 +296,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro
editUserList
[
i
]
.
Name
=
mVal
.
Name
editUserList
[
i
]
.
Status
=
mVal
.
Status
editUserList
[
i
]
.
CompanyId
=
mVal
.
CompanyId
editUserList
[
i
]
.
EntryTime
=
mVal
.
EntryTime
editUserList
[
i
]
.
UpdatedAt
=
nowTime
_
,
err
=
userRepo
.
Update
(
editUserList
[
i
])
if
err
!=
nil
{
...
...
@@ -312,6 +315,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro
AdminType
:
param
.
AddUsers
[
i
]
.
AdminType
,
Name
:
param
.
AddUsers
[
i
]
.
Name
,
Status
:
param
.
AddUsers
[
i
]
.
Status
,
EntryTime
:
param
.
AddUsers
[
i
]
.
EntryTime
,
UpdatedAt
:
nowTime
,
DeletedAt
:
nil
,
CreatedAt
:
nowTime
,
...
...
pkg/application/user/user.go
0 → 100644
查看文件 @
5cb7d59
package
user
import
(
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query"
)
type
UserService
struct
{}
func
(
service
*
UserService
)
ListUsers
(
listUserQuery
*
query
.
ListUserQuery
)
(
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
StartTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
userRepo
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
count
,
list
,
err
:=
userRepo
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
listUserQuery
.
CompanyId
,
"name"
:
listUserQuery
.
Name
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
tool_funs
.
SimpleWrapGridMap
(
int64
(
count
),
list
),
nil
}
...
...
pkg/domain/user.go
查看文件 @
5cb7d59
...
...
@@ -3,19 +3,20 @@ package domain
import
"time"
type
User
struct
{
Id
int64
// 用户Id
Account
string
// 用户账号
AvatarUrl
string
// 用户头像URL
CompanyId
int64
// 公司编号
AdminType
int
// 1普通员工 2 主管理员
Name
string
// 用户姓名
Email
string
// 邮箱
Status
int
// 用户状态(1正常 2禁用)
DepartmentId
[]
int
// 用户归属的部门
PositionId
[]
int
//用户职位
UpdatedAt
time
.
Time
// 更新时间
DeletedAt
*
time
.
Time
CreatedAt
time
.
Time
Id
int64
`json:"id"`
// 用户Id
Account
string
`json:"account"`
// 用户账号
AvatarUrl
string
`json:"avatarUrl"`
// 用户头像URL
CompanyId
int64
`json:"companyId"`
// 公司编号
AdminType
int
`json:"adminType"`
// 1普通员工 2 主管理员
Name
string
`json:"name"`
// 用户姓名
Email
string
`json:"email"`
// 邮箱
Status
int
`json:"status"`
// 用户状态(1正常 2禁用)
DepartmentId
[]
int
`json:"departmentId"`
// 用户归属的部门
PositionId
[]
int
`json:"PositionId"`
//用户职位
EntryTime
string
`json:"entryTime"`
//入职日期
UpdatedAt
time
.
Time
`json:"updatedAt"`
// 更新时间
DeletedAt
*
time
.
Time
`json:"deletedAt"`
CreatedAt
time
.
Time
`json:"createdAt"`
}
// 1普通员工 2 主管理员
...
...
pkg/infrastructure/pg/models/user.go
查看文件 @
5cb7d59
...
...
@@ -14,6 +14,7 @@ type User struct {
Status
int
// 用户状态(1正常 2禁用)
DepartmentId
[]
int
// 用户归属的部门
PositionId
[]
int
// 用户职位
EntryTime
string
//入职日期
CreatedAt
time
.
Time
// 创建时间
UpdatedAt
time
.
Time
// 更新时间
DeletedAt
*
time
.
Time
`pg:",soft_delete"`
// 删除时间
...
...
pkg/port/beego/controllers/user_controller.go
0 → 100644
查看文件 @
5cb7d59
package
controllers
import
(
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type
UserController
struct
{
beego
.
BaseController
}
// ListUsers 搜索用户
func
(
controller
*
UserController
)
ListUsers
()
{
listUserQuery
:=
&
query
.
ListUserQuery
{}
_
=
controller
.
Unmarshal
(
listUserQuery
)
userAuth
:=
controller
.
Ctx
.
Input
.
GetData
(
domain
.
UserAuth
{})
.
(
*
domain
.
UserAuth
)
listUserQuery
.
CompanyId
=
userAuth
.
CompanyId
resp
,
err
:=
(
&
user
.
UserService
{})
.
ListUsers
(
listUserQuery
)
controller
.
Response
(
resp
,
err
)
}
...
...
pkg/port/beego/routers/user_router.go
0 → 100644
查看文件 @
5cb7d59
package
routers
import
(
"github.com/beego/beego/v2/server/web"
"github.com/linmadan/egglib-go/web/beego/filters"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
func
init
()
{
ns
:=
web
.
NewNamespace
(
"/v1/users"
,
web
.
NSBefore
(
filters
.
AllowCors
(),
middlewares
.
CheckAdminToken
()),
web
.
NSRouter
(
"/search"
,
&
controllers
.
UserController
{},
"Post:ListUsers"
),
)
web
.
AddNamespace
(
ns
)
}
...
...
请
注册
或
登录
后发表评论