Pārlūkot izejas kodu

230228版本改进与修复

bigcat 2 gadi atpakaļ
vecāks
revīzija
6b85af3ae9
5 mainītis faili ar 112 papildinājumiem un 0 dzēšanām
  1. 17 0
      controller/software.go
  2. 1 0
      model/plan.go
  3. 15 0
      model/version.go
  4. 7 0
      router.go
  5. 72 0
      tools/tools.go

+ 17 - 0
controller/software.go

@@ -5,6 +5,7 @@ import (
 	"lims-extend/common"
 	"lims-extend/model"
 	"lims-extend/response"
+	"net/http"
 )
 
 func ShowRelatedSoftwares(c *gin.Context) {
@@ -32,3 +33,19 @@ func ShowRelatedSoftwares(c *gin.Context) {
 	}
 	response.Success(c, gin.H{"softwares": res}, "success")
 }
+
+func GetReportDownloadLink(c *gin.Context) {
+	httpHead := "http://61.132.52.98:18003/static/case-file/"
+	db := common.GetDB()
+	softwareId := c.Params.ByName("softwareId")
+	var software model.Software
+	db.Model(&model.Software{}).Where("id = ?", softwareId).First(&software)
+	var plan model.Plan
+	db.Model(&model.Plan{}).Where("software_id = ? and plan.delete <> 1", software.ID).First(&plan)
+	var task model.Task
+	db.Model(&model.Task{}).Where("plan_id = ? and task.delete <> 1 and state = 2", plan.Id).First(&task)
+	var file model.File
+	db.Model(&model.File{}).Where("id = ?", task.CaseFile).First(&file)
+
+	c.Redirect(http.StatusMovedPermanently, httpHead+file.Path)
+}

+ 1 - 0
model/plan.go

@@ -10,6 +10,7 @@ type Plan struct {
 	Delete        int    `json:"delete" gorm:"type:tinyint(1);not null"`
 	CreatorId     string `json:"creatorId" gorm:"column:creator_id;type:varchar(128);not null"`
 	SoftwareId    string `json:"softwareId" gorm:"column:software_id;type:varchar(128);not null"`
+	Type          string `json:"type" gorm:"type:varchar(20);not null"`
 	CreatedAt     Time   `json:"created_at" gorm:"column:create_time;type:datetime default CURRENT_TIMESTAMP"`
 	UpdatedAt     Time   `json:"updated_at" gorm:"column:update_time;type:datetime default CURRENT_TIMESTAMP"`
 	CompanyId     int    `json:"company_id" gorm:"column:company_id;type:bigint(20)"`

+ 15 - 0
model/version.go

@@ -0,0 +1,15 @@
+package model
+
+type Version struct {
+	Id          string `json:"id" gorm:"type:varchar(128);not null"`
+	Number      string `json:"number" gorm:"type:varchar(20);not null"`
+	VersionFile string `json:"version_file" gorm:"type:longtext;not null"`
+	CreatedAt   Time   `json:"created_at" gorm:"column:create_time;type:datetime default CURRENT_TIMESTAMP"`
+	UpdatedAt   Time   `json:"updated_at" gorm:"column:update_time;type:datetime default CURRENT_TIMESTAMP"`
+	Delete      int    `json:"delete" gorm:"type:tinyint(1);not null"`
+	SoftwareId  string `json:"softwareId" gorm:"column:software_id;type:varchar(128);not null"`
+}
+
+func (Version) TableName() string {
+	return "version"
+}

+ 7 - 0
router.go

@@ -3,6 +3,7 @@ package main
 import (
 	"github.com/gin-gonic/gin"
 	"lims-extend/controller"
+	"lims-extend/tools"
 )
 
 func CollectRoute(r *gin.Engine) *gin.Engine {
@@ -27,6 +28,7 @@ func CollectRoute(r *gin.Engine) *gin.Engine {
 	software := r.Group("/api/v-go/software")
 	{
 		software.GET("lists/:userId", controller.ShowRelatedSoftwares)
+		software.GET("report/:softwareId", controller.GetReportDownloadLink)
 
 	}
 	user := r.Group("/api/v-go/user")
@@ -61,5 +63,10 @@ func CollectRoute(r *gin.Engine) *gin.Engine {
 	{
 		file.GET(":fileType/:fileName", controller.OfferFile)
 	}
+	_tools := r.Group("tools")
+	{
+		_tools.POST("modifyTime", tools.ModifyTime)
+	}
+
 	return r
 }

+ 72 - 0
tools/tools.go

@@ -0,0 +1,72 @@
+package tools
+
+import (
+	"github.com/gin-gonic/gin"
+	"lims-extend/common"
+	"lims-extend/model"
+	"lims-extend/response"
+	"time"
+)
+
+type InfoVo struct {
+	SoftwareTitle string `json:"software_title"`
+	CreateTime    string `json:"create_time"`
+	SendTime      string `json:"send_time"`
+	By            string `json:"by"`
+}
+
+func ModifyTime(c *gin.Context) {
+	var info InfoVo
+	c.ShouldBind(&info)
+	db := common.GetDB()
+	createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", info.CreateTime, time.Local)
+	sendTime, _ := time.ParseInLocation("2006-01-02 15:04:05", info.SendTime, time.Local)
+	var software model.Software
+	if info.By == "name" {
+		if err := db.Model(&model.Software{}).Where("name = ? and software.delete <> 1", info.SoftwareTitle).First(&software).Error; err != nil {
+			response.Fail(c, nil, "该软件不存在xiaohezi")
+			return
+		}
+	} else if info.By == "id" {
+		if err := db.Model(&model.Software{}).Where("id = ? and software.delete <> 1", info.SoftwareTitle).First(&software).Error; err != nil {
+			response.Fail(c, nil, "该软件不存在_xiaohezi")
+			return
+		}
+	} else {
+		response.Fail(c, nil, "未选择查询方法")
+		return
+	}
+
+	var plan model.Plan
+	if err := db.Model(&model.Plan{}).Where("software_id = ? and plan.delete <> 1", software.ID).First(&plan).Error; err != nil {
+		response.Fail(c, nil, "计划不存在")
+	}
+	var tasks []model.Task
+	if err := db.Model(&model.Task{}).Where("plan_id = ?", plan.Id).Find(&tasks).Error; err != nil {
+		response.Fail(c, nil, "任务不存在")
+	}
+
+	var version model.Version
+	db.Model(&model.Version{}).Where("software_id = ?", software.ID).First(&version)
+	version.CreatedAt = model.Time(createTime)
+	version.UpdatedAt = model.Time(createTime)
+
+	software.CreatedAt = model.Time(createTime)
+	software.UpdatedAt = model.Time(createTime)
+	plan.CreatedAt = model.Time(createTime)
+	plan.UpdatedAt = model.Time(createTime)
+
+	db.Model(&model.Version{}).Where("id = ?", version.Id).Updates(&version)
+	db.Model(&model.Software{}).Where("id = ?", software.ID).Updates(&software)
+	db.Model(&model.Plan{}).Where("id = ?", plan.Id).Updates(&plan)
+
+	for i := 0; i < len(tasks); i++ {
+		tasks[i].CreatedAt = model.Time(sendTime)
+		tasks[i].UpdatedAt = model.Time(sendTime)
+		db.Model(&model.Task{}).Where("id = ?", tasks[i].ID).Updates(&tasks[i])
+	}
+	response.Success(c, gin.H{"software": software,
+		"plan":  plan,
+		"tasks": tasks}, "done!")
+
+}