Browse Source

值班列表保存添加限制

liuyang 5 years ago
parent
commit
45fdb969d7
1 changed files with 15 additions and 4 deletions
  1. 15 4
      backend/src/dashoo.cn/modi_webapi/app/api/duty/detail.go

+ 15 - 4
backend/src/dashoo.cn/modi_webapi/app/api/duty/detail.go

@@ -5,6 +5,8 @@ import (
 	"dashoo.cn/modi_webapi/app/model/duty/detail"
 	detailService "dashoo.cn/modi_webapi/app/service/duty"
 	"dashoo.cn/modi_webapi/library/request"
+	"github.com/gogf/gf/os/glog"
+
 	//"dashoo.cn/micro_libary/response"
 	"dashoo.cn/modi_webapi/library/response"
 	"github.com/gogf/gf/net/ghttp"
@@ -197,6 +199,8 @@ func (c *DetailController) BatchAdd(r *ghttp.Request) {
 		response.Json(r, 1, err.Error())
 		r.ExitAll()
 	}
+	//
+
 	if id, err := service.Adds(detail, realName); err != nil {
 		response.Json(r, 1, err.Error())
 	} else {
@@ -221,10 +225,6 @@ func (c *DetailController) Saves(r *ghttp.Request) {
 	if DutyId == 0 {
 		response.Json(r, 1, "父级id不能为空")
 	}
-	// 先删除
-	if err := service.DeleteByDutyId(DutyId, delUpdReq); err != nil {
-		response.Json(r, 1, err.Error())
-	}
 
 	// 新增
 	detail := new(detail.ListEntity)
@@ -238,6 +238,17 @@ func (c *DetailController) Saves(r *ghttp.Request) {
 		response.Json(r, 1, err.Error())
 		r.ExitAll()
 	}
+	// 判断是否为空
+	if len(detail.DataList) == 0 {
+		response.Json(r, 1, "值班列表不能为空")
+	}
+
+	// 先删除
+	if err := service.DeleteByDutyId(DutyId, delUpdReq); err != nil {
+		response.Json(r, 1, err.Error())
+	}
+
+	glog.Info(detail)
 	if id, err := service.Adds(detail, realName); err != nil {
 		response.Json(r, 1, err.Error())
 	} else {