作者 yangfu

用户更新修改 子部门列表获取

... ... @@ -157,6 +157,7 @@ func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCusto
menuCategory = m
}
queryOptions["menuTypeIn"] = []string{"catalog", "menu"}
queryOptions["isPublish"] = domain.MenuPublic
_, menus, err := menuRepository.Find(queryOptions)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -145,16 +145,21 @@ func (orgService *OrgService) GetOrgSubDepartment(getOrgSubDepartmentQuery *quer
orgRepository, org, err := factory.FastPgOrg(transactionContext, getOrgSubDepartmentQuery.OrgId)
_, orgs, err := orgRepository.Find(map[string]interface{}{"companyId": org.CompanyId, "parentId": getOrgSubDepartmentQuery.OrgId})
_, orgs, err := orgRepository.Find(map[string]interface{}{"companyId": org.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var treeNodes = make([]domain.TreeNode, len(orgs))
for i := 0; i < len(orgs); i++ {
treeNodes[i] = orgs[i]
}
tree := domain.NewTrees(treeNodes)
nodes := tree.AllChildNodes(org)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"orgs": orgs,
"orgs": nodes,
}, nil
}
... ...
... ... @@ -15,9 +15,9 @@ type UpdateUserCommand struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
// 组织机构
OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty"`
OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty" valid:"Required"`
// 所属部门
DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty"`
DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty" valid:"Required"`
// 用户关联的组织
UserOrg []*domain.Org `cname:"用户关联的组织" json:"userOrg,omitempty"`
// 用户关联的角色
... ... @@ -33,9 +33,9 @@ type UpdateUserCommand struct {
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 头像
Avatar string `cname:"头像" json:"avatar" valid:"Required"`
Avatar string `cname:"头像" json:"avatar"`
// 邮箱
Email string `cname:"邮箱" json:"email" valid:"Required"`
Email string `cname:"邮箱" json:"email"`
}
func (updateUserCommand *UpdateUserCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -14,9 +14,9 @@ type UserDto struct {
// 用户编号 企业内标识
UserCode string `json:"userCode,omitempty"`
// 用户关联的组织
UserOrg []*domain.Org `json:"userOrg,omitempty"`
UserOrg []*domain.Org `json:"userOrg"`
// 用户关联的角色
UserRole []*domain.Role `json:"userRole,omitempty"`
UserRole []*domain.Role `json:"userRole"`
// 收藏的菜单(工作台)(菜单编码列表)
FavoriteMenus []string `json:"favoriteMenus,omitempty"`
// 共创信息 (共创用户有效)
... ... @@ -65,6 +65,12 @@ func (dto *UserDto) LoadDto(user *domain.User, company *domain.Company) error {
Phone: user.Ext.Phone,
}
}
if len(dto.UserRole) == 0 {
dto.UserRole = make([]*domain.Role, 0)
}
if len(dto.UserOrg) == 0 {
dto.UserOrg = make([]*domain.Org, 0)
}
dto.Organization = user.Organization
dto.Department = user.Department
return nil
... ...
... ... @@ -41,7 +41,7 @@ func NewTree(node TreeNode) *Tree {
}
}
// AllChildNodes 返回node下所有子节点
// AllChildNodes 返回node下所有子节点,包含本身
func (tree *Tree) AllChildNodes(node TreeNode) []TreeNode {
treeNode := tree.find(node)
if treeNode == nil {
... ...
... ... @@ -163,9 +163,9 @@ func (repository *MenuRepository) Find(queryOptions map[string]interface{}) (int
if v, ok := queryOptions["menuName"]; ok {
query.Where(fmt.Sprintf("menu_name like '%%%v%%'", v))
}
//if v, ok := queryOptions["menuTypeIn"]; ok {
// query.Where("menu_type in (?)",v)
//}
if v, ok := queryOptions["menuTypeIn"]; ok {
query.Where("menu_type in (?)", pg.In(v))
}
query.SetWhereByQueryOption("parent_id = ?", "parentId")
query.SetWhereByQueryOption("is_publish =?", "isPublish")
query.SetOrderDirect("parent_id", "asc")
... ...