123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package models
- import (
- "eta/eta_mini_bridge/utils"
- "fmt"
- "strings"
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- type ChartPermission struct {
- ChartPermissionId int `orm:"pk" description:"权限ID"`
- ChartPermissionName string `description:"名称"`
- PermissionName string `description:"权限名"`
- Sort int `description:"排序"`
- Enabled int `description:"是否可用"`
- CreatedTime time.Time `description:"创建时间"`
- LastUpdatedTime time.Time `description:"更新时间"`
- TeleconferenceSort int `description:"电话会类型排序"`
- Remark string `description:"备注"`
- ClassifyName string `description:"分类名称"`
- ProductName string `description:"产品名称" `
- ProductId int `description:"产品ID"`
- ImageUrl string `description:"图片地址"`
- ShowType int `description:"1:查研观向小程序展示"`
- IsOther int `description:"是否是其他,用于查研观向小程序后台展示"`
- IsReport int `description:"是否是报告,用于查研观向小程序前台报告展示"`
- CygxAuth int `description:"是否是权限,用于查研观向小程序前台权限校验"`
- PermissionType int `description:"1主观,2客观"`
- YbImgUrl string `description:"研报小程序报告列表icon"`
- ProductPermissionName string `description:"种类权限名称"`
- PriceDrivenState int `description:"品种价格驱动开启状态 0-关闭 1-开启"`
- ImageUrlM string `description:"图片地址(查研观向移动端)"`
- ParentId int `description:"父级权限id"`
- IsPublic int `description:"是否是公有权限1:公有权限,0私有权限"`
- }
- type ChartPermissionView struct {
- ChartPermissionId int `orm:"pk" description:"权限ID"`
- PermissionName string `description:"权限名"`
- Child []*ChartPermissionView `description:"子权限"`
- IsPublic int `description:"是否是公有权限1:公有权限,0私有权限"`
- ParentId int `description:"父级权限id"`
- Sort int `description:"排序"`
- }
- type BySortChartPermissionView []*ChartPermissionView
- func (a BySortChartPermissionView) Len() int { return len(a) }
- func (a BySortChartPermissionView) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
- func (a BySortChartPermissionView) Less(i, j int) bool { return a[i].Sort < a[j].Sort }
- // GetChartPermissionList 获取全部权限品种权限列表
- func GetChartPermissionList() (items []*ChartPermission, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM chart_permission WHERE enabled=1 AND product_id=1 ORDER BY sort ASC`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // GetChildChartPermissionListById 根据品种id获取子品种权限列表
- func GetChildChartPermissionListById(id int) (items []*ChartPermission, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM chart_permission WHERE enabled=1 AND product_id=1 AND parent_id=? ORDER BY sort ASC`
- _, err = o.Raw(sql, id).QueryRows(&items)
- return
- }
- // GetChartPermissionListByStrIds 根据品种ids获取品种权限列表
- func GetChartPermissionListByStrIds(chartPermissionIds []string) (items []*ChartPermission, err error) {
- // 没有品种权限就返回空
- if len(chartPermissionIds) == 0 {
- return
- }
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM chart_permission WHERE enabled=1 AND product_id=1 `
- if len(chartPermissionIds) > 0 {
- sql += fmt.Sprintf(" AND chart_permission_id IN (%s) ", strings.Join(chartPermissionIds, ","))
- }
- sql += ` ORDER BY sort ASC `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // GetChartPermissionListByIds 根据品种ids获取品种权限列表
- func GetChartPermissionListByIds(chartPermissionIds []int) (items []*ChartPermission, err error) {
- // 没有品种权限就返回空
- if len(chartPermissionIds) == 0 {
- return
- }
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM chart_permission WHERE enabled=1 AND product_id=1 `
- if len(chartPermissionIds) > 0 {
- sql += fmt.Sprintf(" AND chart_permission_id IN (%s) ", utils.GetOrmReplaceHolder(len(chartPermissionIds)))
- }
- sql += ` ORDER BY sort ASC `
- _, err = o.Raw(sql, chartPermissionIds).QueryRows(&items)
- return
- }
- // GetChartPermissionById 根据品种id获取品种权限
- func GetChartPermissionById(chartPermissionId int) (item *ChartPermission, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM chart_permission WHERE enabled=1 AND product_id=1 AND chart_permission_id=?`
- err = o.Raw(sql, chartPermissionId).QueryRow(&item)
- return
- }
- // GetChildChartPermissionIdsById 根据品种id获取子品种权限的id列表
- func GetChildChartPermissionIdsById(chartPermissionId int) (items []int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT chart_permission_id FROM chart_permission WHERE enabled=1 AND product_id=1 AND parent_id=? ORDER BY sort ASC`
- _, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
- return
- }
- // // GetChartPermissionListByIds2 根据品种ids获取品种权限列表
- // func GetChartPermissionListByIds2(chartPermissionIds []string) (items []*ChartPermission, err error) {
- // if len(chartPermissionIds) == 0 {
- // return
- // }
- // o := orm.NewOrmUsingDB("rddp")
- // sql := `SELECT * FROM chart_permission
- // WHERE enabled=1 AND product_id=1 `
- // var idsStr string
- // if len(chartPermissionIds) > 0 {
- // idsStr = strings.Join(chartPermissionIds, ",")
- // sql += fmt.Sprintf(" AND chart_permission_id in (%s) ", idsStr)
- // }
- // sql += ` ORDER BY sort ASC`
- // _, err = o.Raw(sql).QueryRows(&items)
- // return
- // }
|