123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package entity
- import (
- . "app.yhyue.com/moapp/jybase/common"
- . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/db"
- )
- var Base_ent_empower = base_ent_empower{}
- //企业授权表
- type base_ent_empower struct {
- Id int64
- Appid string
- Ent_id int64 //企业id
- Ent_user_id int64 //企业员工id
- Function_code string //功能代码
- }
- //授权记录
- func (b *base_ent_empower) FindMyEntId(appid, function_code string, ent_id int64) *[]*base_ent_empower {
- list := Mysql_BaseService.SelectBySql(`select * from base_ent_empower where appid=? and function_code=? and ent_id=?`, appid, function_code, ent_id)
- return JsonUnmarshal(list, &[]*base_ent_empower{}).(*[]*base_ent_empower)
- }
- //授权记录数量
- func (b *base_ent_empower) Count(appid, function_code string, ent_id int64) int64 {
- return Mysql_BaseService.CountBySql(`select count(1) as count from base_ent_empower where appid=? and function_code=? and ent_id=?`, appid, function_code, ent_id)
- }
- //是否授权
- func (b *base_ent_empower) HasEmpower(appid, function_code string, ent_id, ent_user_id int64) bool {
- empower := b.FindMyEntId(appid, function_code, ent_id)
- if empower != nil {
- if len(*empower) == 1 && (*empower)[0].Ent_user_id == 0 {
- return true
- } else {
- for _, vv := range *empower {
- if vv.Ent_id == ent_id && vv.Ent_user_id == ent_user_id {
- return true
- }
- }
- }
- }
- return false
- }
|