diff --git a/app/db/dao/agent_dao.go b/app/db/dao/agent_dao.go deleted file mode 100644 index e316ffd..0000000 --- a/app/db/dao/agent_dao.go +++ /dev/null @@ -1,13 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type AgentDao interface { - GetAgentByUsername(username string) (medium *model.Agent, err error) - AgentInsert(m *model.Agent) (int64, error) - AgentDeleteBySession(session *xorm.Session, id interface{}) (int64, error) - UpdateAgent(m *model.Agent, columns ...string) (int64, error) -} diff --git a/app/db/dao/agent_domain_dao.go b/app/db/dao/agent_domain_dao.go deleted file mode 100644 index 5e7a804..0000000 --- a/app/db/dao/agent_domain_dao.go +++ /dev/null @@ -1,5 +0,0 @@ -package dao - -type AgentDomainDao interface { - //TODO:: You can add specific method definitions here -} diff --git a/app/db/dao/agent_permission_dao.go b/app/db/dao/agent_permission_dao.go deleted file mode 100644 index fc4f02a..0000000 --- a/app/db/dao/agent_permission_dao.go +++ /dev/null @@ -1,5 +0,0 @@ -package dao - -type AgentPermissionDao interface { - //TODO:: You can add specific method definitions here -} diff --git a/app/db/dao/agent_permission_group_dao.go b/app/db/dao/agent_permission_group_dao.go deleted file mode 100644 index d1e615a..0000000 --- a/app/db/dao/agent_permission_group_dao.go +++ /dev/null @@ -1,8 +0,0 @@ -package dao - -import "applet/app/db/model" - -type AgentPermissionGroupDao interface { - FindAgentPermissionGroup() (*[]model.AgentPermissionGroup, error) - FindAgentPermissionGroupV2() (*[]model.AgentPermissionGroup, error) -} diff --git a/app/db/dao/agent_permission_group_permission_dao.go b/app/db/dao/agent_permission_group_permission_dao.go deleted file mode 100644 index f831b9a..0000000 --- a/app/db/dao/agent_permission_group_permission_dao.go +++ /dev/null @@ -1,5 +0,0 @@ -package dao - -type AgentPermissionGroupPermissionDao interface { - //TODO:: You can add specific method definitions here -} diff --git a/app/db/dao/agent_role_dao.go b/app/db/dao/agent_role_dao.go deleted file mode 100644 index 84be201..0000000 --- a/app/db/dao/agent_role_dao.go +++ /dev/null @@ -1,25 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type AgentRoleDao interface { - FindAgentRole() (*[]model.AgentRole, error) - GetAgentRole() (m *model.AgentRole, err error) - UpdateAgentRole(m *model.AgentRole, columns ...string) (int64, error) - AgentRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) - AgentRoleInsert(m *model.AgentRole) (int, error) - FindPermissionGroupByAgentRole(roleId int) (list []*AgentRolePermissionGroup, total int64, err error) -} - -type AgentRolePermissionGroup struct { - model.AgentRole `xorm:"extends"` - model.AgentRolePermissionGroup `xorm:"extends"` - model.AgentPermissionGroup `xorm:"extends"` -} - -func (AgentRolePermissionGroup) TableName() string { - return "agent_role" -} diff --git a/app/db/dao/agent_role_permission_group_dao.go b/app/db/dao/agent_role_permission_group_dao.go deleted file mode 100644 index 0d4bc79..0000000 --- a/app/db/dao/agent_role_permission_group_dao.go +++ /dev/null @@ -1,11 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type AgentRolePermissionGroupDao interface { - AgentRolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) - BatchAddAgentRolePermissionGroupBySession(session *xorm.Session, mm []*model.AgentRolePermissionGroup) (int64, error) -} diff --git a/app/db/dao/agent_with_role_dao.go b/app/db/dao/agent_with_role_dao.go deleted file mode 100644 index 58c83a4..0000000 --- a/app/db/dao/agent_with_role_dao.go +++ /dev/null @@ -1,16 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type AgentWithRoleDao interface { - FindAgentWithRole(id int) (*[]model.AgentWithRole, error) - FindAgentWithRoleByRoleId(id int) (*[]model.AgentWithRole, error) - AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) - GetAgentWithRoleByRole(id int) (m *model.AgentWithRole, err error) - AgentWithRoleDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) - AgentWithRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) - BatchAddAgentWithRoleBySession(session *xorm.Session, mm []*model.AgentWithRole) (int64, error) -} diff --git a/app/db/dao/medium_dao.go b/app/db/dao/medium_dao.go deleted file mode 100644 index eb77ea1..0000000 --- a/app/db/dao/medium_dao.go +++ /dev/null @@ -1,13 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type MediumDao interface { - GetMediumByUsername(username string) (medium *model.Medium, err error) - MediumInsert(m *model.Medium) (int64, error) - MediumDeleteBySession(session *xorm.Session, id interface{}) (int64, error) - UpdateMedium(m *model.Medium, columns ...string) (int64, error) -} diff --git a/app/db/dao/medium_domain_dao.go b/app/db/dao/medium_domain_dao.go deleted file mode 100644 index ef6693b..0000000 --- a/app/db/dao/medium_domain_dao.go +++ /dev/null @@ -1,10 +0,0 @@ -package dao - -import ( - "applet/app/db/model" -) - -type MediumDomainDao interface { - GetMediumDomain(mediumId int) (medium *model.MediumDomain, err error) - MediumDomainInsert(m *model.MediumDomain) (int64, error) -} diff --git a/app/db/dao/medium_permission_dao.go b/app/db/dao/medium_permission_dao.go deleted file mode 100644 index 67db1c7..0000000 --- a/app/db/dao/medium_permission_dao.go +++ /dev/null @@ -1,5 +0,0 @@ -package dao - -type MediumPermissionDao interface { - //TODO:: You can add specific method definitions here -} diff --git a/app/db/dao/medium_permission_group_dao.go b/app/db/dao/medium_permission_group_dao.go deleted file mode 100644 index 403d3f7..0000000 --- a/app/db/dao/medium_permission_group_dao.go +++ /dev/null @@ -1,8 +0,0 @@ -package dao - -import "applet/app/db/model" - -type MediumPermissionGroupDao interface { - FindMediumPermissionGroup() (*[]model.MediumPermissionGroup, error) - FindMediumPermissionGroupV2() (*[]model.MediumPermissionGroup, error) -} diff --git a/app/db/dao/medium_permission_group_permission_dao.go b/app/db/dao/medium_permission_group_permission_dao.go deleted file mode 100644 index a4585d2..0000000 --- a/app/db/dao/medium_permission_group_permission_dao.go +++ /dev/null @@ -1,5 +0,0 @@ -package dao - -type MediumPermissionGroupPermissionDao interface { - //TODO:: You can add specific method definitions here -} diff --git a/app/db/dao/medium_role_dao.go b/app/db/dao/medium_role_dao.go deleted file mode 100644 index 84190c4..0000000 --- a/app/db/dao/medium_role_dao.go +++ /dev/null @@ -1,25 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type MediumRoleDao interface { - FindMediumRole() (*[]model.MediumRole, error) - GetMediumRole() (m *model.MediumRole, err error) - UpdateMediumRole(m *model.MediumRole, columns ...string) (int64, error) - MediumRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) - MediumRoleInsert(m *model.MediumRole) (int, error) - FindPermissionGroupByMediumRole(roleId int) (list []*MediumRolePermissionGroup, total int64, err error) -} - -type MediumRolePermissionGroup struct { - model.MediumRole `xorm:"extends"` - model.MediumRolePermissionGroup `xorm:"extends"` - model.MediumPermissionGroup `xorm:"extends"` -} - -func (MediumRolePermissionGroup) TableName() string { - return "medium_role" -} diff --git a/app/db/dao/medium_role_permission_group_dao.go b/app/db/dao/medium_role_permission_group_dao.go deleted file mode 100644 index 68ab9ba..0000000 --- a/app/db/dao/medium_role_permission_group_dao.go +++ /dev/null @@ -1,11 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type MediumRolePermissionGroupDao interface { - MediumRolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) - BatchAddMediumRolePermissionGroupBySession(session *xorm.Session, mm []*model.MediumRolePermissionGroup) (int64, error) -} diff --git a/app/db/dao/medium_with_role_dao.go b/app/db/dao/medium_with_role_dao.go deleted file mode 100644 index f6d285f..0000000 --- a/app/db/dao/medium_with_role_dao.go +++ /dev/null @@ -1,16 +0,0 @@ -package dao - -import ( - "applet/app/db/model" - "xorm.io/xorm" -) - -type MediumWithRoleDao interface { - FindMediumWithRole(id int) (*[]model.MediumWithRole, error) - FindMediumWithRoleByRoleId(id int) (*[]model.MediumWithRole, error) - AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) - GetMediumWithRoleByRole(id int) (m *model.MediumWithRole, err error) - MediumWithRoleDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) - MediumWithRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) - BatchAddMediumWithRoleBySession(session *xorm.Session, mm []*model.MediumWithRole) (int64, error) -} diff --git a/app/db/dao/sys_cfg_dao.go b/app/db/dao/sys_cfg_dao.go index 0df0ba2..75dca1e 100644 --- a/app/db/dao/sys_cfg_dao.go +++ b/app/db/dao/sys_cfg_dao.go @@ -1,6 +1,6 @@ package dao -import "applet/app/db/model" +import "code.fnuoos.com/zhimeng/model.git/src/super/model" type SysCfgDao interface { SysCfgGetAll() (*[]model.SysCfg, error) diff --git a/app/db/implement/agent_domain_implement.go b/app/db/implement/agent_domain_implement.go deleted file mode 100644 index 7ce2d7c..0000000 --- a/app/db/implement/agent_domain_implement.go +++ /dev/null @@ -1,14 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "xorm.io/xorm" -) - -func NewAgentDomainDb(engine *xorm.Engine) dao.AgentDomainDao { - return &AgentDomainDb{Db: engine} -} - -type AgentDomainDb struct { - Db *xorm.Engine -} diff --git a/app/db/implement/agent_implement.go b/app/db/implement/agent_implement.go deleted file mode 100644 index abf6e4c..0000000 --- a/app/db/implement/agent_implement.go +++ /dev/null @@ -1,53 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "applet/app/utils/logx" - "reflect" - "xorm.io/xorm" -) - -func NewAgentDb(engine *xorm.Engine) dao.AgentDao { - return &AgentDb{Db: engine} -} - -type AgentDb struct { - Db *xorm.Engine -} - -func (a AgentDb) GetAgentByUsername(username string) (agent *model.Agent, err error) { - agent = new(model.Agent) - has, err := a.Db.Where("username =?", username).Get(agent) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return agent, nil -} - -func (a AgentDb) AgentInsert(m *model.Agent) (int64, error) { - insertAffected, err := a.Db.InsertOne(m) - if err != nil { - return 0, err - } - return insertAffected, nil -} - -func (a AgentDb) AgentDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { - if reflect.TypeOf(id).Kind() == reflect.Slice { - return session.In("id", id).Delete(model.Admin{}) - } else { - return session.Where("id = ?", id).Delete(model.Admin{}) - } -} - -func (a AgentDb) UpdateAgent(m *model.Agent, columns ...string) (int64, error) { - affected, err := a.Db.Where("id =?", m.Id).Cols(columns...).Update(m) - if err != nil { - return 0, err - } - return affected, nil -} diff --git a/app/db/implement/agent_permission_group_implement.go b/app/db/implement/agent_permission_group_implement.go deleted file mode 100644 index 8c0a5f8..0000000 --- a/app/db/implement/agent_permission_group_implement.go +++ /dev/null @@ -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 NewAgentPermissionGroupDb(engine *xorm.Engine) dao.AgentPermissionGroupDao { - return &AgentPermissionGroupDb{Db: engine} -} - -type AgentPermissionGroupDb struct { - Db *xorm.Engine -} - -func (a AgentPermissionGroupDb) FindAgentPermissionGroup() (*[]model.AgentPermissionGroup, error) { - var mm []model.AgentPermissionGroup - if err := a.Db.Where("state = ?", enum.PermissionGroupStateForNormal).Asc("id").Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (a AgentPermissionGroupDb) FindAgentPermissionGroupV2() (*[]model.AgentPermissionGroup, error) { - var mm []model.AgentPermissionGroup - if err := a.Db.Asc("id").Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} diff --git a/app/db/implement/agent_permission_group_permission_implement.go b/app/db/implement/agent_permission_group_permission_implement.go deleted file mode 100644 index 9926689..0000000 --- a/app/db/implement/agent_permission_group_permission_implement.go +++ /dev/null @@ -1,14 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "xorm.io/xorm" -) - -func NewAgentPermissionGroupPermissionDb(engine *xorm.Engine) dao.AgentPermissionGroupPermissionDao { - return &AgentPermissionGroupPermissionDb{Db: engine} -} - -type AgentPermissionGroupPermissionDb struct { - Db *xorm.Engine -} diff --git a/app/db/implement/agent_permission_implement.go b/app/db/implement/agent_permission_implement.go deleted file mode 100644 index 088c5a5..0000000 --- a/app/db/implement/agent_permission_implement.go +++ /dev/null @@ -1,14 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "xorm.io/xorm" -) - -func NewAgentPermissionDb(engine *xorm.Engine) dao.AgentPermissionDao { - return &AgentPermissionDb{Db: engine} -} - -type AgentPermissionDb struct { - Db *xorm.Engine -} diff --git a/app/db/implement/agent_role_implement.go b/app/db/implement/agent_role_implement.go deleted file mode 100644 index aeae0ef..0000000 --- a/app/db/implement/agent_role_implement.go +++ /dev/null @@ -1,69 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "applet/app/utils/logx" - "reflect" - "xorm.io/xorm" -) - -func NewAgentRoleDb(engine *xorm.Engine) dao.AgentRoleDao { - return &AgentRoleDb{Db: engine} -} - -type AgentRoleDb struct { - Db *xorm.Engine -} - -func (a AgentRoleDb) FindAgentRole() (*[]model.AgentRole, error) { - var mm []model.AgentRole - if err := a.Db.Desc("id").Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (a AgentRoleDb) GetAgentRole() (m *model.AgentRole, err error) { - m = new(model.AgentRole) - has, err := a.Db.Where("id = ?", m.Id).Get(m) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return m, nil -} - -func (a AgentRoleDb) UpdateAgentRole(m *model.AgentRole, columns ...string) (int64, error) { - affected, err := a.Db.Where("id =?", m.Id).Cols(columns...).Update(m) - if err != nil { - return 0, err - } - return affected, nil -} - -func (a AgentRoleDb) AgentRoleDeleteBySession(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 (a AgentRoleDb) AgentRoleInsert(m *model.AgentRole) (int, error) { - _, err := a.Db.InsertOne(m) - if err != nil { - return 0, err - } - return m.Id, nil -} - -func (a AgentRoleDb) FindPermissionGroupByAgentRole(roleId int) (list []*dao.AgentRolePermissionGroup, total int64, err error) { - total, err = a.Db.Where("agent_role.id =?", roleId). - Join("LEFT", "agent_role_permission_group", "agent_role_permission_group.role_id = agent_role.id"). - Join("LEFT", "agent_permission_group", "agent_permission_group.id = agent_role_permission_group.group_id"). - FindAndCount(&list) - return -} diff --git a/app/db/implement/agent_role_permission_group_implement.go b/app/db/implement/agent_role_permission_group_implement.go deleted file mode 100644 index 6bcd04f..0000000 --- a/app/db/implement/agent_role_permission_group_implement.go +++ /dev/null @@ -1,32 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "reflect" - "xorm.io/xorm" -) - -func NewAgentRolePermissionGroupDb(engine *xorm.Engine) dao.AgentRolePermissionGroupDao { - return &AgentRolePermissionGroupDb{Db: engine} -} - -type AgentRolePermissionGroupDb struct { - Db *xorm.Engine -} - -func (a AgentRolePermissionGroupDb) AgentRolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { - if reflect.TypeOf(roleId).Kind() == reflect.Slice { - return session.In("role_id", roleId).Delete(model.AgentRolePermissionGroup{}) - } else { - return session.Where("role_id = ?", roleId).Delete(model.AgentRolePermissionGroup{}) - } -} - -func (a AgentRolePermissionGroupDb) BatchAddAgentRolePermissionGroupBySession(session *xorm.Session, mm []*model.AgentRolePermissionGroup) (int64, error) { - affected, err := session.Insert(mm) - if err != nil { - return 0, err - } - return affected, nil -} diff --git a/app/db/implement/agent_with_role_implement.go b/app/db/implement/agent_with_role_implement.go deleted file mode 100644 index 385ccdd..0000000 --- a/app/db/implement/agent_with_role_implement.go +++ /dev/null @@ -1,77 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "applet/app/utils/logx" - "reflect" - "xorm.io/xorm" -) - -func NewAgentWithRoleDb(engine *xorm.Engine) dao.AgentWithRoleDao { - return &AgentWithRoleDb{Db: engine} -} - -type AgentWithRoleDb struct { - Db *xorm.Engine -} - -func (a AgentWithRoleDb) FindAgentWithRole(id int) (*[]model.AgentWithRole, error) { - var mm []model.AgentWithRole - if err := a.Db.Where("adm_id =?", id).Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (a AgentWithRoleDb) FindAgentWithRoleByRoleId(id int) (*[]model.AgentWithRole, error) { - var mm []model.AgentWithRole - if err := a.Db.Where("role_id =?", id).Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (a AgentWithRoleDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) { - if reflect.TypeOf(admId).Kind() == reflect.Slice { - return session.In("adm_id", admId).Delete(model.AgentWithRole{}) - } else { - return session.Where("adm_id = ?", admId).Delete(model.AgentWithRole{}) - } -} - -func (a AgentWithRoleDb) GetAgentWithRoleByRole(id int) (mm *model.AgentWithRole, err error) { - mm = new(model.AgentWithRole) - has, err := a.Db.Where("role_id =?", id).Get(mm) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return mm, nil -} - -func (a AgentWithRoleDb) AgentWithRoleDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { - if reflect.TypeOf(roleId).Kind() == reflect.Slice { - return session.In("role_id", roleId).Delete(model.AgentWithRole{}) - } else { - return session.Where("role_id = ?", roleId).Delete(model.AgentWithRole{}) - } -} - -func (a AgentWithRoleDb) AgentWithRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { - if reflect.TypeOf(id).Kind() == reflect.Slice { - return session.In("agent_id", id).Delete(model.AgentWithRole{}) - } else { - return session.Where("agent_id = ?", id).Delete(model.AgentWithRole{}) - } -} - -func (a AgentWithRoleDb) BatchAddAgentWithRoleBySession(session *xorm.Session, mm []*model.AgentWithRole) (int64, error) { - affected, err := session.Insert(mm) - if err != nil { - return 0, err - } - return affected, nil -} diff --git a/app/db/implement/medium_domain_implement.go b/app/db/implement/medium_domain_implement.go deleted file mode 100644 index dfc56e4..0000000 --- a/app/db/implement/medium_domain_implement.go +++ /dev/null @@ -1,36 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "applet/app/utils/logx" - "xorm.io/xorm" -) - -func NewMediumDomainDb(engine *xorm.Engine) dao.MediumDomainDao { - return &MediumDomainDb{Db: engine} -} - -type MediumDomainDb struct { - Db *xorm.Engine -} - -func (m MediumDomainDb) GetMediumDomain(mediumId int) (medium *model.MediumDomain, err error) { - medium = new(model.MediumDomain) - has, err := m.Db.Where("medium_id =?", mediumId).Get(medium) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return medium, nil -} - -func (m MediumDomainDb) MediumDomainInsert(medium *model.MediumDomain) (int64, error) { - insertAffected, err := m.Db.InsertOne(medium) - if err != nil { - return 0, err - } - return insertAffected, nil -} diff --git a/app/db/implement/medium_implement.go b/app/db/implement/medium_implement.go deleted file mode 100644 index fdb3757..0000000 --- a/app/db/implement/medium_implement.go +++ /dev/null @@ -1,53 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "applet/app/utils/logx" - "reflect" - "xorm.io/xorm" -) - -func NewMediumDb(engine *xorm.Engine) dao.MediumDao { - return &MediumDb{Db: engine} -} - -type MediumDb struct { - Db *xorm.Engine -} - -func (m MediumDb) UpdateMedium(medium *model.Medium, columns ...string) (int64, error) { - affected, err := m.Db.Where("id =?", medium.Id).Cols(columns...).Update(m) - if err != nil { - return 0, err - } - return affected, nil -} - -func (m MediumDb) GetMediumByUsername(username string) (medium *model.Medium, err error) { - medium = new(model.Medium) - has, err := m.Db.Where("username =?", username).Get(medium) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return medium, nil -} - -func (m MediumDb) MediumInsert(medium *model.Medium) (int64, error) { - insertAffected, err := m.Db.InsertOne(medium) - if err != nil { - return 0, err - } - return insertAffected, nil -} - -func (m MediumDb) MediumDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { - if reflect.TypeOf(id).Kind() == reflect.Slice { - return session.In("id", id).Delete(model.Admin{}) - } else { - return session.Where("id = ?", id).Delete(model.Admin{}) - } -} diff --git a/app/db/implement/medium_permission_group_implement.go b/app/db/implement/medium_permission_group_implement.go deleted file mode 100644 index a85ac46..0000000 --- a/app/db/implement/medium_permission_group_implement.go +++ /dev/null @@ -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 NewMediumPermissionGroupDb(engine *xorm.Engine) dao.MediumPermissionGroupDao { - return &MediumPermissionGroupDb{Db: engine} -} - -type MediumPermissionGroupDb struct { - Db *xorm.Engine -} - -func (m MediumPermissionGroupDb) FindMediumPermissionGroup() (*[]model.MediumPermissionGroup, error) { - var mm []model.MediumPermissionGroup - if err := m.Db.Where("state = ?", enum.PermissionGroupStateForNormal).Asc("id").Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (m MediumPermissionGroupDb) FindMediumPermissionGroupV2() (*[]model.MediumPermissionGroup, error) { - var mm []model.MediumPermissionGroup - if err := m.Db.Asc("id").Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} diff --git a/app/db/implement/medium_permission_group_permission_implement.go b/app/db/implement/medium_permission_group_permission_implement.go deleted file mode 100644 index 997217c..0000000 --- a/app/db/implement/medium_permission_group_permission_implement.go +++ /dev/null @@ -1,14 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "xorm.io/xorm" -) - -func NewMediumPermissionGroupPermissionDb(engine *xorm.Engine) dao.MediumPermissionGroupPermissionDao { - return &MediumPermissionGroupPermissionDb{Db: engine} -} - -type MediumPermissionGroupPermissionDb struct { - Db *xorm.Engine -} diff --git a/app/db/implement/medium_permission_implement.go b/app/db/implement/medium_permission_implement.go deleted file mode 100644 index b543f53..0000000 --- a/app/db/implement/medium_permission_implement.go +++ /dev/null @@ -1,14 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "xorm.io/xorm" -) - -func NewMediumPermissionDb(engine *xorm.Engine) dao.MediumPermissionDao { - return &MediumPermissionDb{Db: engine} -} - -type MediumPermissionDb struct { - Db *xorm.Engine -} diff --git a/app/db/implement/medium_role_implement.go b/app/db/implement/medium_role_implement.go deleted file mode 100644 index 1a1e4c1..0000000 --- a/app/db/implement/medium_role_implement.go +++ /dev/null @@ -1,69 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "applet/app/utils/logx" - "reflect" - "xorm.io/xorm" -) - -func NewMediumRoleDb(engine *xorm.Engine) dao.MediumRoleDao { - return &MediumRoleDb{Db: engine} -} - -type MediumRoleDb struct { - Db *xorm.Engine -} - -func (m MediumRoleDb) FindMediumRole() (*[]model.MediumRole, error) { - var mm []model.MediumRole - if err := m.Db.Desc("id").Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (m MediumRoleDb) GetMediumRole() (mm *model.MediumRole, err error) { - mm = new(model.MediumRole) - has, err := m.Db.Where("id = ?", mm.Id).Get(mm) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return mm, nil -} - -func (m MediumRoleDb) UpdateMediumRole(mm *model.MediumRole, columns ...string) (int64, error) { - affected, err := m.Db.Where("id =?", mm.Id).Cols(columns...).Update(m) - if err != nil { - return 0, err - } - return affected, nil -} - -func (m MediumRoleDb) MediumRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { - if reflect.TypeOf(id).Kind() == reflect.Slice { - return session.In("id", id).Delete(model.MediumRole{}) - } else { - return session.Where("id = ?", id).Delete(model.MediumRole{}) - } -} - -func (m MediumRoleDb) MediumRoleInsert(mm *model.MediumRole) (int, error) { - _, err := m.Db.InsertOne(mm) - if err != nil { - return 0, err - } - return mm.Id, nil -} - -func (m MediumRoleDb) FindPermissionGroupByMediumRole(roleId int) (list []*dao.MediumRolePermissionGroup, total int64, err error) { - total, err = m.Db.Where("medium_role.id =?", roleId). - Join("LEFT", "medium_role_permission_group", "medium_role_permission_group.role_id = medium_role.id"). - Join("LEFT", "medium_permission_group", "medium_permission_group.id = medium_role_permission_group.group_id"). - FindAndCount(&list) - return -} diff --git a/app/db/implement/medium_role_permission_group_implement.go b/app/db/implement/medium_role_permission_group_implement.go deleted file mode 100644 index 9367d7d..0000000 --- a/app/db/implement/medium_role_permission_group_implement.go +++ /dev/null @@ -1,32 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "reflect" - "xorm.io/xorm" -) - -func NewMediumRolePermissionGroupDb(engine *xorm.Engine) dao.MediumRolePermissionGroupDao { - return &MediumRolePermissionGroupDb{Db: engine} -} - -type MediumRolePermissionGroupDb struct { - Db *xorm.Engine -} - -func (m MediumRolePermissionGroupDb) MediumRolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { - if reflect.TypeOf(roleId).Kind() == reflect.Slice { - return session.In("role_id", roleId).Delete(model.MediumRolePermissionGroup{}) - } else { - return session.Where("role_id = ?", roleId).Delete(model.MediumRolePermissionGroup{}) - } -} - -func (m MediumRolePermissionGroupDb) BatchAddMediumRolePermissionGroupBySession(session *xorm.Session, mm []*model.MediumRolePermissionGroup) (int64, error) { - affected, err := session.Insert(mm) - if err != nil { - return 0, err - } - return affected, nil -} diff --git a/app/db/implement/medium_with_role_implement.go b/app/db/implement/medium_with_role_implement.go deleted file mode 100644 index 0bef8b1..0000000 --- a/app/db/implement/medium_with_role_implement.go +++ /dev/null @@ -1,77 +0,0 @@ -package implement - -import ( - "applet/app/db/dao" - "applet/app/db/model" - "applet/app/utils/logx" - "reflect" - "xorm.io/xorm" -) - -func NewMediumWithRoleDb(engine *xorm.Engine) dao.MediumWithRoleDao { - return &MediumWithRoleDb{Db: engine} -} - -type MediumWithRoleDb struct { - Db *xorm.Engine -} - -func (m MediumWithRoleDb) FindMediumWithRole(id int) (*[]model.MediumWithRole, error) { - var mm []model.MediumWithRole - if err := m.Db.Where("adm_id =?", id).Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (m MediumWithRoleDb) FindMediumWithRoleByRoleId(id int) (*[]model.MediumWithRole, error) { - var mm []model.MediumWithRole - if err := m.Db.Where("role_id =?", id).Find(&mm); err != nil { - return nil, logx.Error(err) - } - return &mm, nil -} - -func (m MediumWithRoleDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) { - if reflect.TypeOf(admId).Kind() == reflect.Slice { - return session.In("adm_id", admId).Delete(model.MediumWithRole{}) - } else { - return session.Where("adm_id = ?", admId).Delete(model.MediumWithRole{}) - } -} - -func (m MediumWithRoleDb) GetMediumWithRoleByRole(id int) (mm *model.MediumWithRole, err error) { - mm = new(model.MediumWithRole) - has, err := m.Db.Where("role_id =?", id).Get(mm) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return mm, nil -} - -func (m MediumWithRoleDb) MediumWithRoleDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { - if reflect.TypeOf(roleId).Kind() == reflect.Slice { - return session.In("role_id", roleId).Delete(model.MediumWithRole{}) - } else { - return session.Where("role_id = ?", roleId).Delete(model.MediumWithRole{}) - } -} - -func (m MediumWithRoleDb) MediumWithRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { - if reflect.TypeOf(id).Kind() == reflect.Slice { - return session.In("medium_id", id).Delete(model.MediumWithRole{}) - } else { - return session.Where("medium_id = ?", id).Delete(model.MediumWithRole{}) - } -} - -func (m MediumWithRoleDb) BatchAddMediumWithRoleBySession(session *xorm.Session, mm []*model.MediumWithRole) (int64, error) { - affected, err := session.Insert(mm) - if err != nil { - return 0, err - } - return affected, nil -} diff --git a/app/db/implement/sys_cfg_implement.go b/app/db/implement/sys_cfg_implement.go index 2c87384..bec668b 100644 --- a/app/db/implement/sys_cfg_implement.go +++ b/app/db/implement/sys_cfg_implement.go @@ -2,10 +2,10 @@ package implement import ( "applet/app/db/dao" - "applet/app/db/model" "applet/app/md" "applet/app/utils/cache" "applet/app/utils/logx" + "code.fnuoos.com/zhimeng/model.git/src/super/model" "fmt" "xorm.io/xorm" ) @@ -51,7 +51,7 @@ func (s SysCfgDb) SysCfgGetOne(key string) (*model.SysCfg, error) { } func (s SysCfgDb) SysCfgInsert(key, val, memo string) bool { - cfg := model.SysCfg{Key: key, Val: val, Memo: memo} + cfg := model.SysCfg{K: key, V: val, Memo: memo} _, err := s.Db.InsertOne(&cfg) if err != nil { logx.Error(err) @@ -61,7 +61,7 @@ func (s SysCfgDb) SysCfgInsert(key, val, memo string) bool { } func (s SysCfgDb) SysCfgUpdate(key, val string) bool { - cfg := model.SysCfg{Key: key, Val: val} + cfg := model.SysCfg{K: key, V: val} _, err := s.Db.Where("`key`=?", key).Cols("val").Update(&cfg) if err != nil { logx.Error(err) @@ -88,7 +88,7 @@ func (s SysCfgDb) SysCfgGetWithDb(HKey string) string { } // 设置缓存 - _, err = cache.HSet(cacheKey, HKey, cfg.Val) + _, err = cache.HSet(cacheKey, HKey, cfg.V) if err != nil { _ = logx.Error(err) return "" @@ -100,7 +100,7 @@ func (s SysCfgDb) SysCfgGetWithDb(HKey string) string { return "" } } - return cfg.Val + return cfg.V } return get } diff --git a/app/db/model/agent.go b/app/db/model/agent.go deleted file mode 100644 index 703db69..0000000 --- a/app/db/model/agent.go +++ /dev/null @@ -1,13 +0,0 @@ -package model - -type Agent struct { - Id int `json:"id" xorm:"not null pk default 0 INT(11)"` - AgentId int `json:"agent_id" xorm:"not null default 0 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"` -} diff --git a/app/db/model/agent_domain.go b/app/db/model/agent_domain.go deleted file mode 100644 index 79f4953..0000000 --- a/app/db/model/agent_domain.go +++ /dev/null @@ -1,8 +0,0 @@ -package model - -type AgentDomain struct { - Domain string `json:"domain" xorm:"not null pk comment('绑定域名') VARCHAR(100)"` - MediumId int `json:"medium_id" xorm:"not null comment('媒体id') index unique INT(11)"` - IsOfficial int `json:"is_official" xorm:"not null default 1 comment('是否官方指定域名(1:是 2:否)') TINYINT(1)"` - IsSsl int `json:"is_ssl" xorm:"not null default 0 comment('是否开启ssl:0否;1是') TINYINT(255)"` -} diff --git a/app/db/model/agent_permission.go b/app/db/model/agent_permission.go deleted file mode 100644 index d519721..0000000 --- a/app/db/model/agent_permission.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -type AgentPermission 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"` -} diff --git a/app/db/model/agent_permission_group.go b/app/db/model/agent_permission_group.go deleted file mode 100644 index a559a0e..0000000 --- a/app/db/model/agent_permission_group.go +++ /dev/null @@ -1,11 +0,0 @@ -package model - -type AgentPermissionGroup 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"` -} diff --git a/app/db/model/agent_permission_group_permission.go b/app/db/model/agent_permission_group_permission.go deleted file mode 100644 index d7712d8..0000000 --- a/app/db/model/agent_permission_group_permission.go +++ /dev/null @@ -1,9 +0,0 @@ -package model - -type AgentPermissionGroupPermission 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"` -} diff --git a/app/db/model/agent_role.go b/app/db/model/agent_role.go deleted file mode 100644 index 91ebe49..0000000 --- a/app/db/model/agent_role.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -type AgentRole 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"` -} diff --git a/app/db/model/agent_role_permission_group.go b/app/db/model/agent_role_permission_group.go deleted file mode 100644 index 32a2f95..0000000 --- a/app/db/model/agent_role_permission_group.go +++ /dev/null @@ -1,9 +0,0 @@ -package model - -type AgentRolePermissionGroup 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"` -} diff --git a/app/db/model/agent_with_role.go b/app/db/model/agent_with_role.go deleted file mode 100644 index 4ec6adb..0000000 --- a/app/db/model/agent_with_role.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -type AgentWithRole struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - AgentId int `json:"agent_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"` -} diff --git a/app/db/model/medium.go b/app/db/model/medium.go deleted file mode 100644 index a728b69..0000000 --- a/app/db/model/medium.go +++ /dev/null @@ -1,13 +0,0 @@ -package model - -type Medium struct { - Id int `json:"id" xorm:"not null pk default 0 INT(11)"` - MediumId int `json:"medium_id" xorm:"not null default 0 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"` -} diff --git a/app/db/model/medium_domain.go b/app/db/model/medium_domain.go deleted file mode 100644 index 337e167..0000000 --- a/app/db/model/medium_domain.go +++ /dev/null @@ -1,8 +0,0 @@ -package model - -type MediumDomain struct { - Domain string `json:"domain" xorm:"not null pk comment('绑定域名') VARCHAR(100)"` - MediumId int `json:"medium_id" xorm:"not null comment('媒体id') index unique INT(11)"` - IsOfficial int `json:"is_official" xorm:"not null default 1 comment('是否官方指定域名(1:是 2:否)') TINYINT(1)"` - IsSsl int `json:"is_ssl" xorm:"not null default 0 comment('是否开启ssl:0否;1是') TINYINT(255)"` -} diff --git a/app/db/model/medium_permission.go b/app/db/model/medium_permission.go deleted file mode 100644 index 31e6929..0000000 --- a/app/db/model/medium_permission.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -type MediumPermission 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"` -} diff --git a/app/db/model/medium_permission_group.go b/app/db/model/medium_permission_group.go deleted file mode 100644 index 95eddc6..0000000 --- a/app/db/model/medium_permission_group.go +++ /dev/null @@ -1,11 +0,0 @@ -package model - -type MediumPermissionGroup 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"` -} diff --git a/app/db/model/medium_permission_group_permission.go b/app/db/model/medium_permission_group_permission.go deleted file mode 100644 index ec60f27..0000000 --- a/app/db/model/medium_permission_group_permission.go +++ /dev/null @@ -1,9 +0,0 @@ -package model - -type MediumPermissionGroupPermission 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"` -} diff --git a/app/db/model/medium_role.go b/app/db/model/medium_role.go deleted file mode 100644 index 9384bfb..0000000 --- a/app/db/model/medium_role.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -type MediumRole 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"` -} diff --git a/app/db/model/medium_role_permission_group.go b/app/db/model/medium_role_permission_group.go deleted file mode 100644 index 1ed49e4..0000000 --- a/app/db/model/medium_role_permission_group.go +++ /dev/null @@ -1,9 +0,0 @@ -package model - -type MediumRolePermissionGroup 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"` -} diff --git a/app/db/model/medium_with_role.go b/app/db/model/medium_with_role.go deleted file mode 100644 index f90e9ff..0000000 --- a/app/db/model/medium_with_role.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -type MediumWithRole struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - MediumId int `json:"medium_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"` -} diff --git a/app/db/model/sys_cfg.go b/app/db/model/sys_cfg.go deleted file mode 100644 index 22d906b..0000000 --- a/app/db/model/sys_cfg.go +++ /dev/null @@ -1,7 +0,0 @@ -package model - -type SysCfg struct { - Key string `json:"key" xorm:"not null pk comment('键') VARCHAR(127)"` - Val string `json:"val" xorm:"comment('值') TEXT"` - Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` -} diff --git a/app/db/super/dao/admin_dao.go b/app/db/super/dao/admin_dao.go deleted file mode 100644 index 742fdd4..0000000 --- a/app/db/super/dao/admin_dao.go +++ /dev/null @@ -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" -} diff --git a/app/db/super/dao/admin_role_dao.go b/app/db/super/dao/admin_role_dao.go deleted file mode 100644 index d1ce742..0000000 --- a/app/db/super/dao/admin_role_dao.go +++ /dev/null @@ -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" -} diff --git a/app/db/super/dao/agent_list_dao.go b/app/db/super/dao/agent_list_dao.go deleted file mode 100644 index f2ac208..0000000 --- a/app/db/super/dao/agent_list_dao.go +++ /dev/null @@ -1,9 +0,0 @@ -package dao - -import "applet/app/db/super/model" - -type AgentListDao interface { - GetAgentList(agentId int) (medium *model.AgentList, err error) - AgentListInsert(m *model.AgentList) (int64, error) - UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) -} diff --git a/app/db/super/dao/permission_dao.go b/app/db/super/dao/permission_dao.go deleted file mode 100644 index e94d561..0000000 --- a/app/db/super/dao/permission_dao.go +++ /dev/null @@ -1,5 +0,0 @@ -package dao - -type PermissionDao interface { - //TODO:: You can add specific method definitions here -} diff --git a/app/db/super/dao/permission_group_dao.go b/app/db/super/dao/permission_group_dao.go deleted file mode 100644 index bcec860..0000000 --- a/app/db/super/dao/permission_group_dao.go +++ /dev/null @@ -1,8 +0,0 @@ -package dao - -import "applet/app/db/model" - -type PermissionGroupDao interface { - FindPermissionGroup() (*[]model.PermissionGroup, error) - FindPermissionGroupV2() (*[]model.PermissionGroup, error) -} diff --git a/app/db/super/dao/permission_group_permission_dao.go b/app/db/super/dao/permission_group_permission_dao.go deleted file mode 100644 index 3f32ce3..0000000 --- a/app/db/super/dao/permission_group_permission_dao.go +++ /dev/null @@ -1,5 +0,0 @@ -package dao - -type PermissionGroupPermissionDao interface { - //TODO:: You can add specific method definitions here -} diff --git a/app/db/super/dao/role_dao.go b/app/db/super/dao/role_dao.go deleted file mode 100644 index 0a65841..0000000 --- a/app/db/super/dao/role_dao.go +++ /dev/null @@ -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" -} diff --git a/app/db/super/dao/role_permission_group_dao.go b/app/db/super/dao/role_permission_group_dao.go deleted file mode 100644 index 2c2000d..0000000 --- a/app/db/super/dao/role_permission_group_dao.go +++ /dev/null @@ -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) -} diff --git a/app/db/super/implement/admin_implement.go b/app/db/super/implement/admin_implement.go deleted file mode 100644 index c7a5d5a..0000000 --- a/app/db/super/implement/admin_implement.go +++ /dev/null @@ -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("adm_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 -} diff --git a/app/db/super/implement/admin_role_implement.go b/app/db/super/implement/admin_role_implement.go deleted file mode 100644 index d189b2f..0000000 --- a/app/db/super/implement/admin_role_implement.go +++ /dev/null @@ -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("adm_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 -} diff --git a/app/db/super/implement/agent_list_implement.go b/app/db/super/implement/agent_list_implement.go deleted file mode 100644 index e46b95c..0000000 --- a/app/db/super/implement/agent_list_implement.go +++ /dev/null @@ -1,44 +0,0 @@ -package implement - -import ( - "applet/app/db/super/dao" - "applet/app/db/super/model" - "applet/app/utils/logx" - "xorm.io/xorm" -) - -func NewAgentListDb(engine *xorm.Engine) dao.AgentListDao { - return &AgentListDb{Db: engine} -} - -type AgentListDb struct { - Db *xorm.Engine -} - -func (a AgentListDb) GetAgentList(agentId int) (medium *model.AgentList, err error) { - medium = new(model.AgentList) - has, err := a.Db.Where("agent_id =?", agentId).Get(medium) - if err != nil { - return nil, logx.Error(err) - } - if has == false { - return nil, nil - } - return medium, nil -} - -func (a AgentListDb) AgentListInsert(m *model.AgentList) (int64, error) { - insertAffected, err := a.Db.InsertOne(m) - if err != nil { - return 0, err - } - return insertAffected, nil -} - -func (a AgentListDb) UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) { - affected, err := a.Db.Where("agent_id =?", m.Id).Cols(columns...).Update(m) - if err != nil { - return 0, err - } - return affected, nil -} diff --git a/app/db/super/implement/permission_group_implement.go b/app/db/super/implement/permission_group_implement.go deleted file mode 100644 index b1126d1..0000000 --- a/app/db/super/implement/permission_group_implement.go +++ /dev/null @@ -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 -} diff --git a/app/db/super/implement/permission_group_permission_implement.go b/app/db/super/implement/permission_group_permission_implement.go deleted file mode 100644 index 1bd1f48..0000000 --- a/app/db/super/implement/permission_group_permission_implement.go +++ /dev/null @@ -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} -} diff --git a/app/db/super/implement/permission_implement.go b/app/db/super/implement/permission_implement.go deleted file mode 100644 index 0cfad56..0000000 --- a/app/db/super/implement/permission_implement.go +++ /dev/null @@ -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} -} diff --git a/app/db/super/implement/role_implement.go b/app/db/super/implement/role_implement.go deleted file mode 100644 index 8dd9020..0000000 --- a/app/db/super/implement/role_implement.go +++ /dev/null @@ -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 -} diff --git a/app/db/super/implement/role_permission_group_implement.go b/app/db/super/implement/role_permission_group_implement.go deleted file mode 100644 index b9aeb70..0000000 --- a/app/db/super/implement/role_permission_group_implement.go +++ /dev/null @@ -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 -} diff --git a/app/db/super/model/admin.go b/app/db/super/model/admin.go deleted file mode 100644 index 125ae65..0000000 --- a/app/db/super/model/admin.go +++ /dev/null @@ -1,12 +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"` -} diff --git a/app/db/super/model/admin_role.go b/app/db/super/model/admin_role.go deleted file mode 100644 index 5a35baa..0000000 --- a/app/db/super/model/admin_role.go +++ /dev/null @@ -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"` -} diff --git a/app/db/super/model/agent_list.go b/app/db/super/model/agent_list.go deleted file mode 100644 index 3c2debf..0000000 --- a/app/db/super/model/agent_list.go +++ /dev/null @@ -1,25 +0,0 @@ -package model - -type AgentList 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)"` - AgentId int `json:"agent_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"` -} diff --git a/app/db/super/model/permission.go b/app/db/super/model/permission.go deleted file mode 100644 index 82e00e2..0000000 --- a/app/db/super/model/permission.go +++ /dev/null @@ -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"` -} diff --git a/app/db/super/model/permission_group.go b/app/db/super/model/permission_group.go deleted file mode 100644 index ac927e3..0000000 --- a/app/db/super/model/permission_group.go +++ /dev/null @@ -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"` -} diff --git a/app/db/super/model/permission_group_permission.go b/app/db/super/model/permission_group_permission.go deleted file mode 100644 index 7d1bad7..0000000 --- a/app/db/super/model/permission_group_permission.go +++ /dev/null @@ -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"` -} diff --git a/app/db/super/model/role.go b/app/db/super/model/role.go deleted file mode 100644 index 4b46b20..0000000 --- a/app/db/super/model/role.go +++ /dev/null @@ -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"` -} diff --git a/app/db/super/model/role_permission_group.go b/app/db/super/model/role_permission_group.go deleted file mode 100644 index b9d04a1..0000000 --- a/app/db/super/model/role_permission_group.go +++ /dev/null @@ -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"` -} diff --git a/app/hdl/hdl_wx_open.go b/app/hdl/hdl_wx_open.go index 43b05b6..a551a9c 100644 --- a/app/hdl/hdl_wx_open.go +++ b/app/hdl/hdl_wx_open.go @@ -184,53 +184,53 @@ func GetPreAuthCode(c *gin.Context) { } func GetAuthUrlCallBack(c *gin.Context) { - //authCode := c.DefaultQuery("auth_code", "") - //if authCode == "" { - // e.OutErr(c, e.ERR_NOT_FAN, "auth_code获取失败") - // return - //} - // - //fmt.Println("auth_code>>>>>>>>", authCode) - // - //masterId := c.DefaultQuery("masterId", "") - //wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db) - //wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) - //if err != nil { - // return - //} - //if wxOpenThirdPartyAppList == nil { - // e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") - // return - //} - //wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) - //if err != nil { - // e.OutErr(c, e.ERR, err.Error()) - // return - //} - //resp, err := wxApiService.GetAuthorizerAccessTokenByAuthCode(authCode) - //if err != nil { - // e.OutErr(c, e.ERR, err.Error()) - // return - //} - // - //userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db) - //userWxAppletList, err := userWxAppletListDb.GetUserWxAppletListByAppId(resp.AuthorizationInfo.AuthorizerAppid) - //if err != nil { - // return - //} - //if userWxAppletList == nil { - // e.OutErr(c, e.ERR_NOT_FAN, "未查询到小程序应用记录") - // return - //} - //userWxAppletList.AuthorizerRefreshToken = resp.AuthorizationInfo.AuthorizerRefreshToken - //_, err = userWxAppletListDb.UpdateUserWxAppletList(userWxAppletList, "authorizer_refresh_token") - //if err != nil { - // e.OutErr(c, e.ERR_DB_ORM, err.Error()) - // return - //} + authCode := c.DefaultQuery("auth_code", "") + if authCode == "" { + e.OutErr(c, e.ERR_NOT_FAN, "auth_code获取失败") + return + } + + fmt.Println("auth_code>>>>>>>>", authCode) + + masterId := c.DefaultQuery("masterId", "") + wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db) + wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) + if err != nil { + return + } + if wxOpenThirdPartyAppList == nil { + e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") + return + } + wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + resp, err := wxApiService.GetAuthorizerAccessTokenByAuthCode(authCode) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + + userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db) + userWxAppletList, err := userWxAppletListDb.GetUserWxAppletListByAppId(resp.AuthorizationInfo.AuthorizerAppid) + if err != nil { + return + } + if userWxAppletList == nil { + e.OutErr(c, e.ERR_NOT_FAN, "未查询到小程序应用记录") + return + } + userWxAppletList.AuthorizerRefreshToken = resp.AuthorizationInfo.AuthorizerRefreshToken + _, err = userWxAppletListDb.UpdateUserWxAppletList(userWxAppletList, "authorizer_refresh_token") + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } c.HTML(http.StatusOK, "success.html", gin.H{ - "applet_name": "激活鸟", + //"applet_name": "激活鸟", }) return } diff --git a/app/svc/svc_sys_cfg_get.go b/app/svc/svc_sys_cfg_get.go index aa9dd14..060a84b 100644 --- a/app/svc/svc_sys_cfg_get.go +++ b/app/svc/svc_sys_cfg_get.go @@ -1,6 +1,7 @@ package svc import ( + "applet/app/db/implement" db "code.fnuoos.com/zhimeng/model.git/src" "github.com/gin-gonic/gin" "xorm.io/xorm" @@ -11,9 +12,10 @@ import ( // 单挑记录获取 func SysCfgGet(c *gin.Context, key string) string { - mid := c.GetString("mid") - eg := db.Db - return db.SysCfgGetWithDb(eg, mid, key) + masterId := GetMasterId(c) + eg := db.DBs[masterId] + sysCfgDb := implement.NewSysCfgDb(eg, masterId) + return sysCfgDb.SysCfgGetWithDb(key) } // 多条记录获取 @@ -22,7 +24,7 @@ func SysCfgFind(c *gin.Context, keys ...string) map[string]string { if c == nil { masterId = "" } else { - masterId = c.GetString("mid") + masterId = GetMasterId(c) } tmp := SysCfgFindComm(masterId, keys...) return tmp @@ -32,55 +34,27 @@ func SysCfgFindComm(masterId string, keys ...string) map[string]string { if masterId == "" { eg = db.Db } else { - eg = db.Db + eg = db.DBs[masterId] } res := map[string]string{} //TODO::判断keys长度(大于10个直接查数据库) + sysCfgDb := implement.NewSysCfgDb(eg, masterId) if len(keys) > 10 { - cfgList, _ := db.SysCfgGetAll(eg) + cfgList, _ := sysCfgDb.SysCfgGetAll() if cfgList == nil { return nil } for _, v := range *cfgList { - res[v.Key] = v.Val + res[v.K] = v.V } } else { for _, key := range keys { - res[key] = db.SysCfgGetWithDb(eg, masterId, key) + res[key] = sysCfgDb.SysCfgGetWithDb(key) } } return res } -// 多条记录获取 -func EgSysCfgFind(keys ...string) map[string]string { - var e *xorm.Engine - res := map[string]string{} - if len(res) == 0 { - cfgList, _ := db.SysCfgGetAll(e) - if cfgList == nil { - return nil - } - for _, v := range *cfgList { - res[v.Key] = v.Val - } - // 先不设置缓存 - // cache.SetJson(md.KEY_SYS_CFG_CACHE, res, 60) - } - if len(keys) == 0 { - return res - } - tmp := map[string]string{} - for _, v := range keys { - if val, ok := res[v]; ok { - tmp[v] = val - } else { - tmp[v] = "" - } - } - return tmp -} - // 清理系统配置信息 func SysCfgCleanCache() { cache.Del(md.KEY_SYS_CFG_CACHE) @@ -88,13 +62,17 @@ func SysCfgCleanCache() { // 写入系统设置 func SysCfgSet(c *gin.Context, key, val, memo string) bool { - cfg, err := db.SysCfgGetOne(db.Db, key) + masterId := GetMasterId(c) + eg := db.DBs[masterId] + sysCfgDb := implement.NewSysCfgDb(eg, masterId) + + cfg, err := sysCfgDb.SysCfgGetOne(key) if err != nil || cfg == nil { - return db.SysCfgInsert(db.Db, key, val, memo) + return sysCfgDb.SysCfgInsert(key, val, memo) } if memo != "" && cfg.Memo != memo { cfg.Memo = memo } SysCfgCleanCache() - return db.SysCfgUpdate(db.Db, key, val, cfg.Memo) + return sysCfgDb.SysCfgUpdate(key, val) } diff --git a/go.mod b/go.mod index 0188ea7..28e31b0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 //replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models require ( - code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240820125928-6ce4c06dda24 + code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240821082038-bfd73b32452e github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/boombuler/barcode v1.0.1 github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5