123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- package advisory
- import (
- "github.com/beego/beego/v2/client/orm"
- )
- type ChartPermission struct {
- ChartPermissionId int `description:"权限id"`
- ClassifyName string `description:"分类名称"`
- PermissionName string `description:"名称"`
- ImageUrl string `description:"图片地址"`
- IsHaveNoRead bool `description:"是否存在未阅读的文章"`
- ChildPermission []*ChartPermission
- }
- type ChartPermissionResp struct {
- List []*ChartPermission
- }
- // 用户关注的分类
- type ChartPermissionListResp struct {
- ChartPermissionId int `description:"权限id"`
- ChartPermissionName string `description:"名称"`
- PermissionName string `description:"名称"`
- ClassifyName string `description:"分类名称"`
- ImageUrl string `description:"图片地址"`
- IsFllow bool `description:"是否关注过分类"`
- }
- type GetChartPermissionAllByChartIdResp struct {
- ChartPermissionId int `description:"权限id"`
- }
- // 用户关注的分类
- type MyChartPermission struct {
- ChartPermissionId int `description:"权限id"`
- ClassifyName string `description:"分类名称"`
- PermissionName string `description:"名称"`
- ChartPermissionName string `description:"名称"`
- ImageUrl string `description:"图片地址"`
- }
- type MyChartPermissionResp struct {
- List []*MyChartPermission
- }
- type AdminInfoResp struct {
- AdminName string `description:"系统用户名称"`
- CreatedTime string `description:"注册时间"`
- Headimgurl string `description:"头像"`
- Mobile string `description:"手机号"`
- ArticleNum int `description:"文章数量"`
- IsFllow bool `description:"是否关注过分类"`
- List []*MyChartPermission
- }
- type NoAdminInfoResp struct {
- List []*MyChartPermission
- }
- func GetCategoryInfoById(chartPermissionId int) (item *ChartPermission, err error) {
- o := orm.NewOrm()
- //o.Using("rddp")
- sql := `SELECT * FROM chart_permission WHERE chart_permission_id=? AND product_id = 1 AND product_name = 'ficc' `
- err = o.Raw(sql, chartPermissionId).QueryRow(&item)
- return
- }
- // 获取分类列表
- func GetChartPermissionList() (items []*MyChartPermission, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM chart_permission as ch WHERE product_id = 1 AND product_name = 'ficc' and parent_id > 0 ORDER BY sort ASC; `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type GetBuChartPermissionResp struct {
- ChartPermissionId int `description:"权限id"`
- PermissionName string `description:"分类名称"`
- ImageUrl string `description:"图片链接"`
- }
- type GetBuChartPermissionRespLIst struct {
- List []*GetBuChartPermissionResp
- }
- // 获取用户购买的分类信息
- func GetBuChartPermission(CompanyId int, pars []interface{}) (items []*GetBuChartPermissionResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT ch.chart_permission_id , ch.permission_name ,ch.image_url FROM chart_permission as ch INNER JOIN company_report_permission as co ON co.chart_permission_id = ch.chart_permission_id WHERE co.company_id = ? `
- _, err = o.Raw(sql, CompanyId, pars).QueryRows(&items)
- return
- }
- // 获取分类列表
- func GetPermissionList(condition string, pars []interface{}, startSize, pageSize int) (items []*ChartPermission, err error) {
- sql := ` SELECT * FROM chart_permission WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- sql += ` ORDER BY sort ASC LIMIT ?,? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // 获取用户权限的一级分类名称
- func GetFirstChartPermissionAllByUser(Ids string) (items []*ChartPermission, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM chart_permission as ch WHERE product_id = 1 AND product_name = 'ficc' AND chart_permission_id IN (` + Ids + `)` + ` GROUP BY ch.classify_name ORDER BY sort ASC; `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // 获取用户权限的二级分类名称
- func GetChartToClassifyNameByUser(ClassifyName, Ids string) (items []*ChartPermission, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM chart_permission WHERE product_id = 1 AND product_name = 'ficc' AND classify_name = ? AND chart_permission_id IN (` + Ids + `)`
- _, err = o.Raw(sql, ClassifyName).QueryRows(&items)
- return
- }
- func GetChartPermissionAllByChartId(chartPermissionId int) (items []*GetChartPermissionAllByChartIdResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT chart_permission_id FROM chart_permission WHERE classify_name = (SELECT classify_name FROM chart_permission WHERE chart_permission_id = ?)`
- _, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
- return
- }
|