package company import ( "eta_gn/eta_api/global" "time" ) type ChartPermission struct { ChartPermissionId int `gorm:"primaryKey;column:chart_permission_id;type:bigint(20) unsigned;not null"` // 主键 ChartPermissionName string `gorm:"column:chart_permission_name;type:varchar(20)"` // 名称 PermissionName string `gorm:"column:permission_name;type:varchar(50);default:''"` // 权限名 Sort int `gorm:"column:sort;type:int(10);default:1"` // 排序 Enabled int `gorm:"column:enabled;type:tinyint(1);default:1"` // 是否可用 CreatedTime time.Time `gorm:"index:created_time;column:created_time;type:datetime;default:CURRENT_TIMESTAMP"` // 创建时间 LastUpdatedTime time.Time `gorm:"index:last_updated_time;column:last_updated_time;type:timestamp;not null;default:CURRENT_TIMESTAMP"` TeleconferenceSort int `gorm:"column:teleconference_sort;type:int(4);default:0"` // 电话会类型排序 Remark string `gorm:"column:remark;type:varchar(30)"` ClassifyName string `gorm:"column:classify_name;type:varchar(50)"` ProductName string `gorm:"column:product_name;type:varchar(50);default:''"` ProductId int `gorm:"column:product_id;type:int(11);default:0"` ImageURL string `gorm:"column:image_url;type:varchar(255)"` // 图片地址 ShowType int `gorm:"column:show_type;type:tinyint(4);default:0"` // 1:查研观向小程序展示 IsOther int `gorm:"column:is_other;type:tinyint(2);not null;default:0"` // 是否是其他,用于查研观向小程序后台展示 IsReport int `gorm:"index:is_report;column:is_report;type:tinyint(4);not null;default:0"` // 是否是报告,用于查研观向小程序前台报告展示 CygxAuth int `gorm:"column:cygx_auth;type:tinyint(4);not null;default:0"` // 是否是权限,用于查研观向小程序前台权限校验 PermissionType int `gorm:"column:permission_type;type:tinyint(2) unsigned;not null;default:0"` // 1主观,2客观 YbImgURL string `gorm:"column:yb_img_url;type:varchar(255)"` // 研报小程序报告列表icon ProductPermissionName string `gorm:"column:product_permission_name;type:varchar(50);default:''"` // 种类权限名称 PriceDrivenState int `gorm:"column:price_driven_state;type:tinyint(4);not null;default:1"` // 品种价格驱动状态 0-关闭 1-开启 ImageURLM string `gorm:"column:image_url_m;type:varchar(255)"` // 图片地址(查研观向移动端) ParentId int `gorm:"column:parent_id;type:int(11);not null;default:0"` // 父级权限id IsPublic int `gorm:"column:is_public;type:tinyint(4);not null;default:0"` // 是否是公有权限1:公有权限,0私有权限 Checked bool `description:"选中状态" gorm:"-"` } type PermissionSetItem struct { ChartPermissionId int `description:"权限id"` PermissionName string `description:"权限名称"` PermissionType int `description:"1主观,2客观"` Checked bool `description:"选中状态"` Child []*PermissionSetItem `description:"具体的主客观-方便前端的排版用的"` } type PermissionSetItemType struct { PermissionName string `description:"权限名称"` Checked bool `description:"选中状态"` CheckedMinate bool `description:"不确定状态"` NoClicking bool `description:"是否禁止点击"` Items []*PermissionLookItem } type PermissionSetList struct { PermissionName string `description:"分类"` Child []*PermissionSetItem CheckList []int } type PermissionSetListType struct { PermissionName string `description:"分类"` Child []*PermissionSetItemType CheckList []int } type PermissionSetResp struct { List []*PermissionSetList ListType []*PermissionSetListType `description:"主观客观列表"` } type PermissionLookItem struct { ChartPermissionId int `description:"权限id"` PermissionName string `description:"权限名称"` StartDate string `description:"权限开始日期"` EndDate string `description:"权限结束日期"` Status string `description:"'正式','试用','关闭'"` ExpireDay string `description:"到期天数"` ClassifyName string `description:"分类"` PermissionType int `description:"1主观,2客观"` PermissionTypeName string `description:"主观、客观"` Checked bool `description:"选中状态"` Remark string `description:"备注"` IsMerge bool `description:"是否合并行业, 给前端的标识, 暂时仅权益使用"` RaiBothHas bool `description:"权益-是否主客观都有"` IsUpgrade int `description:"是否升级,1是,0否"` Child []*PermissionLookItem `description:"子权限"` } type PermissionVarietyResp struct { List []*PermissionVarietyList } type PermissionVarietyItem struct { ChartPermissionId int `gorm:"column:chart_permission_id;type:bigint(20) unsigned;not null"` ClassifyName string `gorm:"column:classify_name;type:varchar(50)"` } type PermissionVarietyList struct { ChartPermissionId int `description:"父级id"` ClassifyName string `description:"分类"` Items []*PermissionVarietyItem } func GetPermissionVarietyItems(productId int, classifyName string) (items []*PermissionVarietyItem, err error) { sql := ` SELECT chart_permission_id, chart_permission_name, permission_name, sort, enabled, created_time, last_updated_time, teleconference_sort, remark, classify_name, product_name, product_id, image_url, show_type, is_other, is_report, cygx_auth, permission_type, yb_img_url, product_permission_name, price_driven_state, image_url_m, parent_id, is_public FROM chart_permission WHERE enabled=1 AND product_id=? AND classify_name=? GROUP BY permission_name, chart_permission_id, chart_permission_name, sort, enabled, created_time, last_updated_time, teleconference_sort, remark, classify_name, product_name, product_id, image_url, show_type, is_other, is_report, cygx_auth, permission_type, yb_img_url, product_permission_name, price_driven_state, image_url_m, parent_id, is_public ORDER BY sort ASC ` err = global.DmSQL["rddp"].Raw(sql, productId, classifyName).Find(&items).Error return } // GetChartPermissionListById 根据权限id获取产品权限详情 func GetChartPermissionListById(chartPermissionId int) (item *ChartPermission, err error) { sql := `SELECT * FROM chart_permission WHERE chart_permission_id =? ` err = global.DmSQL["rddp"].Raw(sql, chartPermissionId).First(&item).Error return } func GetParentIdFromGroup(gid int) (items *int, err error) { sql := `SELECT parent_id FROM sys_group WHERE group_id=? ` err = global.DEFAULT_DmSQL.Raw(sql, gid).Scan(&items).Error return } func GetGroupNamesById(gid int) (items *string, err error) { sql := `SELECT group_name FROM sys_group WHERE group_id=? ` err = global.DEFAULT_DmSQL.Raw(sql, gid).Scan(&items).Error return }