浏览代码

录入巡更点接口修改

lilifeng 2 年之前
父节点
当前提交
8f66986c2c
共有 1 个文件被更改,包括 41 次插入13 次删除
  1. 41 13
      PMS.NetCore/PMS.NetCore/Controllers/ElectronicInspectionController.cs

+ 41 - 13
PMS.NetCore/PMS.NetCore/Controllers/ElectronicInspectionController.cs

@@ -67,41 +67,69 @@ namespace PMS.NetCore.Controllers
         [AllowAnonymous]
         public JsonResult PointAdd([FromBody] fdc_pm_inspection_point model)
         {
-
+            var res = new ApiResponse();
             logger.Info($"【PointAdd】接口输入:{JsonConvert.SerializeObject(model)}");
-            var manger = new fdc_pm_inspection_pointManager();
+            var manger = new fdc_pm_inspection_pointManager();           
 
-            var point = manger.GetById(model.pointcode);
+            if (model.pointcode.IsNullOrEmpty())
+            {
+                res.IsSuccess = false;
+                res.ErrMsg = "巡更点编号不能为空";
+                return Json(res);
+            }
 
-            if (point != null )
+            if (model.pointname.IsNullOrEmpty())
             {
-                return Json("巡更点已经存在");
+                res.IsSuccess = false;
+                res.ErrMsg = "巡更点名称不能为空";
+                return Json(res);
             }
 
+
             if (model.pcode.IsNullOrEmpty())
-            {
-                return Json("项目不能为空");
+            {               
+                res.IsSuccess = false;
+                res.ErrMsg = "项目不能为空";
+                return Json(res);
             }
 
             if (model.bcode.IsNullOrEmpty())
-            {
-                return Json("楼栋不能为空");
+            {               
+                res.IsSuccess = false;
+                res.ErrMsg = "楼栋不能为空";
+                return Json(res);
             }
 
             if (model.hcode.IsNullOrEmpty())
             {
-                return Json("房间不能为空");
+                res.IsSuccess = false;
+                res.ErrMsg = "房间不能为空";
+                return Json(res);               
+            }
+
+
+            var point = manger.GetById(model.pointcode);
+            if (point != null)
+            {
+                res.IsSuccess = false;
+                res.ErrMsg = "巡更点已经存在";
+                return Json(res);
             }
 
+
             model.createtime = DateTime.Now;
             var success = manger.Insert(model);
             if (success)
             {
-                return Json("添加成功");
+                res.IsSuccess = true;
+                res.Msg = "添加成功";               
+                return Json(res);
             }
             else
-            {
-                return Json("添加失败");
+            {              
+                res.IsSuccess = false;
+                res.ErrMsg = "添加失败";
+                return Json(res);
 
             }
         }