作者 yangfu

模板列表修改

@@ -148,6 +148,7 @@ func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.Re @@ -148,6 +148,7 @@ func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.Re
148 rsp = &protocolx.ListProjectModuleFilesResponse{} 148 rsp = &protocolx.ListProjectModuleFilesResponse{}
149 if err = request.ValidateCommand(); err != nil { 149 if err = request.ValidateCommand(); err != nil {
150 err = protocol.NewCustomMessage(2, err.Error()) 150 err = protocol.NewCustomMessage(2, err.Error())
  151 + return
151 } 152 }
152 if err = transactionContext.StartTransaction(); err != nil { 153 if err = transactionContext.StartTransaction(); err != nil {
153 log.Error(err) 154 log.Error(err)
@@ -20,5 +20,5 @@ type ProjectModule struct { @@ -20,5 +20,5 @@ type ProjectModule struct {
20 // 更新时间 20 // 更新时间
21 UpdateTime time.Time 21 UpdateTime time.Time
22 // 外键 22 // 外键
23 - ProjectModuleVersion []*ProjectModuleVersion `pg:"fk:project_module_id"` 23 + ProjectModuleVersion []*ProjectModuleVersion `pg:"rel:has_many"`
24 } 24 }
@@ -67,6 +67,8 @@ func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]int @@ -67,6 +67,8 @@ func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]int
67 var ProjectModuleFilesModels []*models.ProjectModuleFiles 67 var ProjectModuleFilesModels []*models.ProjectModuleFiles
68 ProjectModuleFiless := make([]*domain.ProjectModuleFiles, 0) 68 ProjectModuleFiless := make([]*domain.ProjectModuleFiles, 0)
69 query := NewQuery(tx.Model(&ProjectModuleFilesModels), queryOptions). 69 query := NewQuery(tx.Model(&ProjectModuleFilesModels), queryOptions).
  70 + SetWhere("project_module_id=?", "projectModuleId").
  71 + SetWhere("project_module_version_id=?", "projectModuleVersionId").
70 SetOrder("create_time", "sortByCreateTime"). 72 SetOrder("create_time", "sortByCreateTime").
71 SetOrder("update_time", "sortByUpdateTime") 73 SetOrder("update_time", "sortByUpdateTime")
72 var err error 74 var err error
@@ -49,7 +49,7 @@ func (repository *ProjectModuleRepository) Remove(ProjectModule *domain.ProjectM @@ -49,7 +49,7 @@ func (repository *ProjectModuleRepository) Remove(ProjectModule *domain.ProjectM
49 func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModule, error) { 49 func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModule, error) {
50 tx := repository.transactionContext.PgTx 50 tx := repository.transactionContext.PgTx
51 ProjectModuleModel := new(models.ProjectModule) 51 ProjectModuleModel := new(models.ProjectModule)
52 - query := NewQuery(tx.Model(ProjectModuleModel), queryOptions) 52 + query := NewQuery(tx.Model(ProjectModuleModel).Relation("ProjectModuleVersion"), queryOptions)
53 query.SetWhere("id = ?", "id") 53 query.SetWhere("id = ?", "id")
54 query.SetWhere("project_key = ?", "projectKey") 54 query.SetWhere("project_key = ?", "projectKey")
55 if err := query.First(); err != nil { 55 if err := query.First(); err != nil {
@@ -65,7 +65,7 @@ func (repository *ProjectModuleRepository) Find(queryOptions map[string]interfac @@ -65,7 +65,7 @@ func (repository *ProjectModuleRepository) Find(queryOptions map[string]interfac
65 tx := repository.transactionContext.PgTx 65 tx := repository.transactionContext.PgTx
66 var ProjectModuleModels []*models.ProjectModule 66 var ProjectModuleModels []*models.ProjectModule
67 ProjectModules := make([]*domain.ProjectModule, 0) 67 ProjectModules := make([]*domain.ProjectModule, 0)
68 - query := NewQuery(tx.Model(&ProjectModuleModels), queryOptions). 68 + query := NewQuery(tx.Model(&ProjectModuleModels).Relation("ProjectModuleVersion"), queryOptions).
69 SetOrder("create_time", "sortByCreateTime"). 69 SetOrder("create_time", "sortByCreateTime").
70 SetOrder("update_time", "sortByUpdateTime") 70 SetOrder("update_time", "sortByUpdateTime")
71 var err error 71 var err error
@@ -109,15 +109,13 @@ func (this *ProjectModuleFilesController) ListProjectModuleFiles() { @@ -109,15 +109,13 @@ func (this *ProjectModuleFilesController) ListProjectModuleFiles() {
109 var ( 109 var (
110 msg *protocol.ResponseMessage 110 msg *protocol.ResponseMessage
111 svr = project_module_files.NewProjectModuleFilesService(nil) 111 svr = project_module_files.NewProjectModuleFilesService(nil)
112 - request *protocolx.ListProjectModuleFilesRequest 112 + request = &protocolx.ListProjectModuleFilesRequest{}
113 ) 113 )
114 defer func() { 114 defer func() {
115 this.Resp(msg) 115 this.Resp(msg)
116 }() 116 }()
117 - if err := this.JsonUnmarshal(&request); err != nil {  
118 - msg = protocol.BadRequestParam(1)  
119 - return  
120 - } 117 + request.ProjectModuleVersionId, _ = this.GetInt64("projectModuleVersionId")
  118 + request.ProjectModuleId, _ = this.GetInt64("projectModuleId")
121 header := this.GetRequestHeader(this.Ctx) 119 header := this.GetRequestHeader(this.Ctx)
122 data, err := svr.ListProjectModuleFiles(header, request) 120 data, err := svr.ListProjectModuleFiles(header, request)
123 if err != nil { 121 if err != nil {
@@ -6,6 +6,10 @@ import ( @@ -6,6 +6,10 @@ import (
6 ) 6 )
7 7
8 type ListProjectModuleFilesRequest struct { 8 type ListProjectModuleFilesRequest struct {
  9 + // 项目模块编号
  10 + ProjectModuleId int64 `json:"projectModuleId,omitempty" valid:"Required"`
  11 + // 项目模块版本编号
  12 + ProjectModuleVersionId int64 `json:"projectModuleVersionId,omitempty" valid:"Required"`
9 } 13 }
10 14
11 func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateCommand() error { 15 func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateCommand() error {