作者 唐旭辉

分页数据修改

@@ -39,7 +39,7 @@ func (c *AuditController) AuditList() { @@ -39,7 +39,7 @@ func (c *AuditController) AuditList() {
39 uid := c.GetUserId() 39 uid := c.GetUserId()
40 companyId := c.GetCompanyId() 40 companyId := c.GetCompanyId()
41 list, err := serveaudit.GetAuditList(param, companyId, uid) 41 list, err := serveaudit.GetAuditList(param, companyId, uid)
42 - msg = protocol.NewReturnResponse(list, err) 42 + msg = protocol.NewPageDataResponse(list, err)
43 return 43 return
44 } 44 }
45 45
@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 "oppmg/utils/exceltool" 8 "oppmg/utils/exceltool"
9 "strconv" 9 "strconv"
10 10
  11 + serveauth "oppmg/services/auth"
  12 +
11 "github.com/astaxie/beego" 13 "github.com/astaxie/beego"
12 "github.com/astaxie/beego/context" 14 "github.com/astaxie/beego/context"
13 "github.com/astaxie/beego/validation" 15 "github.com/astaxie/beego/validation"
@@ -28,16 +30,21 @@ func (this *BaseController) Prepare() { @@ -28,16 +30,21 @@ func (this *BaseController) Prepare() {
28 this.Ctx.WriteString("") 30 this.Ctx.WriteString("")
29 return 31 return
30 } 32 }
31 - // p := this.Ctx.Input.GetData("RouterPattern")  
32 - // userid := this.GetUserId()  
33 - // companyid := this.GetCompanyId() 33 + p := fmt.Sprint(this.Ctx.Input.GetData("RouterPattern"))
  34 + userid := this.GetUserId()
  35 + companyid := this.GetCompanyId()
  36 + ok := serveauth.ValidUserPermission(p, userid, companyid)
  37 + if !ok {
  38 + // msg := protocol.NewMessage("10080")
  39 + // this.ResposeJson(msg)
  40 + return
  41 + }
34 //权限校验 42 //权限校验
35 - 43 + return
36 } 44 }
37 45
38 func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) { 46 func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) {
39 appHead.AccessToken = this.Ctx.Input.Header(protocol.HeaderAccessToken) 47 appHead.AccessToken = this.Ctx.Input.Header(protocol.HeaderAccessToken)
40 - //appHead.RefreshToken = this.Ctx.Input.Header(protocol.HeaderRefreshToken)  
41 return 48 return
42 49
43 } 50 }
@@ -33,6 +33,7 @@ var errmessge ErrorMap = map[string]string{ @@ -33,6 +33,7 @@ var errmessge ErrorMap = map[string]string{
33 "10027": "无操作权限", 33 "10027": "无操作权限",
34 "10028": "验证码错误", 34 "10028": "验证码错误",
35 "10029": "获取验证码失败", 35 "10029": "获取验证码失败",
  36 + "10080": "无操作权限",
36 37
37 //用户相关 38 //用户相关
38 "10031": "无效角色", 39 "10031": "无效角色",
@@ -143,30 +143,6 @@ func ChangeLoginToken(userid, companyid int64) (protocol.LoginAuthToken, error) @@ -143,30 +143,6 @@ func ChangeLoginToken(userid, companyid int64) (protocol.LoginAuthToken, error)
143 return logintoken, nil 143 return logintoken, nil
144 } 144 }
145 145
146 -// func RefreshLoginToken(refreshtoken string) (protocol.LoginAuthToken, error) {  
147 -// var (  
148 -// logintoken protocol.LoginAuthToken  
149 -// mtoken *MyToken  
150 -// err error  
151 -// storetoken redisdata.RedisLoginToken  
152 -// )  
153 -// mtoken, err = ValidJWTToken(refreshtoken)  
154 -// if err != nil {  
155 -// log.Debug("token失效 err:%s", err)  
156 -// return logintoken, protocol.NewErrWithMessage("10024")  
157 -// }  
158 -// storetoken, err = redisdata.GetLoginToken(mtoken.UID, mtoken.CompanyID)  
159 -// if err != nil {  
160 -// log.Error("redis err:%s", err)  
161 -// return logintoken, protocol.NewErrWithMessage("10024")  
162 -// }  
163 -// if storetoken.RefreshToken != refreshtoken {  
164 -// return logintoken, protocol.NewErrWithMessage("10024")  
165 -// }  
166 -// logintoken, _ = GenerateAuthToken(mtoken.UID, mtoken.CompanyID)  
167 -// return logintoken, nil  
168 -// }  
169 -  
170 func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, error) { 146 func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, error) {
171 var ( 147 var (
172 err error 148 err error
@@ -392,22 +368,6 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er @@ -392,22 +368,6 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er
392 return list, nil 368 return list, nil
393 } 369 }
394 370
395 -//主管拥有全部的菜单  
396 -// func getAdminHasMenu() ([]protocol.PermissionItem, error) {  
397 -// const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code  
398 -// FROM menu WHERE enabled=1 ORDER BY sort `  
399 -// var (  
400 -// list = make([]protocol.PermissionItem, 0)  
401 -// err error  
402 -// )  
403 -// err = utils.ExecuteQueryAll(&list, datasql)  
404 -// if err != nil {  
405 -// log.Error("EXECUTE SQL err:%s", err)  
406 -// return nil, protocol.NewErrWithMessage("1")  
407 -// }  
408 -// return list, nil  
409 -// }  
410 -  
411 func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) { 371 func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) {
412 var ( 372 var (
413 err error 373 err error
@@ -532,10 +492,20 @@ func ValidUserPermission(urlPath string, userid int64, companyid int64) bool { @@ -532,10 +492,20 @@ func ValidUserPermission(urlPath string, userid int64, companyid int64) bool {
532 ok bool = false 492 ok bool = false
533 permissionObj serverbac.PermissionOptionObject 493 permissionObj serverbac.PermissionOptionObject
534 ) 494 )
  495 +
535 permissionbase, ok = serverbac.RouterPermission[urlPath] 496 permissionbase, ok = serverbac.RouterPermission[urlPath]
536 if !ok { 497 if !ok {
537 return true 498 return true
538 } 499 }
  500 + companyinfo, err := models.GetCompanyById(companyid)
  501 + if err != nil {
  502 + log.Error("获取公司数据失败")
  503 + return false
  504 + }
  505 + if companyinfo.AdminId == userid {
  506 + return true
  507 + }
  508 +
539 permissionObj, err = redisdata.GetUserPermission(userid, permissionbase.CodeName) 509 permissionObj, err = redisdata.GetUserPermission(userid, permissionbase.CodeName)
540 if err != nil { 510 if err != nil {
541 log.Error("未取到权限数据") 511 log.Error("未取到权限数据")
@@ -143,3 +143,26 @@ func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, @@ -143,3 +143,26 @@ func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject,
143 } 143 }
144 return objMap, nil 144 return objMap, nil
145 } 145 }
  146 +
  147 +// func ValidUserPermission(urlPath string, userid int64, companyid int64) bool {
  148 +// var (
  149 +// err error
  150 +// permissionbase PermissionBase
  151 +// ok bool = false
  152 +// permissionObj PermissionOptionObject
  153 +// )
  154 +// permissionbase, ok = RouterPermission[urlPath]
  155 +// if !ok {
  156 +// return true
  157 +// }
  158 +// permissionObj, err = redisdata.GetUserPermission(userid, permissionbase.CodeName)
  159 +// if err != nil {
  160 +// log.Error("未取到权限数据")
  161 +// return false
  162 +// }
  163 +// ok = permissionObj.GetValidFunc(permissionbase.ActionName)
  164 +// if ok {
  165 +// return true
  166 +// }
  167 +// return false
  168 +// }