切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
庄敏学
2 years ago
提交
429addc2974185a58ce3acfb323a75580c310ad2
1 个父辈
57452e0e
用户增加保存职位
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
29 行增加
和
16 行删除
go_build_main_go
pkg/application/position/command/save_position.go
pkg/application/user/command/save_user.go
pkg/application/user/sync_data_service.go
pkg/infrastructure/repository/pg_department_repository.go
pkg/infrastructure/repository/pg_user_repository.go
go_build_main_go
查看文件 @
429addc
不能预览此文件类型
pkg/application/position/command/save_position.go
查看文件 @
429addc
...
...
@@ -4,11 +4,11 @@ type SavePositionCommand struct {
//职位ID
Id
int64
`json:"id"`
//公司ID
CompanyId
int64
`json:"company
I
d"`
CompanyId
int64
`json:"company
_i
d"`
//职位名称
Name
string
`json:"name"`
//父级职位ID
ParentId
int64
`json:"parent
I
d"`
ParentId
int64
`json:"parent
_i
d"`
//职位路径
Path
string
`json:"path"`
//职位层级
...
...
pkg/application/user/command/save_user.go
查看文件 @
429addc
...
...
@@ -12,4 +12,25 @@ type SaveUserCommand struct {
UserDepartments
[]
struct
{
DepartmentId
int
`json:"department_id" `
}
`json:"user_departments"`
//用户的组织ids
UserPositions
[]
struct
{
PositionId
int
`json:"position_id"`
CompanyId
int64
`json:"company_id"`
UserId
int64
`json:"user_id"`
}
`json:"user_positions"`
}
func
(
saveUserCommand
*
SaveUserCommand
)
DepartmentIds
()
[]
int
{
ids
:=
make
([]
int
,
0
)
for
_
,
v
:=
range
saveUserCommand
.
UserDepartments
{
ids
=
append
(
ids
,
v
.
DepartmentId
)
}
return
ids
}
func
(
saveUserCommand
*
SaveUserCommand
)
PositionIds
()
[]
int
{
ids
:=
make
([]
int
,
0
)
for
_
,
v
:=
range
saveUserCommand
.
UserPositions
{
ids
=
append
(
ids
,
v
.
PositionId
)
}
return
ids
}
...
...
pkg/application/user/sync_data_service.go
查看文件 @
429addc
...
...
@@ -83,10 +83,6 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error {
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
departmentIds
:=
make
([]
int
,
0
)
for
_
,
v
:=
range
param
.
UserDepartments
{
departmentIds
=
append
(
departmentIds
,
v
.
DepartmentId
)
}
nowTime
:=
time
.
Now
()
newUser
:=
domain
.
User
{
Id
:
param
.
Id
,
...
...
@@ -94,7 +90,8 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error {
AvatarUrl
:
param
.
Avatar
,
CompanyId
:
param
.
CompanyId
,
AdminType
:
param
.
AdminType
,
DepartmentId
:
departmentIds
,
DepartmentId
:
param
.
DepartmentIds
(),
PositionId
:
param
.
PositionIds
(),
Name
:
param
.
Name
,
Email
:
param
.
Email
,
Status
:
param
.
Status
,
...
...
@@ -156,8 +153,8 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error
newUser
.
AdminType
=
param
.
AdminType
newUser
.
Name
=
param
.
Name
newUser
.
Status
=
param
.
Status
newUser
.
PositionId
=
make
([]
int
,
0
)
newUser
.
DepartmentId
=
make
([]
int
,
0
)
newUser
.
PositionId
=
param
.
PositionIds
()
newUser
.
DepartmentId
=
param
.
DepartmentIds
()
newUser
.
UpdatedAt
=
nowTime
if
len
(
userList
)
>
0
{
...
...
pkg/infrastructure/repository/pg_department_repository.go
查看文件 @
429addc
package
repository
import
(
"time"
"github.com/go-pg/pg/v10"
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
...
...
@@ -65,13 +63,11 @@ func (repo *DepartmentRepository) Update(u *domain.Department) (*domain.Departme
}
func
(
repo
*
DepartmentRepository
)
Remove
(
ids
[]
int64
)
error
{
nowTime
:=
time
.
Now
()
tx
:=
repo
.
transactionContext
.
PgTx
uModel
:=
models
.
Department
{}
_
,
err
:=
tx
.
Model
(
&
uModel
)
.
Set
(
"delete_at"
,
nowTime
)
.
Where
(
"id in (?)"
,
pg
.
In
(
ids
))
.
Upda
te
()
Dele
te
()
return
err
}
...
...
pkg/infrastructure/repository/pg_user_repository.go
查看文件 @
429addc
...
...
@@ -94,8 +94,7 @@ func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domai
func
(
repo
*
UserRepository
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
domain
.
User
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
userModel
:=
[]
models
.
User
{}
query
:=
tx
.
Model
(
&
userModel
)
.
Where
(
"delete_at is null"
)
.
Limit
(
20
)
query
:=
tx
.
Model
(
&
userModel
)
.
Limit
(
20
)
if
v
,
ok
:=
queryOptions
[
"id"
];
ok
{
query
.
Where
(
"id=?"
,
v
)
}
...
...
请
注册
或
登录
后发表评论