优化代码
This commit is contained in:
		
							parent
							
								
									742458ee1d
								
							
						
					
					
						commit
						9cf26fba4c
					
				@ -13,7 +13,6 @@ import (
 | 
				
			|||||||
	. "github.com/gofiber/fiber/v2"
 | 
						. "github.com/gofiber/fiber/v2"
 | 
				
			||||||
	"github.com/tidwall/gjson"
 | 
						"github.com/tidwall/gjson"
 | 
				
			||||||
	"go.uber.org/zap"
 | 
						"go.uber.org/zap"
 | 
				
			||||||
	"strings"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//BI用户控制器
 | 
					//BI用户控制器
 | 
				
			||||||
@ -185,10 +184,6 @@ func (this ManagerUserController) UserUpdateAction(ctx *Ctx) error {
 | 
				
			|||||||
		return this.Error(ctx, err)
 | 
							return this.Error(ctx, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if strings.TrimSpace(reqData.Password) == "" {
 | 
					 | 
				
			||||||
		return this.Error(ctx, errors.New("密码不能为空"))
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var userModel model.GmUserModel
 | 
						var userModel model.GmUserModel
 | 
				
			||||||
	var id = reqData.Id
 | 
						var id = reqData.Id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -36,12 +36,10 @@ func Rbac(ctx *fiber.Ctx) error {
 | 
				
			|||||||
		if obj == routerConfig.Url {
 | 
							if obj == routerConfig.Url {
 | 
				
			||||||
			ok, err := rbac.Enforcer.EnforceSafe(strconv.Itoa(sub), obj, "*")
 | 
								ok, err := rbac.Enforcer.EnforceSafe(strconv.Itoa(sub), obj, "*")
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				res.Error(ctx, my_error.NewBusiness(TOKEN_ERROR, ERROR_RBAC_LOAD))
 | 
									return res.Error(ctx, my_error.NewBusiness(TOKEN_ERROR, ERROR_RBAC_LOAD))
 | 
				
			||||||
				return err
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if !ok {
 | 
								if !ok {
 | 
				
			||||||
				res.Error(ctx, my_error.NewBusiness(TOKEN_ERROR, ERROR_RBAC_AUTH))
 | 
									return res.Error(ctx, my_error.NewBusiness(TOKEN_ERROR, ERROR_RBAC_AUTH))
 | 
				
			||||||
				return err
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
	"github.com/1340691923/xwl_bi/engine/logs"
 | 
						"github.com/1340691923/xwl_bi/engine/logs"
 | 
				
			||||||
	"github.com/1340691923/xwl_bi/platform-basic-libs/util"
 | 
						"github.com/1340691923/xwl_bi/platform-basic-libs/util"
 | 
				
			||||||
	"go.uber.org/zap"
 | 
						"go.uber.org/zap"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GmUserModel BI用户
 | 
					// GmUserModel BI用户
 | 
				
			||||||
@ -61,6 +62,10 @@ func (this GmUserModel) Insert() (id int64, err error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Update
 | 
					// Update
 | 
				
			||||||
func (this GmUserModel) Update() (err error) {
 | 
					func (this GmUserModel) Update() (err error) {
 | 
				
			||||||
 | 
						if strings.TrimSpace(this.Password) == ""{
 | 
				
			||||||
 | 
							_, err = db.Sqlx.Exec("update gm_user set username = ?,role_id=?,realname=? where id = ? ;", this.Username, this.RoleId, this.Realname, this.ID)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	_, err = db.Sqlx.Exec("update gm_user set username = ?,password=?,role_id=?,realname=? where id = ? ;", this.Username, this.GetPassword(), this.RoleId, this.Realname, this.ID)
 | 
						_, err = db.Sqlx.Exec("update gm_user set username = ?,password=?,role_id=?,realname=? where id = ? ;", this.Username, this.GetPassword(), this.RoleId, this.Realname, this.ID)
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -26,8 +26,6 @@ func Run(driverName string, datasource string) (err error) {
 | 
				
			|||||||
	model := xormadapter.NewAdapter(driverName, datasource, true)
 | 
						model := xormadapter.NewAdapter(driverName, datasource, true)
 | 
				
			||||||
	Enforcer = casbin.NewEnforcer(policy, model)
 | 
						Enforcer = casbin.NewEnforcer(policy, model)
 | 
				
			||||||
	err = Enforcer.LoadPolicy()
 | 
						err = Enforcer.LoadPolicy()
 | 
				
			||||||
	if err != nil {
 | 
					
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -236,7 +236,7 @@ export default {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    async confirmRole() {
 | 
					    async confirmRole() {
 | 
				
			||||||
      const isEdit = this.dialogType === 'edit'
 | 
					      const isEdit = this.dialogType === 'edit'
 | 
				
			||||||
      if (this.role.password.length < 5) {
 | 
					      if (this.role.password.length < 5 && this.role.password.trim()!="") {
 | 
				
			||||||
        this.$message({
 | 
					        this.$message({
 | 
				
			||||||
          offset: 60,
 | 
					          offset: 60,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user