|
|
@@ -1,7 +1,9 @@
|
|
|
package result
|
|
|
|
|
|
import (
|
|
|
+ "errors"
|
|
|
"lims_adapter/dao"
|
|
|
+ "log"
|
|
|
|
|
|
"dashoo.cn/common_definition/admin/result_def"
|
|
|
"dashoo.cn/micro_libary/request"
|
|
|
@@ -18,6 +20,37 @@ func NewSrv(tenant string) Service {
|
|
|
return Service{ConsequentDao: dao.NewConsequentDao(tenant), ConsequentDetailDao: dao.NewConsequentDetailDao(tenant), Tenant: tenant}
|
|
|
}
|
|
|
|
|
|
+func (s Service) GetResultList(req result_def.ResultListReq) ([]result_def.ResultList, int, error) {
|
|
|
+ query := s.ConsequentDao.M
|
|
|
+ log.Println(req.PublishTime)
|
|
|
+
|
|
|
+ // FILTER
|
|
|
+ if len(req.PublishTime) == 2 {
|
|
|
+ query = query.Where("(PublishTime BETWEEN ? and ?)", (req.PublishTime)[0], (req.PublishTime)[1])
|
|
|
+ }
|
|
|
+ if req.Name != "" {
|
|
|
+ query = query.Where("Name LIKE ?", "%"+req.Name+"%")
|
|
|
+ }
|
|
|
+ if req.ProjectId != 0 {
|
|
|
+ query = query.Where("ProjectId = ?", req.ProjectId)
|
|
|
+ }
|
|
|
+
|
|
|
+ total, err := query.Count()
|
|
|
+ if err != nil {
|
|
|
+ return nil, 0, errors.New("读取行数失败")
|
|
|
+ }
|
|
|
+ // 无数据返回空
|
|
|
+ if total == 0 {
|
|
|
+ return nil, 0, nil
|
|
|
+ }
|
|
|
+
|
|
|
+ // FIXME owners_name: ["123,123333,实验室管理员,123"],没有拆分类,原接口亦是如此
|
|
|
+ data, err := query.Page(int(req.Current), int(req.Size)).FindAll()
|
|
|
+ result := make([]result_def.ResultList, 0, 0)
|
|
|
+ data.Structs(&result)
|
|
|
+ return result, total, err
|
|
|
+}
|
|
|
+
|
|
|
func (s Service) BatchInsertPapers(insertList []result_def.BatchInsertPapersReq, userInfo request.UserInfo) (int, int, int, []interface{}, error) {
|
|
|
failCount := 0
|
|
|
duplicatedCount := 0
|