mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-12-01 09:33:15 +00:00
add i18n
This commit is contained in:
@@ -31,7 +31,7 @@ func (ct *Peer) Detail(c *gin.Context) {
|
||||
response.Success(c, u)
|
||||
return
|
||||
}
|
||||
response.Fail(c, 101, "信息不存在")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ func (ct *Peer) Detail(c *gin.Context) {
|
||||
func (ct *Peer) Create(c *gin.Context) {
|
||||
f := &admin.PeerForm{}
|
||||
if err := c.ShouldBindJSON(f); err != nil {
|
||||
response.Fail(c, 101, "参数错误")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
errList := global.Validator.ValidStruct(f)
|
||||
errList := global.Validator.ValidStruct(c, f)
|
||||
if len(errList) > 0 {
|
||||
response.Fail(c, 101, errList[0])
|
||||
return
|
||||
@@ -60,7 +60,7 @@ func (ct *Peer) Create(c *gin.Context) {
|
||||
u := f.ToPeer()
|
||||
err := service.AllService.PeerService.Create(u)
|
||||
if err != nil {
|
||||
response.Fail(c, 101, "创建失败")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "OperationFailed")+err.Error())
|
||||
return
|
||||
}
|
||||
response.Success(c, u)
|
||||
@@ -81,7 +81,7 @@ func (ct *Peer) Create(c *gin.Context) {
|
||||
func (ct *Peer) List(c *gin.Context) {
|
||||
query := &admin.PageQuery{}
|
||||
if err := c.ShouldBindQuery(query); err != nil {
|
||||
response.Fail(c, 101, "参数错误")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
res := service.AllService.PeerService.List(query.Page, query.PageSize, nil)
|
||||
@@ -102,14 +102,14 @@ func (ct *Peer) List(c *gin.Context) {
|
||||
func (ct *Peer) Update(c *gin.Context) {
|
||||
f := &admin.PeerForm{}
|
||||
if err := c.ShouldBindJSON(f); err != nil {
|
||||
response.Fail(c, 101, "参数错误")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
if f.RowId == 0 {
|
||||
response.Fail(c, 101, "参数错误")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError"))
|
||||
return
|
||||
}
|
||||
errList := global.Validator.ValidStruct(f)
|
||||
errList := global.Validator.ValidStruct(c, f)
|
||||
if len(errList) > 0 {
|
||||
response.Fail(c, 101, errList[0])
|
||||
return
|
||||
@@ -117,7 +117,7 @@ func (ct *Peer) Update(c *gin.Context) {
|
||||
u := f.ToPeer()
|
||||
err := service.AllService.PeerService.Update(u)
|
||||
if err != nil {
|
||||
response.Fail(c, 101, "更新失败")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "OperationFailed")+err.Error())
|
||||
return
|
||||
}
|
||||
response.Success(c, nil)
|
||||
@@ -137,11 +137,11 @@ func (ct *Peer) Update(c *gin.Context) {
|
||||
func (ct *Peer) Delete(c *gin.Context) {
|
||||
f := &admin.PeerForm{}
|
||||
if err := c.ShouldBindJSON(f); err != nil {
|
||||
response.Fail(c, 101, "系统错误")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
id := f.RowId
|
||||
errList := global.Validator.ValidVar(id, "required,gt=0")
|
||||
errList := global.Validator.ValidVar(c, id, "required,gt=0")
|
||||
if len(errList) > 0 {
|
||||
response.Fail(c, 101, errList[0])
|
||||
return
|
||||
@@ -153,8 +153,8 @@ func (ct *Peer) Delete(c *gin.Context) {
|
||||
response.Success(c, nil)
|
||||
return
|
||||
}
|
||||
response.Fail(c, 101, err.Error())
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "OperationFailed")+err.Error())
|
||||
return
|
||||
}
|
||||
response.Fail(c, 101, "信息不存在")
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user