package models import ( "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" "time" ) type CygxProductInterior struct { ProductInteriorId int `orm:"column(product_interior_id);pk"` ColumnName string `description:"栏目名称"` Title string `description:"标题"` PublishTime time.Time `description:"发布日期"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"更新时间"` Status int `description:"0:未发布,1:已发布"` Body string `description:"内容"` IsCancel int `description:"是否取消,1是,0否"` VisibleRange int `description:"设置可见范围1全部,0内部"` Abstract string `description:"摘要"` Department string `description:"作者"` AdminId int `description:"管理员ID"` } type AddProductInteriorReq struct { ProductInteriorId int `description:"ID"` DoType int `description:"操作类型 0,保存 、1,发布"` ColumnName string `description:"栏目名称"` Title string `description:"标题"` Abstract string `description:"摘要"` Department string `description:"作者"` Body string `description:"内容"` PublishTime string `description:"发布日期"` } type ProductInteriorIdReq struct { ProductInteriorId int `description:"ID"` } type GetCygxProductInteriorResp struct { Paging *paging.PagingItem `description:"分页数据"` List []*CygxProductInteriorResp } type CygxProductInteriorResp struct { ProductInteriorId int `description:"ID"` PublishTime string `description:"发布日期"` CreateTime string `description:"创建时间"` ModifyTime string `description:"更新时间"` Title string `description:"标题"` ColumnName string `description:"栏目名称"` Body string `description:"内容"` BodySlice []*ProductInteriorUrlResp `description:"内容切片"` IsCancel int `description:"是否取消,1是,0否"` VisibleRange int `description:"设置可见范围1全部,0内部"` Abstract string `description:"摘要"` Department string `description:"作者"` Pv int `description:"PV"` } type ProductInteriorUrlResp struct { ChartPermissionId int `description:"行业id"` SourceId int `description:"资源ID"` Type int `description:"类型:1普通文本,2:文章、3:活动、4:产业"` Body string `description:"内容"` ActivityVideo *CygxActivityVideoReq //活动视频 AuthInfo *UserPermissionAuthInfo // 权限 } // 获取数量 func GetCygxProductInteriorCount(condition string, pars []interface{}) (count int, err error) { sqlCount := ` SELECT COUNT(1) AS count FROM cygx_product_interior as art WHERE 1= 1 ` if condition != "" { sqlCount += condition } o := orm.NewOrm() err = o.Raw(sqlCount, pars).QueryRow(&count) return } // 列表 func GetCygxProductInteriorList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxProductInteriorResp, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_product_interior as art WHERE 1= 1 ` if condition != "" { sql += condition } sql += ` LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } type GetCygxProductInteriorDetailResp struct { Detail *CygxProductInteriorResp HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"` IsShow bool `description:"是否展示"` Disclaimers string `description:"免责声明"` } // 通过ID获取详情 func GetCygxProductInteriorDetail(productInteriorId int) (item *CygxProductInteriorResp, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_product_interior WHERE product_interior_id=? AND status = 1 ` err = o.Raw(sql, productInteriorId).QueryRow(&item) return } // 删除数据 func DeleteProductInterior(productInteriorId int) (err error) { o := orm.NewOrm() sql := ` DELETE FROM cygx_product_interior WHERE product_interior_id = ?` _, err = o.Raw(sql, productInteriorId).Exec() return } // 修改是否展示 func EditProductInteriorStatus(status, isCancel, productInteriorId int) (err error) { o := orm.NewOrm() sql := `UPDATE cygx_product_interior SET status=?,is_cancel = ? , modify_time=NOW() WHERE product_interior_id=? ` _, err = o.Raw(sql, status, isCancel, productInteriorId).Exec() return } // 修改可见范围 func ProductInteriorVisibleRange(visibleRange, productInteriorId int) (err error) { o := orm.NewOrm() sql := `UPDATE cygx_product_interior SET visible_range=?, modify_time=NOW() WHERE product_interior_id=? ` _, err = o.Raw(sql, visibleRange, productInteriorId).Exec() return }