12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ActivityPermission 活动权限表结构体
- type ActivityPermission struct {
- ActivityPermissionId int `orm:"column(activity_permission_id);pk" description:"活动权限ID"`
- ActivityId int ` description:"活动ID"`
- PermissionId int ` description:"权限ID"`
- PermissionName string `description:"权限名称"`
- CreateTime time.Time `description:"创建时间"`
- }
- // TableName 表名变更
- func (activityPermission *ActivityPermission) TableName() string {
- return "yb_activity_permission"
- }
- // DelPermissionByActivityId 根据活动id删除所有权限
- func DelPermissionByActivityId(activityId int) (err error) {
- o := orm.NewOrm()
- sql := "delete from yb_activity_permission where activity_id=?"
- _, err = o.Raw(sql, activityId).Exec()
- return
- }
- // AddActivityPermission 新增活动权限
- func AddActivityPermission(activityPermissionInfo *ActivityPermission) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(activityPermissionInfo)
- return
- }
- // AddActivityPermissionMulti 批量新增活动权限
- func AddActivityPermissionMulti(activityPermissionList []*ActivityPermission) (err error) {
- o := orm.NewOrm()
- _, err = o.InsertMulti(len(activityPermissionList), activityPermissionList)
- return
- }
- // GetPermissionListByActivityIds 根据活动id集合获取权限列表
- func GetPermissionListByActivityIds(activityIds string) (list []*ActivityPermission, err error) {
- if activityIds == "" {
- return
- }
- o := orm.NewOrm()
- sql := `select * from yb_activity_permission where activity_id in (` + activityIds + `) `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- // GetPermissionListByActivityId 根据活动id获取权限列表
- func GetPermissionListByActivityId(activityId int) (list []*ActivityPermission, err error) {
- o := orm.NewOrm()
- sql := `select * from yb_activity_permission where activity_id = ? `
- _, err = o.Raw(sql, activityId).QueryRows(&list)
- return
- }
|