作者 yangfu

组织 用户调整

正在显示 37 个修改的文件 包含 176 行增加42 行删除
... ... @@ -8,9 +8,11 @@ import (
type CustomizeMenuDto struct {
}
func (dto *CustomizeMenuDto) LoadDto(menus []*domain.Menu, customizeMenus []*domain.CustomizeMenu) (interface{}, error) {
func (dto *CustomizeMenuDto) LoadDto(menus []*domain.Menu, customizeMenus []*domain.CustomizeMenu, rootMenu *domain.Menu) (interface{}, error) {
var ret []interface{}
ret = append(ret, rootMenu)
menusMap := make(map[int64]*domain.Menu)
menusMap[rootMenu.MenuId] = rootMenu
for i := range menus {
menusMap[menus[i].MenuId] = menus[i]
}
... ... @@ -19,6 +21,7 @@ func (dto *CustomizeMenuDto) LoadDto(menus []*domain.Menu, customizeMenus []*dom
m := customizeMenus[i]
if menu, ok := menusMap[m.MenuId]; ok {
menu.MenuAlias = m.MenuAlias
menu.Sort = m.Sort
}
}
... ...
... ... @@ -151,9 +151,12 @@ func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCusto
menuRepository = value
}
queryOptions := common.SimpleStructToMap(listCompanyCustomizeMenusCommand)
var menuCategory *domain.Menu
if m, e := menuRepository.FindOne(map[string]interface{}{"code": listCompanyCustomizeMenusCommand.MenuCategory}); e == nil && m != nil {
queryOptions["category"] = strconv.Itoa(int(m.MenuId))
menuCategory = m
}
queryOptions["menuTypeIn"] = []string{"catalog", "menu"}
_, menus, err := menuRepository.Find(queryOptions)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -171,7 +174,7 @@ func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCusto
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
customizeMenuDto := dto.CustomizeMenuDto{}
ret, _ := customizeMenuDto.LoadDto(menus, customizeMenus)
ret, _ := customizeMenuDto.LoadDto(menus, customizeMenus, menuCategory)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type CreateOrgCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
// 组织编码
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type EnableOrgCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId" valid:"Required"`
// 组织状态 1:启用 2:禁用 3.删除
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type RemoveOrgCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId,string" valid:"Required"`
}
... ...
... ... @@ -10,10 +10,11 @@ import (
)
type UpdateOrgCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户ID
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId,string"`
OrgId int64 `cname:"组织ID" json:"orgId`
// 组织编码
OrgCode string `cname:"组织编码" json:"orgCode"`
// 组织名称
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type GetOrgQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId" valid:"Required"`
}
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type GetOrgSubDepartmentQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId,string" valid:"Required"`
// 获取所有子节点 (1:获取当前下级子节点 2:获取当前下级所有子节点)
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type ListOrgQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset,omitempty"`
// 查询限制
... ...
... ... @@ -258,13 +258,16 @@ func (orgService *OrgService) UpdateOrg(updateOrgCommand *command.UpdateOrgComma
}
//判断当前组织内是否唯一 组织编码、组织名称
if findOne, err := orgRepository.FindOne(map[string]interface{}{"companyId": org.CompanyId, "parentId": updateOrgCommand.ParentId, "orgName": updateOrgCommand.OrgName, "notEqualOrgId": org.OrgId}); err == nil || findOne != nil {
return nil, fmt.Errorf("部门名称重复")
if org.OrgName != updateOrgCommand.OrgName {
if findOne, err := orgRepository.FindOne(map[string]interface{}{"companyId": updateOrgCommand.OperateInfo.GetCompanyId(org.CompanyId), "parentId": updateOrgCommand.ParentId, "orgName": updateOrgCommand.OrgName, "notEqualOrgId": org.OrgId}); err == nil && findOne != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "部门名称重复")
}
}
if findOne, err := orgRepository.FindOne(map[string]interface{}{"companyId": org.CompanyId, "parentId": updateOrgCommand.ParentId, "orgCode": updateOrgCommand.OrgCode, "notEqualOrgId": org.OrgId}); err == nil || findOne != nil {
return nil, fmt.Errorf("部门编码重复")
if org.OrgCode != updateOrgCommand.OrgCode {
if findOne, err := orgRepository.FindOne(map[string]interface{}{"companyId": updateOrgCommand.OperateInfo.GetCompanyId(org.CompanyId), "parentId": updateOrgCommand.ParentId, "orgCode": updateOrgCommand.OrgCode, "notEqualOrgId": org.OrgId}); err == nil && findOne != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "部门编码重复")
}
}
if err := org.Update(tool_funs.SimpleStructToMap(updateOrgCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -272,7 +275,7 @@ func (orgService *OrgService) UpdateOrg(updateOrgCommand *command.UpdateOrgComma
if updateOrgCommand.ParentId != 0 {
_, parentOrg, err := factory.FastPgOrg(transactionContext, updateOrgCommand.ParentId)
if err != nil {
return nil, err
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
org.Ext.ParentDepName = parentOrg.OrgName
}
... ...
... ... @@ -10,6 +10,7 @@ import (
)
type BatchAddCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType int `cname:"用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)" json:"userType" valid:"Required"`
// 用户列表
... ...
... ... @@ -10,7 +10,8 @@ import (
)
type BatchEnableCommand struct {
UserIds []int64 `cname:"" json:"userIds" valid:"Required"`
OperateInfo *domain.OperateInfo `json:"-"`
UserIds []int64 `cname:"用户id列表" json:"userIds" valid:"Required"`
// 启用状态(启用:1 禁用:2 注销:3)
EnableStatus int `cname:"启用状态(启用:1 禁用:2 注销:3)" json:"enableStatus" valid:"Required"`
}
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,7 +10,8 @@ import (
)
type BatchResetPasswordCommand struct {
UserIds []int64 `cname:"" json:"userIds" valid:"Required"`
OperateInfo *domain.OperateInfo `json:"-"`
UserIds []int64 `cname:"" json:"userIds" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
}
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
"time"
... ... @@ -10,6 +11,7 @@ import (
)
type CreateCooperatorCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 企业ID
CompanyId int64 `cname:"企业ID" json:"companyId" valid:"Required"`
// 共创公司
... ...
... ... @@ -3,12 +3,14 @@ package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
"time"
)
type CreateUserCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type DeleteFavoriteMenusCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 编码
Code int `cname:"编码" json:"code" valid:"Required"`
// 用户Id 用户唯一标识
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type RemoveUserCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string" valid:"Required"`
}
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
"time"
... ... @@ -10,16 +11,17 @@ import (
)
type UpdateCooperatorCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 共创公司
CooperationCompany string `cname:"共创公司" json:"cooperationCompany" valid:"Required"`
// 共创到期时间
CooperationDeadline time.Time `cname:"共创到期时间" json:"cooperationDeadline" valid:"Required"`
// 邮箱
Email string `cname:"邮箱" json:"email" valid:"Required"`
Email string `cname:"邮箱" json:"email"`
// 启用状态(启用:1 禁用:2 注销:3)
EnableStatus int `cname:"启用状态(启用:1 禁用:2 注销:3)" json:"enableStatus" valid:"Required"`
// 用户编号 企业内标识
UserCode string `cname:"用户编号 企业内标识" json:"userCode" valid:"Required"`
//UserCode string `cname:"用户编号" json:"userCode" valid:"Required"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
// 手机号码
... ... @@ -27,9 +29,9 @@ type UpdateCooperatorCommand struct {
// 用户姓名
UserName string `cname:"用户姓名" json:"userName" valid:"Required"`
// 头像
Avatar string `cname:"头像" json:"avatar" valid:"Required"`
Avatar string `cname:"头像" json:"avatar"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId" valid:"Required"`
//OrgId int64 `cname:"组织ID" json:"orgId" valid:"Required"`
}
func (updateCooperatorCommand *UpdateCooperatorCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type UpdateFavoriteMenusCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 菜单编码列表
FavoriteMenus []string `cname:"菜单编码列表" json:"favoriteMenus,omitempty"`
// 用户Id 用户唯一标识
... ...
... ... @@ -11,6 +11,7 @@ import (
)
type UpdateUserCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
// 组织机构
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type UpdateUsersBaseCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string" valid:"Required"`
// 用户姓名
... ...
... ... @@ -62,6 +62,7 @@ func (dto *UserDto) LoadDto(user *domain.User, company *domain.Company) error {
if user.UserInfo == nil {
dto.UserInfo = &domain.UserInfo{
UserName: user.Ext.UserName,
Phone: user.Ext.Phone,
}
}
dto.Organization = user.Organization
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type GetFavoriteMenusQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string" valid:"Required"`
}
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type GetUserQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string" valid:"Required"`
}
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type GetUserAccessMenusQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
// 当前登录组织orgId
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type GetUserProfileQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string,omitempty"`
// 手机号码
... ...
... ... @@ -2,6 +2,7 @@ package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -9,6 +10,7 @@ import (
)
type ListUserQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset"`
// 查询限制
... ... @@ -23,7 +25,7 @@ type ListUserQuery struct {
UserBaseId string `cname:"用户基础ID" json:"userBaseId,omitempty"`
// 用户姓名
UserName string `cname:"用户姓名" json:"userName,omitempty"`
// 用户姓名
// 共创公司
CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"`
// 部门名称
DepName string `cname:"部门名称" json:"depName,omitempty"`
... ...
... ... @@ -139,18 +139,22 @@ func (userService *UserService) CreateCooperator(createCooperatorCommand *comman
var sampleUserOrg = make([]*domain.Org, 0)
var sampleUserRole = make([]*domain.Role, 0)
newUser := &domain.User{
CompanyId: createCooperatorCommand.CompanyId,
UserType: domain.UserTypeCooperation,
UserCode: createCooperatorCommand.UserCode,
OrganizationId: createCooperatorCommand.OrgId,
UserOrg: sampleUserOrg,
UserRole: sampleUserRole,
FavoriteMenus: []string{},
CooperationInfo: &domain.CooperationInfo{},
UserInfo: nweUserInfo,
//EnableStatus: createUserCommand.EnableStatus,
CompanyId: createCooperatorCommand.CompanyId,
UserType: domain.UserTypeCooperation,
UserCode: createCooperatorCommand.UserCode,
OrganizationId: createCooperatorCommand.OrgId,
UserOrg: sampleUserOrg,
UserRole: sampleUserRole,
FavoriteMenus: []string{},
CooperationInfo: &domain.CooperationInfo{
CooperationCompany: createCooperatorCommand.CooperationCompany,
CooperationDeadline: createCooperatorCommand.CooperationDeadline,
},
UserInfo: nweUserInfo,
EnableStatus: createCooperatorCommand.EnableStatus,
Ext: &domain.Ext{
Phone: createCooperatorCommand.Phone,
Phone: createCooperatorCommand.Phone,
UserName: createCooperatorCommand.UserName,
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
... ... @@ -351,7 +355,7 @@ func (userService *UserService) GetUserAccessMenus(getUserAccessMenusQuery *quer
}()
// 1.用户角色包含的菜单Set
_, user, err := factory.FastPgUser(transactionContext, getUserAccessMenusQuery.UserId)
_, user, err := factory.FastPgUser(transactionContext, getUserAccessMenusQuery.OperateInfo.GetUserId(getUserAccessMenusQuery.UserId))
if err != nil {
return nil, err
}
... ... @@ -547,7 +551,7 @@ func (userService *UserService) UpdateCooperator(updateCooperatorCommand *comman
if err != nil {
return nil, err
}
user.OrganizationId = updateCooperatorCommand.OrgId
//user.OrganizationId = updateCooperatorCommand.OrgId
userInfo := &domain.UserInfo{
UserName: updateCooperatorCommand.UserName,
... ...
... ... @@ -155,9 +155,9 @@ func (org *Org) SetOrgStatus(orgStatus int) error {
if org.OrgStatus == orgStatus {
return nil
}
if !org.DeletedAt.IsZero() {
return fmt.Errorf("组织不存在")
}
//if !org.DeletedAt.IsZero() {
// return fmt.Errorf("组织不存在")
//}
org.UpdatedAt = time.Now()
org.OrgStatus = orgStatus
return nil
... ...
... ... @@ -111,17 +111,35 @@ func traverse(tree *Tree, node TreeNode) bool {
return match
}
// Int64String 1 -> "1" ""
// Int64String 1 -> "1" 1->1
type Int64String int64
func (t Int64String) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf(`"%d"`, t)
return []byte(stamp), nil
}
func (t Int64String) UnMarshalJSON(data []byte) error {
func (t *Int64String) UnMarshalJSON(data []byte) error {
v, err := strconv.ParseInt(string(data), 10, 64)
t = Int64String(v)
*t = Int64String(v)
return err
}
// Int64String 1 -> "1" "1"->1
type StringInt64 int64
func (t StringInt64) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf(`"%d"`, t)
return []byte(stamp), nil
}
func (t *StringInt64) UnmarshalJSON(data []byte) error {
if len(data) < 2 {
*t = 0
return fmt.Errorf("字符数字格式有误:" + string(data))
}
data = data[1 : len(data)-1]
v, err := strconv.ParseInt(string(data), 10, 64)
*t = StringInt64(v)
return err
}
... ...
... ... @@ -65,3 +65,37 @@ func TestInt64String(t *testing.T) {
t.Log(string(data))
}
}
func TestStringInt64(t *testing.T) {
type value struct {
Value StringInt64 `json:"v"`
}
jsonData := `{"v":"1"}`
var v = value{}
if err := json.Unmarshal([]byte(jsonData), &v); err != nil {
assert.Error(t, err)
}
assert.Equal(t, StringInt64(1), v.Value)
if data, err := json.Marshal(v); err != nil {
assert.Error(t, err)
} else {
t.Log(string(data))
}
}
func TestStringInt64_Array(t *testing.T) {
type value struct {
Value []StringInt64 `json:"v"`
}
jsonData := `{"v":["1","2","3"]}`
var v = value{}
if err := json.Unmarshal([]byte(jsonData), &v); err != nil {
assert.Error(t, err)
}
assert.Equal(t, []StringInt64{StringInt64(1), StringInt64(2), StringInt64(3)}, v.Value)
if data, err := json.Marshal(v); err != nil {
assert.Error(t, err)
} else {
t.Log(string(data))
}
}
... ...
... ... @@ -173,7 +173,7 @@ func (user *User) SetEnableStatus(enableStatus int) error {
if user.EnableStatus == enableStatus {
return nil //fmt.Errorf("重复设置状态")
}
if !(userStatus == UserStatusEnable || userStatus == UserStatusDisable || userStatus == UserStatusDestroy) {
if !(enableStatus == int(UserStatusEnable) || enableStatus == int(UserStatusDisable) || enableStatus == int(UserStatusDestroy)) {
return fmt.Errorf("非法启用状态")
}
user.EnableStatus = enableStatus
... ...
... ... @@ -78,6 +78,7 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain
// 4.建用户
newUser.UserBaseId = userBase.UserBaseId
newUser.Ext.UserName = userBase.UserInfo.UserName
if user, err = userRepository.Save(newUser); err != nil {
return nil, err
}
... ...
... ... @@ -163,6 +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)
//}
query.SetWhereByQueryOption("parent_id = ?", "parentId")
query.SetWhereByQueryOption("is_publish =?", "isPublish")
query.SetOrderDirect("parent_id", "asc")
... ...
... ... @@ -42,10 +42,10 @@ func (repository *OrgRepository) Save(org *domain.Org) (*domain.Org, error) {
"parent_id",
"parent_path",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "org_id"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "org_id"))
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "org_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "org_id", "deleted_at"))
returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "org_id")
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "org_id", "deleted_at")
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
tx := repository.transactionContext.PgTx
if org.Identify() == nil {
... ... @@ -75,7 +75,7 @@ func (repository *OrgRepository) Save(org *domain.Org) (*domain.Org, error) {
org.CompanyId,
org.CreatedAt,
org.UpdatedAt,
org.DeletedAt,
//org.DeletedAt,
org.OrgCode,
org.OrgName,
org.Ext,
... ... @@ -107,7 +107,7 @@ func (repository *OrgRepository) Save(org *domain.Org) (*domain.Org, error) {
org.CompanyId,
org.CreatedAt,
org.UpdatedAt,
org.DeletedAt,
//org.DeletedAt,
org.OrgCode,
org.OrgName,
org.Ext,
... ...
... ... @@ -15,6 +15,7 @@ func (controller *OrgController) CreateOrg() {
orgService := service.NewOrgService(nil)
createOrgCommand := &command.CreateOrgCommand{}
controller.Unmarshal(createOrgCommand)
createOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.CreateOrg(createOrgCommand)
controller.Response(data, err)
}
... ... @@ -25,6 +26,7 @@ func (controller *OrgController) UpdateOrg() {
controller.Unmarshal(updateOrgCommand)
orgId, _ := controller.GetInt64(":orgId")
updateOrgCommand.OrgId = orgId
updateOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.UpdateOrg(updateOrgCommand)
controller.Response(data, err)
}
... ... @@ -34,6 +36,7 @@ func (controller *OrgController) GetOrg() {
getOrgQuery := &query.GetOrgQuery{}
orgId, _ := controller.GetInt64(":orgId")
getOrgQuery.OrgId = orgId
getOrgQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.GetOrg(getOrgQuery)
controller.Response(data, err)
}
... ... @@ -44,6 +47,7 @@ func (controller *OrgController) RemoveOrg() {
controller.Unmarshal(removeOrgCommand)
orgId, _ := controller.GetInt64(":orgId")
removeOrgCommand.OrgId = orgId
removeOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.RemoveOrg(removeOrgCommand)
controller.Response(data, err)
}
... ... @@ -51,6 +55,7 @@ func (controller *OrgController) RemoveOrg() {
func (controller *OrgController) ListOrg() {
orgService := service.NewOrgService(nil)
listOrgQuery := &query.ListOrgQuery{}
listOrgQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.ListOrg(listOrgQuery)
controller.Response(data, err)
}
... ... @@ -62,6 +67,7 @@ func (controller *OrgController) GetOrgSubDepartment() {
getOrgSubDepartmentQuery.OrgId = orgId
childFlag, _ := controller.GetInt("childFlag")
getOrgSubDepartmentQuery.ChildFlag = childFlag
getOrgSubDepartmentQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.GetOrgSubDepartment(getOrgSubDepartmentQuery)
controller.Response(data, err)
}
... ... @@ -70,6 +76,7 @@ func (controller *OrgController) EnableOrg() {
orgService := service.NewOrgService(nil)
enableOrgCommand := &command.EnableOrgCommand{}
controller.Unmarshal(enableOrgCommand)
enableOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.EnableOrg(enableOrgCommand)
controller.Response(data, err)
}
... ... @@ -78,6 +85,7 @@ func (controller *OrgController) SearchOrg() {
orgService := service.NewOrgService(nil)
listOrgQuery := &query.ListOrgQuery{}
Must(controller.Unmarshal(listOrgQuery))
listOrgQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.ListOrg(listOrgQuery)
controller.Response(data, err)
}
... ...
... ... @@ -15,6 +15,7 @@ func (controller *UserController) CreateUser() {
userService := service.NewUserService(nil)
createUserCommand := &command.CreateUserCommand{}
Must(controller.Unmarshal(createUserCommand))
createUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.CreateUser(createUserCommand)
controller.Response(data, err)
}
... ... @@ -25,6 +26,7 @@ func (controller *UserController) UpdateUser() {
Must(controller.Unmarshal(updateUserCommand))
userId, _ := controller.GetInt64(":userId")
updateUserCommand.UserId = userId
updateUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.UpdateUser(updateUserCommand)
controller.Response(data, err)
}
... ... @@ -34,6 +36,7 @@ func (controller *UserController) GetUser() {
getUserQuery := &query.GetUserQuery{}
userId, _ := controller.GetInt64(":userId")
getUserQuery.UserId = userId
getUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.GetUser(getUserQuery)
controller.Response(data, err)
}
... ... @@ -44,6 +47,7 @@ func (controller *UserController) RemoveUser() {
controller.Unmarshal(removeUserCommand)
userId, _ := controller.GetInt64(":userId")
removeUserCommand.UserId = userId
removeUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.RemoveUser(removeUserCommand)
controller.Response(data, err)
}
... ... @@ -51,6 +55,7 @@ func (controller *UserController) RemoveUser() {
func (controller *UserController) ListUser() {
userService := service.NewUserService(nil)
listUserQuery := &query.ListUserQuery{}
listUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.ListUser(listUserQuery)
controller.Response(data, err)
}
... ... @@ -64,6 +69,7 @@ func (controller *UserController) GetUserAccessMenus() {
getUserAccessMenusQuery.MenuCategory = menuCategory
getUserAccessMenusQuery.OrgId, _ = controller.GetInt64("orgId", 0)
getUserAccessMenusQuery.ALLDisableMenu, _ = controller.GetInt("allDisableMenu", 0)
getUserAccessMenusQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.GetUserAccessMenus(getUserAccessMenusQuery)
controller.Response(data, err)
}
... ... @@ -73,6 +79,7 @@ func (controller *UserController) GetUserProfile() {
getUserProfileQuery := &query.GetUserProfileQuery{}
userId, _ := controller.GetInt64(":userId")
getUserProfileQuery.UserId = userId
getUserProfileQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.GetUserProfile(getUserProfileQuery)
controller.Response(data, err)
}
... ... @@ -81,6 +88,7 @@ func (controller *UserController) BatchAdd() {
userService := service.NewUserService(nil)
batchAddCommand := &command.BatchAddCommand{}
Must(controller.Unmarshal(batchAddCommand))
batchAddCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.BatchAdd(batchAddCommand)
controller.Response(data, err)
}
... ... @@ -89,6 +97,7 @@ func (controller *UserController) BatchEnable() {
userService := service.NewUserService(nil)
batchEnableCommand := &command.BatchEnableCommand{}
controller.Unmarshal(batchEnableCommand)
batchEnableCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.BatchEnable(batchEnableCommand)
controller.Response(data, err)
}
... ... @@ -97,6 +106,7 @@ func (controller *UserController) BatchResetPassword() {
userService := service.NewUserService(nil)
batchResetPasswordCommand := &command.BatchResetPasswordCommand{}
controller.Unmarshal(batchResetPasswordCommand)
batchResetPasswordCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.BatchResetPassword(batchResetPasswordCommand)
controller.Response(data, err)
}
... ... @@ -107,6 +117,7 @@ func (controller *UserController) UpdateUsersBase() {
controller.Unmarshal(updateUsersBaseCommand)
userId, _ := controller.GetInt64(":userId")
updateUsersBaseCommand.UserId = userId
updateUsersBaseCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.UpdateUsersBase(updateUsersBaseCommand)
controller.Response(data, err)
}
... ... @@ -115,6 +126,7 @@ func (controller *UserController) CreateCooperator() {
userService := service.NewUserService(nil)
createCooperatorCommand := &command.CreateCooperatorCommand{}
Must(controller.Unmarshal(createCooperatorCommand))
createCooperatorCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.CreateCooperator(createCooperatorCommand)
controller.Response(data, err)
}
... ... @@ -125,6 +137,7 @@ func (controller *UserController) UpdateCooperator() {
controller.Unmarshal(updateCooperatorCommand)
userId, _ := controller.GetInt64(":userId")
updateCooperatorCommand.UserId = userId
updateCooperatorCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.UpdateCooperator(updateCooperatorCommand)
controller.Response(data, err)
}
... ... @@ -133,6 +146,7 @@ func (controller *UserController) SearchUser() {
userService := service.NewUserService(nil)
listUserQuery := &query.ListUserQuery{}
Must(controller.Unmarshal(listUserQuery))
listUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.ListUser(listUserQuery)
controller.Response(data, err)
}
... ...