作者 yangfu

模板列表修改

... ... @@ -148,6 +148,7 @@ func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.Re
rsp = &protocolx.ListProjectModuleFilesResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
}
if err = transactionContext.StartTransaction(); err != nil {
log.Error(err)
... ...
... ... @@ -20,5 +20,5 @@ type ProjectModule struct {
// 更新时间
UpdateTime time.Time
// 外键
ProjectModuleVersion []*ProjectModuleVersion `pg:"fk:project_module_id"`
ProjectModuleVersion []*ProjectModuleVersion `pg:"rel:has_many"`
}
... ...
... ... @@ -67,6 +67,8 @@ func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]int
var ProjectModuleFilesModels []*models.ProjectModuleFiles
ProjectModuleFiless := make([]*domain.ProjectModuleFiles, 0)
query := NewQuery(tx.Model(&ProjectModuleFilesModels), queryOptions).
SetWhere("project_module_id=?", "projectModuleId").
SetWhere("project_module_version_id=?", "projectModuleVersionId").
SetOrder("create_time", "sortByCreateTime").
SetOrder("update_time", "sortByUpdateTime")
var err error
... ...
... ... @@ -49,7 +49,7 @@ func (repository *ProjectModuleRepository) Remove(ProjectModule *domain.ProjectM
func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModule, error) {
tx := repository.transactionContext.PgTx
ProjectModuleModel := new(models.ProjectModule)
query := NewQuery(tx.Model(ProjectModuleModel), queryOptions)
query := NewQuery(tx.Model(ProjectModuleModel).Relation("ProjectModuleVersion"), queryOptions)
query.SetWhere("id = ?", "id")
query.SetWhere("project_key = ?", "projectKey")
if err := query.First(); err != nil {
... ... @@ -65,7 +65,7 @@ func (repository *ProjectModuleRepository) Find(queryOptions map[string]interfac
tx := repository.transactionContext.PgTx
var ProjectModuleModels []*models.ProjectModule
ProjectModules := make([]*domain.ProjectModule, 0)
query := NewQuery(tx.Model(&ProjectModuleModels), queryOptions).
query := NewQuery(tx.Model(&ProjectModuleModels).Relation("ProjectModuleVersion"), queryOptions).
SetOrder("create_time", "sortByCreateTime").
SetOrder("update_time", "sortByUpdateTime")
var err error
... ...
... ... @@ -109,15 +109,13 @@ func (this *ProjectModuleFilesController) ListProjectModuleFiles() {
var (
msg *protocol.ResponseMessage
svr = project_module_files.NewProjectModuleFilesService(nil)
request *protocolx.ListProjectModuleFilesRequest
request = &protocolx.ListProjectModuleFilesRequest{}
)
defer func() {
this.Resp(msg)
}()
if err := this.JsonUnmarshal(&request); err != nil {
msg = protocol.BadRequestParam(1)
return
}
request.ProjectModuleVersionId, _ = this.GetInt64("projectModuleVersionId")
request.ProjectModuleId, _ = this.GetInt64("projectModuleId")
header := this.GetRequestHeader(this.Ctx)
data, err := svr.ListProjectModuleFiles(header, request)
if err != nil {
... ...
... ... @@ -6,6 +6,10 @@ import (
)
type ListProjectModuleFilesRequest struct {
// 项目模块编号
ProjectModuleId int64 `json:"projectModuleId,omitempty" valid:"Required"`
// 项目模块版本编号
ProjectModuleVersionId int64 `json:"projectModuleVersionId,omitempty" valid:"Required"`
}
func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateCommand() error {
... ...