切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
庄敏学
2 years ago
提交
5971e2eaf7b7f7b70e3fa93fb53eef628ba59308
1 个父辈
78d1bf99
增加用户搜索
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
86 行增加
和
0 行删除
pkg/application/department/sync_data_service.go
pkg/application/user/query/list_user_query.go
pkg/application/user/user.go
pkg/infrastructure/repository/pg_user_repository.go
pkg/port/beego/controllers/user_controller.go
pkg/port/beego/routers/user_router.go
pkg/application/department/sync_data_service.go
查看文件 @
5971e2e
...
...
@@ -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/query/list_user_query.go
0 → 100644
查看文件 @
5971e2e
package
query
type
ListUserQuery
struct
{
CompanyId
int64
`json:"companyId"`
// 公司ID
Name
string
`json:"name"`
// 用户姓名
}
...
...
pkg/application/user/user.go
0 → 100644
查看文件 @
5971e2e
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/infrastructure/repository/pg_user_repository.go
查看文件 @
5971e2e
...
...
@@ -114,6 +114,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
if
v
,
ok
:=
queryOptions
[
"account"
];
ok
{
query
.
Where
(
"account like ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
];
ok
&&
v
.
(
string
)
!=
""
{
query
.
Where
(
"name like ?"
,
"%"
+
v
.
(
string
)
+
"%"
)
}
if
v
,
ok
:=
queryOptions
[
"offset"
];
ok
{
query
.
Offset
(
v
.
(
int
))
}
...
...
pkg/port/beego/controllers/user_controller.go
0 → 100644
查看文件 @
5971e2e
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
查看文件 @
5971e2e
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/user"
,
web
.
NSBefore
(
filters
.
AllowCors
(),
middlewares
.
CheckAdminToken
()),
web
.
NSRouter
(
"/search"
,
&
controllers
.
UserController
{},
"Post:ListUsers"
),
)
web
.
AddNamespace
(
ns
)
}
...
...
请
注册
或
登录
后发表评论