@@ -1,44 +0,0 @@ | |||||
package dao | |||||
import ( | |||||
"applet/app/db/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type AdminDao interface { | |||||
CreateAdminId() (admId int, err error) | |||||
AdminDeleteBySession(session *xorm.Session, admId interface{}) (int64, error) | |||||
GetAdmin(id int) (m *model.Admin, err error) | |||||
GetAdminByUserName(userName string) (m *model.Admin, err error) | |||||
GetAdminRolePermission(admId int) (list []*AdminRolePermission, total int64, err error) | |||||
FindAdmin(username string, state, page, limit int) (list []model.Admin, total int64, err error) | |||||
UpdateAdmin(m *model.Admin, columns ...string) (int64, error) | |||||
AdminInsert(m *model.Admin) (int64, error) | |||||
FindAdminRolePermissionGroup(admId int) (list []*AdminRolePermissionGroup, total int64, err error) | |||||
} | |||||
type AdminRolePermissionGroup struct { | |||||
model.Admin `xorm:"extends"` | |||||
model.AdminRole `xorm:"extends"` | |||||
model.Role `xorm:"extends"` | |||||
model.RolePermissionGroup `xorm:"extends"` | |||||
model.PermissionGroup `xorm:"extends"` | |||||
} | |||||
func (AdminRolePermissionGroup) TableName() string { | |||||
return "admin" | |||||
} | |||||
type AdminRolePermission struct { | |||||
model.Admin `xorm:"extends"` | |||||
model.AdminRole `xorm:"extends"` | |||||
model.Role `xorm:"extends"` | |||||
model.RolePermissionGroup `xorm:"extends"` | |||||
model.PermissionGroup `xorm:"extends"` | |||||
model.PermissionGroupPermission `xorm:"extends"` | |||||
model.Permission `xorm:"extends"` | |||||
} | |||||
func (AdminRolePermission) TableName() string { | |||||
return "admin" | |||||
} |
@@ -1,25 +0,0 @@ | |||||
package dao | |||||
import ( | |||||
"applet/app/db/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type AdminRoleDao interface { | |||||
FindAdminRole(id int) (*[]model.AdminRole, error) | |||||
FindAdminRoleByRoleId(id int) (*[]model.AdminRole, error) | |||||
AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) | |||||
GetAdminRoleByRole(id int) (m *model.AdminRole, err error) | |||||
AdminRoleDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) | |||||
AdminRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) | |||||
BatchAddAdminRoleBySession(session *xorm.Session, mm []*model.AdminRole) (int64, error) | |||||
} | |||||
type AdminRole struct { | |||||
model.Admin `xorm:"extends"` | |||||
model.AdminRole `xorm:"extends"` | |||||
} | |||||
func (AdminRole) TableName() string { | |||||
return "admin_role" | |||||
} |
@@ -1,5 +0,0 @@ | |||||
package dao | |||||
type PermissionDao interface { | |||||
//TODO:: You can add specific method definitions here | |||||
} |
@@ -1,8 +0,0 @@ | |||||
package dao | |||||
import "applet/app/db/model" | |||||
type PermissionGroupDao interface { | |||||
FindPermissionGroup() (*[]model.PermissionGroup, error) | |||||
FindPermissionGroupV2() (*[]model.PermissionGroup, error) | |||||
} |
@@ -1,5 +0,0 @@ | |||||
package dao | |||||
type PermissionGroupPermissionDao interface { | |||||
//TODO:: You can add specific method definitions here | |||||
} |
@@ -1,25 +0,0 @@ | |||||
package dao | |||||
import ( | |||||
"applet/app/db/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type RoleDao interface { | |||||
FindRole() (*[]model.Role, error) | |||||
GetRole() (m *model.Role, err error) | |||||
UpdateRole(m *model.Role, columns ...string) (int64, error) | |||||
RoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) | |||||
RoleInsert(m *model.Role) (int, error) | |||||
FindPermissionGroupByRole(roleId int) (list []*RolePermissionGroup, total int64, err error) | |||||
} | |||||
type RolePermissionGroup struct { | |||||
model.Role `xorm:"extends"` | |||||
model.RolePermissionGroup `xorm:"extends"` | |||||
model.PermissionGroup `xorm:"extends"` | |||||
} | |||||
func (RolePermissionGroup) TableName() string { | |||||
return "role" | |||||
} |
@@ -1,11 +0,0 @@ | |||||
package dao | |||||
import ( | |||||
"applet/app/db/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type RolePermissionGroupDao interface { | |||||
RolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) | |||||
BatchAddRolePermissionGroupBySession(session *xorm.Session, mm []*model.RolePermissionGroup) (int64, error) | |||||
} |
@@ -0,0 +1,14 @@ | |||||
package dao | |||||
import "applet/app/db/model" | |||||
type SysCfgDao interface { | |||||
SysCfgGetAll() (*[]model.SysCfg, error) | |||||
SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) | |||||
SysCfgGetOne(key string) (*model.SysCfg, error) | |||||
SysCfgInsert(key, val, memo string) bool | |||||
SysCfgUpdate(key, val string) bool | |||||
SysCfgGetWithDb(HKey string) string | |||||
SysCfgDel(HKey string) error | |||||
SysCfgFindWithDb(keys ...string) map[string]string | |||||
} |
@@ -1,112 +0,0 @@ | |||||
package db | |||||
import ( | |||||
"database/sql" | |||||
"fmt" | |||||
"os" | |||||
"time" | |||||
_ "github.com/go-sql-driver/mysql" //必须导入mysql驱动,否则会panic | |||||
"xorm.io/xorm" | |||||
"xorm.io/xorm/log" | |||||
"applet/app/cfg" | |||||
"applet/app/utils/logx" | |||||
) | |||||
var Db *xorm.Engine | |||||
//根据DB配置文件初始化数据库 | |||||
func InitDB(c *cfg.DBCfg) error { | |||||
var ( | |||||
err error | |||||
f *os.File | |||||
) | |||||
//创建Orm引擎 | |||||
if Db, err = xorm.NewEngine("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4", c.User, c.Psw, c.Host, c.Name)); err != nil { | |||||
return err | |||||
} | |||||
Db.SetConnMaxLifetime(c.MaxLifetime * time.Second) //设置最长连接时间 | |||||
Db.SetMaxOpenConns(c.MaxOpenConns) //设置最大打开连接数 | |||||
Db.SetMaxIdleConns(c.MaxIdleConns) //设置连接池的空闲数大小 | |||||
if err = Db.Ping(); err != nil { //尝试ping数据库 | |||||
return err | |||||
} | |||||
if c.ShowLog { //根据配置文件设置日志 | |||||
Db.ShowSQL(true) //设置是否打印sql | |||||
Db.Logger().SetLevel(0) //设置日志等级 | |||||
//修改日志文件存放路径文件名是%s.log | |||||
path := fmt.Sprintf(c.Path, c.Name) | |||||
f, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777) | |||||
if err != nil { | |||||
os.RemoveAll(c.Path) | |||||
if f, err = os.OpenFile(c.Path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777); err != nil { | |||||
return err | |||||
} | |||||
} | |||||
logger := log.NewSimpleLogger(f) | |||||
logger.ShowSQL(true) | |||||
Db.SetLogger(logger) | |||||
} | |||||
return nil | |||||
} | |||||
/********************************************* 公用方法 *********************************************/ | |||||
// 数据批量插入 | |||||
func DbInsertBatch(Db *xorm.Engine, m ...interface{}) error { | |||||
if len(m) == 0 { | |||||
return nil | |||||
} | |||||
id, err := Db.Insert(m...) | |||||
if id == 0 || err != nil { | |||||
return logx.Warn("cannot insert data :", err) | |||||
} | |||||
return nil | |||||
} | |||||
// QueryNativeString 查询原生sql | |||||
func QueryNativeString(Db *xorm.Engine, sql string, args ...interface{}) ([]map[string]string, error) { | |||||
results, err := Db.SQL(sql, args...).QueryString() | |||||
return results, err | |||||
} | |||||
// UpdateComm common update | |||||
func UpdateComm(Db *xorm.Engine, id interface{}, model interface{}) (int64, error) { | |||||
row, err := Db.ID(id).Update(model) | |||||
return row, err | |||||
} | |||||
// InsertComm common insert | |||||
func InsertComm(Db *xorm.Engine, model interface{}) (int64, error) { | |||||
row, err := Db.InsertOne(model) | |||||
return row, err | |||||
} | |||||
// ExecuteOriginalSql 执行原生sql | |||||
func ExecuteOriginalSql(session *xorm.Session, sql string) (sql.Result, error) { | |||||
result, err := session.Exec(sql) | |||||
if err != nil { | |||||
_ = logx.Warn(err) | |||||
return nil, err | |||||
} | |||||
return result, nil | |||||
} | |||||
// GetComm | |||||
// payload *model | |||||
// return *model,has,err | |||||
func GetComm(Db *xorm.Engine, model interface{}) (interface{}, bool, error) { | |||||
has, err := Db.Get(model) | |||||
if err != nil { | |||||
_ = logx.Warn(err) | |||||
return nil, false, err | |||||
} | |||||
return model, has, nil | |||||
} | |||||
// InsertCommWithSession common insert | |||||
func InsertCommWithSession(session *xorm.Session, model interface{}) (int64, error) { | |||||
row, err := session.InsertOne(model) | |||||
return row, err | |||||
} |
@@ -1,82 +0,0 @@ | |||||
package db | |||||
import ( | |||||
"applet/app/db/model" | |||||
"applet/app/md" | |||||
"applet/app/utils/cache" | |||||
"applet/app/utils/logx" | |||||
"fmt" | |||||
"xorm.io/xorm" | |||||
) | |||||
// 系统配置get | |||||
func SysCfgGetAll(Db *xorm.Engine) (*[]model.SysCfg, error) { | |||||
var cfgList []model.SysCfg | |||||
if err := Db.Cols("key,val,memo").Find(&cfgList); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &cfgList, nil | |||||
} | |||||
// 获取一条记录 | |||||
func SysCfgGetOne(Db *xorm.Engine, key string) (*model.SysCfg, error) { | |||||
var cfgList model.SysCfg | |||||
if has, err := Db.Where("`key`=?", key).Get(&cfgList); err != nil || has == false { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &cfgList, nil | |||||
} | |||||
// 返回最后插入id | |||||
func SysCfgInsert(Db *xorm.Engine, key, val, memo string) bool { | |||||
cfg := model.SysCfg{Key: key, Val: val, Memo: memo} | |||||
_, err := Db.InsertOne(&cfg) | |||||
if err != nil { | |||||
logx.Error(err) | |||||
return false | |||||
} | |||||
return true | |||||
} | |||||
func SysCfgUpdate(Db *xorm.Engine, key, val, memo string) bool { | |||||
cfg := model.SysCfg{Key: key, Val: val, Memo: memo} | |||||
_, err := Db.Where("`key`=?", key).Cols("val,memo").Update(&cfg) | |||||
if err != nil { | |||||
logx.Error(err) | |||||
return false | |||||
} | |||||
return true | |||||
} | |||||
func SysCfgGetWithDb(eg *xorm.Engine, masterId string, HKey string) string { | |||||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, masterId) + HKey | |||||
get, err := cache.GetString(cacheKey) | |||||
if err != nil || get == "" { | |||||
cfg, err := SysCfgGetOne(eg, HKey) | |||||
if err != nil || cfg == nil { | |||||
_ = logx.Error(err) | |||||
return "" | |||||
} | |||||
// key是否存在 | |||||
cacheKeyExist := false | |||||
if cache.Exists(cacheKey) { | |||||
cacheKeyExist = true | |||||
} | |||||
// 设置缓存 | |||||
_, err = cache.SetEx(cacheKey, cfg.Val, 30) | |||||
if err != nil { | |||||
_ = logx.Error(err) | |||||
return "" | |||||
} | |||||
if !cacheKeyExist { // 如果是首次设置 设置过期时间 | |||||
_, err := cache.Expire(cacheKey, md.CfgCacheTime) | |||||
if err != nil { | |||||
_ = logx.Error(err) | |||||
return "" | |||||
} | |||||
} | |||||
return cfg.Val | |||||
} | |||||
return get | |||||
} |
@@ -1,104 +0,0 @@ | |||||
package db | |||||
import ( | |||||
"fmt" | |||||
"os" | |||||
"time" | |||||
"xorm.io/xorm" | |||||
"xorm.io/xorm/log" | |||||
"applet/app/cfg" | |||||
"applet/app/db/model" | |||||
"applet/app/utils/logx" | |||||
) | |||||
var DBs map[string]*xorm.Engine | |||||
// 每个站长都要有自己的syscfg 缓存, 键是站长id,值是缓存名 | |||||
// var SysCfgMapKey map[string]string | |||||
func NewDB(c *cfg.DBCfg) (*xorm.Engine, error) { | |||||
db, err := xorm.NewEngine("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4", c.User, c.Psw, c.Host, c.Name)) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
db.SetConnMaxLifetime(c.MaxLifetime * time.Second) | |||||
db.SetMaxOpenConns(c.MaxOpenConns) | |||||
db.SetMaxIdleConns(c.MaxIdleConns) | |||||
err = db.Ping() | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if c.ShowLog { | |||||
db.ShowSQL(true) | |||||
db.Logger().SetLevel(log.LOG_DEBUG) | |||||
f, err := os.OpenFile(c.Path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777) | |||||
if err != nil { | |||||
os.RemoveAll(c.Path) | |||||
if f, err = os.OpenFile(c.Path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777); err != nil { | |||||
return nil, err | |||||
} | |||||
} | |||||
logger := log.NewSimpleLogger(f) | |||||
logger.ShowSQL(true) | |||||
db.SetLogger(logger) | |||||
} | |||||
return db, nil | |||||
} | |||||
// InitDBs is 初始化多数据库 | |||||
func InitDBs(ch chan int) { | |||||
// 初始化多数据库 | |||||
var tables *[]model.DbMapping | |||||
InitMapDbs(cfg.DB, cfg.Prd) | |||||
ch <- 1 | |||||
// 每10s 查询一次模板数据库的db mapping 表,如果有新增数据库记录,则添加到 DBs中 | |||||
ticker := time.NewTicker(time.Duration(time.Second * 120)) | |||||
for range ticker.C { | |||||
if cfg.Prd { | |||||
tables = GetAllDatabasePrd() //默认获取全部 | |||||
} else { | |||||
tables = GetAllDatabaseDev() //默认获取全部 | |||||
} | |||||
if tables == nil { | |||||
logx.Warn("no database tables data") | |||||
continue | |||||
} | |||||
for _, item := range *tables { | |||||
_, ok := DBs[item.DbMasterId] | |||||
if !ok { | |||||
// 不在db.DBs 则添加进去 | |||||
dbCfg := cfg.DBCfg{ | |||||
Name: item.DbName, | |||||
ShowLog: cfg.DB.ShowLog, | |||||
MaxLifetime: cfg.DB.MaxLifetime, | |||||
MaxOpenConns: cfg.DB.MaxOpenConns, | |||||
MaxIdleConns: cfg.DB.MaxIdleConns, | |||||
Path: fmt.Sprintf(cfg.DB.Path, item.DbName), | |||||
} | |||||
if item.DbHost != "" && item.DbUsername != "" && item.DbPassword != "" { | |||||
dbCfg.Host = item.DbHost | |||||
dbCfg.User = item.DbUsername | |||||
dbCfg.Psw = item.DbPassword | |||||
} else { | |||||
dbCfg.Host = cfg.DB.Host | |||||
dbCfg.User = cfg.DB.User | |||||
dbCfg.Psw = cfg.DB.Psw | |||||
} | |||||
e, err := NewDB(&dbCfg) | |||||
if err != nil || e == nil { | |||||
logx.Warnf("db engine can't create, please check config, params[host:%s, user:%s, psw: %s, name: %s], err: %v", dbCfg.Host, dbCfg.User, dbCfg.Psw, dbCfg.Name, err) | |||||
} else { | |||||
DBs[item.DbMasterId] = e | |||||
} | |||||
} | |||||
// 如果 被禁用则删除 | |||||
if item.DeletedAt == 1 { | |||||
logx.Infof("%s have been removed", item.DbMasterId) | |||||
delete(DBs, item.DbMasterId) | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -1,194 +0,0 @@ | |||||
package db | |||||
import ( | |||||
"errors" | |||||
"fmt" | |||||
"xorm.io/xorm" | |||||
"applet/app/cfg" | |||||
"applet/app/db/model" | |||||
"applet/app/utils/logx" | |||||
) | |||||
func MapBaseExists() (bool, error) { | |||||
return Db.IsTableExist("db_mapping") | |||||
} | |||||
func InitMapDbs(c *cfg.DBCfg, prd bool) { | |||||
var tables *[]model.DbMapping | |||||
exists, err := MapBaseExists() | |||||
if !exists || err != nil { | |||||
logx.Fatalf("db_mapping not exists : %v", err) | |||||
} | |||||
// tables := MapAllDatabases(debug) | |||||
if prd { | |||||
tables = GetAllDatabasePrd() //debug 获取生产 | |||||
} else { | |||||
tables = GetAllDatabaseDev() //debug 获取开发 | |||||
} | |||||
if tables == nil { | |||||
logx.Fatal("no database tables data") | |||||
} | |||||
var e *xorm.Engine | |||||
DBs = map[string]*xorm.Engine{} | |||||
for _, v := range *tables { | |||||
if v.DbName != "" && v.DeletedAt == 0 && v.DbName != c.Name { | |||||
dbCfg := cfg.DBCfg{ | |||||
Name: v.DbName, | |||||
ShowLog: c.ShowLog, | |||||
MaxLifetime: c.MaxLifetime, | |||||
MaxOpenConns: c.MaxOpenConns, | |||||
MaxIdleConns: c.MaxIdleConns, | |||||
Path: fmt.Sprintf(c.Path, v.DbName), | |||||
} | |||||
if v.DbHost != "" && v.DbUsername != "" && v.DbPassword != "" { | |||||
dbCfg.Host = v.DbHost | |||||
dbCfg.User = v.DbUsername | |||||
dbCfg.Psw = v.DbPassword | |||||
} else { | |||||
dbCfg.Host = c.Host | |||||
dbCfg.User = c.User | |||||
dbCfg.Psw = c.Psw | |||||
} | |||||
e, err = NewDB(&dbCfg) | |||||
if err != nil || e == nil { | |||||
logx.Warnf("db engine can't create, please check config, params[host:%s, user:%s, psw: %s, name: %s], err: %v", dbCfg.Host, dbCfg.User, dbCfg.Psw, dbCfg.Name, err) | |||||
} else { | |||||
DBs[v.DbMasterId] = e | |||||
} | |||||
} | |||||
} | |||||
} | |||||
func MapAllDatabases(debug bool) *[]model.DbMapping { | |||||
sql := "`db_name` != ?" | |||||
if debug { | |||||
sql = "`db_name` = ?" | |||||
} | |||||
var m []model.DbMapping | |||||
if err := Db.Where(sql, cfg.DB.Name).Find(&m); err != nil || len(m) == 0 { | |||||
logx.Warn(err) | |||||
return nil | |||||
} | |||||
return &m | |||||
} | |||||
// GetAllDatabasePrd is 获取生成库 所有db 除了 deleted_at = 1 的 | |||||
func GetAllDatabasePrd() *[]model.DbMapping { | |||||
var m []model.DbMapping | |||||
if err := Db.Where("deleted_at != ? AND is_dev = '0' ", 1).Find(&m); err != nil || len(m) == 0 { | |||||
logx.Warn(err) | |||||
return nil | |||||
} | |||||
return &m | |||||
} | |||||
// GetAllDatabaseDev is 获取开发库 所有db 除了 deleted_at = 1 的 | |||||
func GetAllDatabaseDev() *[]model.DbMapping { | |||||
var m []model.DbMapping | |||||
var err error | |||||
fmt.Println("cfg.Local is: ", cfg.Local) | |||||
if cfg.Local { // 本地调试 加快速度 | |||||
fmt.Println("notice:LOCAL TEST, only masterId:** 123456 ** available!") | |||||
err = Db.Where("deleted_at != ? AND is_dev = '1' AND db_master_id=?", 1, 123456).Find(&m) | |||||
} else { | |||||
err = Db.Where("deleted_at != ? AND is_dev = '1' ", 1).Find(&m) | |||||
} | |||||
//err := Db.Where("deleted_at != ? AND is_dev = '1' and db_master_id='123456'", 1).Find(&m) | |||||
if err != nil || len(m) == 0 { | |||||
logx.Warn(err) | |||||
return nil | |||||
} | |||||
return &m | |||||
} | |||||
//GetDatabaseByMasterID is 根据站长id 获取对应的的数据库信息 | |||||
func GetDatabaseByMasterID(Db *xorm.Engine, id string) (*model.DbMapping, error) { | |||||
var m model.DbMapping | |||||
has, err := Db.Where("db_master_id=?", id).Get(&m) | |||||
if !has { | |||||
return nil, errors.New("Not Found DB data by " + id) | |||||
} | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if m.DbHost == "" { | |||||
m.DbHost = cfg.DB.Host | |||||
m.DbUsername = cfg.DB.User | |||||
m.DbPassword = cfg.DB.Psw | |||||
} | |||||
return &m, nil | |||||
} | |||||
//SessionGetDatabaseByMasterID is 根据站长id 获取对应的的数据库信息 | |||||
func SessionGetDatabaseByMasterID(Db *xorm.Session, id string) (*model.DbMapping, error) { | |||||
var m model.DbMapping | |||||
has, err := Db.Where("db_master_id=?", id).Get(&m) | |||||
if !has { | |||||
return nil, errors.New("Not Found DB data by " + id) | |||||
} | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if m.DbHost == "" { | |||||
m.DbHost = cfg.DB.Host | |||||
m.DbName = cfg.DB.Name | |||||
m.DbUsername = cfg.DB.User | |||||
m.DbPassword = cfg.DB.Psw | |||||
} | |||||
return &m, nil | |||||
} | |||||
// 获取自动任务队列 | |||||
func MapCrontabCfg(eg *xorm.Engine) *[]model.SysCfg { | |||||
var c []model.SysCfg | |||||
// 数据库查询如果有下划线会认为是一个任意字符 | |||||
if err := eg.Where("`key` LIKE 'mall_cron\\_%' AND val != ''").Cols("`key`,`val`").Find(&c); err != nil || len(c) == 0 { | |||||
logx.Warn(err) | |||||
return nil | |||||
} | |||||
return &c | |||||
} | |||||
// 获取官方域名 | |||||
func GetOfficialDomainInfoByType(Db *xorm.Engine, masterId, key string) (string, error) { | |||||
type SysCfg struct { | |||||
K string | |||||
V string | |||||
Memo string | |||||
} | |||||
var domainBase SysCfg | |||||
has, err := Db.Where("k=?", "domain_base").Get(&domainBase) | |||||
if err != nil { | |||||
return "", err | |||||
} | |||||
if has == false { | |||||
return "", errors.New("can not find key by : domain_base") | |||||
} | |||||
if key == "wap" { | |||||
return "h5." + masterId + "." + domainBase.V, nil | |||||
} | |||||
if key == "api" { | |||||
var apiDomain SysCfg | |||||
has, err = Db.Where("k=?", "domain_api_base").Get(&apiDomain) | |||||
if err != nil { | |||||
return "", err | |||||
} | |||||
if has == false { | |||||
return "", errors.New("can not find key by : domain_api_base") | |||||
} | |||||
return apiDomain.V, nil | |||||
} | |||||
if key == "admin" { | |||||
return "admin." + masterId + "." + domainBase.V, nil | |||||
} | |||||
// 默认返回H5的 | |||||
return "h5." + masterId + "." + domainBase.V, nil | |||||
} |
@@ -1,115 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"applet/app/db/model" | |||||
"applet/app/utils/logx" | |||||
"reflect" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewAdminDb(engine *xorm.Engine) dao.AdminDao { | |||||
return &AdminDb{Db: engine} | |||||
} | |||||
type AdminDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func (a AdminDb) CreateAdminId() (admId int, err error) { | |||||
m := new(model.Admin) | |||||
has, err := a.Db.Desc("adm_id").Get(m) | |||||
if err != nil { | |||||
return 0, logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return 0, nil | |||||
} | |||||
admId = m.AdmId + 1 | |||||
return admId, nil | |||||
} | |||||
func (a AdminDb) AdminDeleteBySession(session *xorm.Session, admId interface{}) (int64, error) { | |||||
if reflect.TypeOf(admId).Kind() == reflect.Slice { | |||||
return session.In("adm_id", admId).Delete(model.Admin{}) | |||||
} else { | |||||
return session.Where("id = ?", admId).Delete(model.Admin{}) | |||||
} | |||||
} | |||||
func (a AdminDb) GetAdmin(id int) (m *model.Admin, err error) { | |||||
m = new(model.Admin) | |||||
has, err := a.Db.Where("adm_id =?", id).Get(m) | |||||
if err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return m, nil | |||||
} | |||||
func (a AdminDb) GetAdminByUserName(userName string) (m *model.Admin, err error) { | |||||
m = new(model.Admin) | |||||
has, err := a.Db.Where("username =?", userName).Get(m) | |||||
if err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return m, nil | |||||
} | |||||
func (a AdminDb) GetAdminRolePermission(admId int) (list []*dao.AdminRolePermission, total int64, err error) { | |||||
total, err = a.Db.Where("admin.adm_id =?", admId). | |||||
Join("LEFT", "admin_role", "admin.adm_id = admin_role.adm_id"). | |||||
Join("LEFT", "role", "admin_role.role_id = role.id"). | |||||
Join("LEFT", "role_permission_group", "role.id = role_permission_group.role_id"). | |||||
Join("LEFT", "permission_group", "role_permission_group.group_id = permission_group.id"). | |||||
Join("LEFT", "permission_group_permission", "permission_group.id = permission_group_permission.group_id"). | |||||
Join("LEFT", "permission", "permission_group_permission.permission_id = permission.id"). | |||||
FindAndCount(&list) | |||||
return | |||||
} | |||||
func (a AdminDb) FindAdmin(username string, state, page, limit int) (list []model.Admin, total int64, err error) { | |||||
sess := a.Db.Desc("adm_id").Limit(limit, (page-1)*limit) | |||||
if username != "" { | |||||
sess.And("username like ?", "%"+username+"%") | |||||
} | |||||
if state != 0 { | |||||
sess.And("state = ?", state) | |||||
} | |||||
total, err = sess.FindAndCount(&list) | |||||
if err != nil { | |||||
return nil, 0, err | |||||
} | |||||
return | |||||
} | |||||
func (a AdminDb) UpdateAdmin(m *model.Admin, columns ...string) (int64, error) { | |||||
affected, err := a.Db.Where("adm_id =?", m.AdmId).Cols(columns...).Update(m) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return affected, nil | |||||
} | |||||
func (a AdminDb) AdminInsert(m *model.Admin) (int64, error) { | |||||
insertAffected, err := a.Db.InsertOne(m) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return insertAffected, nil | |||||
} | |||||
func (a AdminDb) FindAdminRolePermissionGroup(admId int) (list []*dao.AdminRolePermissionGroup, total int64, err error) { | |||||
total, err = a.Db.Where("admin.adm_id =?", admId). | |||||
Join("LEFT", "admin_role", "admin.adm_id = admin_role.adm_id"). | |||||
Join("LEFT", "role", "admin_role.role_id = role.id"). | |||||
//Join("LEFT", "role_permission_group", "role.id = role_permission_group.role_id"). | |||||
//Join("LEFT", "permission_group", "role_permission_group.group_id = permission_group.id"). | |||||
FindAndCount(&list) | |||||
return | |||||
} |
@@ -1,77 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"applet/app/db/model" | |||||
"applet/app/utils/logx" | |||||
"reflect" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewAdminRoleDb(engine *xorm.Engine) dao.AdminRoleDao { | |||||
return &AdminRoleDb{Db: engine} | |||||
} | |||||
type AdminRoleDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func (a AdminRoleDb) FindAdminRole(id int) (*[]model.AdminRole, error) { | |||||
var m []model.AdminRole | |||||
if err := a.Db.Where("adm_id =?", id).Find(&m); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &m, nil | |||||
} | |||||
func (a AdminRoleDb) FindAdminRoleByRoleId(id int) (*[]model.AdminRole, error) { | |||||
var m []model.AdminRole | |||||
if err := a.Db.Where("role_id =?", id).Find(&m); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &m, nil | |||||
} | |||||
func (a AdminRoleDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) { | |||||
if reflect.TypeOf(admId).Kind() == reflect.Slice { | |||||
return session.In("adm_id", admId).Delete(model.AdminRole{}) | |||||
} else { | |||||
return session.Where("adm_id = ?", admId).Delete(model.AdminRole{}) | |||||
} | |||||
} | |||||
func (a AdminRoleDb) GetAdminRoleByRole(id int) (m *model.AdminRole, err error) { | |||||
m = new(model.AdminRole) | |||||
has, err := a.Db.Where("role_id =?", id).Get(m) | |||||
if err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return m, nil | |||||
} | |||||
func (a AdminRoleDb) AdminRoleDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { | |||||
if reflect.TypeOf(roleId).Kind() == reflect.Slice { | |||||
return session.In("role_id", roleId).Delete(model.AdminRole{}) | |||||
} else { | |||||
return session.Where("role_id = ?", roleId).Delete(model.AdminRole{}) | |||||
} | |||||
} | |||||
func (a AdminRoleDb) AdminRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { | |||||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||||
return session.In("id", id).Delete(model.AdminRole{}) | |||||
} else { | |||||
return session.Where("adm_id = ?", id).Delete(model.AdminRole{}) | |||||
} | |||||
} | |||||
func (a AdminRoleDb) BatchAddAdminRoleBySession(session *xorm.Session, mm []*model.AdminRole) (int64, error) { | |||||
affected, err := session.Insert(mm) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return affected, nil | |||||
} |
@@ -1,33 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"applet/app/db/model" | |||||
"applet/app/enum" | |||||
"applet/app/utils/logx" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewPermissionGroupDb(engine *xorm.Engine) dao.PermissionGroupDao { | |||||
return &PermissionGroupDb{Db: engine} | |||||
} | |||||
type PermissionGroupDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func (p PermissionGroupDb) FindPermissionGroup() (*[]model.PermissionGroup, error) { | |||||
var m []model.PermissionGroup | |||||
if err := p.Db.Where("state = ?", enum.PermissionGroupStateForNormal).Asc("id").Find(&m); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &m, nil | |||||
} | |||||
func (p PermissionGroupDb) FindPermissionGroupV2() (*[]model.PermissionGroup, error) { | |||||
var m []model.PermissionGroup | |||||
if err := p.Db.Asc("id").Find(&m); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &m, nil | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"xorm.io/xorm" | |||||
) | |||||
type PermissionGroupPermissionDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func NewPermissionGroupPermissionDb(engine *xorm.Engine) dao.PermissionGroupPermissionDao { | |||||
return &PermissionGroupPermissionDb{Db: engine} | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"xorm.io/xorm" | |||||
) | |||||
type PermissionDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func NewPermissionDb(engine *xorm.Engine) dao.PermissionDao { | |||||
return &PermissionDb{Db: engine} | |||||
} |
@@ -1,73 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"applet/app/db/model" | |||||
"applet/app/utils/logx" | |||||
"reflect" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewRoleDb(engine *xorm.Engine, id int) dao.RoleDao { | |||||
return &RoleDb{ | |||||
Db: engine, | |||||
Id: id, | |||||
} | |||||
} | |||||
type RoleDb struct { | |||||
Db *xorm.Engine | |||||
Id int `json:"id"` | |||||
} | |||||
func (r RoleDb) FindRole() (*[]model.Role, error) { | |||||
var m []model.Role | |||||
if err := r.Db.Desc("id").Find(&m); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &m, nil | |||||
} | |||||
func (r RoleDb) GetRole() (m *model.Role, err error) { | |||||
m = new(model.Role) | |||||
has, err := r.Db.Where("id = ?", r.Id).Get(m) | |||||
if err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return m, nil | |||||
} | |||||
func (r RoleDb) UpdateRole(m *model.Role, columns ...string) (int64, error) { | |||||
affected, err := r.Db.Where("id =?", m.Id).Cols(columns...).Update(m) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return affected, nil | |||||
} | |||||
func (r RoleDb) RoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { | |||||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||||
return session.In("id", id).Delete(model.Role{}) | |||||
} else { | |||||
return session.Where("id = ?", id).Delete(model.Role{}) | |||||
} | |||||
} | |||||
func (r RoleDb) RoleInsert(m *model.Role) (int, error) { | |||||
_, err := r.Db.InsertOne(m) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return m.Id, nil | |||||
} | |||||
func (r RoleDb) FindPermissionGroupByRole(roleId int) (list []*dao.RolePermissionGroup, total int64, err error) { | |||||
total, err = r.Db.Where("role.id =?", roleId). | |||||
Join("LEFT", "role_permission_group", "role_permission_group.role_id = role.id"). | |||||
Join("LEFT", "permission_group", "permission_group.id = role_permission_group.group_id"). | |||||
FindAndCount(&list) | |||||
return | |||||
} |
@@ -1,32 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"applet/app/db/model" | |||||
"reflect" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewRolePermissionGroupDb(engine *xorm.Engine) dao.RolePermissionGroupDao { | |||||
return &RolePermissionGroupDb{Db: engine} | |||||
} | |||||
type RolePermissionGroupDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func (r RolePermissionGroupDb) RolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { | |||||
if reflect.TypeOf(roleId).Kind() == reflect.Slice { | |||||
return session.In("role_id", roleId).Delete(model.RolePermissionGroup{}) | |||||
} else { | |||||
return session.Where("role_id = ?", roleId).Delete(model.RolePermissionGroup{}) | |||||
} | |||||
} | |||||
func (r RolePermissionGroupDb) BatchAddRolePermissionGroupBySession(session *xorm.Session, mm []*model.RolePermissionGroup) (int64, error) { | |||||
affected, err := session.Insert(mm) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return affected, nil | |||||
} |
@@ -0,0 +1,124 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/dao" | |||||
"applet/app/db/model" | |||||
"applet/app/md" | |||||
"applet/app/utils/cache" | |||||
"applet/app/utils/logx" | |||||
"fmt" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewSysCfgDb(engine *xorm.Engine, masterId string) dao.SysCfgDao { | |||||
return &SysCfgDb{ | |||||
Db: engine, | |||||
MasterId: masterId, | |||||
} | |||||
} | |||||
type SysCfgDb struct { | |||||
Db *xorm.Engine | |||||
MasterId string | |||||
} | |||||
func (s SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) { | |||||
var cfgList []model.SysCfg | |||||
if err := s.Db.Cols("key,val,memo").Find(&cfgList); err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &cfgList, nil | |||||
} | |||||
func (s SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) { | |||||
var cfgList model.SysCfg | |||||
has, err := s.Db.Where("`key`=?", key).Get(&cfgList) | |||||
if err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
if !has { | |||||
return nil, nil | |||||
} | |||||
return &cfgList, nil | |||||
} | |||||
func (s SysCfgDb) SysCfgGetOne(key string) (*model.SysCfg, error) { | |||||
var cfgList model.SysCfg | |||||
if has, err := s.Db.Where("`key`=?", key).Get(&cfgList); err != nil || has == false { | |||||
return nil, logx.Error(err) | |||||
} | |||||
return &cfgList, nil | |||||
} | |||||
func (s SysCfgDb) SysCfgInsert(key, val, memo string) bool { | |||||
cfg := model.SysCfg{Key: key, Val: val, Memo: memo} | |||||
_, err := s.Db.InsertOne(&cfg) | |||||
if err != nil { | |||||
logx.Error(err) | |||||
return false | |||||
} | |||||
return true | |||||
} | |||||
func (s SysCfgDb) SysCfgUpdate(key, val string) bool { | |||||
cfg := model.SysCfg{Key: key, Val: val} | |||||
_, err := s.Db.Where("`key`=?", key).Cols("val").Update(&cfg) | |||||
if err != nil { | |||||
logx.Error(err) | |||||
return false | |||||
} | |||||
s.SysCfgDel(key) | |||||
return true | |||||
} | |||||
func (s SysCfgDb) SysCfgGetWithDb(HKey string) string { | |||||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, s.MasterId, HKey[0:1]) | |||||
get, err := cache.HGetString(cacheKey, HKey) | |||||
if err != nil || get == "" { | |||||
cfg, err := s.SysCfgGetOne(HKey) | |||||
if err != nil || cfg == nil { | |||||
_ = logx.Error(err) | |||||
return "" | |||||
} | |||||
// key是否存在 | |||||
cacheKeyExist := false | |||||
if cache.Exists(cacheKey) { | |||||
cacheKeyExist = true | |||||
} | |||||
// 设置缓存 | |||||
_, err = cache.HSet(cacheKey, HKey, cfg.Val) | |||||
if err != nil { | |||||
_ = logx.Error(err) | |||||
return "" | |||||
} | |||||
if !cacheKeyExist { // 如果是首次设置 设置过期时间 | |||||
_, err := cache.Expire(cacheKey, md.CfgCacheTime) | |||||
if err != nil { | |||||
_ = logx.Error(err) | |||||
return "" | |||||
} | |||||
} | |||||
return cfg.Val | |||||
} | |||||
return get | |||||
} | |||||
func (s SysCfgDb) SysCfgDel(HKey string) error { | |||||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, s.MasterId, HKey[0:1]) | |||||
_, err := cache.HDel(cacheKey, HKey) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
return nil | |||||
} | |||||
func (s SysCfgDb) SysCfgFindWithDb(keys ...string) map[string]string { | |||||
res := map[string]string{} | |||||
for _, v := range keys { | |||||
val := s.SysCfgGetWithDb(v) | |||||
res[v] = val | |||||
} | |||||
return res | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package model | |||||
type Admin struct { | |||||
AdmId int `json:"adm_id" xorm:"not null comment('管理员id') INT(11)"` | |||||
Username string `json:"username" xorm:"not null default '' comment('用户名') VARCHAR(255)"` | |||||
Password string `json:"password" xorm:"not null default '' comment('密码') VARCHAR(255)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` | |||||
IsSuperAdministrator int `json:"is_super_administrator" xorm:"not null default 0 comment('是否为超级管理员(0:否 1:是)') TINYINT(1)"` | |||||
Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
OpenId string `json:"open_id" xorm:"not null default '' comment('微信openid') VARCHAR(255)"` | |||||
UnionId string `json:"union_id" xorm:"not null default '' comment('微信用户id') VARCHAR(255)"` | |||||
} |
@@ -1,10 +0,0 @@ | |||||
package model | |||||
type AdminRole struct { | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
AdmId int `json:"adm_id" xorm:"not null default 0 comment('管理员id') INT(11)"` | |||||
RoleId int `json:"role_id" xorm:"not null default 0 comment('角色id') INT(11)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package model | |||||
type DbMapping struct { | |||||
DbMasterId string `json:"db_master_id" xorm:"not null pk comment('站长id') VARCHAR(16)"` | |||||
DbHost string `json:"db_host" xorm:"not null default '' comment('数据库连接(带port)') VARCHAR(255)"` | |||||
DbUsername string `json:"db_username" xorm:"not null default '' comment('数据库用户名') VARCHAR(255)"` | |||||
DbPassword string `json:"db_password" xorm:"not null default '' comment('数据库用户名密码') VARCHAR(255)"` | |||||
DbName string `json:"db_name" xorm:"not null comment('数据库名') VARCHAR(255)"` | |||||
ExternalMysql string `json:"external_mysql" xorm:"not null default '0' comment('是否外部mysql(0是内部,1是外部)') VARCHAR(255)"` | |||||
IsDev int `json:"is_dev" xorm:"not null default 0 comment('开发库是1,0是生产库') TINYINT(1)"` | |||||
CreatedAt string `json:"created_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"` | |||||
UpdatedAt string `json:"updated_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"` | |||||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 comment('是否已删除') TINYINT(1)"` | |||||
} |
@@ -1,10 +0,0 @@ | |||||
package model | |||||
type Permission struct { | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` | |||||
Action string `json:"action" xorm:"not null default '' comment('路由') unique VARCHAR(255)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:废弃)') TINYINT(1)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} |
@@ -1,11 +0,0 @@ | |||||
package model | |||||
type PermissionGroup struct { | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
ParentId int `json:"parent_id" xorm:"not null default 0 comment('父级id') INT(11)"` | |||||
Key string `json:"key" xorm:"not null default '' VARCHAR(255)"` | |||||
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:废弃)') TINYINT(1)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} |
@@ -1,9 +0,0 @@ | |||||
package model | |||||
type PermissionGroupPermission struct { | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
GroupId int `json:"group_id" xorm:"not null default 0 comment('权限组id') INT(11)"` | |||||
PermissionId int `json:"permission_id" xorm:"not null default 0 comment('权限id') INT(11)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} |
@@ -1,10 +0,0 @@ | |||||
package model | |||||
type Role struct { | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` | |||||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} |
@@ -1,9 +0,0 @@ | |||||
package model | |||||
type RolePermissionGroup struct { | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
RoleId int `json:"role_id" xorm:"not null default 0 comment('角色id') INT(11)"` | |||||
GroupId int `json:"group_id" xorm:"not null default 0 comment('权限组id') INT(11)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} |
@@ -1,5 +0,0 @@ | |||||
package dao | |||||
type MediumListDao interface { | |||||
//TODO:: You can add specific method definitions here | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package implement | |||||
import ( | |||||
"applet/app/db/super/dao" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewMediumListDb(engine *xorm.Engine) dao.MediumListDao { | |||||
return &MediumListDb{Db: engine} | |||||
} | |||||
type MediumListDb struct { | |||||
Db *xorm.Engine | |||||
} |
@@ -1,25 +0,0 @@ | |||||
package model | |||||
type MediumList struct { | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
Uuid int `json:"uuid" xorm:"not null comment('站长id') index unique(IDX_UUID_TYPE) INT(11)"` | |||||
MediumId int `json:"medium_id" xorm:"not null comment('媒体id') unique(IDX_UUID_TYPE) INT(11)"` | |||||
Kind int `json:"kind" xorm:"not null default 1 comment('类型(1:企业 2:个人)') TINYINT(1)"` | |||||
CompanyName string `json:"company_name" xorm:"not null default '' comment('公司名称') VARCHAR(255)"` | |||||
CompanyAbbreviation string `json:"company_abbreviation" xorm:"not null default '' comment('公司简称') VARCHAR(255)"` | |||||
UnifiedSocialCreditCode string `json:"unified_social_credit_code" xorm:"not null default '' comment('统一社会信用代码') VARCHAR(255)"` | |||||
CertificateType int `json:"certificate_type" xorm:"not null default 1 comment('证件类型') TINYINT(1)"` | |||||
BusinessLicenseImgUrl string `json:"business_license_img_url" xorm:"not null default '' comment('营业执照照片') VARCHAR(255)"` | |||||
LegalRepresentative string `json:"legal_representative" xorm:"not null default '' comment('法定代表人') CHAR(50)"` | |||||
CountryRegionId int `json:"country_region_id" xorm:"not null default 1 comment('国家地区id') TINYINT(3)"` | |||||
CountryRegion string `json:"country_region" xorm:"not null default '' comment('国家地区') CHAR(50)"` | |||||
RegisteredAddressProvinceId int `json:"registered_address_province_id" xorm:"not null default 0 comment('注册地址-省份id') INT(11)"` | |||||
RegisteredAddressCityId int `json:"registered_address_city_id" xorm:"not null default 0 comment('注册地址-市id') INT(11)"` | |||||
RegisteredAddressCountyId int `json:"registered_address_county_id" xorm:"not null default 0 comment('注册地址-县/区id') INT(11)"` | |||||
RegisteredAddress string `json:"registered_address" xorm:"not null default '' comment('注册地址') VARCHAR(255)"` | |||||
BusinessLicenseAddress string `json:"business_license_address" xorm:"not null default '' comment('营业执照地址') VARCHAR(255)"` | |||||
CertificateValidity string `json:"certificate_validity" xorm:"not null default '0000-00-00' comment('证件有效期') CHAR(50)"` | |||||
State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} |
@@ -1,13 +1,13 @@ | |||||
package hdl | package hdl | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
"applet/app/db/implement" | |||||
"applet/app/e" | "applet/app/e" | ||||
"applet/app/lib/validate" | "applet/app/lib/validate" | ||||
"applet/app/md" | "applet/app/md" | ||||
"applet/app/svc" | "applet/app/svc" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"fmt" | "fmt" | ||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
) | ) | ||||
@@ -32,8 +32,8 @@ func Login(c *gin.Context) { | |||||
return | return | ||||
} | } | ||||
engine := db.DBs[svc.GetMasterId(c)] | engine := db.DBs[svc.GetMasterId(c)] | ||||
adminDb := implement.NewAdminDb(engine) | |||||
admin, err := adminDb.GetAdminByUserName(req.UserName) | |||||
adminDb := implement.NewAgentDb(engine) | |||||
admin, err := adminDb.GetAgentByUsername(req.UserName) | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err) | e.OutErr(c, e.ERR_DB_ORM, err) | ||||
return | return | ||||
@@ -47,7 +47,7 @@ func Login(c *gin.Context) { | |||||
return | return | ||||
} | } | ||||
ip := utils.GetIP(c.Request) | ip := utils.GetIP(c.Request) | ||||
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(admin.AdmId)) | |||||
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(admin.Id)) | |||||
token, err := svc.HandleLoginToken(key, admin) | token, err := svc.HandleLoginToken(key, admin) | ||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR, err.Error()) | e.OutErr(c, e.ERR, err.Error()) | ||||
@@ -1,15 +1,15 @@ | |||||
package hdl | package hdl | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
"applet/app/db/implement" | |||||
"applet/app/db/model" | |||||
"applet/app/e" | "applet/app/e" | ||||
"applet/app/enum" | "applet/app/enum" | ||||
"applet/app/lib/validate" | "applet/app/lib/validate" | ||||
"applet/app/md" | "applet/app/md" | ||||
"applet/app/svc" | "applet/app/svc" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"time" | "time" | ||||
) | ) | ||||
@@ -28,8 +28,8 @@ import ( | |||||
func PermissionGroupList(c *gin.Context) { | func PermissionGroupList(c *gin.Context) { | ||||
roleId := c.DefaultQuery("role_id", "") | roleId := c.DefaultQuery("role_id", "") | ||||
engine := db.DBs[svc.GetMasterId(c)] | engine := db.DBs[svc.GetMasterId(c)] | ||||
qrcodeWithBatchRecordsDb := implement.NewPermissionGroupDb(engine) | |||||
groupList, err := qrcodeWithBatchRecordsDb.FindPermissionGroup() | |||||
qrcodeWithBatchRecordsDb := implement.NewAgentPermissionGroupDb(engine) | |||||
groupList, err := qrcodeWithBatchRecordsDb.FindAgentPermissionGroup() | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
@@ -111,26 +111,26 @@ func PermissionGroupList(c *gin.Context) { | |||||
// @Router /admin/role/roleList [GET] | // @Router /admin/role/roleList [GET] | ||||
func RoleList(c *gin.Context) { | func RoleList(c *gin.Context) { | ||||
engine := db.DBs[svc.GetMasterId(c)] | engine := db.DBs[svc.GetMasterId(c)] | ||||
roleDb := implement.NewRoleDb(engine, 0) | |||||
roleList, err := roleDb.FindRole() | |||||
roleDb := implement.NewAgentRoleDb(engine) | |||||
roleList, err := roleDb.FindAgentRole() | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
} | } | ||||
adminRoleDb := implement.NewAdminRoleDb(engine) | |||||
adminDb := implement.NewAdminDb(engine) | |||||
adminRoleDb := implement.NewAgentWithRoleDb(engine) | |||||
adminDb := implement.NewAgentDb(engine) | |||||
var result []*md.RoleListResp | var result []*md.RoleListResp | ||||
for _, v := range *roleList { | for _, v := range *roleList { | ||||
var temp md.RoleListResp | var temp md.RoleListResp | ||||
temp.Data = v | temp.Data = v | ||||
adminRoles, err1 := adminRoleDb.FindAdminRoleByRoleId(v.Id) | |||||
adminRoles, err1 := adminRoleDb.FindAgentWithRoleByRoleId(v.Id) | |||||
if err1 != nil { | if err1 != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | ||||
return | return | ||||
} | } | ||||
for _, adminRole := range *adminRoles { | for _, adminRole := range *adminRoles { | ||||
admin, err2 := adminDb.GetAdmin(adminRole.AdmId) | |||||
admin, err2 := adminDb.GetAgent(adminRole.Id) | |||||
if err2 != nil { | if err2 != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | ||||
return | return | ||||
@@ -180,9 +180,10 @@ func AddRole(c *gin.Context) { | |||||
return | return | ||||
} | } | ||||
engine := db.DBs[svc.GetMasterId(c)] | engine := db.DBs[svc.GetMasterId(c)] | ||||
roleDb := implement.NewRoleDb(engine, 0) | |||||
roleDb := implement.NewAgentRoleDb(engine) | |||||
now := time.Now() | now := time.Now() | ||||
_, err = roleDb.RoleInsert(&model.Role{ | |||||
_, err = roleDb.AgentRoleInsert(&model.AgentRole{ | |||||
Name: req.Name, | Name: req.Name, | ||||
State: enum.RoleStateForNormal, | State: enum.RoleStateForNormal, | ||||
Memo: req.Memo, | Memo: req.Memo, | ||||
@@ -219,8 +220,8 @@ func UpdateRole(c *gin.Context) { | |||||
return | return | ||||
} | } | ||||
engine := db.DBs[svc.GetMasterId(c)] | engine := db.DBs[svc.GetMasterId(c)] | ||||
roleDb := implement.NewRoleDb(engine, req.RoleId) | |||||
role, err := roleDb.GetRole() | |||||
roleDb := implement.NewAgentRoleDb(engine) | |||||
role, err := roleDb.GetAgentRole(req.RoleId) | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
@@ -231,7 +232,7 @@ func UpdateRole(c *gin.Context) { | |||||
} | } | ||||
role.Name = req.Name | role.Name = req.Name | ||||
role.Memo = req.Memo | role.Memo = req.Memo | ||||
_, err = roleDb.UpdateRole(role, "name", "memo") | |||||
_, err = roleDb.UpdateAgentRole(role, "name", "memo") | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
@@ -392,7 +393,7 @@ func AdminList(c *gin.Context) { | |||||
} | } | ||||
result = append(result, md.AdminListResp{ | result = append(result, md.AdminListResp{ | ||||
AdmId: v.AdmId, | |||||
Id: v.AdmId, | |||||
Username: v.Username, | Username: v.Username, | ||||
State: v.State, | State: v.State, | ||||
IsSuperAdministrator: v.IsSuperAdministrator, | IsSuperAdministrator: v.IsSuperAdministrator, | ||||
@@ -443,7 +444,7 @@ func UpdateAdminState(c *gin.Context) { | |||||
engine := db.DBs[svc.GetMasterId(c)] | engine := db.DBs[svc.GetMasterId(c)] | ||||
admDb := implement.NewAdminDb(engine) | admDb := implement.NewAdminDb(engine) | ||||
admin, err := admDb.GetAdmin(req.AdmId) | |||||
admin, err := admDb.GetAdmin(req.Id) | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
@@ -484,7 +485,7 @@ func UpdateAdmin(c *gin.Context) { | |||||
} | } | ||||
engine := db.DBs[svc.GetMasterId(c)] | engine := db.DBs[svc.GetMasterId(c)] | ||||
admDb := implement.NewAdminDb(engine) | admDb := implement.NewAdminDb(engine) | ||||
admin, err := admDb.GetAdmin(req.AdmId) | |||||
admin, err := admDb.GetAdmin(req.Id) | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
@@ -1,8 +1,9 @@ | |||||
package md | package md | ||||
type LoginReq struct { | type LoginReq struct { | ||||
UserName string `json:"username" binding:"required" label:"登录账号"` | |||||
PassWord string `json:"password" binding:"required" label:"登录密码"` | |||||
UserName string `json:"username" binding:"required" example:"登录账号"` | |||||
PassWord string `json:"password" binding:"required" example:"登录密码"` | |||||
Code string `json:"code" example:"验证码"` | |||||
} | } | ||||
type LoginResponse struct { | type LoginResponse struct { | ||||
@@ -1,11 +1,11 @@ | |||||
package md | package md | ||||
import ( | import ( | ||||
"applet/app/db/model" | |||||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||||
) | ) | ||||
type RoleListResp struct { | type RoleListResp struct { | ||||
Data model.Role `json:"data"` | |||||
Data model.AgentRole `json:"data"` | |||||
AdminList []struct { | AdminList []struct { | ||||
Name string `json:"name"` | Name string `json:"name"` | ||||
} `json:"admin_list"` | } `json:"admin_list"` | ||||
@@ -52,7 +52,7 @@ type AdminListReq struct { | |||||
} | } | ||||
type AdminListResp struct { | type AdminListResp struct { | ||||
AdmId int `json:"adm_id"` | |||||
Id int `json:"id"` | |||||
Username string `json:"username"` | Username string `json:"username"` | ||||
State int `json:"state"` | State int `json:"state"` | ||||
IsSuperAdministrator int `json:"is_super_administrator"` | IsSuperAdministrator int `json:"is_super_administrator"` | ||||
@@ -63,7 +63,7 @@ type AdminListResp struct { | |||||
} | } | ||||
type UpdateAdminStateReq struct { | type UpdateAdminStateReq struct { | ||||
AdmId int `json:"adm_id" binding:"required" label:"管理员id"` | |||||
Id int `json:"id" binding:"required" label:"管理员id"` | |||||
State int `json:"state" binding:"required" label:"状态"` | State int `json:"state" binding:"required" label:"状态"` | ||||
} | } | ||||
@@ -74,18 +74,18 @@ type AddAdminReq struct { | |||||
} | } | ||||
type UpdateAdminReq struct { | type UpdateAdminReq struct { | ||||
AdmId int `json:"adm_id" binding:"required" label:"管理员id"` | |||||
Id int `json:"id" binding:"required" label:"管理员id"` | |||||
Username string `json:"username" binding:"required" label:"名称"` | Username string `json:"username" binding:"required" label:"名称"` | ||||
Password string `json:"password" binding:"required" label:"密码"` | Password string `json:"password" binding:"required" label:"密码"` | ||||
Memo string `json:"memo" label:"备注"` | Memo string `json:"memo" label:"备注"` | ||||
} | } | ||||
type BindAdminRoleReq struct { | type BindAdminRoleReq struct { | ||||
AdmId int `json:"adm_id" binding:"required" label:"管理员id"` | |||||
Id int `json:"id" binding:"required" label:"管理员id"` | |||||
RoleIds []int `json:"role_ids" label:"角色id"` | RoleIds []int `json:"role_ids" label:"角色id"` | ||||
} | } | ||||
type BindAdminWithEnterpriseReq struct { | type BindAdminWithEnterpriseReq struct { | ||||
AdmId int `json:"adm_id" binding:"required" label:"管理员id"` | |||||
Ids []int `json:"ids" label:"记录id"` | |||||
Id int `json:"id" binding:"required" label:"管理员id"` | |||||
Ids []int `json:"ids" label:"记录id"` | |||||
} | } |
@@ -1,9 +1,9 @@ | |||||
package mw | package mw | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
"applet/app/e" | "applet/app/e" | ||||
"applet/app/svc" | "applet/app/svc" | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"errors" | "errors" | ||||
"fmt" | "fmt" | ||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
@@ -18,7 +18,6 @@ func DB(c *gin.Context) { | |||||
e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id")) | e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id")) | ||||
return | return | ||||
} | } | ||||
_, ok := db.DBs[masterID] | _, ok := db.DBs[masterID] | ||||
if !ok { | if !ok { | ||||
e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id in DBs")) | e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id in DBs")) | ||||
@@ -6,6 +6,8 @@ import ( | |||||
"applet/app/mw" | "applet/app/mw" | ||||
_ "applet/docs" | _ "applet/docs" | ||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
swaggerFiles "github.com/swaggo/files" | |||||
ginSwagger "github.com/swaggo/gin-swagger" | |||||
) | ) | ||||
// 初始化路由 | // 初始化路由 | ||||
@@ -18,6 +20,11 @@ func Init() *gin.Engine { | |||||
gin.SetMode(mode) | gin.SetMode(mode) | ||||
//创建一个新的启动器 | //创建一个新的启动器 | ||||
r := gin.New() | r := gin.New() | ||||
r.GET("/api/swagger/*any", func(c *gin.Context) { | |||||
//r.Use(mw.SwagAuth()) | |||||
ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c) | |||||
}) | |||||
r.Use(mw.ChangeHeader) | r.Use(mw.ChangeHeader) | ||||
// 是否打印访问日志, 在非正式环境都打印 | // 是否打印访问日志, 在非正式环境都打印 | ||||
@@ -1,8 +1,8 @@ | |||||
package svc | package svc | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
"applet/app/db/implement" | |||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
) | ) | ||||
@@ -12,16 +12,16 @@ func AdminDelete(c *gin.Context, admIds []int) (err error) { | |||||
defer session.Close() | defer session.Close() | ||||
session.Begin() | session.Begin() | ||||
//1、删除 `admin` | //1、删除 `admin` | ||||
adminDb := implement.NewAdminDb(engine) | |||||
_, err = adminDb.AdminDeleteBySession(session, admIds) | |||||
adminDb := implement.NewAgentDb(engine) | |||||
_, err = adminDb.AgentDeleteBySession(session, admIds) | |||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
return | return | ||||
} | } | ||||
//2、删除 `admin_role` | //2、删除 `admin_role` | ||||
adminRoleDb := implement.NewAdminRoleDb(engine) | |||||
_, err = adminRoleDb.AdminDeleteBySessionForAdmId(session, admIds) | |||||
adminRoleDb := implement.NewAgentWithRoleDb(engine) | |||||
_, err = adminRoleDb.AgentDeleteBySessionForAdmId(session, admIds) | |||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
return | return | ||||
@@ -1,20 +1,20 @@ | |||||
package svc | package svc | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
"applet/app/db/implement" | |||||
"applet/app/db/model" | |||||
"applet/app/lib/auth" | "applet/app/lib/auth" | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||||
"errors" | "errors" | ||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"strings" | "strings" | ||||
) | ) | ||||
func GetUser(c *gin.Context) *model.Admin { | |||||
func GetUser(c *gin.Context) *model.Agent { | |||||
user, _ := c.Get("admin") | user, _ := c.Get("admin") | ||||
if user == nil { | if user == nil { | ||||
return &model.Admin{ | |||||
AdmId: 0, | |||||
return &model.Agent{ | |||||
Id: 0, | |||||
Username: "", | Username: "", | ||||
Password: "", | Password: "", | ||||
State: 0, | State: 0, | ||||
@@ -22,14 +22,12 @@ func GetUser(c *gin.Context) *model.Admin { | |||||
Memo: "", | Memo: "", | ||||
CreateAt: "", | CreateAt: "", | ||||
UpdateAt: "", | UpdateAt: "", | ||||
OpenId: "", | |||||
UnionId: "", | |||||
} | } | ||||
} | } | ||||
return user.(*model.Admin) | |||||
return user.(*model.Agent) | |||||
} | } | ||||
func CheckUser(c *gin.Context) (*model.Admin, error) { | |||||
func CheckUser(c *gin.Context) (*model.Agent, error) { | |||||
token := c.GetHeader("Authorization") | token := c.GetHeader("Authorization") | ||||
if token == "" { | if token == "" { | ||||
return nil, errors.New("token not exist") | return nil, errors.New("token not exist") | ||||
@@ -46,8 +44,8 @@ func CheckUser(c *gin.Context) (*model.Admin, error) { | |||||
} | } | ||||
// 获取admin | // 获取admin | ||||
adminDb := implement.NewAdminDb(db.DBs[GetMasterId(c)]) | |||||
admin, err := adminDb.GetAdmin(mc.AdmId) | |||||
adminDb := implement.NewAgentDb(db.DBs[GetMasterId(c)]) | |||||
admin, err := adminDb.GetAgent(mc.AdmId) | |||||
if err != nil { | if err != nil { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
package svc | package svc | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -1,14 +1,14 @@ | |||||
package svc | package svc | ||||
import ( | import ( | ||||
"applet/app/db/model" | |||||
"applet/app/lib/auth" | "applet/app/lib/auth" | ||||
"applet/app/md" | "applet/app/md" | ||||
"applet/app/utils/cache" | "applet/app/utils/cache" | ||||
"applet/app/utils/logx" | "applet/app/utils/logx" | ||||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||||
) | ) | ||||
func HandleLoginToken(cacheKey string, admin *model.Admin) (string, error) { | |||||
func HandleLoginToken(cacheKey string, admin *model.Agent) (string, error) { | |||||
// 获取之前生成的token | // 获取之前生成的token | ||||
token, err := cache.GetString(cacheKey) | token, err := cache.GetString(cacheKey) | ||||
if err != nil { | if err != nil { | ||||
@@ -17,7 +17,7 @@ func HandleLoginToken(cacheKey string, admin *model.Admin) (string, error) { | |||||
// 没有获取到 | // 没有获取到 | ||||
if err != nil || token == "" { | if err != nil || token == "" { | ||||
// 生成token | // 生成token | ||||
token, err = auth.GenToken(admin.AdmId, admin.Username) | |||||
token, err = auth.GenToken(admin.Id, admin.Username) | |||||
if err != nil { | if err != nil { | ||||
return "", err | return "", err | ||||
} | } | ||||
@@ -1,12 +1,12 @@ | |||||
package svc | package svc | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
"applet/app/db/implement" | |||||
"applet/app/db/model" | |||||
"applet/app/md" | "applet/app/md" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
"applet/app/utils/cache" | "applet/app/utils/cache" | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||||
"encoding/json" | "encoding/json" | ||||
"errors" | "errors" | ||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
@@ -113,25 +113,25 @@ func RoleBindPermissionGroup(c *gin.Context, req md.RoleBindPermissionGroupReq) | |||||
} | } | ||||
//1、删除 `role_permission_group` | //1、删除 `role_permission_group` | ||||
rolePermissionGroupDb := implement.NewRolePermissionGroupDb(db.DBs[GetMasterId(c)]) | |||||
_, err = rolePermissionGroupDb.RolePermissionGroupDeleteForRoleBySession(session, req.RoleId) | |||||
rolePermissionGroupDb := implement.NewAgentRolePermissionGroupDb(db.DBs[GetMasterId(c)]) | |||||
_, err = rolePermissionGroupDb.AgentRolePermissionGroupDeleteForRoleBySession(session, req.RoleId) | |||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
return | return | ||||
} | } | ||||
//2、新增 `role_permission_group`` | //2、新增 `role_permission_group`` | ||||
var mm []*model.RolePermissionGroup | |||||
var mm []*model.AgentRolePermissionGroup | |||||
now := time.Now() | now := time.Now() | ||||
for _, v := range req.PermissionIds { | for _, v := range req.PermissionIds { | ||||
mm = append(mm, &model.RolePermissionGroup{ | |||||
mm = append(mm, &model.AgentRolePermissionGroup{ | |||||
RoleId: role.Id, | RoleId: role.Id, | ||||
GroupId: v, | GroupId: v, | ||||
CreateAt: now.Format("2006-01-02 15:04:05"), | CreateAt: now.Format("2006-01-02 15:04:05"), | ||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | UpdateAt: now.Format("2006-01-02 15:04:05"), | ||||
}) | }) | ||||
} | } | ||||
_, err = rolePermissionGroupDb.BatchAddRolePermissionGroupBySession(session, mm) | |||||
_, err = rolePermissionGroupDb.BatchAddAgentRolePermissionGroupBySession(session, mm) | |||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
return | return | ||||
@@ -145,8 +145,8 @@ func BindAdminRole(c *gin.Context, req md.BindAdminRoleReq) (err error) { | |||||
defer session.Close() | defer session.Close() | ||||
session.Begin() | session.Begin() | ||||
//1、查询 `role` | //1、查询 `role` | ||||
adminDb := implement.NewAdminDb(db.DBs[GetMasterId(c)]) | |||||
role, err := adminDb.GetAdmin(req.AdmId) | |||||
adminDb := implement.NewAgentDb(db.DBs[GetMasterId(c)]) | |||||
role, err := adminDb.GetAgent(req.Id) | |||||
if err != nil { | if err != nil { | ||||
return | return | ||||
} | } | ||||
@@ -155,26 +155,26 @@ func BindAdminRole(c *gin.Context, req md.BindAdminRoleReq) (err error) { | |||||
} | } | ||||
//1、删除 `admin_role` | //1、删除 `admin_role` | ||||
adminRoleDb := implement.NewAdminRoleDb(db.DBs[GetMasterId(c)]) | |||||
_, err = adminRoleDb.AdminRoleDeleteBySession(session, req.AdmId) | |||||
adminRoleDb := implement.NewAgentWithRoleDb(db.DBs[GetMasterId(c)]) | |||||
_, err = adminRoleDb.AgentWithRoleDeleteBySession(session, req.Id) | |||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
return | return | ||||
} | } | ||||
//2、新增 `删除 `admin_role`` | //2、新增 `删除 `admin_role`` | ||||
var mm []*model.AdminRole | |||||
var mm []*model.AgentWithRole | |||||
now := time.Now() | now := time.Now() | ||||
for _, v := range req.RoleIds { | for _, v := range req.RoleIds { | ||||
mm = append(mm, &model.AdminRole{ | |||||
AdmId: req.AdmId, | |||||
mm = append(mm, &model.AgentWithRole{ | |||||
AgentId: req.Id, | |||||
RoleId: v, | RoleId: v, | ||||
State: 1, | State: 1, | ||||
CreateAt: now.Format("2006-01-02 15:04:05"), | CreateAt: now.Format("2006-01-02 15:04:05"), | ||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | UpdateAt: now.Format("2006-01-02 15:04:05"), | ||||
}) | }) | ||||
} | } | ||||
_, err = adminRoleDb.BatchAddAdminRoleBySession(session, mm) | |||||
_, err = adminRoleDb.BatchAddAgentWithRoleBySession(session, mm) | |||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
return | return | ||||
@@ -1,10 +1,10 @@ | |||||
package svc | package svc | ||||
import ( | import ( | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
"applet/app/db" | |||||
"applet/app/md" | "applet/app/md" | ||||
"applet/app/utils/cache" | "applet/app/utils/cache" | ||||
) | ) | ||||
@@ -2,14 +2,14 @@ package task | |||||
import ( | import ( | ||||
taskMd "applet/app/task/md" | taskMd "applet/app/task/md" | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||||
"time" | "time" | ||||
"github.com/robfig/cron/v3" | "github.com/robfig/cron/v3" | ||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
"applet/app/cfg" | "applet/app/cfg" | ||||
"applet/app/db" | |||||
"applet/app/db/model" | |||||
"applet/app/md" | "applet/app/md" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
"applet/app/utils/logx" | "applet/app/utils/logx" | ||||
@@ -113,5 +113,5 @@ func doTask(dbName, fnName string) func() { | |||||
// 增加自动任务队列 | // 增加自动任务队列 | ||||
func initTasks() { | func initTasks() { | ||||
jobs[taskMd.MallCronOrderCancel] = taskCancelOrder // 取消订单 | |||||
jobs[taskMd.MallCronOrderCancel] = taskCancelOrder // 取消订单 | |||||
} | } |
@@ -1,10 +1,8 @@ | |||||
package svc | package svc | ||||
import ( | import ( | ||||
"applet/app/db" | |||||
"applet/app/utils" | "applet/app/utils" | ||||
"applet/app/utils/logx" | "applet/app/utils/logx" | ||||
"errors" | |||||
"fmt" | "fmt" | ||||
"time" | "time" | ||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
@@ -55,10 +53,5 @@ func handleOnePage(eg *xorm.Engine, dbName, expTimeStr string) (isEmpty bool, er | |||||
} | } | ||||
func getCancelCfg(eg *xorm.Engine, masterId string) (string, error) { | func getCancelCfg(eg *xorm.Engine, masterId string) (string, error) { | ||||
cfg := db.SysCfgGetWithDb(eg, masterId, "order_expiration_time") | |||||
if cfg == "" { | |||||
return "", errors.New("order_expiration_time no found") | |||||
} | |||||
return cfg, nil | |||||
return "", nil | |||||
} | } |
@@ -1,13 +1,13 @@ | |||||
package main | package main | ||||
import ( | import ( | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"fmt" | "fmt" | ||||
"os" | "os" | ||||
"os/signal" | "os/signal" | ||||
"syscall" | "syscall" | ||||
"applet/app/cfg" | "applet/app/cfg" | ||||
"applet/app/db" | |||||
"applet/app/task" | "applet/app/task" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
"applet/app/utils/logx" | "applet/app/utils/logx" | ||||
@@ -2,7 +2,10 @@ module applet | |||||
go 1.18 | go 1.18 | ||||
replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models | |||||
require ( | require ( | ||||
code.fnuoos.com/zhimeng/model.git v0.0.2 | |||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 | github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 | ||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 | ||||
github.com/boombuler/barcode v1.0.1 | github.com/boombuler/barcode v1.0.1 | ||||
@@ -10,12 +13,11 @@ require ( | |||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible | github.com/dgrijalva/jwt-go v3.2.0+incompatible | ||||
github.com/forgoer/openssl v0.0.0-20201023062029-c3112b0c8700 | github.com/forgoer/openssl v0.0.0-20201023062029-c3112b0c8700 | ||||
github.com/gin-contrib/sessions v0.0.3 | github.com/gin-contrib/sessions v0.0.3 | ||||
github.com/gin-gonic/gin v1.6.3 | |||||
github.com/go-playground/locales v0.13.0 | |||||
github.com/go-playground/universal-translator v0.17.0 | |||||
github.com/go-playground/validator/v10 v10.4.2 | |||||
github.com/gin-gonic/gin v1.9.0 | |||||
github.com/go-playground/locales v0.14.1 | |||||
github.com/go-playground/universal-translator v0.18.1 | |||||
github.com/go-playground/validator/v10 v10.11.2 | |||||
github.com/go-redis/redis v6.15.9+incompatible | github.com/go-redis/redis v6.15.9+incompatible | ||||
github.com/go-sql-driver/mysql v1.6.0 | |||||
github.com/gocolly/colly v1.2.0 | github.com/gocolly/colly v1.2.0 | ||||
github.com/gomodule/redigo v2.0.0+incompatible | github.com/gomodule/redigo v2.0.0+incompatible | ||||
github.com/iGoogle-ink/gopay v1.5.36 | github.com/iGoogle-ink/gopay v1.5.36 | ||||
@@ -23,16 +25,19 @@ require ( | |||||
github.com/qiniu/api.v7/v7 v7.8.2 | github.com/qiniu/api.v7/v7 v7.8.2 | ||||
github.com/robfig/cron/v3 v3.0.1 | github.com/robfig/cron/v3 v3.0.1 | ||||
github.com/sony/sonyflake v1.0.0 | github.com/sony/sonyflake v1.0.0 | ||||
github.com/swaggo/swag v1.7.0 | |||||
github.com/syyongx/php2go v0.9.4 | |||||
github.com/swaggo/files v1.0.1 | |||||
github.com/swaggo/gin-swagger v1.6.0 | |||||
github.com/swaggo/swag v1.8.12 | |||||
github.com/syyongx/php2go v0.9.8 | |||||
github.com/tidwall/gjson v1.7.4 | github.com/tidwall/gjson v1.7.4 | ||||
go.uber.org/zap v1.16.0 | go.uber.org/zap v1.16.0 | ||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 | |||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 | |||||
gopkg.in/yaml.v2 v2.4.0 | gopkg.in/yaml.v2 v2.4.0 | ||||
xorm.io/xorm v1.0.7 | |||||
xorm.io/xorm v1.3.1 | |||||
) | ) | ||||
require ( | require ( | ||||
filippo.io/edwards25519 v1.1.0 // indirect | |||||
github.com/KyleBanks/depth v1.2.1 // indirect | github.com/KyleBanks/depth v1.2.1 // indirect | ||||
github.com/PuerkitoBio/goquery v1.5.1 // indirect | github.com/PuerkitoBio/goquery v1.5.1 // indirect | ||||
github.com/PuerkitoBio/purell v1.1.1 // indirect | github.com/PuerkitoBio/purell v1.1.1 // indirect | ||||
@@ -41,50 +46,57 @@ require ( | |||||
github.com/antchfx/htmlquery v1.3.2 // indirect | github.com/antchfx/htmlquery v1.3.2 // indirect | ||||
github.com/antchfx/xmlquery v1.4.1 // indirect | github.com/antchfx/xmlquery v1.4.1 // indirect | ||||
github.com/antchfx/xpath v1.3.1 // indirect | github.com/antchfx/xpath v1.3.1 // indirect | ||||
github.com/bytedance/sonic v1.8.0 // indirect | |||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect | |||||
github.com/gin-contrib/sse v0.1.0 // indirect | github.com/gin-contrib/sse v0.1.0 // indirect | ||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect | github.com/go-openapi/jsonpointer v0.19.5 // indirect | ||||
github.com/go-openapi/jsonreference v0.19.5 // indirect | |||||
github.com/go-openapi/spec v0.20.3 // indirect | |||||
github.com/go-openapi/jsonreference v0.19.6 // indirect | |||||
github.com/go-openapi/spec v0.20.4 // indirect | |||||
github.com/go-openapi/swag v0.19.15 // indirect | github.com/go-openapi/swag v0.19.15 // indirect | ||||
github.com/go-sql-driver/mysql v1.8.1 // indirect | |||||
github.com/gobwas/glob v0.2.3 // indirect | github.com/gobwas/glob v0.2.3 // indirect | ||||
github.com/goccy/go-json v0.10.2 // indirect | |||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||||
github.com/golang/protobuf v1.5.2 // indirect | github.com/golang/protobuf v1.5.2 // indirect | ||||
github.com/golang/snappy v0.0.3 // indirect | |||||
github.com/golang/snappy v0.0.4 // indirect | |||||
github.com/gookit/color v1.3.8 // indirect | github.com/gookit/color v1.3.8 // indirect | ||||
github.com/gorilla/context v1.1.1 // indirect | github.com/gorilla/context v1.1.1 // indirect | ||||
github.com/gorilla/securecookie v1.1.1 // indirect | github.com/gorilla/securecookie v1.1.1 // indirect | ||||
github.com/gorilla/sessions v1.2.1 // indirect | github.com/gorilla/sessions v1.2.1 // indirect | ||||
github.com/josharian/intern v1.0.0 // indirect | github.com/josharian/intern v1.0.0 // indirect | ||||
github.com/json-iterator/go v1.1.10 // indirect | |||||
github.com/json-iterator/go v1.1.12 // indirect | |||||
github.com/kennygrant/sanitize v1.2.4 // indirect | github.com/kennygrant/sanitize v1.2.4 // indirect | ||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect | |||||
github.com/leodido/go-urn v1.2.1 // indirect | github.com/leodido/go-urn v1.2.1 // indirect | ||||
github.com/mailru/easyjson v0.7.7 // indirect | github.com/mailru/easyjson v0.7.7 // indirect | ||||
github.com/mattn/go-isatty v0.0.12 // indirect | |||||
github.com/mattn/go-isatty v0.0.19 // indirect | |||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||||
github.com/modern-go/reflect2 v1.0.1 // indirect | |||||
github.com/modern-go/reflect2 v1.0.2 // indirect | |||||
github.com/onsi/ginkgo v1.15.0 // indirect | github.com/onsi/ginkgo v1.15.0 // indirect | ||||
github.com/onsi/gomega v1.10.5 // indirect | github.com/onsi/gomega v1.10.5 // indirect | ||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect | |||||
github.com/pkg/errors v0.9.1 // indirect | github.com/pkg/errors v0.9.1 // indirect | ||||
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect | github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect | ||||
github.com/smartystreets/goconvey v1.6.4 // indirect | |||||
github.com/stretchr/testify v1.7.0 // indirect | |||||
github.com/syndtr/goleveldb v1.0.0 // indirect | github.com/syndtr/goleveldb v1.0.0 // indirect | ||||
github.com/temoto/robotstxt v1.1.2 // indirect | github.com/temoto/robotstxt v1.1.2 // indirect | ||||
github.com/tidwall/match v1.0.3 // indirect | github.com/tidwall/match v1.0.3 // indirect | ||||
github.com/tidwall/pretty v1.1.0 // indirect | github.com/tidwall/pretty v1.1.0 // indirect | ||||
github.com/ugorji/go/codec v1.2.5 // indirect | |||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | |||||
github.com/ugorji/go/codec v1.2.9 // indirect | |||||
go.uber.org/atomic v1.7.0 // indirect | go.uber.org/atomic v1.7.0 // indirect | ||||
go.uber.org/multierr v1.6.0 // indirect | go.uber.org/multierr v1.6.0 // indirect | ||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect | |||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect | |||||
golang.org/x/crypto v0.5.0 // indirect | |||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect | golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect | ||||
golang.org/x/net v0.7.0 // indirect | |||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect | |||||
golang.org/x/sys v0.5.0 // indirect | |||||
golang.org/x/text v0.7.0 // indirect | |||||
golang.org/x/tools v0.1.12 // indirect | |||||
golang.org/x/net v0.10.0 // indirect | |||||
golang.org/x/sync v0.1.0 // indirect | |||||
golang.org/x/sys v0.8.0 // indirect | |||||
golang.org/x/text v0.9.0 // indirect | |||||
golang.org/x/tools v0.7.0 // indirect | |||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | ||||
google.golang.org/appengine v1.6.1 // indirect | google.golang.org/appengine v1.6.1 // indirect | ||||
google.golang.org/protobuf v1.26.0 // indirect | |||||
google.golang.org/protobuf v1.28.1 // indirect | |||||
gopkg.in/yaml.v3 v3.0.1 // indirect | |||||
honnef.co/go/tools v0.0.1-2020.1.4 // indirect | honnef.co/go/tools v0.0.1-2020.1.4 // indirect | ||||
xorm.io/builder v0.3.9 // indirect | |||||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect | |||||
) | ) |
@@ -1,6 +1,7 @@ | |||||
package main | package main | ||||
import ( | import ( | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"context" | "context" | ||||
"fmt" | "fmt" | ||||
"log" | "log" | ||||
@@ -11,12 +12,11 @@ import ( | |||||
"time" | "time" | ||||
"applet/app/cfg" | "applet/app/cfg" | ||||
"applet/app/db" | |||||
"applet/app/router" | "applet/app/router" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
) | ) | ||||
//系统初始化 | |||||
// 系统初始化 | |||||
func init() { | func init() { | ||||
cfg.InitCfg() //配置初始化 | cfg.InitCfg() //配置初始化 | ||||
cfg.InitLog() //日志初始化 | cfg.InitLog() //日志初始化 | ||||
@@ -33,16 +33,23 @@ func init() { | |||||
} | } | ||||
// @title 智莺生活移动端接口 | |||||
// @title 广告联盟-渠道代理平台 | |||||
// @version 1.0 | // @version 1.0 | ||||
// @description 移动端接口 | |||||
// @termsOfService 智莺生活后端组 | |||||
// @contact.name sherlockwhite | |||||
// @host localhost:5000 | |||||
// @description 渠道代理后台接口 | |||||
// @termsOfService http://swagger.io/terms/ | |||||
// @contact.name dengbiao | |||||
// @contact.url http://www.swagger.io/support | |||||
// @contact.email 1239118001@qq.com | |||||
// @license.name Apache 2.0 | |||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html | |||||
// @host localhost:1003 or advertisement.dengbiao.top | |||||
// @securityDefinitions.apikey MasterID | // @securityDefinitions.apikey MasterID | ||||
// @in header | // @in header | ||||
// @name MasterID | // @name MasterID | ||||
// @BasePath / | |||||
// @BasePath /api | |||||
func main() { | func main() { | ||||
// 启动获取所有品牌 | // 启动获取所有品牌 | ||||
//go taoke.GetAllBrand() | //go taoke.GetAllBrand() | ||||