|
|
package project_module_files
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
"bytes"
|
...
|
...
|
@@ -6,11 +6,12 @@ import ( |
|
|
"github.com/tiptok/gocomm/common"
|
|
|
"github.com/tiptok/gocomm/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModuleFiles/command"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModuleFiles/query"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
|
|
|
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/project_module_files"
|
|
|
"path/filepath"
|
|
|
"strconv"
|
|
|
"strings"
|
...
|
...
|
@@ -20,12 +21,12 @@ import ( |
|
|
type ProjectModuleFilesService struct {
|
|
|
}
|
|
|
|
|
|
func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.CreateProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol.RequestHeader, request *command.CreateProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
ProjectModuleVersion, _ = factory.CreateProjectModuleVersionRepository(transactionContext)
|
|
|
)
|
|
|
rsp = &protocolx.CreateProjectModuleFilesResponse{}
|
|
|
rsp = &command.CreateProjectModuleFilesResponse{}
|
|
|
if err = request.ValidateCommand(); err != nil {
|
|
|
err = protocol.NewCustomMessage(2, err.Error())
|
|
|
}
|
...
|
...
|
@@ -63,12 +64,12 @@ func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol. |
|
|
return
|
|
|
}
|
|
|
|
|
|
func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.UpdateProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.RequestHeader, request *command.UpdateProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
ProjectModuleFilesDao, _ = dao.NewProjectModuleFilesDao(transactionContext)
|
|
|
)
|
|
|
rsp = &protocolx.UpdateProjectModuleFilesResponse{}
|
|
|
rsp = &command.UpdateProjectModuleFilesResponse{}
|
|
|
if err = request.ValidateCommand(); err != nil {
|
|
|
err = protocol.NewCustomMessage(2, err.Error())
|
|
|
return
|
...
|
...
|
@@ -134,11 +135,11 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol. |
|
|
return
|
|
|
}
|
|
|
|
|
|
func (svr *ProjectModuleFilesService) GetProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.GetProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
func (svr *ProjectModuleFilesService) GetProjectModuleFiles(header *protocol.RequestHeader, request *query.GetProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
)
|
|
|
rsp = &protocolx.GetProjectModuleFilesResponse{}
|
|
|
rsp = &query.GetProjectModuleFilesResponse{}
|
|
|
if err = request.ValidateCommand(); err != nil {
|
|
|
err = protocol.NewCustomMessage(2, err.Error())
|
|
|
}
|
...
|
...
|
@@ -160,11 +161,11 @@ func (svr *ProjectModuleFilesService) GetProjectModuleFiles(header *protocol.Req |
|
|
return
|
|
|
}
|
|
|
|
|
|
func (svr *ProjectModuleFilesService) DeleteProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.DeleteProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
func (svr *ProjectModuleFilesService) DeleteProjectModuleFiles(header *protocol.RequestHeader, request *command.DeleteProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
)
|
|
|
rsp = &protocolx.DeleteProjectModuleFilesResponse{}
|
|
|
rsp = &command.DeleteProjectModuleFilesResponse{}
|
|
|
if err = request.ValidateCommand(); err != nil {
|
|
|
err = protocol.NewCustomMessage(2, err.Error())
|
|
|
}
|
...
|
...
|
@@ -196,11 +197,11 @@ func (svr *ProjectModuleFilesService) DeleteProjectModuleFiles(header *protocol. |
|
|
return
|
|
|
}
|
|
|
|
|
|
func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.ListProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.RequestHeader, request *query.ListProjectModuleFilesRequest) (rsp interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
)
|
|
|
rsp = &protocolx.ListProjectModuleFilesResponse{}
|
|
|
rsp = &query.ListProjectModuleFilesResponse{}
|
|
|
if err = request.ValidateCommand(); err != nil {
|
|
|
err = protocol.NewCustomMessage(2, err.Error())
|
|
|
return
|
...
|
...
|
@@ -252,12 +253,12 @@ func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.Re |
|
|
return
|
|
|
}
|
|
|
|
|
|
func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, request *protocolx.ImportRequest) (rsp *protocolx.ImportResponse, err error) {
|
|
|
func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, request *command.ImportRequest) (rsp *command.ImportResponse, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
ProjectModuleVersion, _ = factory.CreateProjectModuleVersionRepository(transactionContext)
|
|
|
)
|
|
|
rsp = &protocolx.ImportResponse{}
|
|
|
rsp = &command.ImportResponse{}
|
|
|
if err = request.ValidateCommand(); err != nil {
|
|
|
err = protocol.NewCustomMessage(2, err.Error())
|
|
|
return
|
...
|
...
|
@@ -325,11 +326,11 @@ func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, req |
|
|
|
|
|
// ReviseTag
|
|
|
// 修订标签
|
|
|
func (svr *ProjectModuleFilesService) ReviseTag(header *protocol.RequestHeader, request *protocolx.ReviseTagRequest) (rsp interface{}, err error) {
|
|
|
func (svr *ProjectModuleFilesService) ReviseTag(header *protocol.RequestHeader, request *command.ReviseTagRequest) (rsp interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
)
|
|
|
rsp = &protocolx.ReviseTagResponse{}
|
|
|
rsp = &command.ReviseTagResponse{}
|
|
|
if err = request.ValidateCommand(); err != nil {
|
|
|
err = protocol.NewCustomMessage(2, err.Error())
|
|
|
return
|
...
|
...
|
@@ -427,11 +428,11 @@ func (svr *ProjectModuleFilesService) mkdirF(fileDir string, mid, vid, pid int64 |
|
|
|
|
|
func (svr *ProjectModuleFilesService) traverseModuleFiles(files []*domain.ProjectModuleFiles) interface{} {
|
|
|
|
|
|
retSlice := make([]*protocolx.ModuleFiles, 0)
|
|
|
retSlice := make([]*query.ModuleFiles, 0)
|
|
|
|
|
|
for i := range files {
|
|
|
if files[i].ParentId == 0 {
|
|
|
retSlice = append(retSlice, &protocolx.ModuleFiles{ModuleFile: protocolx.NewModuleFile(files[i]), List: make([]*protocolx.ModuleFiles, 0)})
|
|
|
retSlice = append(retSlice, &query.ModuleFiles{ModuleFile: query.NewModuleFile(files[i]), List: make([]*query.ModuleFiles, 0)})
|
|
|
continue
|
|
|
}
|
|
|
traverse(retSlice, files[i])
|
...
|
...
|
@@ -439,17 +440,17 @@ func (svr *ProjectModuleFilesService) traverseModuleFiles(files []*domain.Projec |
|
|
return retSlice
|
|
|
}
|
|
|
|
|
|
func traverse(list []*protocolx.ModuleFiles, file *domain.ProjectModuleFiles) {
|
|
|
func traverse(list []*query.ModuleFiles, file *domain.ProjectModuleFiles) {
|
|
|
for i := range list {
|
|
|
if list[i].Id == file.ParentId {
|
|
|
list[i].List = append(list[i].List, &protocolx.ModuleFiles{ModuleFile: protocolx.NewModuleFile(file), List: make([]*protocolx.ModuleFiles, 0)})
|
|
|
list[i].List = append(list[i].List, &query.ModuleFiles{ModuleFile: query.NewModuleFile(file), List: make([]*query.ModuleFiles, 0)})
|
|
|
return
|
|
|
}
|
|
|
traverse(list[i].List, file)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
func changeLog(request *protocolx.UpdateProjectModuleFilesRequest, old *domain.ProjectModuleFiles) string {
|
|
|
func changeLog(request *command.UpdateProjectModuleFilesRequest, old *domain.ProjectModuleFiles) string {
|
|
|
buf := bytes.NewBuffer(nil)
|
|
|
if len(request.FileName) > 0 && request.FileName != old.FileName {
|
|
|
buf.WriteString("【文件名】修改为:" + request.FileName + "\n")
|
...
|
...
|
|