Browse Source

删除成果

wanglei 4 năm trước cách đây
mục cha
commit
4b61d79c7c
3 tập tin đã thay đổi với 131 bổ sung1 xóa
  1. 23 1
      handler/results.go
  2. 24 0
      service/result/result.go
  3. 84 0
      test/result.http

+ 23 - 1
handler/results.go

@@ -11,7 +11,7 @@ import (
 	"github.com/gogf/gf/frame/g"
 )
 
-// 设备
+// 成果
 type Result struct{}
 
 func (r Result) BatchInsertPapers(ctx context.Context, req []result_def.BatchInsertPapersReq, rsp *comm_def.CommonMsg) error {
@@ -23,8 +23,10 @@ func (r Result) BatchInsertPapers(ctx context.Context, req []result_def.BatchIns
 	if err != nil {
 		return err
 	}
+
 	g.Log().Info("Received Result.BatchInsertPapers request @ " + tenant)
 	failCount, successCount, duplicatedCount, failList, err := resultSrv.NewSrv(tenant).BatchInsertPapers(req, userinfo)
+
 	_, err, code, msg := myerrors.CheckError(err)
 	if err != nil {
 		return err
@@ -40,8 +42,10 @@ func (r Result) GetResultList(ctx context.Context, req result_def.ResultListReq,
 	if err != nil {
 		return err
 	}
+
 	g.Log().Info("Received Result.GetResultList request @ " + tenant)
 	data, total, err := resultSrv.NewSrv(tenant).GetResultList(req)
+
 	_, err, code, msg := myerrors.CheckError(err)
 	if err != nil {
 		return err
@@ -51,3 +55,21 @@ func (r Result) GetResultList(ctx context.Context, req result_def.ResultListReq,
 	rsp.Data = g.Map{"Total": total, "Data": data}
 	return nil
 }
+
+func (r Result) DeleteResult(ctx context.Context, req comm_def.IdOnlyReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+
+	g.Log().Info("Received Result.DeleteResult request @ " + tenant)
+	err = resultSrv.NewSrv(tenant).DeleteResult(req)
+
+	_, err, code, msg := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Code = code
+	rsp.Msg = msg
+	return nil
+}

+ 24 - 0
service/result/result.go

@@ -1,12 +1,15 @@
 package result
 
 import (
+	"context"
 	"errors"
 	"lims_adapter/dao"
 	"log"
 
 	"dashoo.cn/common_definition/admin/result_def"
+	"dashoo.cn/common_definition/comm_def"
 	"dashoo.cn/micro_libary/request"
+	"github.com/gogf/gf/database/gdb"
 )
 
 type Service struct {
@@ -51,6 +54,7 @@ func (s Service) GetResultList(req result_def.ResultListReq) ([]result_def.Resul
 	return result, total, err
 }
 
+// 论文批量插入
 func (s Service) BatchInsertPapers(insertList []result_def.BatchInsertPapersReq, userInfo request.UserInfo) (int, int, int, []interface{}, error) {
 	failCount := 0
 	duplicatedCount := 0
@@ -102,3 +106,23 @@ func (s Service) BatchInsertPapers(insertList []result_def.BatchInsertPapersReq,
 	}
 	return failCount, successCount, duplicatedCount, failList, nil
 }
+
+// 删除成果
+func (s Service) DeleteResult(req comm_def.IdOnlyReq) error {
+	ctx := context.TODO()
+	return s.ConsequentDao.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
+		if err := s.ConsequentDao.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
+			_, err := s.ConsequentDao.M.Ctx(ctx).Where("Id = ?", req.Id).Delete()
+			return err
+		}); err != nil {
+			return err
+		}
+		if err := s.ConsequentDetailDao.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
+			_, err := s.ConsequentDetailDao.M.Ctx(ctx).Where("ConsequentId = ?", req.Id).Delete()
+			return err
+		}); err != nil {
+			return err
+		}
+		return nil
+	})
+}

+ 84 - 0
test/result.http

@@ -0,0 +1,84 @@
+### 列表
+POST http://127.0.0.1:9981/dashoo.lims.adapter-0.1-wl
+Content-Type: application/json
+X-RPCX-SerializeType: 1
+X-RPCX-ServicePath: Result
+X-RPCX-ServiceMethod: GetResultList
+Tenant:EmGVD5szuT
+SrvEnv: dev
+Authorization: Bearer LygMayNczyP8dlrHOmq+//JVcRMX29aPXSSyCW5uUf084JMv3BQcBjCSgD2nboscjgVUKVt7Fyp/7/EOyVRmNA==
+
+{
+  "current": 1,
+  "size": 10
+}
+###
+
+### 列表筛选
+POST http://127.0.0.1:9981/dashoo.lims.adapter-0.1-wl
+Content-Type: application/json
+X-RPCX-SerializeType: 1
+X-RPCX-ServicePath: Result
+X-RPCX-ServiceMethod: GetResultList
+Tenant:EmGVD5szuT
+SrvEnv: dev
+Authorization: Bearer LygMayNczyP8dlrHOmq+//JVcRMX29aPXSSyCW5uUf084JMv3BQcBjCSgD2nboscjgVUKVt7Fyp/7/EOyVRmNA==
+
+{
+  "name": "a",
+  "current": 1,
+  "size": 10,
+  "project_id": 168,
+  "publish_time": [
+    "2021-10-01",
+    "2021-10-31"
+  ]
+}
+###
+
+### 论文导入
+POST http://127.0.0.1:9981/dashoo.lims.adapter-0.1-wl
+Content-Type: application/json
+X-RPCX-SerializeType: 1
+X-RPCX-ServicePath: Result
+X-RPCX-ServiceMethod: BatchInsertPapers
+Tenant:EmGVD5szuT
+SrvEnv: dev
+Authorization: Bearer LygMayNczyP8dlrHOmq+//JVcRMX29aPXSSyCW5uUf084JMv3BQcBjCSgD2nboscjgVUKVt7Fyp/7/EOyVRmNA==
+
+[
+  {
+    "entity": {
+      "name": "Dux-Mediated Corrections of Aberrant H3K9ac during 2-Cell Genome Activation Optimize Efficiency of Somatic Cell Nuclear Transfer",
+      "type": 3,
+      "code": "",
+      "publish_time": "2021-01-07"
+    },
+    "detail": {
+      "paper_topic": "Dux-Mediated Corrections of Aberrant H3K9ac during 2-Cell Genome Activation Optimize Efficiency of Somatic Cell Nuclear Transfer",
+      "paper_author": "Yang, Guang,Zhang, Linfeng,Liu, Wenqiang,Qiao, Zhibin,Shen, Shijun,Zhu, Qianshu,Gao, Rui,Wang, Mengting,Wang, Mingzhu,Li, Chong,Liu, Meng,Sun, Jin,Wang, Liping,Liu, Wenju,Cui, Xinyu,Zhao, Kun,Zang, Ruge,Chen, Mo,Liang, Zehang,Wang, Lu,Kou, Xiaochen,Zhao, Yanhong,Wang, Hong,Wang, Yixuan,Gao, Shaorong,Chen, Jiayu,Jiang, Cizhong",
+      "paper_corresponding_author": "",
+      "paper_issuing_time": "2021-01-07",
+      "paper_volume": "28(1)",
+      "paper_page": "150-163.e5",
+      "paper_magazine_name": "Cell Stem Cell",
+      "paper_subsidy_fund": ""
+    }
+  }
+]
+###
+
+### 删除成果
+POST http://127.0.0.1:9981/dashoo.lims.adapter-0.1-wl
+Content-Type: application/json
+X-RPCX-SerializeType: 1
+X-RPCX-ServicePath: Result
+X-RPCX-ServiceMethod: DeleteResult
+Tenant:EmGVD5szuT
+SrvEnv: dev
+Authorization: Bearer LygMayNczyP8dlrHOmq+//JVcRMX29aPXSSyCW5uUf084JMv3BQcBjCSgD2nboscjgVUKVt7Fyp/7/EOyVRmNA==
+
+{
+  "id": 434
+}
+###