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