@@ -13,7 +13,7 @@ REM 将文件名转换成大驼峰格式并设置成最终实现类名 | |||||
for /f "delims=" %%i in ('powershell -File "%BasePath%etc\ps\ConvertToUpperCase.ps1" -inputString "%FileName%"') do set "ImplementName=%%i" | for /f "delims=" %%i in ('powershell -File "%BasePath%etc\ps\ConvertToUpperCase.ps1" -inputString "%FileName%"') do set "ImplementName=%%i" | ||||
REM 使用 PowerShell 替换接口名称,并指定 UTF-8 编码 | REM 使用 PowerShell 替换接口名称,并指定 UTF-8 编码 | ||||
powershell -Command "(Get-Content '%BasePath%etc\template\template_implement.tpl') -replace 'DemoImplement', '%ImplementName%' | Out-File -FilePath '%BasePath%temp_implement.go' -Encoding UTF8" | |||||
powershell -Command "(Get-Content '%BasePath%etc\template\template_super_implement.tpl') -replace 'DemoImplement', '%ImplementName%' | Out-File -FilePath '%BasePath%temp_implement.go' -Encoding UTF8" | |||||
REM 如果需要,将临时文件重命名为最终文件(取决于move Y?N) | REM 如果需要,将临时文件重命名为最终文件(取决于move Y?N) | ||||
move /Y "%BasePath%temp_implement.go" "%FinalFile%" | move /Y "%BasePath%temp_implement.go" "%FinalFile%" | ||||
@@ -1,7 +1,7 @@ | |||||
package implement | package implement | ||||
import ( | import ( | ||||
"applet/app/db/dao" | |||||
"code.fnuoos.com/zhimeng/model.git/src/dao" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -0,0 +1,14 @@ | |||||
package implement | |||||
import ( | |||||
"code.fnuoos.com/zhimeng/model.git/src/super/dao" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewDemoImplementDb(engine *xorm.Engine) dao.DemoImplementDao { | |||||
return &DemoImplementDb{Db: engine} | |||||
} | |||||
type DemoImplementDb struct { | |||||
Db *xorm.Engine | |||||
} |
@@ -1,4 +1,4 @@ | |||||
package dao | |||||
package dao | |||||
import ( | import ( | ||||
"code.fnuoos.com/zhimeng/model.git/src/model" | "code.fnuoos.com/zhimeng/model.git/src/model" | ||||
@@ -14,6 +14,8 @@ type AgentDao interface { | |||||
FindAdmin(username string, state, page, limit int) (list []model.Agent, total int64, err error) | FindAdmin(username string, state, page, limit int) (list []model.Agent, total int64, err error) | ||||
GetAgent(id int) (m *model.Agent, err error) | GetAgent(id int) (m *model.Agent, err error) | ||||
FindAgentRolePermissionGroup(id int) (list []*AgentWithRolePermissionGroup, total int64, err error) | FindAgentRolePermissionGroup(id int) (list []*AgentWithRolePermissionGroup, total int64, err error) | ||||
GetSuperAdmin(agentId int) (list *model.Agent) | |||||
GetSuperAgentByUsername(username string) (agent *model.Agent, err error) | |||||
} | } | ||||
type AgentWithRolePermissionGroup struct { | type AgentWithRolePermissionGroup struct { | ||||
@@ -15,6 +15,7 @@ type MediumDao interface { | |||||
GetMedium(id int) (m *model.Medium, err error) | GetMedium(id int) (m *model.Medium, err error) | ||||
FindMediumRolePermissionGroup(id int) (list []*MediumWithRolePermissionGroup, total int64, err error) | FindMediumRolePermissionGroup(id int) (list []*MediumWithRolePermissionGroup, total int64, err error) | ||||
FindSuperAdmin(username, memo string, page, limit int) (list []model.Medium, total int64, err error) | FindSuperAdmin(username, memo string, page, limit int) (list []model.Medium, total int64, err error) | ||||
GetSuperAdmin(mediumId int) (list *model.Medium) | |||||
} | } | ||||
type MediumWithRolePermissionGroup struct { | type MediumWithRolePermissionGroup struct { | ||||
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/zhimeng/model.git/src/dao" | "code.fnuoos.com/zhimeng/model.git/src/dao" | ||||
@@ -98,3 +98,23 @@ func (a AgentDb) FindAgentRolePermissionGroup(id int) (list []*dao.AgentWithRole | |||||
FindAndCount(&list) | FindAndCount(&list) | ||||
return | return | ||||
} | } | ||||
func (a AgentDb) GetSuperAdmin(agentId int) (list *model.Agent) { | |||||
list = new(model.Agent) | |||||
sess := a.Db.Where("is_super_administrator=1 and agent_id=?", agentId) | |||||
get, err := sess.Get(list) | |||||
if err != nil || get == false { | |||||
return nil | |||||
} | |||||
return list | |||||
} | |||||
func (a AgentDb) GetSuperAgentByUsername(username string) (agent *model.Agent, err error) { | |||||
agent = new(model.Agent) | |||||
has, err := a.Db.Where("is_super_administrator=1 and username =?", username).Get(agent) | |||||
if err != nil { | |||||
return nil, zhios_order_relate_logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return agent, nil | |||||
} |
@@ -112,3 +112,12 @@ func (m MediumDb) FindSuperAdmin(username, memo string, page, limit int) (list [ | |||||
} | } | ||||
return | return | ||||
} | } | ||||
func (m MediumDb) GetSuperAdmin(mediumId int) (list *model.Medium) { | |||||
list = new(model.Medium) | |||||
sess := m.Db.Where("is_super_administrator=1 and medium_id=?", mediumId) | |||||
get, err := sess.Get(list) | |||||
if err != nil || get == false { | |||||
return nil | |||||
} | |||||
return list | |||||
} |
@@ -4,7 +4,7 @@ import "code.fnuoos.com/zhimeng/model.git/src/super/model" | |||||
type AgentBankInfoDao interface { | type AgentBankInfoDao interface { | ||||
GetAgentBankInfoList(agentId int) (medium *model.AgentBankInfo, err error) | GetAgentBankInfoList(agentId int) (medium *model.AgentBankInfo, err error) | ||||
FindAgentBankInfoList(name, state string, page, limit int) (list []AgentBankInfoGroup, total int64, err error) | |||||
FindAgentBankInfoList(uuid, name, state string, page, limit int) (list []AgentBankInfoGroup, total int64, err error) | |||||
} | } | ||||
type AgentBankInfoGroup struct { | type AgentBankInfoGroup struct { | ||||
model.AgentList `xorm:"extends"` | model.AgentList `xorm:"extends"` | ||||
@@ -4,7 +4,7 @@ import "code.fnuoos.com/zhimeng/model.git/src/super/model" | |||||
type AgentContactInfoDao interface { | type AgentContactInfoDao interface { | ||||
GetAgentContactInfoList(agentId int) (medium *model.AgentContactInfo, err error) | GetAgentContactInfoList(agentId int) (medium *model.AgentContactInfo, err error) | ||||
FindAgentContactInfoList(name, state string, page, limit int) (list []AgentContactInfoGroup, total int64, err error) | |||||
FindAgentContactInfoList(uuid, name, state string, page, limit int) (list []AgentContactInfoGroup, total int64, err error) | |||||
} | } | ||||
type AgentContactInfoGroup struct { | type AgentContactInfoGroup struct { | ||||
model.AgentList `xorm:"extends"` | model.AgentList `xorm:"extends"` | ||||
@@ -6,5 +6,5 @@ type AgentListDao interface { | |||||
GetAgentList(agentId int) (medium *model.AgentList, err error) | GetAgentList(agentId int) (medium *model.AgentList, err error) | ||||
AgentListInsert(m *model.AgentList) (int64, error) | AgentListInsert(m *model.AgentList) (int64, error) | ||||
UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) | UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) | ||||
FindAgentList(name, state string, page, limit int) (list []model.AgentList, total int64, err error) | |||||
FindAgentList(uuid, name, state string, minState, page, limit int) (list []model.AgentList, total int64, err error) | |||||
} | } |
@@ -0,0 +1,17 @@ | |||||
package dao | |||||
import "code.fnuoos.com/zhimeng/model.git/src/super/model" | |||||
type AgentWithMediumDao interface { | |||||
FindAgentWithMediumList(name, state string, agentId, mediumId, page, limit int) (list []AgentWithMediumGroup, total int64, err error) | |||||
GetAgentWithMediumByMediumIdAndAgentId(mediumId, agentId int) (medium *model.AgentWithMedium) | |||||
} | |||||
type AgentWithMediumGroup struct { | |||||
model.AgentWithMedium `xorm:"extends"` | |||||
model.MediumList `xorm:"extends"` | |||||
model.AgentList `xorm:"extends"` | |||||
} | |||||
func (AgentWithMediumGroup) TableName() string { | |||||
return "agent_with_medium" | |||||
} |
@@ -6,5 +6,5 @@ type MediumListDao interface { | |||||
GetMediumList(mediumId int) (medium *model.MediumList, err error) | GetMediumList(mediumId int) (medium *model.MediumList, err error) | ||||
MediumListInsert(m *model.MediumList) (int64, error) | MediumListInsert(m *model.MediumList) (int64, error) | ||||
UpdateMediumList(m *model.MediumList, columns ...string) (int64, error) | UpdateMediumList(m *model.MediumList, columns ...string) (int64, error) | ||||
FindMediumList(uuid, name, state string, page, limit int) (list []model.MediumList, total int64, err error) | |||||
FindMediumList(uuid, name, state string, minState, page, limit int) (list []model.MediumList, total int64, err error) | |||||
} | } |
@@ -26,7 +26,7 @@ func (a AgentBankInfoDb) GetAgentBankInfoList(agentId int) (medium *model.AgentB | |||||
} | } | ||||
return medium, nil | return medium, nil | ||||
} | } | ||||
func (a AgentBankInfoDb) FindAgentBankInfoList(name, state string, page, limit int) (list []dao.AgentBankInfoGroup, total int64, err error) { | |||||
func (a AgentBankInfoDb) FindAgentBankInfoList(uuid, name, state string, page, limit int) (list []dao.AgentBankInfoGroup, total int64, err error) { | |||||
sess := a.Db.Where("agent_bank_info.state>0").Desc("agent_bank_info.id").Limit(limit, (page-1)*limit) | sess := a.Db.Where("agent_bank_info.state>0").Desc("agent_bank_info.id").Limit(limit, (page-1)*limit) | ||||
if name != "" { | if name != "" { | ||||
sess.And("agent_list.company_name like ?", "%"+name+"%") | sess.And("agent_list.company_name like ?", "%"+name+"%") | ||||
@@ -34,6 +34,9 @@ func (a AgentBankInfoDb) FindAgentBankInfoList(name, state string, page, limit i | |||||
if state != "" { | if state != "" { | ||||
sess.And("agent_bank_info.state = ?", state) | sess.And("agent_bank_info.state = ?", state) | ||||
} | } | ||||
if uuid != "" { | |||||
sess.And("agent_bank_info.uuid = ?", uuid) | |||||
} | |||||
sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_bank_info.agent_id") | sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_bank_info.agent_id") | ||||
total, err = sess.FindAndCount(&list) | total, err = sess.FindAndCount(&list) | ||||
if err != nil { | if err != nil { | ||||
@@ -26,7 +26,7 @@ func (a AgentContactInfoDb) GetAgentContactInfoList(agentId int) (medium *model. | |||||
} | } | ||||
return medium, nil | return medium, nil | ||||
} | } | ||||
func (a AgentContactInfoDb) FindAgentContactInfoList(name, state string, page, limit int) (list []dao.AgentContactInfoGroup, total int64, err error) { | |||||
func (a AgentContactInfoDb) FindAgentContactInfoList(uuid, name, state string, page, limit int) (list []dao.AgentContactInfoGroup, total int64, err error) { | |||||
sess := a.Db.Where("agent_contact_info.state>0").Desc("agent_contact_info.id").Limit(limit, (page-1)*limit) | sess := a.Db.Where("agent_contact_info.state>0").Desc("agent_contact_info.id").Limit(limit, (page-1)*limit) | ||||
if name != "" { | if name != "" { | ||||
sess.And("agent_list.company_name like ?", "%"+name+"%") | sess.And("agent_list.company_name like ?", "%"+name+"%") | ||||
@@ -34,6 +34,9 @@ func (a AgentContactInfoDb) FindAgentContactInfoList(name, state string, page, l | |||||
if state != "" { | if state != "" { | ||||
sess.And("agent_contact_info.state = ?", state) | sess.And("agent_contact_info.state = ?", state) | ||||
} | } | ||||
if uuid != "" { | |||||
sess.And("agent_contact_info.uuid = ?", uuid) | |||||
} | |||||
sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_contact_info.agent_id") | sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_contact_info.agent_id") | ||||
total, err = sess.FindAndCount(&list) | total, err = sess.FindAndCount(&list) | ||||
if err != nil { | if err != nil { | ||||
@@ -42,14 +42,20 @@ func (a AgentListDb) UpdateAgentList(m *model.AgentList, columns ...string) (int | |||||
} | } | ||||
return affected, nil | return affected, nil | ||||
} | } | ||||
func (a AgentListDb) FindAgentList(name, state string, page, limit int) (list []model.AgentList, total int64, err error) { | |||||
sess := a.Db.Where("state>0").Desc("id").Limit(limit, (page-1)*limit) | |||||
func (a AgentListDb) FindAgentList(uuid, name, state string, minState, page, limit int) (list []model.AgentList, total int64, err error) { | |||||
sess := a.Db.Desc("id").Limit(limit, (page-1)*limit) | |||||
if name != "" { | if name != "" { | ||||
sess.And("company_name like ?", "%"+name+"%") | sess.And("company_name like ?", "%"+name+"%") | ||||
} | } | ||||
if state != "" { | if state != "" { | ||||
sess.And("state = ?", state) | sess.And("state = ?", state) | ||||
} | } | ||||
if uuid != "" { | |||||
sess.And("uuid = ?", uuid) | |||||
} | |||||
if minState > 0 { | |||||
sess.And("state >= ?", minState) | |||||
} | |||||
total, err = sess.FindAndCount(&list) | total, err = sess.FindAndCount(&list) | ||||
if err != nil { | if err != nil { | ||||
return nil, 0, err | return nil, 0, err | ||||
@@ -0,0 +1,46 @@ | |||||
package implement | |||||
import ( | |||||
"code.fnuoos.com/zhimeng/model.git/src/super/dao" | |||||
"code.fnuoos.com/zhimeng/model.git/src/super/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
func NewAgentWithMediumDb(engine *xorm.Engine) dao.AgentWithMediumDao { | |||||
return &AgentWithMediumDb{Db: engine} | |||||
} | |||||
type AgentWithMediumDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func (a AgentWithMediumDb) GetAgentWithMediumByMediumIdAndAgentId(mediumId, agentId int) (medium *model.AgentWithMedium) { | |||||
medium = new(model.AgentWithMedium) | |||||
get, err := a.Db.Where("medium_id=? and agent_id=?", mediumId, agentId).Get(medium) | |||||
if get == false || err != nil { | |||||
return nil | |||||
} | |||||
return medium | |||||
} | |||||
func (a AgentWithMediumDb) FindAgentWithMediumList(name, state string, agentId, mediumId, page, limit int) (list []dao.AgentWithMediumGroup, total int64, err error) { | |||||
sess := a.Db.Desc("agent_with_medium.id").Limit(limit, (page-1)*limit) | |||||
if name != "" { | |||||
sess.And("medium_list.company_name like ?", "%"+name+"%") | |||||
} | |||||
if state != "" { | |||||
sess.And("medium_list.state = ?", state) | |||||
} | |||||
if agentId > 0 { | |||||
sess.And("agent_with_medium.agent_id = ?", agentId) | |||||
} | |||||
if mediumId > 0 { | |||||
sess.And("agent_with_medium.medium_id = ?", mediumId) | |||||
} | |||||
sess.Join("LEFT", "medium_list", "medium_list.medium_id = agent_with_medium.medium_id") | |||||
sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_with_medium.agent_id") | |||||
total, err = sess.FindAndCount(&list) | |||||
if err != nil { | |||||
return nil, 0, err | |||||
} | |||||
return | |||||
} |
@@ -42,8 +42,8 @@ func (m MediumListDb) UpdateMediumList(medium *model.MediumList, columns ...stri | |||||
} | } | ||||
return affected, nil | return affected, nil | ||||
} | } | ||||
func (m MediumListDb) FindMediumList(uuid, name, state string, page, limit int) (list []model.MediumList, total int64, err error) { | |||||
sess := m.Db.Where("state>0").Desc("id").Limit(limit, (page-1)*limit) | |||||
func (m MediumListDb) FindMediumList(uuid, name, state string, minState, page, limit int) (list []model.MediumList, total int64, err error) { | |||||
sess := m.Db.Desc("id").Limit(limit, (page-1)*limit) | |||||
if name != "" { | if name != "" { | ||||
sess.And("company_name like ?", "%"+name+"%") | sess.And("company_name like ?", "%"+name+"%") | ||||
} | } | ||||
@@ -53,6 +53,9 @@ func (m MediumListDb) FindMediumList(uuid, name, state string, page, limit int) | |||||
if uuid != "" { | if uuid != "" { | ||||
sess.And("uuid = ?", uuid) | sess.And("uuid = ?", uuid) | ||||
} | } | ||||
if minState > 0 { | |||||
sess.And("state >= ?", minState) | |||||
} | |||||
total, err = sess.FindAndCount(&list) | total, err = sess.FindAndCount(&list) | ||||
if err != nil { | if err != nil { | ||||
return nil, 0, err | return nil, 0, err | ||||
@@ -0,0 +1,13 @@ | |||||
package model | |||||
import ( | |||||
"time" | |||||
) | |||||
type AgentWithMedium 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)"` | |||||
MediumId int `json:"medium_id" xorm:"not null default 0 comment('媒体id') INT(11)"` | |||||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` | |||||
UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` | |||||
} |