participate.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package util
  2. import (
  3. IC "jyBXCore/rpc/init"
  4. "sync"
  5. )
  6. var (
  7. PLock *ParticipateLock
  8. )
  9. type ParticipateLock struct {
  10. sync.Mutex
  11. UserLock map[string]*sync.Mutex
  12. }
  13. func NewParticipateLock() *ParticipateLock {
  14. return &ParticipateLock{
  15. UserLock: make(map[string]*sync.Mutex),
  16. }
  17. }
  18. func GetParticipateLock(str string) *sync.Mutex {
  19. PLock.Lock()
  20. if PLock.UserLock[str] == nil {
  21. PLock.UserLock[str] = &sync.Mutex{}
  22. }
  23. PLock.Unlock()
  24. return PLock.UserLock[str]
  25. }
  26. // 参标权限判断
  27. func IsAllowedParticipate(appId, userId string, newUserId, accountId, entAccountId, entId, entUserId, positionId, positionType int64) (b bool, role int64) {
  28. powerCheck := IC.Middleground.PowerCheckCenter.Check(appId, userId, newUserId, accountId, entId, positionType, positionId)
  29. //不是超级订阅 也不是大会员
  30. if powerCheck.Vip.Status <= 0 && powerCheck.Member.Status <= 0 {
  31. return
  32. }
  33. role = powerCheck.Ent.EntRoleId
  34. resource := IC.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
  35. if len(resource.Powers) != 0 {
  36. for _, r := range resource.Powers {
  37. //资源中台 cb_zy_code
  38. if r == IC.C.ResourceCode {
  39. b = true
  40. break
  41. }
  42. }
  43. }
  44. return
  45. }