浏览代码

更新

master
huangjiajun 1周前
父节点
当前提交
df7a456382
共有 3 个文件被更改,包括 56 次插入0 次删除
  1. +8
    -0
      src/dao/admin_bind_medium_dao.go
  2. +35
    -0
      src/implement/admin_bind_medium_implement.go
  3. +13
    -0
      src/model/admin_bind_medium.go

+ 8
- 0
src/dao/admin_bind_medium_dao.go 查看文件

@@ -0,0 +1,8 @@
package dao

import "code.fnuoos.com/zhimeng/model.git/src/model"

type AdminBindMediumDao interface {
FindAll(adminId int) (list []model.AdminBindMedium)
FindMediumList(mediumId []int, adminId, page, limit int) (list []model.AdminBindMedium, total int64, err error)
}

+ 35
- 0
src/implement/admin_bind_medium_implement.go 查看文件

@@ -0,0 +1,35 @@
package implement

import (
"code.fnuoos.com/zhimeng/model.git/src/dao"
"code.fnuoos.com/zhimeng/model.git/src/model"
"xorm.io/xorm"
)

func NewAdminBindMediumDb(engine *xorm.Engine) dao.AdminBindMediumDao {
return &AdminBindMediumDb{Db: engine}
}

type AdminBindMediumDb struct {
Db *xorm.Engine
}

func (a AdminBindMediumDb) FindAll(adminId int) (list []model.AdminBindMedium) {
sess := a.Db.Where("admin_id=?", adminId)
err := sess.Find(&list)
if err != nil {
return nil
}
return
}
func (a AdminBindMediumDb) FindMediumList(mediumId []int, adminId, page, limit int) (list []model.AdminBindMedium, total int64, err error) {
sess := a.Db.Where("admin_id=?", adminId).Desc("id").Limit(limit, (page-1)*limit)
if len(mediumId) > 0 {
sess.In("medium_id", mediumId)
}
total, err = sess.FindAndCount(&list)
if err != nil {
return nil, 0, err
}
return
}

+ 13
- 0
src/model/admin_bind_medium.go 查看文件

@@ -0,0 +1,13 @@
package model

import (
"time"
)

type AdminBindMedium struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
AdminId int `json:"admin_id" xorm:"default 0 comment('管理员id') INT(11)"`
MediumId int `json:"medium_id" xorm:"not null default 0 comment('媒体id') INT(11)"`
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"`
}

正在加载...
取消
保存