mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-07 09:01:18 +08:00
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package protocol
|
|
|
|
import (
|
|
"x_admin/core"
|
|
"x_admin/core/response"
|
|
"x_admin/middleware"
|
|
"x_admin/util"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func ProtocolRoute(rg *gin.RouterGroup) {
|
|
db := core.GetDB()
|
|
// permSrv := system.NewSystemAuthPermService(db)
|
|
// roleSrv := system.NewSystemAuthRoleService(db, permSrv)
|
|
// adminSrv := system.NewSystemAuthAdminService(db, permSrv, roleSrv)
|
|
// service := system.NewSystemLoginService(db, adminSrv)
|
|
|
|
server := NewSettingProtocolService(db)
|
|
|
|
handle := protocolHandler{Service: server}
|
|
|
|
rg = rg.Group("/setting", middleware.TokenAuth())
|
|
rg.GET("/protocol/detail", handle.Detail)
|
|
rg.POST("/protocol/save", handle.save)
|
|
}
|
|
|
|
type protocolHandler struct {
|
|
Service ISettingProtocolService
|
|
}
|
|
|
|
// detail 获取政策信息
|
|
func (ph protocolHandler) Detail(c *gin.Context) {
|
|
res, err := ph.Service.Detail()
|
|
response.CheckAndRespWithData(c, res, err)
|
|
}
|
|
|
|
// save 保存政策信息
|
|
func (ph protocolHandler) save(c *gin.Context) {
|
|
var pReq SettingProtocolReq
|
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &pReq)) {
|
|
return
|
|
}
|
|
response.CheckAndResp(c, ph.Service.Save(pReq))
|
|
}
|