Kaynağa Gözat

员工管理

XMLWAN 4 yıl önce
ebeveyn
işleme
f3ff6c7829

+ 1 - 2
controllers/new_mobile_api_controllers/new_role_api_controller.go Dosyayı Görüntüle

172
 	userTitle := this.GetString("title")
172
 	userTitle := this.GetString("title")
173
 	user_type, _ := this.GetInt("user_type", 0)
173
 	user_type, _ := this.GetInt("user_type", 0)
174
 	user_title, _ := this.GetInt("user_title", 0)
174
 	user_title, _ := this.GetInt("user_title", 0)
175
-	sort, _ := this.GetInt64("sort")
176
 	if len(mobile) == 0 || len(name) == 0 || len(role_ids) <= 0 {
175
 	if len(mobile) == 0 || len(name) == 0 || len(role_ids) <= 0 {
177
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
176
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
178
 		return
177
 		return
185
 		return
184
 		return
186
 	} else {
185
 	} else {
187
 		if adminUser == nil { //新增账号和用户
186
 		if adminUser == nil { //新增账号和用户
188
-			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.Org.Id, adminUserInfo.App.Id, mobile, name, userTitle, role_ids, user_type, user_title, sort)
187
+			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.Org.Id, adminUserInfo.App.Id, mobile, name, userTitle, role_ids, user_type, user_title)
189
 			if createErr != nil {
188
 			if createErr != nil {
190
 				//beego.Error("创建管理员失败:", createErr)
189
 				//beego.Error("创建管理员失败:", createErr)
191
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
190
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)

+ 1 - 5
controllers/role_controller.go Dosyayı Görüntüle

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"fmt"
5
 	"github.com/jinzhu/gorm"
4
 	"github.com/jinzhu/gorm"
6
 	"strconv"
5
 	"strconv"
7
 	"strings"
6
 	"strings"
487
 	userTitle, _ := this.GetInt("title")
486
 	userTitle, _ := this.GetInt("title")
488
 	roleIds := this.GetString("role")
487
 	roleIds := this.GetString("role")
489
 	user_title_name := this.GetString("user_title_name")
488
 	user_title_name := this.GetString("user_title_name")
490
-	sort, _ := this.GetInt64("sort")
491
-	fmt.Println("sort--------------------------------", sort)
492
-	fmt.Println("sort", sort)
493
 	if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || len(roleIds) <= 0 {
489
 	if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || len(roleIds) <= 0 {
494
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
490
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
495
 		return
491
 		return
502
 		return
498
 		return
503
 	} else {
499
 	} else {
504
 		if adminUser == nil { //新增账号和用户
500
 		if adminUser == nil { //新增账号和用户
505
-			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle, sort)
501
+			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle)
506
 			if createErr != nil {
502
 			if createErr != nil {
507
 				//beego.Error("创建管理员失败:", createErr)
503
 				//beego.Error("创建管理员失败:", createErr)
508
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
504
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)

+ 2 - 3
service/role_service.go Dosyayı Görüntüle

141
 		page = 1
141
 		page = 1
142
 	}
142
 	}
143
 	var viewModels []*AdminUserManageViewModel = make([]*AdminUserManageViewModel, 0)
143
 	var viewModels []*AdminUserManageViewModel = make([]*AdminUserManageViewModel, 0)
144
-	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name, u_a_r.user_title, u_l.ip, u_l.ctime, u_a_r.status,u_a_r.avatar,u_a_r.role_ids,u_a_r.sort FROM sgj_user_admin_role AS u_a_r   LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, ctime FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ?  ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l  ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? GROUP BY u_a_r.admin_user_id order by u_a_r.sort LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
144
+	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name, u_a_r.user_title, u_l.ip, u_l.ctime, u_a_r.status,u_a_r.avatar,u_a_r.role_ids,u_a_r.sort FROM sgj_user_admin_role AS u_a_r   LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, ctime FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ?  ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l  ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? GROUP BY u_a_r.admin_user_id  LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
145
 	defer rows.Close()
145
 	defer rows.Close()
146
 	if err != nil {
146
 	if err != nil {
147
 		if err == gorm.ErrRecordNotFound {
147
 		if err == gorm.ErrRecordNotFound {
309
 	return user.IsSuperAdmin, nil
309
 	return user.IsSuperAdmin, nil
310
 }
310
 }
311
 
311
 
312
-func CreateGeneralAdminUser(orgID int64, appID int64, mobile string, name string, userTitle string, roleIds string, user_type int, user_title int, sort int64) (*models.AdminUser, string, error) {
312
+func CreateGeneralAdminUser(orgID int64, appID int64, mobile string, name string, userTitle string, roleIds string, user_type int, user_title int) (*models.AdminUser, string, error) {
313
 	now := time.Now().Unix()
313
 	now := time.Now().Unix()
314
 	tx := writeUserDb.Begin()
314
 	tx := writeUserDb.Begin()
315
 	var adminUser models.AdminUser
315
 	var adminUser models.AdminUser
345
 		CreateTime:    now,
345
 		CreateTime:    now,
346
 		ModifyTime:    now,
346
 		ModifyTime:    now,
347
 		RoleIds:       roleIds,
347
 		RoleIds:       roleIds,
348
-		Sort:          sort,
349
 	}
348
 	}
350
 	if createApp_RoleErr := tx.Create(&app_role).Error; createApp_RoleErr != nil {
349
 	if createApp_RoleErr := tx.Create(&app_role).Error; createApp_RoleErr != nil {
351
 		tx.Rollback()
350
 		tx.Rollback()