@@ -0,0 +1,51 @@ | |||||
package models | |||||
import ( | |||||
"code.gitea.io/gitea/modules/timeutil" | |||||
) | |||||
type TechConvergeBaseInfo struct { | |||||
ID int64 `xorm:"pk autoincr"` | |||||
ProjectNumber string `xorm:"index"` //项目立项编号 | |||||
ProjectName string //科技项目名称 | |||||
Institution string //项目承担单位 | |||||
ApplyYear int //申报年度 | |||||
Province string //所属省(省市) | |||||
Category string //单位性质 | |||||
Recommend string //推荐单位 | |||||
Owner string //项目负责人 | |||||
Phone string //负责人电话 | |||||
Email string //负责人邮箱 | |||||
Contact string //项目联系人 | |||||
ContactPhone string //联系人电话 | |||||
ContactEmail string //联系人邮箱 | |||||
ExecutePeriod int //执行周期 | |||||
ExecuteStartYear int //执行开始年份 | |||||
ExecuteEndYear int //执行结束年份 | |||||
ExecuteDeadLine string //执行期限 | |||||
Type string //项目类型 | |||||
StartUp timeutil.TimeStamp //启动会时间 | |||||
NameAndInstitution1 string | |||||
NameAndInstitution2 string | |||||
NameAndInstitution3 string | |||||
NameAndInstitution4 string | |||||
NameAndInstitution5 string | |||||
AllInstitution string `xorm:"TEXT"` | |||||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` | |||||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` | |||||
} | |||||
type RepoConvergeInfo struct { | |||||
ID int64 `xorm:"pk autoincr"` | |||||
RepoID int64 | |||||
Url string | |||||
BaseInfoID int64 | |||||
Institution string | |||||
UID int64 | |||||
Status int | |||||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` | |||||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` | |||||
User *User `xorm:"-"` | |||||
Repo *Repository `xorm:"-"` | |||||
BaseInfo *TechConvergeBaseInfo `xorm:"-"` | |||||
} |
@@ -62,6 +62,8 @@ import ( | |||||
"net/http" | "net/http" | ||||
"strings" | "strings" | ||||
"code.gitea.io/gitea/routers/api/v1/tech" | |||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/auth" | "code.gitea.io/gitea/modules/auth" | ||||
@@ -535,6 +537,15 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
}, reqToken()) | }, reqToken()) | ||||
m.Group("/tech", func() { | |||||
m.Post("/basic", tech.ImportBasicInfo) | |||||
m.Get("/custom", repo.GetCustomImages) | |||||
m.Get("/star", repo.GetStarImages) | |||||
m.Get("/npu", repo.GetNpuImages) | |||||
}, reqToken()) | |||||
m.Group("/attachments", func() { | m.Group("/attachments", func() { | ||||
m.Get("/:uuid", repo.GetAttachment) | m.Get("/:uuid", repo.GetAttachment) | ||||
@@ -0,0 +1,48 @@ | |||||
package tech | |||||
import ( | |||||
"net/http" | |||||
"strconv" | |||||
"github.com/lunny/log" | |||||
"code.gitea.io/gitea/models" | |||||
"code.gitea.io/gitea/modules/context" | |||||
"github.com/360EntSecGroup-Skylar/excelize/v2" | |||||
) | |||||
func ImportBasicInfo(ctx *context.APIContext) { | |||||
file, _, err := ctx.GetFile("file") | |||||
if err != nil { | |||||
ctx.JSON(http.StatusBadRequest, models.BaseErrorMessageApi(ctx.Tr("model_app.get_file_fail"))) | |||||
return | |||||
} | |||||
defer file.Close() | |||||
f, err := excelize.OpenReader(file) | |||||
if err != nil { | |||||
ctx.JSON(http.StatusBadRequest, models.BaseErrorMessageApi(ctx.Tr("model_app.get_file_fail"))) | |||||
return | |||||
} | |||||
rows, err := f.GetRows(f.GetSheetName(1)) | |||||
if err != nil { | |||||
ctx.JSON(http.StatusBadRequest, models.BaseErrorMessageApi(ctx.Tr("model_app.get_file_fail"))) | |||||
return | |||||
} | |||||
for i, row := range rows { | |||||
if i != 0 { | |||||
baseInfo := &models.TechConvergeBaseInfo{} | |||||
baseInfo.ProjectNumber = row[2] | |||||
baseInfo.ApplyYear, err = strconv.Atoi(row[1]) | |||||
log.Warn("base info apply year parse err ", i) | |||||
baseInfo.ProjectName = row[3] | |||||
baseInfo.Type = row[16] | |||||
baseInfo.Owner = row[8] | |||||
baseInfo.Email = row[10] | |||||
baseInfo.Phone = row[9] | |||||
baseInfo.Recommend = row[7] | |||||
baseInfo.Institution = row[4] | |||||
} | |||||
} | |||||
} |