作者 tangxuhui

Merge branch 'dev' into test

FROM 192.168.0.243:5000/mmm/allied-creation-user:20210809
ENV APP_DIR $GOPATH/src/project-20210825
ENV APP_DIR $GOPATH/src/project-20210906
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
COPY ./config config
COPY ./go.mod go.mod
COPY ./go.sum go.sum
COPY ./main.go main.go
... ...
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAy0OxRf+NheQG9epxbrudwnrzqVgqK5zCuRAkLUgaSMATVXEA
iDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8tJq0E+bSDtSK3n+2mjZb6pChmgHw
KEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpog1RlfKgft6NYUzNLUqE5Mxzq7lpD
eRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttKeg+hKqIottQ/H6Tq4c8deEQGnO0+
RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr6uCOq5MSt2WsU8CTuhRwGXSvcQCO
FLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm+QIDAQABAoIBAQC8X7+qX2uI6gqJ
XPxC4x0RX2DxUAPE50KOv6bHUEsLoPZJ+K/Fko/oHuuTja47Lax3inhKb4gSDUhS
x754YivgNH8u8ns5wz/vc+yGflowyFj7oVAwAqslA2luDnD0Df6crcAx+wAQQCjN
RRF9T2QMUeq73BOI3Ji+gosLyN55vms2KadrwpPQwYN7qhdrerE7vPqCZeswzs1/
A5M9PVGBG+simNea5kv+tVJUdLi6ckGAB5KabyhpG779ckwzV/aZy3wIj4SvUvCd
bewH0xPHx5TqnMOXtzHgktClmL7hIYxy9sL14Dn0KVHbyolQ7IqmJtjXYqG84Fmx
AfyDfeABAoGBAPP820tKElrfTuZ+Z19kJBTp6I5iax2Ph10glUHLlLqJ82clI/Gl
CbMtnGmD72HfnJei82xqoVLsUkN9Sp+TSNJALh4N8rHkAtwq5kWToiAWZydwxVsp
x5OWEN3+QFId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QojPpbxB+zirynvgqV/0DCktDAdBgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rID
ZsswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAG
BgRVHSAAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29t
L0FBQUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDQGCCsGAQUFBwEBBCgwJjAkBggr
BgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqGSIb3DQEBDAUA
A4IBAQAYh1HcdCE9nIrgJ7cz0C7M7PDmy14R3iJvm3WOnnL+5Nb+qh+cli3vA0p+
rvSNb3I8QzvAP+u431yqqcau8vzY7qN7Q/aGNnwU4M309z/+3ri0ivCRlv79Q2R+
/czSAaF9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA
CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F
zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA
vGp4z7h/jnZymQyd/teRCBaho1+V
-----END CERTIFICATE-----
... ...
... ... @@ -10,7 +10,7 @@ import (
type DestroyAccountCommand struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
Account string `cname:"账号" json:"account" valid:"Required"`
}
func (destroyAccountCommand *DestroyAccountCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -7,6 +7,7 @@ import (
type UserBaseDto struct {
// 用户基础数据id
UserBaseId int64 `json:"userBaseId,omitempty"`
UserType int `json:"userType"`
// 用户信息
UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
// 手机号码
... ... @@ -28,5 +29,6 @@ type UserBaseDto struct {
func (u *UserBaseDto) LoadDto(ub *domain.UserBase) {
u.UserBaseId = ub.UserBaseId
u.UserInfo = ub.UserInfo
u.UserType = domain.UserTypeVisitor
u.Im = ub.Im
}
... ...
... ... @@ -9,11 +9,15 @@ import (
)
type UserInfoQuery struct {
Account string `cname:"账号" json:"account" valid:"Required"`
Account string `cname:"账号" json:"account"`
UserBaseId int64 `cname:"用户编号" json:"userBaseId"`
}
func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
if len(userInfoQuery.Account) == 0 && userInfoQuery.UserBaseId <= 0 {
validation.SetError("CustomValid", "参数不能为空")
}
}
func (userInfoQuery *UserInfoQuery) ValidateQuery() error {
... ...
... ... @@ -81,7 +81,7 @@ func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.De
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.UserId); err != nil {
if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.Account); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -319,8 +319,13 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in
transactionContext.RollbackTransaction()
}()
var userBase *domain.UserBase
userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0)
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account})
if len(userInfoQuery.Account) > 0 {
userBase, err = userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account})
} else if userInfoQuery.UserBaseId > 0 {
userBase, err = userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userInfoQuery.UserBaseId})
}
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ...
... ... @@ -25,6 +25,8 @@ type ListOrgQuery struct {
ParentId int64 `cname:"父级ID" json:"parentId,omitempty"`
// 是否是组织(是:1 不是:2)
IsOrg int `cname:"是否是组织(是:1 不是:2)" json:"isOrg,omitempty"`
// 模糊匹配组织名称
MatchOrgName string `cname:"部门名称" json:"matchOrgName,omitempty"`
}
func (listOrgQuery *ListOrgQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -185,7 +185,7 @@ func (orgService *OrgService) GetOrgSubDepartment(getOrgSubDepartmentQuery *quer
treeNodes[i] = orgs[i]
}
tree := domain.NewTrees(treeNodes)
nodes := tree.AllChildNodes(org)
nodes := tree.AllSubDepartment(org)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ...
... ... @@ -12,7 +12,7 @@ import (
type GetRoleRelatedUsersQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId,string,omitempty"`
OrgId int64 `cname:"组织ID" json:"orgId,omitempty"`
// 角色ID
RoleId int64 `cname:"角色ID" json:"roleId" valid:"Required"`
... ... @@ -20,6 +20,8 @@ type GetRoleRelatedUsersQuery struct {
DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"`
// 只需要关联的用户 true:仅返回关联用户信息 false:返回所有其他信息(未关联的用户)
//OnlyRelatedUser bool `cname:"部门编号" json:"onlyRelatedUser,omitempty"`
// 组织ID
InOrgIds []int64 `cname:"组织ID" json:"orgIds,omitempty"`
}
func (getRoleRelatedUsersQuery *GetRoleRelatedUsersQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -27,6 +27,8 @@ type ListRoleQuery struct {
OrgId int64 `cname:"组织ID" json:"orgId,omitempty"`
// 匹配多个组织
InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"`
// 角色名称
MatchRoleName string `cname:"匹配角色名称" json:"matchRoleName,omitempty"`
}
func (listRoleQuery *ListRoleQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -218,10 +218,15 @@ func (roleService *RoleService) GetRoleRelatedUsers(getRoleRelatedUsersQuery *qu
}
queryOptions := make(map[string]interface{})
queryOptions["companyId"] = role.CompanyId
queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId
if getRoleRelatedUsersQuery.DepartmentId > 0 {
queryOptions["departmentId"] = getRoleRelatedUsersQuery.DepartmentId
}
// 按组织过滤
if len(getRoleRelatedUsersQuery.InOrgIds) > 0 {
queryOptions["inOrgIds"] = getRoleRelatedUsersQuery.InOrgIds
} else {
queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId
}
queryOptions["userType"] = domain.UserTypeEmployee
_, users, err := userRepository.Find(queryOptions)
if err != nil {
... ...
... ... @@ -39,6 +39,8 @@ type ListUserQuery struct {
PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"`
// 状态(1:启用 2:禁用 3:注销)
EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"`
// 状态(1:启用 2:禁用 3:注销)
InEnableStatus []int `cname:"状态(1:启用 2:禁用 3:注销)" json:"inEnableStatus,omitempty"`
}
func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -65,10 +65,15 @@ func (userService *UserService) BatchAdd2(batchAddCommand *command.BatchAdd2Comm
batchAddUserService, _ := factory.CreateBatchAddUserService(map[string]interface{}{
"transactionContext": transactionContext,
})
if err = batchAddUserService.BatchAddUser2(batchAddCommand.OperateInfo, batchAddCommand.Users, batchAddCommand.Password); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
var failRows []*domain.BatchAddUserItem
if failRows, err = batchAddUserService.BatchAddUser2(batchAddCommand.OperateInfo, batchAddCommand.Users, batchAddCommand.Password); err != nil {
return batchAddCommand.Users, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if len(failRows) != 0 {
return map[string]interface{}{
"failRows": failRows,
}, nil //有错误行,回滚
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -360,12 +365,24 @@ func (userService *UserService) GetUser(getUserQuery *query.GetUserQuery) (inter
_, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId)
_, company, _ := factory.FastPgCompany(transactionContext, user.CompanyId)
_, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId)
if dep != nil && org != nil && userBase != nil {
user.Department = dep.ConvDep()
user.Organization = org.CloneSample()
if company != nil {
user.Company = company.CloneSample()
}
if org != nil {
user.Organization = org.CloneSample()
}
if dep != nil {
user.Department = dep.ConvDep()
}
if userBase != nil {
user.UserInfo = userBase.UserInfo
}
// TODO:后期可以移除有冗余roleType
for i := range user.UserRole {
if _, role, _ := factory.FastPgRole(transactionContext, user.UserRole[i].RoleId); role != nil {
user.UserRole[i].RoleType = role.RoleType
}
}
userDto := &dto.UserDto{Im: userBase.Im}
if err := userDto.LoadDto(user, company); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -402,7 +419,7 @@ func (userService *UserService) GetUserAccessMenus(getUserAccessMenusQuery *quer
"transactionContext": transactionContext,
})
menus, err := roleAccessMenusService.AccessMenus(nil, user.UserRoleIds(), domain.AccessMenusOptions{
menus, err := roleAccessMenusService.AccessMenus(getUserAccessMenusQuery.OperateInfo, user.UserRoleIds(), domain.AccessMenusOptions{
CompanyId: user.CompanyId,
MenuCategory: getUserAccessMenusQuery.MenuCategory,
OrgId: getUserAccessMenusQuery.OrgId,
... ...
... ... @@ -127,6 +127,7 @@ func (role *Role) CloneSample() *Role {
RoleId: role.RoleId,
RoleName: role.RoleName,
Ext: role.Ext,
RoleType: role.RoleType,
}
}
... ...
... ... @@ -4,5 +4,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
// PgAuthAccountDestroyService 账号注销服务
type PgAuthAccountDestroyService interface {
DestroyAccount(optUser *domain.User, userId int64) error
DestroyAccount(optUser *domain.User, userId string) error
}
... ...
... ... @@ -5,5 +5,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
// PgBatchAddUserService 批量添加用户服务
type PgBatchAddUserService interface {
BatchAddUser(optUser *domain.OperateInfo, users []*domain.User, password string) error
BatchAddUser2(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) error
BatchAddUser2(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) ([]*domain.BatchAddUserItem, error)
}
... ...
... ... @@ -111,6 +111,35 @@ func traverse(tree *Tree, node TreeNode) bool {
return match
}
// 返回tree下的所有子部门 (如果节点是组织,跳过)
func (tree *Tree) AllSubDepartment(node TreeNode) []TreeNode {
treeNode := tree.find(node)
if treeNode == nil {
return []TreeNode{}
}
var stack []*Tree
stack = append(stack, treeNode)
var res []TreeNode
rootId := treeNode.Node.(*Org).OrgId
for {
if len(stack) == 0 {
break
}
pop := stack[0]
stack = stack[1:]
/***特殊处理***/
if org, ok := pop.Node.(*Org); ok && org.OrgId != int64(rootId) {
if org.IsOrg == IsOrgFlag {
continue
}
}
/***特殊处理***/
stack = append(stack, pop.Nodes...)
res = append(res, pop.Node)
}
return res
}
// Int64String 1 -> "1" 1->1
type Int64String int64
... ...
... ... @@ -14,6 +14,7 @@ const (
const (
UserTypeEmployee = 1
UserTypeCooperation = 2
UserTypeVisitor = 4 // 游客
UserTypeCompanyAdmin = 1024
)
... ... @@ -293,21 +294,24 @@ type BatchAddUserItem struct {
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType int `json:"userType,omitempty"`
// 用户姓名
UserName string `json:"userName,omitempty"`
UserName string `json:"userName"`
// 手机号码
Phone string `json:"phone,omitempty"`
Phone string `json:"phone"`
// 邮箱
Email string `json:"email,omitempty"`
Email string `json:"email"`
// 用户编号 企业内标识
UserCode string `json:"userCode,omitempty"`
UserCode string `json:"userCode"`
// 组织编码
Org string `json:"org,omitempty"`
Org string `json:"org"`
// 部门编码
Department string `json:"department,omitempty"`
Department string `json:"department"`
// 状态(1:启用 2:禁用 3:注销)
EnableStatus int `json:"enableStatus,omitempty"`
// 共创公司 cooperationCompany
CooperationCompany string `json:"cooperationCompany"`
// 共创到期时间 (yyyy-MM-dd) cooperationDeadline
CooperationDeadline time.Time `json:"cooperationDeadline"`
// 失败理由
FailReason string `json:"failReason"`
}
... ...
... ... @@ -13,21 +13,21 @@ type PgAuthAccountDestroyService struct {
transactionContext *pgTransaction.TransactionContext
}
func (ptr *PgAuthAccountDestroyService) DestroyAccount(optUser *domain.User, userId int64) error {
func (ptr *PgAuthAccountDestroyService) DestroyAccount(optUser *domain.User, account string) error {
// 1.查询账号记录
userRepository, _ := repository.NewUserRepository(ptr.transactionContext)
var userBaseId int64
if user, err := userRepository.FindOne(map[string]interface{}{"userId": userId}); err != nil {
if err == domain.ErrorNotFound {
return fmt.Errorf("该用户不存在")
}
return err
} else {
userBaseId = user.UserBaseId
}
//var userBaseId int64
//if user, err := userRepository.FindOne(map[string]interface{}{"userId": userId}); err != nil {
// if err == domain.ErrorNotFound {
// return fmt.Errorf("该用户不存在")
// }
// return err
//} else {
// userBaseId = user.UserBaseId
//}
userBaseRepository, _ := repository.NewUserBaseRepository(ptr.transactionContext)
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userBaseId})
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": account})
if err != nil {
return err
}
... ...
... ... @@ -14,9 +14,6 @@ type PgBatchAddOrgService struct {
}
func (ptr *PgBatchAddOrgService) BatchAddOrg(optUser *domain.OperateInfo, orgList []*domain.BatchAddOrgItem) error {
var (
err error
)
orgRepository, err := repository.NewOrgRepository(ptr.transactionContext)
if err != nil {
return err
... ... @@ -37,7 +34,7 @@ func (ptr *PgBatchAddOrgService) BatchAddOrg(optUser *domain.OperateInfo, orgLis
CompanyId: optUser.CompanyId,
OrgCode: item.OrgCode,
OrgName: item.OrgName,
IsOrg: domain.IsOrgFlag,
IsOrg: domain.IsNotOrgFlag,
ParentId: 0,
OrgStatus: domain.OrgStatusEnable,
CreatedAt: time.Now(),
... ...
... ... @@ -82,17 +82,18 @@ func (ptr *PgBatchAddUserService) BatchAddUser(optUser *domain.OperateInfo, user
return nil
}
func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) error {
func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) ([]*domain.BatchAddUserItem, error) {
var (
err error
)
var failRows = make([]*domain.BatchAddUserItem, 0)
orgRepository, err := repository.NewOrgRepository(ptr.transactionContext)
if err != nil {
return err
return failRows, err
}
_, orgs, err := orgRepository.Find(map[string]interface{}{"companyId": optUser.CompanyId, "limit": 10000})
if err != nil {
return err
return failRows, err
}
var mapOrg = make(map[string]*domain.Org)
for i := range orgs {
... ... @@ -103,15 +104,24 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
for i := range users {
user := users[i]
if err = ptr.preCheck2(user); err != nil {
return err
user.FailReason = err.Error()
failRows = append(failRows, user)
continue
//return err
}
var org, dep *domain.Org
var ok bool
if org, ok = mapOrg[user.Org]; !ok {
return fmt.Errorf("导入的组织机构不存在:" + user.Org)
user.FailReason = "导入的组织机构不存在:" + user.Org
failRows = append(failRows, user)
continue
//return fmt.Errorf("导入的组织机构不存在:" + user.Org)
}
if dep, ok = mapOrg[user.Department]; !ok {
return fmt.Errorf("导入的所属部门不存在:" + user.Department)
user.FailReason = "导入的所属部门不存在:" + user.Department
failRows = append(failRows, user)
continue
//return fmt.Errorf("导入的所属部门不存在:" + user.Department)
}
newUser := &domain.User{
CompanyId: user.CompanyId,
... ... @@ -143,10 +153,13 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
UpdatedAt: time.Now(),
}
if newUser, err = createUserService.CreateUser(nil, newUser, password); err != nil {
return fmt.Errorf("%v %v", user.UserName, err.Error())
user.FailReason = err.Error()
failRows = append(failRows, user)
continue
//return fmt.Errorf("%v %v", user.UserName, err.Error())
}
}
return nil
return failRows, nil
}
func (ptr *PgBatchAddUserService) preCheck(user *domain.User) error {
... ...
... ... @@ -191,6 +191,9 @@ func (repository *OrgRepository) Find(queryOptions map[string]interface{}) (int6
query.SetWhereByQueryOption("org_name = ?", "depName")
query.SetWhereByQueryOption("org_code = ?", "orgCode")
query.SetWhereByQueryOption("parent_id = ?", "parentId")
if v, ok := queryOptions["matchOrgName"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`org_name like '%%%v%%'`, v))
}
query.SetOrderDirect("org_id", "ASC")
if count, err := query.SelectAndCount(); err != nil {
return 0, orgs, err
... ...
... ... @@ -185,6 +185,9 @@ func (repository *RoleRepository) Find(queryOptions map[string]interface{}) (int
if orgName, ok := queryOptions["orgName"]; ok && len(orgName.(string)) > 0 {
query.Where(fmt.Sprintf("ext->>'orgName' like '%%%v%%'", orgName))
}
if matchRoleName, ok := queryOptions["matchRoleName"]; ok && len(matchRoleName.(string)) > 0 {
query.Where(fmt.Sprintf("role_name like '%%%v%%'", matchRoleName))
}
// 包含删除的
if v, ok := queryOptions["includeDeleted"]; ok && !(v.(bool)) {
query.Where("deleted_at is null")
... ...
... ... @@ -204,7 +204,9 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int
query.SetWhereByQueryOption("(user_type & ?)>0", "userType")
query.SetWhereByQueryOption("enable_status=?", "enableStatus")
query.SetWhereByQueryOption(fmt.Sprintf(`user_role @> '[{"roleId":%v}]'`, queryOptions["roleId"]), "roleId")
if v, ok := queryOptions["inEnableStatus"]; ok && len(v.([]int)) > 0 {
query.Where(`enable_status in (?)`, pg.In(v))
}
if v, ok := queryOptions["depName"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`ext->>'depName' like '%%%v%%'`, v))
}
... ...
package beego
import (
"os"
"strconv"
"github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context"
"github.com/linmadan/egglib-go/log"
... ... @@ -9,8 +12,6 @@ import (
. "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego/routers"
"os"
"strconv"
)
func init() {
... ... @@ -29,6 +30,11 @@ func init() {
web.BConfig.Listen.HTTPPort = port
}
}
//https支持
web.BConfig.Listen.EnableHTTPS = true
web.BConfig.Listen.HTTPSPort = 443
web.BConfig.Listen.HTTPSCertFile = "./config/fjmaimaimai.com_bundle.crt"
web.BConfig.Listen.HTTPSKeyFile = "./config/fjmaimaimai.com.key"
web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors())
web.InsertFilter("/*", web.BeforeExec, CreateRequestLogFilter(Logger))
web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(Logger), web.WithReturnOnOutput(false))
... ...
... ... @@ -92,6 +92,17 @@ func (controller *RoleController) GetRoleRelatedUsers() {
controller.Response(data, err)
}
func (controller *RoleController) RoleRelatedUsers() {
roleService := service.NewRoleService(nil)
getRoleRelatedUsersQuery := &query.GetRoleRelatedUsersQuery{}
controller.Unmarshal(getRoleRelatedUsersQuery)
roleId, _ := controller.GetInt64(":roleId")
getRoleRelatedUsersQuery.RoleId = roleId
getRoleRelatedUsersQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.GetRoleRelatedUsers(getRoleRelatedUsersQuery)
controller.Response(data, err)
}
func (controller *RoleController) GetRoleAccessMenus() {
roleService := service.NewRoleService(nil)
getRoleAccessMenusQuery := &query.GetRoleAccessMenusQuery{}
... ...
... ... @@ -13,5 +13,5 @@ func init() {
web.Router("/auth/reset-phone", &controllers.AuthController{}, "Post:PhoneAuthResetPhone")
web.Router("/auth/destroy-account", &controllers.AuthController{}, "Post:DestroyAccount")
web.Router("/auth/refresh-im", &controllers.AuthController{}, "Post:RefreshIM")
web.Router("/auth/user-base-info", &controllers.AuthController{}, "Post:UserInfo")
web.Router("/auth/user-info", &controllers.AuthController{}, "Post:UserInfo")
}
... ...
... ... @@ -12,6 +12,7 @@ func init() {
web.Router("/role/:roleId", &controllers.RoleController{}, "Delete:RemoveRole")
web.Router("/role/search", &controllers.RoleController{}, "Post:SearchRole")
web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Get:GetRoleRelatedUsers")
web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Post:RoleRelatedUsers")
web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Get:GetRoleAccessMenus")
web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Put:UpdateRoleAccessMenus")
web.Router("/role/assign", &controllers.RoleController{}, "Post:AssginRoleToUsers")
... ...