作者 Your Name
正在显示 32 个修改的文件 包含 247 行增加71 行删除
不能预览此文件类型
... ... @@ -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
}
... ...
... ... @@ -25,9 +25,14 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) {
return
}
if len(in.Name) > 40 {
validation.SetError("name", "角色名称最大长度40个字符")
validation.SetError("name", "名称最大长度40个字符")
return
}
if in.KpiCycle == 0 {
validation.SetError("kpiCycle", "请选择考核周期")
return
}
if in.TimeStart == nil {
validation.SetError("timeStart", "请选择考核周期的开始时间")
return
... ... @@ -37,7 +42,7 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) {
return
}
if len(in.TemplateIds) == 0 {
validation.SetError("templates", "请选择周期内使用的评估模板")
validation.SetError("templates", "请添加评估模板")
return
}
}
... ...
... ... @@ -19,8 +19,7 @@ type CycleTemplateListCommand struct {
}
type CycleTemplateCommand struct {
CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"`
Id int64 `cname:"模板ID" json:"id,string" valid:"Required"`
}
func (in *QueryCycleCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -38,7 +38,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if count > 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在")
return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的周期")
}
_, templates, err := templateRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "ids": in.TemplateIds})
... ... @@ -65,19 +65,27 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
}
// 获取所有模板中的规则对象数据
ruleIds := make([]int64, 0)
ruleMap := map[int64]*domain.EvaluationRule{}
ruleIdsMap := map[int64]int64{}
for i := range templates {
v := templates[i]
for j := range v.LinkNodes {
node := v.LinkNodes[j]
for k := range node.NodeContents {
nodeContent := node.NodeContents[k]
ruleIds = append(ruleIds, nodeContent.RuleId)
if nodeContent.RuleId != 0 {
ruleIdsMap[nodeContent.RuleId] = nodeContent.RuleId
}
}
}
}
ruleIds := make([]int64, 0)
for k := range ruleIdsMap {
ruleIds = append(ruleIds, k)
}
_, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId})
ruleMap := map[int64]*domain.EvaluationRule{}
for i := range rules {
ruleMap[rules[i].Id] = rules[i]
}
... ... @@ -313,6 +321,10 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface
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(total, cycles), nil
}
... ... @@ -325,7 +337,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP
transactionContext.RollbackTransaction()
}()
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
_, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes")
_, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -339,8 +351,8 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP
userIdMap[userId] = userId
}
}
for _, v := range userIdMap {
userIds = append(userIds, v)
for k := range userIdMap {
userIds = append(userIds, k)
}
userTotal := 0
... ... @@ -404,7 +416,7 @@ func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand
}()
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId})
cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -132,7 +132,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes")
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -271,7 +271,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter
}()
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes")
total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -371,7 +371,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes")
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -8,3 +8,8 @@ type RuleAdapter struct {
*domain.EvaluationRule
CreatorName string `json:"creatorName" comment:"创建人名称"`
}
type CreatorAdapter struct {
Id int64 `json:"id,string" comment:"创建人ID"`
Name string `json:"name" comment:"创建人名称"`
}
... ...
... ... @@ -11,9 +11,20 @@ type QueryRuleCommand struct {
PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
}
type QueryCreatorCommand struct {
CompanyId int64 `cname:"公司ID" json:"companyId"`
}
func (in *QueryRuleCommand) Valid(validation *validation.Validation) {
if in.CompanyId == 0 {
validation.SetError("companyId", "公司ID无效")
return
}
}
func (in *QueryCreatorCommand) Valid(validation *validation.Validation) {
if in.CompanyId == 0 {
validation.SetError("companyId", "公司ID无效")
return
}
}
... ...
... ... @@ -212,3 +212,40 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
}
return tool_funs.SimpleWrapGridMap(total, ras), nil
}
func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
if err != nil {
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
_, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 获取所有创建人ID
creatorMap := map[int64]int64{}
for i := range rules {
creatorMap[rules[i].CreatorId] = rules[i].CreatorId
}
creatorIds := make([]int64, 0)
for k := range creatorMap {
creatorIds = append(creatorIds, k)
}
_, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)})
cas := make([]*adapter.CreatorAdapter, 0)
for i := range users {
ca := &adapter.CreatorAdapter{
Id: users[i].Id,
Name: users[i].Name,
}
cas = append(cas, ca)
}
return map[string]interface{}{"list": cas}, nil
}
... ...
... ... @@ -188,8 +188,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
defer func() {
transactionContext.RollbackTransaction()
}()
queryOptions := tool_funs.SimpleStructToMap(in)
if in.CreatedAt == nil {
delete(queryOptions, "createdAt") // 删除创建时间
}
templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
total, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes")
total, templates, err := templateRepository.Find(queryOptions, "link_nodes")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -34,7 +34,7 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{
// int64Array = append(int64Array, int64Num)
//}
// 检测已存在的关联用户
_, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999})
_, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": int64(9999999)})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -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" `
... ...
package query
type ListUserQuery struct {
CompanyId int64 `json:"companyId"` // 公司ID
Name string `json:"name"` // 用户姓名
}
... ...
... ... @@ -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,
... ...
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
}
... ...
... ... @@ -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 主管理员
... ...
... ... @@ -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"` // 删除时间
... ...
... ... @@ -127,11 +127,11 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
query.Where("company_id = ?", v)
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
if v, ok := queryOptions["offset"].(int64); ok {
query.Offset(int(v))
}
if v, ok := queryOptions["timeStart"]; ok {
... ...
... ... @@ -153,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte
query.Where("cycle_id = ?", v)
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
if v, ok := queryOptions["offset"].(int64); ok {
query.Offset(int(v))
}
count, err := query.SelectAndCount()
... ...
... ... @@ -159,11 +159,11 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
}
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
if v, ok := queryOptions["offset"].(int64); ok {
query.Offset(int(v))
}
count, err := query.SelectAndCount()
... ...
... ... @@ -143,11 +143,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{})
query.Where("type = ?", v)
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
if v, ok := queryOptions["offset"].(int64); ok {
query.Offset(int(v))
}
count, err := query.SelectAndCount()
... ...
... ... @@ -142,14 +142,19 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
}
if v, ok := queryOptions["createdAt"]; ok {
query.Where("created_at = ?", v)
t := v.(*time.Time)
year, month, day := t.Date()
begin := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
end := time.Date(year, month, day, 23, 59, 59, 0, time.Local)
query.Where("created_at >= ?", begin)
query.Where("created_at <= ?", end)
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
if v, ok := queryOptions["offset"].(int64); ok {
query.Offset(int(v))
}
count, err := query.SelectAndCount()
... ...
... ... @@ -121,11 +121,11 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, []
query.Where("company_id = ?", companyId)
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
if v, ok := queryOptions["offset"].(int64); ok {
query.Offset(int(v))
}
count, err := query.SelectAndCount()
... ...
... ... @@ -128,11 +128,11 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64
query.Where("user_id in (?)", pg.In(userIds))
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
if v, ok := queryOptions["offset"].(int64); ok {
query.Offset(int(v))
}
count, err := query.SelectAndCount()
... ...
... ... @@ -21,8 +21,6 @@ func (controller *CycleController) CreateCycle() {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
in.CreatorId = ua.UserId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
//in.CreatorId = middlewares.GetUserId(controller.Ctx)
controller.Response(ruService.Create(in))
}
}
... ... @@ -101,9 +99,10 @@ func (controller *CycleController) CycleTemplateList() {
func (controller *CycleController) CycleTemplate() {
ruService := service.NewEvaluationCycleService()
in := &command.CycleTemplateCommand{}
if err := controller.Unmarshal(in); err != nil {
if id, err := controller.GetInt64(":Id"); err != nil {
controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
in.Id = id
controller.Response(ruService.CycleTemplate(in))
}
}
... ...
... ... @@ -85,7 +85,19 @@ func (controller *RuleController) ListRuleRelCreator() {
}
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.ListRelCreator(in))
}
}
func (controller *RuleController) ListCreator() {
ruService := service.NewEvaluationRuleService()
in := &command.QueryCreatorCommand{}
if err := controller.Unmarshal(in); err != nil {
controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
controller.Response(ruService.ListCreator(in))
}
}
... ...
... ... @@ -22,8 +22,6 @@ func (controller *TemplateController) CreateTemplate() {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
in.CreatorId = ua.UserId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
//in.CreatorId = middlewares.GetUserId(controller.Ctx)
controller.Response(ruService.Create(in))
}
}
... ... @@ -36,7 +34,6 @@ func (controller *TemplateController) UpdateTemplate() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.Update(in))
}
}
... ... @@ -74,7 +71,6 @@ func (controller *TemplateController) ListTemplate() {
}
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.List(in))
}
}
... ... @@ -90,7 +86,6 @@ func (controller *TemplateController) ListEnableTemplate() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.List(in))
}
}
... ... @@ -103,7 +98,6 @@ func (controller *TemplateController) StateTemplate() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.State(in))
}
}
... ... @@ -117,8 +111,6 @@ func (controller *TemplateController) CopyTemplate() {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
in.CreatorId = ua.UserId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
//in.CreatorId = middlewares.GetUserId(controller.Ctx)
controller.Response(ruService.Copy(in))
}
}
... ...
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)
}
... ...
... ... @@ -17,6 +17,7 @@ func init() {
web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"),
web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"),
web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"),
web.NSRouter("/template/:Id", &controllers.CycleController{}, "Get:CycleTemplate"),
)
web.AddNamespace(ns)
}
... ...
... ... @@ -15,6 +15,7 @@ func init() {
web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"),
web.NSRouter("/:Id", &controllers.RuleController{}, "Get:GetRule"),
web.NSRouter("/list", &controllers.RuleController{}, "Post:ListRuleRelCreator"),
web.NSRouter("/list-creator", &controllers.RuleController{}, "Post:ListCreator"),
)
web.AddNamespace(ns)
}
... ...
... ... @@ -16,6 +16,7 @@ func init() {
web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"),
web.NSRouter("/list", &controllers.TemplateController{}, "Post:ListTemplate"),
web.NSRouter("/list-enable", &controllers.TemplateController{}, "Post:ListEnableTemplate"),
web.NSRouter("/copy", &controllers.TemplateController{}, "Post:CopyTemplate"),
)
web.AddNamespace(ns)
}
... ...
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)
}
... ...