|
|
@@ -5,6 +5,7 @@ import ( |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
|
"xorm.io/builder" |
|
|
|
) |
|
|
|
|
|
|
|
type TechConvergeBaseInfo struct { |
|
|
@@ -41,6 +42,15 @@ type TechConvergeBaseInfo struct { |
|
|
|
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` |
|
|
|
} |
|
|
|
|
|
|
|
func (t *TechConvergeBaseInfo) Brief() *TechConvergeBrief { |
|
|
|
return &TechConvergeBrief{ |
|
|
|
ProjectNumber: t.ProjectNumber, |
|
|
|
ProjectName: t.ProjectName, |
|
|
|
Institution: t.Institution, |
|
|
|
AllInstitution: t.AllInstitution, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
type RepoConvergeInfo struct { |
|
|
|
ID int64 `xorm:"pk autoincr"` |
|
|
|
RepoID int64 |
|
|
@@ -96,3 +106,36 @@ func getTechConvergeBaseInfo(tb *TechConvergeBaseInfo) (*TechConvergeBaseInfo, e |
|
|
|
} |
|
|
|
return tb, nil |
|
|
|
} |
|
|
|
|
|
|
|
type TechConvergeBrief struct { |
|
|
|
ProjectNumber string `json:"no"` //项目立项编号 |
|
|
|
ProjectName string `json:"name"` //科技项目名称 |
|
|
|
Institution string `json:"institution"` //项目承担单位 |
|
|
|
AllInstitution string `json:"all_institution"` |
|
|
|
} |
|
|
|
|
|
|
|
type FindTechOpt struct { |
|
|
|
TechNo string |
|
|
|
ProjectName string |
|
|
|
Institution string |
|
|
|
} |
|
|
|
|
|
|
|
func FindTech(opt FindTechOpt) ([]*TechConvergeBaseInfo, error) { |
|
|
|
var cond builder.Cond |
|
|
|
if opt.TechNo != "" { |
|
|
|
cond = cond.And(builder.Like{"project_number", opt.TechNo}) |
|
|
|
} |
|
|
|
if opt.ProjectName != "" { |
|
|
|
cond = cond.And(builder.Like{"project_name", opt.ProjectName}) |
|
|
|
} |
|
|
|
if opt.Institution != "" { |
|
|
|
cond = cond.And(builder.Like{"institution", opt.Institution}.Or(builder.Like{"all_institution", opt.Institution})) |
|
|
|
} |
|
|
|
|
|
|
|
r := make([]*TechConvergeBaseInfo, 0) |
|
|
|
err := x.Where(cond).OrderBy("updated_unix desc").Find(&r) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return r, nil |
|
|
|
} |