|
@@ -1,49 +1,49 @@
|
|
|
package models
|
|
|
|
|
|
import (
|
|
|
+ "eta_gn/eta_api/global"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
"fmt"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
type Classify struct {
|
|
|
- Id int `orm:"column(id);pk"`
|
|
|
- ClassifyName string `description:"分类名称"`
|
|
|
- Sort int `json:"-"`
|
|
|
- ParentId int `description:"父级分类id"`
|
|
|
- CreateTime time.Time `description:"创建时间"`
|
|
|
- ModifyTime time.Time `description:"修改时间"`
|
|
|
- Abstract string `description:"栏目简介"`
|
|
|
- Descript string `description:"分享描述"`
|
|
|
- ReportAuthor string `description:"栏目作者"`
|
|
|
- AuthorDescript string `description:"作者简介"`
|
|
|
- ColumnImgUrl string `description:"栏目配图"`
|
|
|
- HeadImgUrl string `description:"头部banner"`
|
|
|
- AvatarImgUrl string `description:"头像"`
|
|
|
- ReportImgUrl string `description:"报告配图"`
|
|
|
- HomeImgUrl string `description:"首页配图"`
|
|
|
- ClassifyLabel string `description:"分类标签"`
|
|
|
- ShowType int `description:"展示类型:1-列表 2-专栏"`
|
|
|
- HasTeleconference int `description:"是否有电话会:0-否 1-是"`
|
|
|
- VipTitle string `description:"研究员头衔"`
|
|
|
- IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
|
|
|
- YbFiccSort int `description:"小程序FICC页排序"`
|
|
|
- YbFiccIcon string `description:"小程序FICC页icon"`
|
|
|
- YbFiccPcIcon string `description:"小程序PC端FICC页背景图"`
|
|
|
- YbIconUrl string `description:"小程序已购页icon"`
|
|
|
- YbBgUrl string `description:"小程序已购详情背景图"`
|
|
|
- YbListImg string `description:"小程序研报列表封面图"`
|
|
|
- YbShareBgImg string `description:"小程序研报详情分享背景图"`
|
|
|
- YbRightBanner string `description:"Pc端详情页,右侧,报告合集背景图"`
|
|
|
- RelateTel int `description:"是否在电话会中可选: 0-否; 1-是"`
|
|
|
- RelateVideo int `description:"是否在路演视频中可选: 0-否; 1-是"`
|
|
|
- IsMassSend int `description:"1:群发,0:非群发"`
|
|
|
- Enabled int `description:"是否可用,1可用,0禁用"`
|
|
|
- Level int `description:"层级"`
|
|
|
- HasChild int `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
|
|
|
- ReportDetailShowType int `description:"报告详情的展示类型:1-拼接;2:目录"`
|
|
|
+ Id int `gorm:"column:id;primaryKey" json:"id"` //`orm:"column(id);pk"`
|
|
|
+ ClassifyName string `gorm:"column:classify_name" json:"classify_name"` //`description:"分类名称"`
|
|
|
+ Sort int `gorm:"column:sort" json:"sort"` //`json:"-"`
|
|
|
+ ParentId int `gorm:"column:parent_id" json:"parent_id"` //`description:"父级分类id"`
|
|
|
+ CreateTime time.Time `gorm:"column:create_time" json:"create_time"` //`description:"创建时间"`
|
|
|
+ ModifyTime time.Time `gorm:"column:modify_time" json:"modify_time"` //`description:"修改时间"`
|
|
|
+ Abstract string `gorm:"column:abstract" json:"abstract"` //`description:"栏目简介"`
|
|
|
+ Descript string `gorm:"column:descript" json:"descript"` //`description:"分享描述"`
|
|
|
+ ReportAuthor string `gorm:"column:report_author" json:"report_author"` //`description:"栏目作者"`
|
|
|
+ AuthorDescript string `gorm:"column:author_descript" json:"author_descript"` //`description:"作者简介"`
|
|
|
+ ColumnImgUrl string `gorm:"column:column_img_url" json:"column_img_url"` //`description:"栏目配图"`
|
|
|
+ HeadImgUrl string `gorm:"column:head_img_url" json:"head_img_url"` //`description:"头部banner"`
|
|
|
+ AvatarImgUrl string `gorm:"column:avatar_img_url" json:"avatar_img_url"` //`description:"头像"`
|
|
|
+ ReportImgUrl string `gorm:"column:report_img_url" json:"report_img_url"` //`description:"报告配图"`
|
|
|
+ HomeImgUrl string `gorm:"column:home_img_url" json:"home_img_url"` //`description:"首页配图"`
|
|
|
+ ClassifyLabel string `gorm:"column:classify_label" json:"classify_label"` //`description:"分类标签"`
|
|
|
+ ShowType int `gorm:"column:show_type" json:"show_type"` //`description:"展示类型:1-列表 2-专栏"`
|
|
|
+ HasTeleconference int `gorm:"column:has_teleconference" json:"has_teleconference"` //`description:"是否有电话会:0-否 1-是"`
|
|
|
+ VipTitle string `gorm:"column:vip_title" json:"vip_title"` //`description:"研究员头衔"`
|
|
|
+ IsShow int `gorm:"column:is_show" json:"is_show"` //`description:"是否在小程序显示:1-显示 0-隐藏"`
|
|
|
+ YbFiccSort int `gorm:"column:yb_ficc_sort" json:"yb_ficc_sort"` //`description:"小程序FICC页排序"`
|
|
|
+ YbFiccIcon string `gorm:"column:yb_ficc_icon" json:"yb_ficc_icon"` // `description:"小程序FICC页icon"`
|
|
|
+ YbFiccPcIcon string `gorm:"column:yb_ficc_pc_icon" json:"yb_ficc_pc_icon"` //`description:"小程序PC端FICC页背景图"`
|
|
|
+ YbIconUrl string `gorm:"column:yb_icon_url" json:"yb_icon_url"` //`description:"小程序已购页icon"`
|
|
|
+ YbBgUrl string `gorm:"column:yb_bg_url" json:"yb_bg_url"` //`description:"小程序已购详情背景图"`
|
|
|
+ YbListImg string `gorm:"column:yb_list_img" json:"yb_list_img"` //`description:"小程序研报列表封面图"`
|
|
|
+ YbShareBgImg string `gorm:"column:yb_share_bg_img" json:"yb_share_bg_img"` //`description:"小程序研报详情分享背景图"`
|
|
|
+ YbRightBanner string `gorm:"column:yb_right_banner" json:"yb_right_banner"` //`description:"Pc端详情页,右侧,报告合集背景图"`
|
|
|
+ RelateTel int `gorm:"column:relate_tel" json:"relate_tel"` //`description:"是否在电话会中可选: 0-否; 1-是"`
|
|
|
+ RelateVideo int `gorm:"column:relate_video" json:"relate_video"` //`description:"是否在路演视频中可选: 0-否; 1-是"`
|
|
|
+ IsMassSend int `gorm:"column:is_mass_send" json:"is_mass_send"` //`description:"1:群发,0:非群发"`
|
|
|
+ Enabled int `gorm:"column:enabled" json:"enabled"` //`description:"是否可用,1可用,0禁用"`
|
|
|
+ Level int `gorm:"column:level" json:"level"` //`description:"层级"`
|
|
|
+ HasChild int `gorm:"column:has_child" json:"has_child"` //`description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
|
|
|
+ ReportDetailShowType int `gorm:"column:report_detail_show_type" json:"report_detail_show_type"` //`description:"报告详情的展示类型:1-拼接;2:目录"`
|
|
|
}
|
|
|
|
|
|
type ClassifyAddReq struct {
|
|
@@ -80,43 +80,52 @@ type ClassifyAddReq struct {
|
|
|
}
|
|
|
|
|
|
func GetClassifyByName(classifyName string, parentId int) (item *Classify, err error) {
|
|
|
+ //sql := `SELECT * FROM classify WHERE classify_name=? AND parent_id=? `
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //err = o.Raw(sql, classifyName, parentId).QueryRow(&item)
|
|
|
sql := `SELECT * FROM classify WHERE classify_name=? AND parent_id=? `
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- err = o.Raw(sql, classifyName, parentId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyName, parentId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetClassifyById(classifyId int) (item *Classify, err error) {
|
|
|
+ //sql := `SELECT * FROM classify WHERE id=? `
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
sql := `SELECT * FROM classify WHERE id=? `
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 添加分类
|
|
|
func AddClassify(item *Classify) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- id, err := o.Insert(item)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- item.Id = int(id)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //id, err := o.Insert(item)
|
|
|
+ //if err != nil {
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //item.Id = int(id)
|
|
|
+ err = global.DmSQL["rddp"].Create(item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetReportCountByClassifyId(classifyId int) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := `SELECT COUNT(1) AS count FROM report WHERE classify_id_second=? `
|
|
|
- err = o.Raw(sql, classifyId).QueryRow(&count)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := `SELECT COUNT(1) AS count FROM report WHERE classify_id_second=? `
|
|
|
+ //err = o.Raw(sql, classifyId).QueryRow(&count)
|
|
|
+ sql := `SELECT COUNT(1) as num FROM report WHERE classify_id_second=? `
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetClassifySubCountByClassifyId(classifyId int) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+
|
|
|
sql := `SELECT COUNT(1) as num FROM classify AS a
|
|
|
INNER JOIN report AS b ON a.id=b.classify_id_second
|
|
|
WHERE a.parent_id=? `
|
|
|
- err = o.Raw(sql, classifyId).QueryRow(&count)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //err = o.Raw(sql, classifyId).QueryRow(&count)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -124,33 +133,37 @@ func GetClassifySubCountByParentId(classifyId int) (count int, err error) {
|
|
|
sqlCount := `
|
|
|
SELECT COUNT(1) as num FROM classify AS a
|
|
|
WHERE a.parent_id=? `
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- err = o.Raw(sqlCount, classifyId).QueryRow(&count)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //err = o.Raw(sqlCount, classifyId).QueryRow(&count)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sqlCount, classifyId).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 删除分类
|
|
|
func DeleteClassify(classifyId int) (err error) {
|
|
|
sql := `DELETE FROM classify WHERE id=? `
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Raw(sql, classifyId).Exec()
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, classifyId).Exec()
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, classifyId).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
deleteImgSql := `DELETE FROM banner WHERE classify_id=? `
|
|
|
- _, err = o.Raw(deleteImgSql, classifyId).Exec()
|
|
|
+ //_, err = o.Raw(deleteImgSql, classifyId).Exec()
|
|
|
+ err = global.DmSQL["rddp"].Exec(deleteImgSql, classifyId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// classifyName, abstract, descript string, parentId, classifyId int
|
|
|
// 修改分类
|
|
|
func EditClassify(req *EditClassifyReq) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+
|
|
|
//sql := `UPDATE classify SET classify_name = ?,abstract=?, parent_id= ?,descript=?,report_author=?,author_descript=?,column_img_url=?,head_img_url=?,avatar_img_url=?,report_img_url=?,home_img_url=?,classify_label=?,show_type=?,has_teleconference=?,vip_title=?,modify_time= NOW() WHERE id = ? `
|
|
|
//_, err = o.Raw(sql, req.ClassifyName, req.Abstract, req.ParentId, req.Descript, req.ReportAuthor, req.AuthorDescript, req.ColumnImgUrl, req.HeadImgUrl, req.AvatarImgUrl, req.ReportImgUrl, req.HomeImgUrl, req.ClassifyLabel, req.ShowType, req.HasTeleconference, req.VipTitle, req.ClassifyId).Exec()
|
|
|
sql := `UPDATE classify SET classify_name = ?,parent_id= ?,modify_time= NOW() WHERE id = ? `
|
|
|
- _, err = o.Raw(sql, req.ClassifyName, req.ParentId, req.ClassifyId).Exec()
|
|
|
-
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, req.ClassifyName, req.ParentId, req.ClassifyId).Exec()
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, req.ClassifyName, req.ParentId, req.ClassifyId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -162,49 +175,51 @@ func EditClassify(req *EditClassifyReq) (err error) {
|
|
|
// @return err error
|
|
|
func ParentClassify() (items []*Classify, err error) {
|
|
|
sql := `SELECT * FROM classify WHERE parent_id=0 order by id desc `
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 根据id获取分类详情
|
|
|
func FindByIdClassify(classifyId int) (item *Classify, err error) {
|
|
|
sql := `SELECT * FROM classify WHERE id=? `
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type ClassifyList struct {
|
|
|
- Id int `orm:"column(id);pk"`
|
|
|
- ClassifyName string `description:"分类名称"`
|
|
|
- Sort int `description:"排序"`
|
|
|
- ParentId int `description:"父级分类id"`
|
|
|
- CreateTime time.Time `description:"创建时间"`
|
|
|
- ModifyTime time.Time `description:"修改时间"`
|
|
|
- Abstract string `description:"简介"`
|
|
|
- Descript string `description:"描述"`
|
|
|
- ClassifyLabel string `description:"分类标签"`
|
|
|
- ShowType int `description:"展示类型:1-列表 2-专栏"`
|
|
|
- HasTeleconference int `description:"是否有电话会:0-否 1-是"`
|
|
|
- IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
|
|
|
- YbFiccSort int `description:"小程序FICC页排序"`
|
|
|
- YbFiccIcon string `description:"小程序FICC页icon"`
|
|
|
- YbFiccPcIcon string `description:"小程序PC端FICC页背景图"`
|
|
|
- YbIconUrl string `description:"小程序已购页icon"`
|
|
|
- YbBgUrl string `description:"小程序已购详情背景图"`
|
|
|
- YbListImg string `description:"小程序研报列表封面图"`
|
|
|
- YbShareBgImg string `description:"小程序研报详情分享背景图"`
|
|
|
- YbRightBanner string `description:"Pc端详情页,右侧,报告合集背景图"`
|
|
|
- RelateTel int `description:"是否在电话会中可选: 0-否; 1-是"`
|
|
|
- RelateVideo int `description:"是否在路演视频中可选: 0-否; 1-是"`
|
|
|
- Enabled int `description:"是否可用,1可用,0禁用"`
|
|
|
- Child []*ClassifyList
|
|
|
- ClassifyMenuId int `description:"二级分类-子目录ID"`
|
|
|
- ClassifyMenuList []*ClassifyMenu
|
|
|
- ChartPermissionIdList []int `description:"绑定的权限ID"`
|
|
|
- Level int `description:"层级"`
|
|
|
- HasChild int `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
|
|
|
+ Id int `gorm:"column:id" json:"id"` //`orm:"column(id);pk"`
|
|
|
+ ClassifyName string `gorm:"column:classify_name" json:"classify_name"` //`description:"分类名称"`
|
|
|
+ Sort int `gorm:"column:sort" json:"sort"` //`description:"排序"`
|
|
|
+ ParentId int `gorm:"column:parent_id" json:"parent_id"` //`description:"父级分类id"`
|
|
|
+ CreateTime time.Time `gorm:"column:create_time" json:"create_time"` //`description:"创建时间"`
|
|
|
+ ModifyTime time.Time `gorm:"column:modify_time" json:"modify_time"` //`description:"修改时间"`
|
|
|
+ Abstract string `gorm:"column:abstract" json:"abstract"` //`description:"简介"`
|
|
|
+ Descript string `gorm:"column:descript" json:"descript"` //`description:"描述"`
|
|
|
+ ClassifyLabel string `gorm:"column:classify_label" json:"classify_label"` //`description:"分类标签"`
|
|
|
+ ShowType int `gorm:"column:show_type" json:"show_type"` //`description:"展示类型:1-列表 2-专栏"`
|
|
|
+ HasTeleconference int `gorm:"column:has_teleconference" json:"has_teleconference"` //`description:"是否有电话会:0-否 1-是"`
|
|
|
+ IsShow int `gorm:"column:is_show" json:"is_show"` //`description:"是否在小程序显示:1-显示 0-隐藏"`
|
|
|
+ YbFiccSort int `gorm:"column:yb_ficc_sort" json:"yb_ficc_sort"` //`description:"小程序FICC页排序"`
|
|
|
+ YbFiccIcon string `gorm:"column:yb_ficc_icon" json:"yb_ficc_icon"` // `description:"小程序FICC页icon"`
|
|
|
+ YbFiccPcIcon string `gorm:"column:yb_ficc_pc_icon" json:"yb_ficc_pc_icon"` //`description:"小程序PC端FICC页背景图"`
|
|
|
+ YbIconUrl string `gorm:"column:yb_icon_url" json:"yb_icon_url"` //`description:"小程序已购页icon"`
|
|
|
+ YbBgUrl string `gorm:"column:yb_bg_url" json:"yb_bg_url"` //`description:"小程序已购详情背景图"`
|
|
|
+ YbListImg string `gorm:"column:yb_list_img" json:"yb_list_img"` //`description:"小程序研报列表封面图"`
|
|
|
+ YbShareBgImg string `gorm:"column:yb_share_bg_img" json:"yb_share_bg_img"` //`description:"小程序研报详情分享背景图"`
|
|
|
+ YbRightBanner string `gorm:"column:yb_right_banner" json:"yb_right_banner"` //`description:"Pc端详情页,右侧,报告合集背景图"`
|
|
|
+ RelateTel int `gorm:"column:relate_tel" json:"relate_tel"` //`description:"是否在电话会中可选: 0-否; 1-是"`
|
|
|
+ RelateVideo int `gorm:"column:relate_video" json:"relate_video"` //`description:"是否在路演视频中可选: 0-否; 1-是"`
|
|
|
+ Enabled int `gorm:"column:enabled" json:"enabled"` //`description:"是否可用,1可用,0禁用"`
|
|
|
+ Child []*ClassifyList `gorm:"-"`
|
|
|
+ ClassifyMenuId int `gorm:"-"` //`description:"二级分类-子目录ID"`
|
|
|
+ ClassifyMenuList []*ClassifyMenu `gorm:"-"`
|
|
|
+ ChartPermissionIdList []int `gorm:"-"` // `description:"绑定的权限ID"`
|
|
|
+ Level int `gorm:"column:level"` //`description:"层级"`
|
|
|
+ HasChild int `gorm:"column:has_child"` //`description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
|
|
|
}
|
|
|
|
|
|
type ClassifyItem struct {
|
|
@@ -250,8 +265,9 @@ func GetClassifyList(keyWord string, enabled int) (items []*ClassifyList, err er
|
|
|
}
|
|
|
pars = append(pars)
|
|
|
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -283,8 +299,9 @@ func GetClassifyListCount(keyWord, companyType string, hideDayWeek int) (count i
|
|
|
sqlCount += ` AND classify_name <> '晨报' AND classify_name <> '周报' `
|
|
|
}
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- err = o.Raw(sqlCount, pars...).QueryRow(&count)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //err = o.Raw(sqlCount, pars...).QueryRow(&count)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sqlCount, pars).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -311,7 +328,6 @@ type FindByIdClassifyReq struct {
|
|
|
}
|
|
|
|
|
|
func GetClassifyChild(parentId int, keyWord string) (items []*Classify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ``
|
|
|
pars := make([]interface{}, 0)
|
|
|
if keyWord != "" {
|
|
@@ -321,8 +337,9 @@ func GetClassifyChild(parentId int, keyWord string) (items []*Classify, err erro
|
|
|
sql = `SELECT * FROM classify WHERE parent_id=? ORDER BY create_time ASC `
|
|
|
}
|
|
|
pars = append(pars, parentId)
|
|
|
- _, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
-
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -331,7 +348,7 @@ func GetClassifyChildByParentIds(parentId []int, keyWord string, enabled int) (i
|
|
|
if parentIdLen == 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+
|
|
|
sql := ``
|
|
|
pars := make([]interface{}, 0)
|
|
|
pars = append(pars, parentId)
|
|
@@ -346,8 +363,9 @@ func GetClassifyChildByParentIds(parentId []int, keyWord string, enabled int) (i
|
|
|
sql += ` AND enabled=1 `
|
|
|
}
|
|
|
sql += ` ORDER BY create_time ASC `
|
|
|
- _, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
-
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -359,25 +377,29 @@ type EditClassifyPermissionReq struct {
|
|
|
|
|
|
// GetAllClassify 获取所有分类
|
|
|
func GetAllClassify() (list []*Classify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := ` SELECT * FROM classify `
|
|
|
+ //_, err = o.Raw(sql).QueryRows(&list)
|
|
|
sql := ` SELECT * FROM classify `
|
|
|
- _, err = o.Raw(sql).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetClassifyByKeyword 名称获取分类
|
|
|
func GetClassifyByKeyword(keyword string) (item Classify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := ` SELECT * FROM classify WHERE classify_name = ? LIMIT 1 `
|
|
|
+ //err = o.Raw(sql, keyword).QueryRow(&item)
|
|
|
sql := ` SELECT * FROM classify WHERE classify_name = ? LIMIT 1 `
|
|
|
- err = o.Raw(sql, keyword).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, keyword).Find(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateClassify 更新分类
|
|
|
func (classifyInfo *Classify) UpdateClassify(cols []string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Update(classifyInfo, cols...)
|
|
|
-
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Update(classifyInfo, cols...)
|
|
|
+ err = global.DmSQL["rddp"].Select(cols).Updates(classifyInfo).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -392,7 +414,7 @@ type SimpleClassifyList struct {
|
|
|
|
|
|
// GetClassifyByCondition 获取分类列表
|
|
|
func GetClassifyByCondition(condition, orderRule string, pars []interface{}) (items []*SimpleClassifyList, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+
|
|
|
sql := `SELECT * FROM classify WHERE 1 = 1 `
|
|
|
if condition != `` {
|
|
|
sql += condition
|
|
@@ -402,15 +424,19 @@ func GetClassifyByCondition(condition, orderRule string, pars []interface{}) (it
|
|
|
order = orderRule
|
|
|
}
|
|
|
sql += ` ORDER BY ` + order
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateChildClassifyRelateSetting 更新子分类关联设置
|
|
|
func UpdateChildClassifyRelateSetting(parentId, relateTel, relateVideo int) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := `UPDATE classify SET relate_tel = ?, relate_video = ? WHERE parent_id = ?`
|
|
|
+ //_, err = o.Raw(sql, relateTel, relateVideo, parentId).Exec()
|
|
|
sql := `UPDATE classify SET relate_tel = ?, relate_video = ? WHERE parent_id = ?`
|
|
|
- _, err = o.Raw(sql, relateTel, relateVideo, parentId).Exec()
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, relateTel, relateVideo, parentId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -423,36 +449,44 @@ type RelateTelSecClassifyWithPermissions struct {
|
|
|
|
|
|
// UpdateClassifySortByParentId 根据父类id更新排序
|
|
|
func UpdateClassifySortByParentId(parentId, permissionId, nowSort int, updateSort string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+
|
|
|
sql := ` update classify set sort = ` + updateSort + ` WHERE parent_id=? AND sort > ? `
|
|
|
if permissionId > 0 {
|
|
|
sql += ` or ( id > ` + fmt.Sprint(permissionId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
|
|
|
}
|
|
|
- _, err = o.Raw(sql, parentId, nowSort).Exec()
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, parentId, nowSort).Exec()
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, parentId, nowSort).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetMaxSortByParentId 获取最大的排序值
|
|
|
func (classifyInfo *Classify) GetMaxSortByParentId(parentId int) (maxSort int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := `SELECT max(sort) AS sort FROM classify WHERE parent_id = ? `
|
|
|
+ //err = o.Raw(sql, parentId).QueryRow(&maxSort)
|
|
|
sql := `SELECT max(sort) AS sort FROM classify WHERE parent_id = ? `
|
|
|
- err = o.Raw(sql, parentId).QueryRow(&maxSort)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, parentId).Scan(&maxSort).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetMaxSort 获取最大的排序值
|
|
|
func (classifyInfo *Classify) GetMaxSort() (maxSort int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := `SELECT max(sort) AS sort FROM classify`
|
|
|
+ //err = o.Raw(sql).QueryRow(&maxSort)
|
|
|
sql := `SELECT max(sort) AS sort FROM classify`
|
|
|
- err = o.Raw(sql).QueryRow(&maxSort)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Scan(&maxSort).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetFirstClassifyByParentId 获取当前父级分类下,且排序数相同 的排序第一条的数据
|
|
|
func (classifyInfo *Classify) GetFirstClassifyByParentId(parentId int) (item *Classify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := `SELECT * FROM classify WHERE parent_id = ? order by sort asc, id asc limit 1`
|
|
|
+ //err = o.Raw(sql, parentId).QueryRow(&item)
|
|
|
sql := `SELECT * FROM classify WHERE parent_id = ? order by sort asc, id asc limit 1`
|
|
|
- err = o.Raw(sql, parentId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, parentId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -468,8 +502,9 @@ type ClassifySetEnabledReq struct {
|
|
|
}
|
|
|
|
|
|
func (classifyInfo *Classify) SetEnabled(id, enabled int) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- to, err := o.Begin()
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //to, err := o.Begin()
|
|
|
+ to := global.DmSQL["rddp"].Begin()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -481,12 +516,14 @@ func (classifyInfo *Classify) SetEnabled(id, enabled int) (err error) {
|
|
|
}
|
|
|
}()
|
|
|
sql := ` UPDATE classify SET enabled =? WHERE id = ?`
|
|
|
- _, err = to.Raw(sql, enabled, id).Exec()
|
|
|
+ //_, err = to.Raw(sql, enabled, id).Exec()
|
|
|
+ err = to.Exec(sql, enabled, id).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
sql = ` UPDATE classify SET enabled =? WHERE parent_id = ?`
|
|
|
- _, err = to.Raw(sql, enabled, id).Exec()
|
|
|
+ //_, err = to.Raw(sql, enabled, id).Exec()
|
|
|
+ err = to.Exec(sql, enabled, id).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -501,10 +538,11 @@ func (classifyInfo *Classify) SetEnabled(id, enabled int) (err error) {
|
|
|
// @return total int
|
|
|
// @return err error
|
|
|
func GetCountClassifyChildByParentId(parentId int) (total int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //sql := `SELECT count(1) AS total FROM classify WHERE parent_id = ? `
|
|
|
+ //err = o.Raw(sql, parentId).QueryRow(&total)
|
|
|
sql := `SELECT count(1) AS total FROM classify WHERE parent_id = ? `
|
|
|
- err = o.Raw(sql, parentId).QueryRow(&total)
|
|
|
-
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, parentId).Scan(&total).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -531,8 +569,9 @@ func GetClassifyListByKeyword(keyWord string, enabled int) (items []*ClassifyLis
|
|
|
}
|
|
|
sql += ` ORDER BY sort ASC, create_time ASC`
|
|
|
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -551,8 +590,9 @@ func GetClassifyListByParentIdList(parentClassifyIdList []int) (items []*Classif
|
|
|
}
|
|
|
sql := `SELECT * FROM classify WHERE id in (` + utils.GetOrmInReplace(num) + `) ORDER BY sort ASC, create_time ASC`
|
|
|
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Raw(sql, parentClassifyIdList).QueryRows(&items)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, parentClassifyIdList).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, parentClassifyIdList).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -569,7 +609,8 @@ func GetClassifyListByIdList(classifyIdList []int) (items []*Classify, err error
|
|
|
return
|
|
|
}
|
|
|
sql := `SELECT * FROM classify WHERE id IN (` + utils.GetOrmInReplace(num) + `) `
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Raw(sql, classifyIdList).QueryRows(&items)
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Raw(sql, classifyIdList).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyIdList).Find(&items).Error
|
|
|
return
|
|
|
}
|