Bläddra i källkod

更新

master
huangjiajun 1 månad sedan
förälder
incheckning
b036c2909d
3 ändrade filer med 66 tillägg och 0 borttagningar
  1. +9
    -0
      src/dao/admin_bind_agent_dao.go
  2. +44
    -0
      src/implement/admin_bind_agent_implement.go
  3. +13
    -0
      src/model/admin_bind_agent.go

+ 9
- 0
src/dao/admin_bind_agent_dao.go Visa fil

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

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

type AdminBindAgentDao interface {
FindAll(adminId int) (list []model.AdminBindAgent)
FindAgentList(agentId string, adminId, page, limit int) (list []model.AdminBindAgent, total int64, err error)
GetAdminByAgentId(adminId, agentId int) (list *model.AdminBindAgent)
}

+ 44
- 0
src/implement/admin_bind_agent_implement.go Visa fil

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

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

func NewAdminBindAgentDb(engine *xorm.Engine) dao.AdminBindAgentDao {
return &AdminBindAgentDb{Db: engine}
}

type AdminBindAgentDb struct {
Db *xorm.Engine
}

func (a AdminBindAgentDb) FindAll(adminId int) (list []model.AdminBindAgent) {
sess := a.Db.Where("admin_id=?", adminId)
err := sess.Find(&list)
if err != nil {
return nil
}
return
}
func (a AdminBindAgentDb) GetAdminByAgentId(adminId, agentId int) (list *model.AdminBindAgent) {
sess := a.Db.Where("agent_id=? and admin_id=?", agentId, adminId)
get, err := sess.Get(&list)
if get == false || err != nil {
return nil
}
return
}
func (a AdminBindAgentDb) FindAgentList(agentId string, adminId, page, limit int) (list []model.AdminBindAgent, total int64, err error) {
sess := a.Db.Where("admin_id=?", adminId).Desc("id").Limit(limit, (page-1)*limit)
if agentId != "" {
sess.In("agent_id", strings.Split(agentId, ","))
}
total, err = sess.FindAndCount(&list)
if err != nil {
return nil, 0, err
}
return
}

+ 13
- 0
src/model/admin_bind_agent.go Visa fil

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

import (
"time"
)

type AdminBindAgent struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
AdminId int `json:"admin_id" xorm:"default 0 comment('管理员id') INT(11)"`
AgentId int `json:"agent_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"`
}

Laddar…
Avbryt
Spara