用户juese
This commit is contained in:
@@ -133,3 +133,15 @@ func UpdateRole(ctx *jxcontext.Context, roleID int, name string, isDelete bool)
|
||||
dao.Commit(db)
|
||||
return num, err
|
||||
}
|
||||
|
||||
func GetUserRole(ctx *jxcontext.Context, userID string) (userRoles []*model.UserRole, err error) {
|
||||
return dao.GetUserRole(dao.GetDB(), userID)
|
||||
}
|
||||
|
||||
func UpdateUserRole(ctx *jxcontext.Context, userIDs []string, roleIDs []int) (err error) {
|
||||
// var (
|
||||
// db = dao.GetDB()
|
||||
// )
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -42,3 +42,20 @@ func GetRole(db *DaoDB, name string) (roles []*model.Role, err error) {
|
||||
err = GetRows(db, &roles, sql, sqlParams)
|
||||
return roles, err
|
||||
}
|
||||
|
||||
func GetUserRole(db *DaoDB, userID string) (userRoles []*model.UserRole, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM user_role
|
||||
WHERE deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if userID != "" {
|
||||
sql += " AND user_id = ?"
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
err = GetRows(db, &userRoles, sql, sqlParams)
|
||||
return userRoles, err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
@@ -102,3 +103,38 @@ func (c *PowerController) UpdateRole() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询用户角色
|
||||
// @Description查询用户角色
|
||||
// @Param token header string true "认证token"
|
||||
// @Param userID formData string false "用户ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetUserRole [put]
|
||||
func (c *PowerController) GetUserRole() {
|
||||
c.callGetUserRole(func(params *tPowerGetUserRoleParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetUserRole(params.Ctx, params.UserID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 修改用户角色
|
||||
// @Description 修改用户角色
|
||||
// @Param token header string true "认证token"
|
||||
// @Param userIDs formData string true "用户IDs"
|
||||
// @Param roleIDs formData string true "角色IDs"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateUserRole [put]
|
||||
func (c *PowerController) UpdateUserRole() {
|
||||
c.callUpdateUserRole(func(params *tPowerUpdateUserRoleParams) (retVal interface{}, errCode string, err error) {
|
||||
var (
|
||||
userIDs []string
|
||||
roleIDs []int
|
||||
)
|
||||
if err = jxutils.Strings2Objs(params.UserIDs, &userIDs, params.RoleIDs, roleIDs); err == nil {
|
||||
err = cms.UpdateUserRole(params.Ctx, userIDs, roleIDs)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user