提交 437e4796 编写于 作者: 雨爱无痕

Fix issue

上级 456a224a
......@@ -32,6 +32,7 @@ var (
ErrRecordWithSamePathExist = ResponseCode{3011, "Record Exist"}
ErrRecordWithSameInterpreterExist = ResponseCode{3012, "Record Exist"}
ErrRecordNotExist = ResponseCode{4000, "Record Not Found"}
ErrRecordNotAllowDelete = ResponseCode{2000, "Record Can Not Delete"}
NotAvailable = ResponseCode{5000, "Not Available"}
ServerNotAvailable = ResponseCode{5001, "Server Not Available"}
......
......@@ -85,7 +85,7 @@ func (c *ServerCtrl) Delete(ctx iris.Context) {
err = c.ServerService.Delete(uint(id))
if err != nil {
ctx.JSON(c.ErrResp(commConsts.CommErr, err.Error()))
ctx.JSON(c.ErrResp(commConsts.ErrRecordNotAllowDelete, err.Error()))
return
}
......
......@@ -8,6 +8,7 @@ import (
"github.com/easysoft/zentaoatf/internal/server/modules/v1/repo"
fileUtils "github.com/easysoft/zentaoatf/pkg/lib/file"
httpUtils "github.com/easysoft/zentaoatf/pkg/lib/http"
i118Utils "github.com/easysoft/zentaoatf/pkg/lib/i118"
)
type ServerService struct {
......@@ -60,6 +61,10 @@ func (s *ServerService) Update(server model.Server) (err error) {
}
func (s *ServerService) Delete(id uint) error {
info, _ := s.Get(id)
if info.IsDefault {
return errors.New(i118Utils.Sprintf("no_delete_default_server"))
}
return s.ServerRepo.Delete(id)
}
......
......@@ -353,6 +353,10 @@
"id": "exit_exec_curr",
"translation": "Exit current case."
},
{
"id": "no_delete_default_server",
"translation": "Can not delete default server."
},
{
"id": "exit_exec_all",
"translation": "Exit follow-up case."
......
......@@ -346,6 +346,10 @@
"id": "exit_exec_curr",
"translation": "退出当前用例。"
},
{
"id": "no_delete_default_server",
"translation": "请勿删除默认服务器"
},
{
"id": "exit_exec_all",
"translation": "放弃后续用例。"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册