作者 yangfu

Squashed commit of the following:

commit 65f30f27951df5823526895d94c89ab0b8b49871
Author: yangfu <785409885@qq.com>
Date:   Wed Nov 18 15:14:17 2020 +0800

    1.操作日志修改
    2.客户端公共接口

commit 5602dfb1b9961cce87a9e08480e281d3fdad2771
Author: yangfu <785409885@qq.com>
Date:   Mon Nov 16 14:24:19 2020 +0800

    1.修复功能异常

commit 779c973def3e3c1ac9b0aa02e289aa3a24600ede
Author: yangfu <785409885@qq.com>
Date:   Wed Nov 11 16:00:19 2020 +0800

    1.token修改  2.查询操作不使用事务
@@ -7,9 +7,12 @@ require ( @@ -7,9 +7,12 @@ require (
7 github.com/astaxie/beego v1.12.2 7 github.com/astaxie/beego v1.12.2
8 github.com/dgrijalva/jwt-go v3.2.0+incompatible 8 github.com/dgrijalva/jwt-go v3.2.0+incompatible
9 github.com/go-pg/pg/v10 v10.0.0-beta.2 9 github.com/go-pg/pg/v10 v10.0.0-beta.2
10 - github.com/tiptok/gocomm v1.0.4  
11 //github.com/tal-tech/go-zero v1.0.11 10 //github.com/tal-tech/go-zero v1.0.11
12 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 11 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
  12 + //github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e
  13 + //github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5
  14 + //github.com/openzipkin/zipkin-go v0.2.5
  15 + github.com/tiptok/gocomm v1.0.4
13 ) 16 )
14 17
15 //replace github.com/tiptok/gocomm v1.0.3 => F:\go\src\learn_project\gocomm 18 //replace github.com/tiptok/gocomm v1.0.3 => F:\go\src\learn_project\gocomm
@@ -21,5 +21,30 @@ func main() { @@ -21,5 +21,30 @@ func main() {
21 Filename: constant.LOG_File, 21 Filename: constant.LOG_File,
22 Level: constant.LOG_LEVEL, 22 Level: constant.LOG_LEVEL,
23 }) 23 })
  24 +
  25 + //{
  26 + // // set up a span reporter
  27 + // reporter := zipkinhttp.NewReporter("http://106.52.15.41:9411/api/v2/spans")
  28 + // defer reporter.Close()
  29 + //
  30 + // // create our local service endpoint
  31 + // endpoint, err := zipkin.NewEndpoint("godevp", "127.0.0.1:8080")
  32 + // if err != nil {
  33 + // log.Error("unable to create local endpoint: %+v\n", err)
  34 + // }
  35 + //
  36 + // // initialize our tracer
  37 + // nativeTracer, err := zipkin.NewTracer(reporter, zipkin.WithLocalEndpoint(endpoint))
  38 + // if err != nil {
  39 + // log.Error("unable to create tracer: %+v\n", err)
  40 + // }
  41 + //
  42 + // // use zipkin-go-opentracing to wrap our tracer
  43 + // tracer := zipkinot.Wrap(nativeTracer)
  44 + //
  45 + // // optionally set as Global OpenTracing tracer instance
  46 + // opentracing.SetGlobalTracer(tracer)
  47 + //}
  48 +
24 beego.Run() 49 beego.Run()
25 } 50 }
@@ -46,6 +46,10 @@ func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx @@ -46,6 +46,10 @@ func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx
46 err = protocol.NewCustomMessage(1, "密码有误!") 46 err = protocol.NewCustomMessage(1, "密码有误!")
47 return 47 return
48 } 48 }
  49 + if user.Status != domain.StatusNormal {
  50 + err = protocol.NewCustomMessage(1, "该账号已被禁用!")
  51 + return
  52 + }
49 token, _ := common.GenerateToken(fmt.Sprintf("%v", user.Id), user.Passwd, common.WithExpire(domain.TokenExpire), common.WithAddData(map[string]interface{}{"UserName": user.Name})) 53 token, _ := common.GenerateToken(fmt.Sprintf("%v", user.Id), user.Passwd, common.WithExpire(domain.TokenExpire), common.WithAddData(map[string]interface{}{"UserName": user.Name}))
50 rsp.Access = map[string]interface{}{ 54 rsp.Access = map[string]interface{}{
51 "accessToken": token, //"Bearer " + token, 55 "accessToken": token, //"Bearer " + token,
@@ -115,11 +119,15 @@ func (svr *AuthService) Profile(header *protocol.RequestHeader, request *protoco @@ -115,11 +119,15 @@ func (svr *AuthService) Profile(header *protocol.RequestHeader, request *protoco
115 "adminType": user.AdminType, 119 "adminType": user.AdminType,
116 "roles": utils.LoadCustomField(roles, "Id", "RoleName"), 120 "roles": utils.LoadCustomField(roles, "Id", "RoleName"),
117 } 121 }
118 -  
119 - accessIds, _ := RoleAccessDao.GetRoleAccess(user.Roles...)  
120 - if len(accessIds) > 0 {  
121 - _, accesses, _ := AccessRepository.Find(map[string]interface{}{"inAccessIds": accessIds}) 122 + if user.AdminType == domain.UserAdmin {
  123 + _, accesses, _ := AccessRepository.Find(map[string]interface{}{})
122 rspMap["menus"] = accesses 124 rspMap["menus"] = accesses
  125 + } else {
  126 + accessIds, _ := RoleAccessDao.GetRoleAccess(user.Roles...)
  127 + if len(accessIds) > 0 {
  128 + _, accesses, _ := AccessRepository.Find(map[string]interface{}{"inAccessIds": accessIds})
  129 + rspMap["menus"] = accesses
  130 + }
123 } 131 }
124 rsp = rspMap 132 rsp = rspMap
125 err = transactionContext.CommitTransaction() 133 err = transactionContext.CommitTransaction()
@@ -78,7 +78,7 @@ func (svr *CacheService) ValidUserAccess(userId int64, object string, method str @@ -78,7 +78,7 @@ func (svr *CacheService) ValidUserAccess(userId int64, object string, method str
78 var userAccess []*domain.Access 78 var userAccess []*domain.Access
79 var isAdmin bool 79 var isAdmin bool
80 defer func() { 80 defer func() {
81 - //log.Info(fmt.Sprintf("ValidUserAccess user:%v object:%v method:%v result:%v", userId, object, method, result)) 81 + log.Info(fmt.Sprintf("ValidUserAccess user:%v object:%v method:%v result:%v", userId, object, method, result))
82 }() 82 }()
83 if isAdmin, err = svr.ValidUser(userId); err != nil { 83 if isAdmin, err = svr.ValidUser(userId); err != nil {
84 return 84 return
@@ -105,12 +105,28 @@ func KeyMatch3(key1 string, key2 string) bool { @@ -105,12 +105,28 @@ func KeyMatch3(key1 string, key2 string) bool {
105 105
106 re := regexp.MustCompile(`\{[^/]+\}`) 106 re := regexp.MustCompile(`\{[^/]+\}`)
107 key2 = re.ReplaceAllString(key2, "$1[^/]+$2") 107 key2 = re.ReplaceAllString(key2, "$1[^/]+$2")
  108 + if RegexMatch(key1HasVersion(key1)+"/", "^"+key2+"$") {
  109 + return true
  110 + }
  111 + if RegexMatch(key1HasVersion(key1), "^"+key2+"$") {
  112 + return true
  113 + }
108 if RegexMatch(key1+"/", "^"+key2+"$") { 114 if RegexMatch(key1+"/", "^"+key2+"$") {
109 return true 115 return true
110 } 116 }
111 return RegexMatch(key1, "^"+key2+"$") 117 return RegexMatch(key1, "^"+key2+"$")
112 } 118 }
113 119
  120 +func key1HasVersion(key1 string) string {
  121 + vTags := []string{"v1", "v2", "v3", "v4"} //,"v5","v6","v7","v8","v9"
  122 + for _, tag := range vTags {
  123 + if index := strings.Index(key1, tag); index >= 0 {
  124 + return key1[index+len(tag):]
  125 + }
  126 + }
  127 + return key1
  128 +}
  129 +
114 // KeyEqual case key1='*' or key1=' ' result=true 130 // KeyEqual case key1='*' or key1=' ' result=true
115 func ActionEqual(key1 string, key2 string) bool { 131 func ActionEqual(key1 string, key2 string) bool {
116 if key1 == "*" { 132 if key1 == "*" {
  1 +package cachex
  2 +
  3 +import "testing"
  4 +
  5 +func TestKeyMatch3(t *testing.T) {
  6 + inputObject := []struct {
  7 + ReqObject string
  8 + CmpObject string
  9 + Result bool
  10 + }{
  11 + {
  12 + "/a/b",
  13 + "/a/b",
  14 + true,
  15 + },
  16 + {
  17 + "/v1/a/b",
  18 + "/a/b",
  19 + true,
  20 + },
  21 + }
  22 + for _, v := range inputObject {
  23 + if KeyMatch3(v.ReqObject, v.CmpObject) != v.Result {
  24 + t.Fatal(v.ReqObject, " not match ", v.CmpObject, "except:", v.Result)
  25 + }
  26 + }
  27 +}
@@ -72,7 +72,7 @@ func (svr *ClientVersionService) UpdateClientVersion(header *protocol.RequestHea @@ -72,7 +72,7 @@ func (svr *ClientVersionService) UpdateClientVersion(header *protocol.RequestHea
72 if clientVersion, err = ClientVersionRepository.FindOne(map[string]interface{}{"id": request.Id}); err != nil { 72 if clientVersion, err = ClientVersionRepository.FindOne(map[string]interface{}{"id": request.Id}); err != nil {
73 return 73 return
74 } 74 }
75 - if err = clientVersion.Update(common.ObjectToMap(request)); err != nil { 75 + if err = clientVersion.Update((utils.LoadCustomField(request, header.BodyKeys...)).(map[string]interface{})); err != nil {
76 return 76 return
77 } 77 }
78 if clientVersion, err = ClientVersionRepository.Save(clientVersion); err != nil { 78 if clientVersion, err = ClientVersionRepository.Save(clientVersion); err != nil {
@@ -165,7 +165,7 @@ func (svr *ClientVersionService) ListClientVersion(header *protocol.RequestHeade @@ -165,7 +165,7 @@ func (svr *ClientVersionService) ListClientVersion(header *protocol.RequestHeade
165 rsp = map[string]interface{}{ 165 rsp = map[string]interface{}{
166 "totalRow": total, 166 "totalRow": total,
167 "pageNumber": (request.Offset + request.Limit) / request.Limit, 167 "pageNumber": (request.Offset + request.Limit) / request.Limit,
168 - "list": utils.LoadCustomField(clientVersion, "Id", "ProjectName", "Version", "Title", "Remark", "CreateTime"), 168 + "lists": utils.LoadCustomField(clientVersion, "Id", "ProjectName", "Version", "Title", "Remark", "CreateTime"),
169 } 169 }
170 err = transactionContext.CommitTransaction() 170 err = transactionContext.CommitTransaction()
171 return 171 return
@@ -41,7 +41,7 @@ func (svr *ProjectModuleService) CreateProjectModule(header *protocol.RequestHea @@ -41,7 +41,7 @@ func (svr *ProjectModuleService) CreateProjectModule(header *protocol.RequestHea
41 } 41 }
42 42
43 var ProjectModuleRepository, _ = factory.CreateProjectModuleRepository(transactionContext) 43 var ProjectModuleRepository, _ = factory.CreateProjectModuleRepository(transactionContext)
44 - if _, err = ProjectModuleRepository.FindOne(map[string]interface{}{"projectKey": request.ProjectKey}); err == nil { 44 + if _, err = ProjectModuleRepository.FindOne(map[string]interface{}{"projectKey": request.ProjectKey, "status": domain.StatusNormal}); err == nil {
45 err = protocol.NewCustomMessage(1, "项目键值已存在:"+request.ProjectKey) 45 err = protocol.NewCustomMessage(1, "项目键值已存在:"+request.ProjectKey)
46 return 46 return
47 } 47 }
@@ -87,9 +87,11 @@ func (svr *ProjectModuleService) UpdateProjectModule(header *protocol.RequestHea @@ -87,9 +87,11 @@ func (svr *ProjectModuleService) UpdateProjectModule(header *protocol.RequestHea
87 err = protocol.NewCustomMessage(1, "模板项目不存在") 87 err = protocol.NewCustomMessage(1, "模板项目不存在")
88 return 88 return
89 } 89 }
90 - if _, err = ProjectModuleRepository.FindOne(map[string]interface{}{"projectKey": request.ProjectKey}); err == nil {  
91 - err = protocol.NewCustomMessage(1, "项目键值已存在:"+request.ProjectKey)  
92 - return 90 + if projectModule.ProjectKey != request.ProjectKey {
  91 + if _, err = ProjectModuleRepository.FindOne(map[string]interface{}{"projectKey": request.ProjectKey, "status": domain.StatusNormal}); err == nil {
  92 + err = protocol.NewCustomMessage(1, "项目键值已存在:"+request.ProjectKey)
  93 + return
  94 + }
93 } 95 }
94 if err = projectModule.Update(common.ObjectToMap(request)); err != nil { 96 if err = projectModule.Update(common.ObjectToMap(request)); err != nil {
95 return 97 return
@@ -181,13 +183,13 @@ func (svr *ProjectModuleService) ListProjectModule(header *protocol.RequestHeade @@ -181,13 +183,13 @@ func (svr *ProjectModuleService) ListProjectModule(header *protocol.RequestHeade
181 var ProjectModuleRepository, _ = factory.CreateProjectModuleRepository(transactionContext) 183 var ProjectModuleRepository, _ = factory.CreateProjectModuleRepository(transactionContext)
182 var projectModule []*domain.ProjectModule 184 var projectModule []*domain.ProjectModule
183 var total int64 185 var total int64
184 - if total, projectModule, err = ProjectModuleRepository.Find(map[string]interface{}{"offset": (request.PageNumber - 1) * request.PageSize, "limit": request.PageSize, "sortByCreateTime": "DESC", "status": domain.StatusNormal}); err != nil { 186 + if total, projectModule, err = ProjectModuleRepository.Find(map[string]interface{}{"offset": (request.PageNumber - 1) * request.PageSize, "limit": request.PageSize, "sortByCreateTime": "DESC", "status": domain.StatusNormal, "searchByText": request.ProjectName}); err != nil {
185 return 187 return
186 } 188 }
187 rsp = map[string]interface{}{ 189 rsp = map[string]interface{}{
188 "totalRow": total, 190 "totalRow": total,
189 "pageNumber": request.PageNumber, 191 "pageNumber": request.PageNumber,
190 - "list": utils.LoadCustomField(projectModule, "Id", "ProjectName", "ProjectKey", "Description", "Status", "CreateTime", "UpdateTime"), //listProjectModuleResponse.LoadDto(projectModule), 192 + "lists": utils.LoadCustomField(projectModule, "Id", "ProjectName", "ProjectKey", "Description", "Status", "CreateTime", "UpdateTime"), //listProjectModuleResponse.LoadDto(projectModule),
191 } 193 }
192 err = transactionContext.CommitTransaction() 194 err = transactionContext.CommitTransaction()
193 return 195 return
@@ -45,7 +45,7 @@ func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol. @@ -45,7 +45,7 @@ func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol.
45 Remark: request.Remark, 45 Remark: request.Remark,
46 CreateTime: time.Now(), 46 CreateTime: time.Now(),
47 UpdateTime: time.Now(), 47 UpdateTime: time.Now(),
48 - Path: request.FileKey, 48 + Path: request.FileName,
49 } 49 }
50 50
51 if _, err = ProjectModuleVersion.FindOne(map[string]interface{}{"id": request.ProjectModuleVersionId, "projectModuleId": request.ProjectModuleId}); err != nil { 51 if _, err = ProjectModuleVersion.FindOne(map[string]interface{}{"id": request.ProjectModuleVersionId, "projectModuleId": request.ProjectModuleId}); err != nil {
@@ -85,20 +85,18 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol. @@ -85,20 +85,18 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.
85 if projectModuleFiles, err = ProjectModuleFilesRepository.FindOne(map[string]interface{}{"id": request.Id}); err != nil { 85 if projectModuleFiles, err = ProjectModuleFilesRepository.FindOne(map[string]interface{}{"id": request.Id}); err != nil {
86 return 86 return
87 } 87 }
  88 + var oldProjectModuleFiles = *projectModuleFiles
88 oldFileName = projectModuleFiles.FileName 89 oldFileName = projectModuleFiles.FileName
89 if err = projectModuleFiles.Update(common.ObjectToMap(request)); err != nil { 90 if err = projectModuleFiles.Update(common.ObjectToMap(request)); err != nil {
90 return 91 return
91 } 92 }
92 - if projectModuleFiles, err = ProjectModuleFilesRepository.Save(projectModuleFiles); err != nil {  
93 - return  
94 - }  
95 93
96 // 更新文件名称,修改子节点跟本身的路径 1.文件夹 2.文件 94 // 更新文件名称,修改子节点跟本身的路径 1.文件夹 2.文件
97 if request.FileName != oldFileName { 95 if request.FileName != oldFileName {
98 // TODO:判断是否重名 96 // TODO:判断是否重名
99 var oldPath = projectModuleFiles.Path 97 var oldPath = projectModuleFiles.Path
100 var newPath string 98 var newPath string
101 - if index := strings.LastIndex(projectModuleFiles.Path, oldFileName); index > 0 { 99 + if index := strings.LastIndex(projectModuleFiles.Path, oldFileName); index >= 0 {
102 newPath = projectModuleFiles.Path[:index] + request.FileName 100 newPath = projectModuleFiles.Path[:index] + request.FileName
103 projectModuleFiles.Path = newPath 101 projectModuleFiles.Path = newPath
104 } 102 }
@@ -108,25 +106,26 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol. @@ -108,25 +106,26 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.
108 } 106 }
109 } 107 }
110 } 108 }
111 - // TODO:移动文件文件夹时pid变更,底下路径需要都变掉 109 +
  110 + if projectModuleFiles, err = ProjectModuleFilesRepository.Save(projectModuleFiles); err != nil {
  111 + return
  112 + }
  113 + // TODO:移动文件文件夹时pid变更,底下路径需要都变掉,单独提取一个移动文件的接口
112 114
113 // 变更记录 115 // 变更记录
114 var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext) 116 var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext)
115 - //var UserRepository, _ = factory.CreateUserRepository(transactionContext)  
116 - //user, _ := UserRepository.FindOne(map[string]interface{}{"id": header.UserId})  
117 - //if user == nil {  
118 - // return  
119 - //}  
120 var OpLog *domain.OperatorLog = &domain.OperatorLog{ 117 var OpLog *domain.OperatorLog = &domain.OperatorLog{
121 UserId: header.UserId, 118 UserId: header.UserId,
122 Operator: header.UserName, 119 Operator: header.UserName,
123 Code: domain.LogCodeEditModuleFile, 120 Code: domain.LogCodeEditModuleFile,
124 ResourceId: request.Id, 121 ResourceId: request.Id,
125 - Content: changeLog(request, projectModuleFiles), 122 + Content: changeLog(request, &oldProjectModuleFiles),
126 CreateTime: time.Now(), 123 CreateTime: time.Now(),
127 } 124 }
128 - if _, err = OperatorLogRepository.Save(OpLog); err != nil {  
129 - return 125 + if len(OpLog.Content) > 0 {
  126 + if _, err = OperatorLogRepository.Save(OpLog); err != nil {
  127 + return
  128 + }
130 } 129 }
131 130
132 err = transactionContext.CommitTransaction() 131 err = transactionContext.CommitTransaction()
@@ -212,6 +211,25 @@ func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.Re @@ -212,6 +211,25 @@ func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.Re
212 transactionContext.RollbackTransaction() 211 transactionContext.RollbackTransaction()
213 }() 212 }()
214 213
  214 + // 通过project_key version_key 获取列表
  215 + if len(request.ProjectKey) > 0 && len(request.VersionKey) > 0 {
  216 + var ProjectModuleRepository, _ = factory.CreateProjectModuleRepository(transactionContext)
  217 + if project, _ := ProjectModuleRepository.FindOne(map[string]interface{}{"projectKey": request.ProjectKey, "status": domain.StatusNormal}); project != nil {
  218 + for _, v := range project.ProjectModuleVersion {
  219 + if v.Version == request.VersionKey {
  220 + request.ProjectModuleId = project.Id
  221 + request.ProjectModuleVersionId = v.Id
  222 + break
  223 + }
  224 + }
  225 + }
  226 + }
  227 +
  228 + if request.ProjectModuleVersionId == 0 && request.ProjectModuleId == 0 {
  229 + err = protocol.NewCustomMessage(1, "不存在")
  230 + return
  231 + }
  232 +
215 var ProjectModuleFilesRepository, _ = factory.CreateProjectModuleFilesRepository(transactionContext) 233 var ProjectModuleFilesRepository, _ = factory.CreateProjectModuleFilesRepository(transactionContext)
216 var projectModuleFiles []*domain.ProjectModuleFiles 234 var projectModuleFiles []*domain.ProjectModuleFiles
217 var total int64 235 var total int64
@@ -261,9 +279,9 @@ func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, req @@ -261,9 +279,9 @@ func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, req
261 fileDir := filepath.Dir(f.FileName) 279 fileDir := filepath.Dir(f.FileName)
262 fileBase := filepath.Base(f.FileName) 280 fileBase := filepath.Base(f.FileName)
263 filename := strings.Split(fileBase, ".")[0] 281 filename := strings.Split(fileBase, ".")[0]
264 - var parentNode *domain.ProjectModuleFiles = &domain.ProjectModuleFiles{Path: "", ProjectModuleId: request.ProjectModuleId, ProjectModuleVersionId: request.ProjectModuleVersionId, Id: 0} 282 + var parentNode *domain.ProjectModuleFiles = &domain.ProjectModuleFiles{Path: "", ProjectModuleId: request.ProjectModuleId, ProjectModuleVersionId: request.ProjectModuleVersionId, Id: request.ParentId}
265 var ok bool 283 var ok bool
266 - if len(fileDir) > 0 { 284 + if len(fileDir) > 0 && f.FileName != fileBase { //如果文件名跟路径一致,说明path是空
267 // create dir node 285 // create dir node
268 if parentNode, ok = mapParent[fileDir]; !ok { 286 if parentNode, ok = mapParent[fileDir]; !ok {
269 parentNodes, _ := svr.mkdirF(fileDir, request.ProjectModuleId, request.ProjectModuleVersionId, request.ParentId, ProjectModuleFilesRepository) 287 parentNodes, _ := svr.mkdirF(fileDir, request.ProjectModuleId, request.ProjectModuleVersionId, request.ParentId, ProjectModuleFilesRepository)
@@ -291,9 +309,10 @@ func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, req @@ -291,9 +309,10 @@ func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, req
291 UpdateTime: time.Now(), 309 UpdateTime: time.Now(),
292 Path: filename, 310 Path: filename,
293 } 311 }
294 - if _, e := svr.save(newItem, ProjectModuleFilesRepository); e != nil {  
295 - log.Error(e)  
296 - continue 312 + if _, err = svr.save(newItem, ProjectModuleFilesRepository); err != nil {
  313 + log.Error(err)
  314 + //continue
  315 + return
297 } 316 }
298 } 317 }
299 318
@@ -311,8 +330,8 @@ func (svr *ProjectModuleFilesService) save(request *domain.ProjectModuleFiles, P @@ -311,8 +330,8 @@ func (svr *ProjectModuleFilesService) save(request *domain.ProjectModuleFiles, P
311 request.Path = filepath.Join(pfile.Path, request.Path) 330 request.Path = filepath.Join(pfile.Path, request.Path)
312 } 331 }
313 } 332 }
314 - if m, e := ProjectModuleFilesRepository.FindOne(map[string]interface{}{"fileKey": request.FileKey, "projectModuleId": request.ProjectModuleId, "projectModuleVersionId": request.ProjectModuleVersionId, "parentId": request.ParentId}); e == nil && m != nil {  
315 - err = protocol.NewCustomMessage(1, "已存在 filekey:"+request.FileKey) 333 + if m, e := ProjectModuleFilesRepository.FindOne(map[string]interface{}{"path": request.Path, "projectModuleId": request.ProjectModuleId, "projectModuleVersionId": request.ProjectModuleVersionId, "parentId": request.ParentId}); e == nil && m != nil {
  334 + err = protocol.NewCustomMessage(1, "已存在:"+request.Path)
316 rsp = m 335 rsp = m
317 return 336 return
318 } 337 }
@@ -382,14 +401,14 @@ func traverse(list []*protocolx.ModuleFiles, file *domain.ProjectModuleFiles) { @@ -382,14 +401,14 @@ func traverse(list []*protocolx.ModuleFiles, file *domain.ProjectModuleFiles) {
382 } 401 }
383 func changeLog(request *protocolx.UpdateProjectModuleFilesRequest, old *domain.ProjectModuleFiles) string { 402 func changeLog(request *protocolx.UpdateProjectModuleFilesRequest, old *domain.ProjectModuleFiles) string {
384 buf := bytes.NewBuffer(nil) 403 buf := bytes.NewBuffer(nil)
385 - if len(request.FileName) > 0 {  
386 - buf.WriteString(" 修改文件名为:" + request.FileName + "\n") 404 + if len(request.FileName) > 0 && request.FileName != old.FileName {
  405 + buf.WriteString("【文件名】修改为:" + request.FileName + "\n")
387 } 406 }
388 - if len(request.Remark) > 0 {  
389 - buf.WriteString(" 修改描述信息为:" + request.Remark + "\n") 407 + if len(request.Remark) > 0 && request.Remark != old.Remark {
  408 + buf.WriteString("【描述信息】修改为:" + request.Remark + "\n")
390 } 409 }
391 - if len(request.CodeBlock) > 0 {  
392 - buf.WriteString(" 修改模板代码") 410 + if len(request.CodeBlock) > 0 && request.CodeBlock != old.CodeBlock {
  411 + buf.WriteString("【模板代码】修改为:\n" + old.CodeBlock)
393 } 412 }
394 return buf.String() 413 return buf.String()
395 } 414 }
@@ -50,7 +50,7 @@ func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *proto @@ -50,7 +50,7 @@ func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *proto
50 } 50 }
51 newProjectModuleVersion.ProjectModuleId = srcVersion.ProjectModuleId 51 newProjectModuleVersion.ProjectModuleId = srcVersion.ProjectModuleId
52 52
53 - if _, e := ProjectModuleVersionRepository.FindOne(map[string]interface{}{"projectModuleId": srcVersion.ProjectModuleId, "version": strings.TrimSpace(request.Version)}); e == nil { 53 + if _, e := ProjectModuleVersionRepository.FindOne(map[string]interface{}{"projectModuleId": srcVersion.ProjectModuleId, "version": strings.TrimSpace(request.Version), "status": 0}); e == nil {
54 err = protocol.NewCustomMessage(1, fmt.Sprintf("当前版本已存在:"+request.Version)) 54 err = protocol.NewCustomMessage(1, fmt.Sprintf("当前版本已存在:"+request.Version))
55 return 55 return
56 } 56 }
@@ -62,7 +62,7 @@ func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *proto @@ -62,7 +62,7 @@ func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *proto
62 } 62 }
63 63
64 var ProjectModuleDao, _ = dao.NewProjectModuleDao(transactionContext) 64 var ProjectModuleDao, _ = dao.NewProjectModuleDao(transactionContext)
65 - if err = ProjectModuleDao.DuplicateVersion(srcVersion.ProjectModuleId, srcVersion.ProjectModuleId, currentPMVersionId); err != nil { 65 + if err = ProjectModuleDao.DuplicateVersion(srcVersion.ProjectModuleId, srcVersion.Id, currentPMVersionId); err != nil {
66 return 66 return
67 } 67 }
68 err = transactionContext.CommitTransaction() 68 err = transactionContext.CommitTransaction()
@@ -90,7 +90,7 @@ func (svr *UserService) UpdateUser(header *protocol.RequestHeader, request *prot @@ -90,7 +90,7 @@ func (svr *UserService) UpdateUser(header *protocol.RequestHeader, request *prot
90 err = protocol.NewCustomMessage(1, "用户不存在") 90 err = protocol.NewCustomMessage(1, "用户不存在")
91 return 91 return
92 } 92 }
93 - if request.Phone != "" { 93 + if request.Phone != "" && request.Phone != user.Phone {
94 if _, err = UserRepository.FindOne(map[string]interface{}{"phone": request.Phone}); err == nil { 94 if _, err = UserRepository.FindOne(map[string]interface{}{"phone": request.Phone}); err == nil {
95 err = protocol.NewCustomMessage(1, "手机号已存在") 95 err = protocol.NewCustomMessage(1, "手机号已存在")
96 return 96 return
@@ -226,7 +226,7 @@ func (svr *UserService) ListUser(header *protocol.RequestHeader, request *protoc @@ -226,7 +226,7 @@ func (svr *UserService) ListUser(header *protocol.RequestHeader, request *protoc
226 } 226 }
227 userList := make([]map[string]interface{}, 0) 227 userList := make([]map[string]interface{}, 0)
228 for _, v := range user { 228 for _, v := range user {
229 - item := map[string]interface{}{"id": v.Id, "name": v.Name, "adminType": v.AdminType, "status": v.Status, "createTime": v.CreateTime.Local().Format("2006-01-02 15:04:05")} 229 + item := map[string]interface{}{"id": v.Id, "name": v.Name, "phone": v.Phone, "adminType": v.AdminType, "status": v.Status, "createTime": v.CreateTime.Local().Format("2006-01-02 15:04:05")}
230 item["roles"] = getRoles(v.Roles) 230 item["roles"] = getRoles(v.Roles)
231 userList = append(userList, item) 231 userList = append(userList, item)
232 } 232 }
@@ -234,7 +234,7 @@ func (svr *UserService) ListUser(header *protocol.RequestHeader, request *protoc @@ -234,7 +234,7 @@ func (svr *UserService) ListUser(header *protocol.RequestHeader, request *protoc
234 rsp = map[string]interface{}{ 234 rsp = map[string]interface{}{
235 "totalRow": total, 235 "totalRow": total,
236 "pageNumber": request.PageNumber, 236 "pageNumber": request.PageNumber,
237 - "list": userList, 237 + "lists": userList,
238 } 238 }
239 if err = transactionContext.CommitTransaction(); err != nil { 239 if err = transactionContext.CommitTransaction(); err != nil {
240 err = application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 240 err = application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1 package domain 1 package domain
2 2
3 -import "time" 3 +import (
  4 + "time"
  5 +)
4 6
5 // ClientVersion 7 // ClientVersion
6 type ClientVersion struct { 8 type ClientVersion struct {
@@ -12,8 +12,8 @@ type ProjectModuleFilesDao struct { @@ -12,8 +12,8 @@ type ProjectModuleFilesDao struct {
12 12
13 func (dao *ProjectModuleFilesDao) UpdateFilesPath(srcProjectId, srcVersionId int64, oldPath, newPath string) error { 13 func (dao *ProjectModuleFilesDao) UpdateFilesPath(srcProjectId, srcVersionId int64, oldPath, newPath string) error {
14 tx := dao.transactionContext.PgTx 14 tx := dao.transactionContext.PgTx
15 - _, err := tx.Exec(fmt.Sprintf(`update project_module_files set "path"= replace("path",?,?) where project_module_id=? and project_module_version_id=? and "path" like '%%%v%%'`, strings.Replace(oldPath, "\\", "\\\\", -1)),  
16 - oldPath, newPath, srcProjectId, srcVersionId) 15 + _, err := tx.Exec(fmt.Sprintf(`update project_module_files set "path"= regexp_replace("path",'^%v',?) where project_module_id=? and project_module_version_id=? and "path" like '%%%v%%'`, oldPath, strings.Replace(oldPath, "\\", "\\\\", -1)),
  16 + newPath, srcProjectId, srcVersionId)
17 return err 17 return err
18 } 18 }
19 19
@@ -97,6 +97,10 @@ func (repository *ClientVersionRepository) Find(queryOptions map[string]interfac @@ -97,6 +97,10 @@ func (repository *ClientVersionRepository) Find(queryOptions map[string]interfac
97 SetOrder("create_time", "sortByCreateTime"). 97 SetOrder("create_time", "sortByCreateTime").
98 SetOrder("update_time", "sortByUpdateTime"). 98 SetOrder("update_time", "sortByUpdateTime").
99 SetLimit() 99 SetLimit()
  100 +
  101 + if searchByText, ok := queryOptions["searchByText"]; ok && len(searchByText.(string)) > 0 {
  102 + query.Where(fmt.Sprintf(`project_name like '%%%v%%'`, searchByText))
  103 + }
100 var err error 104 var err error
101 if query.AffectRow, err = query.SelectAndCount(); err != nil { 105 if query.AffectRow, err = query.SelectAndCount(); err != nil {
102 return 0, ClientVersions, err 106 return 0, ClientVersions, err
@@ -75,9 +75,11 @@ func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]int @@ -75,9 +75,11 @@ func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]int
75 SetOrder("create_time", "sortByCreateTime"). 75 SetOrder("create_time", "sortByCreateTime").
76 SetOrder("update_time", "sortByUpdateTime"). 76 SetOrder("update_time", "sortByUpdateTime").
77 SetOrder("parent_id", "sortByParentId"). 77 SetOrder("parent_id", "sortByParentId").
  78 + SetOrder("file_type", "sortByFileType").
78 SetOrder("id", "sortById") 79 SetOrder("id", "sortById")
79 80
80 query.SetWhere("parent_id = ?", "parentId") 81 query.SetWhere("parent_id = ?", "parentId")
  82 + query.SetWhere("file_name = ?", "fileName")
81 var err error 83 var err error
82 if query.AffectRow, err = query.SelectAndCount(); err != nil { 84 if query.AffectRow, err = query.SelectAndCount(); err != nil {
83 return 0, ProjectModuleFiless, err 85 return 0, ProjectModuleFiless, err
@@ -56,6 +56,8 @@ func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]inter @@ -56,6 +56,8 @@ func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]inter
56 }), queryOptions) 56 }), queryOptions)
57 query.SetWhere("id = ?", "id") 57 query.SetWhere("id = ?", "id")
58 query.SetWhere("project_key = ?", "projectKey") 58 query.SetWhere("project_key = ?", "projectKey")
  59 +
  60 + query.SetWhere("status=?", "status")
59 if err := query.First(); err != nil { 61 if err := query.First(); err != nil {
60 return nil, fmt.Errorf("query row not found") 62 return nil, fmt.Errorf("query row not found")
61 } 63 }
@@ -77,6 +79,11 @@ func (repository *ProjectModuleRepository) Find(queryOptions map[string]interfac @@ -77,6 +79,11 @@ func (repository *ProjectModuleRepository) Find(queryOptions map[string]interfac
77 SetWhere("status=?", "status"). 79 SetWhere("status=?", "status").
78 SetOrder("create_time", "sortByCreateTime"). 80 SetOrder("create_time", "sortByCreateTime").
79 SetOrder("update_time", "sortByUpdateTime").SetLimit() 81 SetOrder("update_time", "sortByUpdateTime").SetLimit()
  82 +
  83 + if searchByText, ok := queryOptions["searchByText"]; ok && len(searchByText.(string)) > 0 {
  84 + query.Where(fmt.Sprintf(`project_name like '%%%v%%'`, searchByText))
  85 + }
  86 +
80 var err error 87 var err error
81 if query.AffectRow, err = query.SelectAndCount(); err != nil { 88 if query.AffectRow, err = query.SelectAndCount(); err != nil {
82 return 0, ProjectModules, err 89 return 0, ProjectModules, err
@@ -63,6 +63,7 @@ func (repository *ProjectModuleVersionRepository) FindOne(queryOptions map[strin @@ -63,6 +63,7 @@ func (repository *ProjectModuleVersionRepository) FindOne(queryOptions map[strin
63 query.SetWhere("id = ?", "id") 63 query.SetWhere("id = ?", "id")
64 query.SetWhere("project_module_id = ?", "projectModuleId") 64 query.SetWhere("project_module_id = ?", "projectModuleId")
65 query.SetWhere("version = ?", "version") 65 query.SetWhere("version = ?", "version")
  66 + query.SetWhere("status = ?", "status")
66 if err := query.First(); err != nil { 67 if err := query.First(); err != nil {
67 return nil, fmt.Errorf("query row not found") 68 return nil, fmt.Errorf("query row not found")
68 } 69 }
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
8 8
9 func init() { 9 func init() {
10 beego.InsertFilter("*", beego.BeforeRouter, middleware.AllowCors()) 10 beego.InsertFilter("*", beego.BeforeRouter, middleware.AllowCors())
  11 + //beego.InsertFilter("*", beego.BeforeRouter, middleware.OpenTracingAdapter)
11 12
12 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequestLogFilter()) 13 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequestLogFilter())
13 beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(), false) 14 beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(), false)
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "encoding/json" 5 "encoding/json"
6 "github.com/astaxie/beego" 6 "github.com/astaxie/beego"
7 "github.com/astaxie/beego/context" 7 "github.com/astaxie/beego/context"
  8 + "github.com/tiptok/gocomm/common"
8 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol" 9 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
9 ) 10 )
10 11
@@ -23,6 +24,19 @@ func (controller BaseController) JsonUnmarshal(v interface{}) error { @@ -23,6 +24,19 @@ func (controller BaseController) JsonUnmarshal(v interface{}) error {
23 return err 24 return err
24 } 25 }
25 26
  27 +func (controller BaseController) BodyKeys(firstCaseToUpper bool) []string {
  28 + var bodyKV map[string]json.RawMessage
  29 + controller.JsonUnmarshal(&bodyKV)
  30 + if len(bodyKV) == 0 {
  31 + return []string{}
  32 + }
  33 + var list []string
  34 + for k, _ := range bodyKV {
  35 + list = append(list, common.CamelCase(k, true))
  36 + }
  37 + return list
  38 +}
  39 +
26 func (controller *BaseController) Resp(msg *protocol.ResponseMessage) { 40 func (controller *BaseController) Resp(msg *protocol.ResponseMessage) {
27 if msg.Errno != 0 { 41 if msg.Errno != 0 {
28 msg.Errno = -1 42 msg.Errno = -1
@@ -51,6 +65,6 @@ func (controller *BaseController) GetRequestHeader(ctx *context.Context) *protoc @@ -51,6 +65,6 @@ func (controller *BaseController) GetRequestHeader(ctx *context.Context) *protoc
51 if v := ctx.Input.GetData("x-mmm-uname"); v != nil { 65 if v := ctx.Input.GetData("x-mmm-uname"); v != nil {
52 h.UserName = v.(string) 66 h.UserName = v.(string)
53 } 67 }
54 - 68 + h.BodyKeys = controller.BodyKeys(true)
55 return h 69 return h
56 } 70 }
@@ -45,6 +45,10 @@ func (controller *ClientVersionController) UpdateClientVersion() { @@ -45,6 +45,10 @@ func (controller *ClientVersionController) UpdateClientVersion() {
45 defer func() { 45 defer func() {
46 controller.Resp(msg) 46 controller.Resp(msg)
47 }() 47 }()
  48 + if err := controller.JsonUnmarshal(&request); err != nil {
  49 + msg = protocol.NewResponseMessage(2, err.Error())
  50 + return
  51 + }
48 request.Id, _ = controller.GetInt64(":clientVersionId") 52 request.Id, _ = controller.GetInt64(":clientVersionId")
49 header := controller.GetRequestHeader(controller.Ctx) 53 header := controller.GetRequestHeader(controller.Ctx)
50 data, err := svr.UpdateClientVersion(header, request) 54 data, err := svr.UpdateClientVersion(header, request)
@@ -106,6 +110,7 @@ func (controller *ClientVersionController) ListClientVersion() { @@ -106,6 +110,7 @@ func (controller *ClientVersionController) ListClientVersion() {
106 controller.Resp(msg) 110 controller.Resp(msg)
107 }() 111 }()
108 request.Offset, request.Limit = controller.GetLimitInfo() 112 request.Offset, request.Limit = controller.GetLimitInfo()
  113 + request.SearchByText = controller.GetString("projectName")
109 header := controller.GetRequestHeader(controller.Ctx) 114 header := controller.GetRequestHeader(controller.Ctx)
110 data, err := svr.ListClientVersion(header, request) 115 data, err := svr.ListClientVersion(header, request)
111 if err != nil { 116 if err != nil {
@@ -119,6 +119,7 @@ func (controller *OperatorLogController) ListOperatorLog() { @@ -119,6 +119,7 @@ func (controller *OperatorLogController) ListOperatorLog() {
119 // return 119 // return
120 //} 120 //}
121 request.Offset, request.Limit = controller.GetLimitInfo() 121 request.Offset, request.Limit = controller.GetLimitInfo()
  122 + request.ResourceId, _ = controller.GetInt64("resourceId")
122 header := controller.GetRequestHeader(controller.Ctx) 123 header := controller.GetRequestHeader(controller.Ctx)
123 data, err := svr.ListOperatorLog(header, request) 124 data, err := svr.ListOperatorLog(header, request)
124 if err != nil { 125 if err != nil {
@@ -115,6 +115,7 @@ func (controller *ProjectModuleController) ListProjectModule() { @@ -115,6 +115,7 @@ func (controller *ProjectModuleController) ListProjectModule() {
115 } 115 }
116 request.PageNumber, _ = controller.GetInt("pageNumber") 116 request.PageNumber, _ = controller.GetInt("pageNumber")
117 request.PageSize, _ = controller.GetInt("pageSize") 117 request.PageSize, _ = controller.GetInt("pageSize")
  118 + request.ProjectName = controller.GetString("projectName")
118 header := controller.GetRequestHeader(controller.Ctx) 119 header := controller.GetRequestHeader(controller.Ctx)
119 data, err := svr.ListProjectModule(header, request) 120 data, err := svr.ListProjectModule(header, request)
120 if err != nil { 121 if err != nil {
@@ -115,6 +115,10 @@ func (controller *ProjectModuleFilesController) ListProjectModuleFiles() { @@ -115,6 +115,10 @@ func (controller *ProjectModuleFilesController) ListProjectModuleFiles() {
115 request.ProjectModuleVersionId, _ = controller.GetInt64("projectModuleVersionId") 115 request.ProjectModuleVersionId, _ = controller.GetInt64("projectModuleVersionId")
116 request.ProjectModuleId, _ = controller.GetInt64("projectModuleId") 116 request.ProjectModuleId, _ = controller.GetInt64("projectModuleId")
117 request.StructType = controller.GetString("structType") 117 request.StructType = controller.GetString("structType")
  118 +
  119 + request.ProjectKey = controller.GetString("projectKey")
  120 + request.VersionKey = controller.GetString("versionKey")
  121 + request.FileName = controller.GetString("fileName")
118 header := controller.GetRequestHeader(controller.Ctx) 122 header := controller.GetRequestHeader(controller.Ctx)
119 data, err := svr.ListProjectModuleFiles(header, request) 123 data, err := svr.ListProjectModuleFiles(header, request)
120 if err != nil { 124 if err != nil {
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "errors" 5 "errors"
6 "fmt" 6 "fmt"
7 "github.com/astaxie/beego/context" 7 "github.com/astaxie/beego/context"
  8 + //"github.com/opentracing/opentracing-go"
8 "github.com/tiptok/gocomm/common" 9 "github.com/tiptok/gocomm/common"
9 "github.com/tiptok/gocomm/pkg/log" 10 "github.com/tiptok/gocomm/pkg/log"
10 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/cachex" 11 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/cachex"
@@ -136,3 +137,19 @@ func AllowCors() func(ctx *context.Context) { @@ -136,3 +137,19 @@ func AllowCors() func(ctx *context.Context) {
136 } 137 }
137 } 138 }
138 } 139 }
  140 +
  141 +//func OpenTracingAdapter(ctx *context.Context) {
  142 +// var sp opentracing.Span
  143 +// opName := ctx.Input.URL()
  144 +// // Attempt to join a trace by getting trace context from the headers.
  145 +// wireContext, err := opentracing.GlobalTracer().Extract(
  146 +// opentracing.HTTPHeaders,
  147 +// opentracing.HTTPHeadersCarrier(ctx.Request.Header))
  148 +// if err != nil {
  149 +// // If for whatever reason we can't join, go ahead an start a new root span.
  150 +// sp = opentracing.StartSpan(opName)
  151 +// } else {
  152 +// sp = opentracing.StartSpan(opName, opentracing.ChildOf(wireContext))
  153 +// }
  154 +// defer sp.Finish()
  155 +//}
@@ -13,4 +13,6 @@ func init() { @@ -13,4 +13,6 @@ func init() {
13 beego.Router("/v1/project_module_files/", &controllers.ProjectModuleFilesController{}, "GET:ListProjectModuleFiles") 13 beego.Router("/v1/project_module_files/", &controllers.ProjectModuleFilesController{}, "GET:ListProjectModuleFiles")
14 14
15 beego.Router("/v1/project_module_files/import", &controllers.ProjectModuleFilesController{}, "post:Import") 15 beego.Router("/v1/project_module_files/import", &controllers.ProjectModuleFilesController{}, "post:Import")
  16 +
  17 + beego.Router("/v1/client/project_module_files/", &controllers.ProjectModuleFilesController{}, "GET:ListProjectModuleFiles")
16 } 18 }
@@ -6,8 +6,9 @@ import ( @@ -6,8 +6,9 @@ import (
6 ) 6 )
7 7
8 type ListClientVersionRequest struct { 8 type ListClientVersionRequest struct {
9 - Offset int `json:"offset"`  
10 - Limit int `json:"limit"` 9 + Offset int `json:"offset"`
  10 + Limit int `json:"limit"`
  11 + SearchByText string `json:"projectName,omitempty"` //按名称搜索
11 } 12 }
12 13
13 func (ListClientVersionRequest *ListClientVersionRequest) ValidateCommand() error { 14 func (ListClientVersionRequest *ListClientVersionRequest) ValidateCommand() error {
@@ -6,8 +6,9 @@ import ( @@ -6,8 +6,9 @@ import (
6 ) 6 )
7 7
8 type ListProjectModuleRequest struct { 8 type ListProjectModuleRequest struct {
9 - PageSize int `json:"pageSize" valid:"Required"`  
10 - PageNumber int `json:"pageNumber" valid:"Required"` 9 + PageSize int `json:"pageSize" valid:"Required"`
  10 + PageNumber int `json:"pageNumber" valid:"Required"`
  11 + ProjectName string `json:"projectName,omitempty"` //按名称搜索
11 } 12 }
12 13
13 func (ListProjectModuleRequest *ListProjectModuleRequest) ValidateCommand() error { 14 func (ListProjectModuleRequest *ListProjectModuleRequest) ValidateCommand() error {
@@ -7,15 +7,24 @@ import ( @@ -7,15 +7,24 @@ import (
7 7
8 type ListProjectModuleFilesRequest struct { 8 type ListProjectModuleFilesRequest struct {
9 // 项目模块编号 9 // 项目模块编号
10 - ProjectModuleId int64 `json:"projectModuleId,omitempty" valid:"Required"` 10 + ProjectModuleId int64 `json:"projectModuleId,omitempty"`
11 // 项目模块版本编号 11 // 项目模块版本编号
12 - ProjectModuleVersionId int64 `json:"projectModuleVersionId,omitempty" valid:"Required"` 12 + ProjectModuleVersionId int64 `json:"projectModuleVersionId,omitempty"`
13 // 返回结构类型 tree list 默认list 13 // 返回结构类型 tree list 默认list
14 StructType string `json:"structType,omitempty"` 14 StructType string `json:"structType,omitempty"`
15 // 按父级Id排序 15 // 按父级Id排序
16 SortByParentId string `json:"sortByParentId,omitempty"` 16 SortByParentId string `json:"sortByParentId,omitempty"`
17 // 按Id排序 17 // 按Id排序
18 SortById string `json:"sortById,omitempty"` 18 SortById string `json:"sortById,omitempty"`
  19 + // 按文件类型
  20 + SortByFileType string `json:"sortByFileType,omitempty"`
  21 +
  22 + // 项目模块编号
  23 + ProjectKey string `json:"projectKey,omitempty"`
  24 + // 项目模块版本编号
  25 + VersionKey string `json:"versionKey,omitempty"`
  26 + // 项目模块文件
  27 + FileName string `json:"fileName,omitempty"`
19 } 28 }
20 29
21 func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateCommand() error { 30 func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateCommand() error {
@@ -27,6 +36,9 @@ func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateComm @@ -27,6 +36,9 @@ func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateComm
27 if len(ListProjectModuleFilesRequest.SortById) == 0 { 36 if len(ListProjectModuleFilesRequest.SortById) == 0 {
28 ListProjectModuleFilesRequest.SortById = "ASC" 37 ListProjectModuleFilesRequest.SortById = "ASC"
29 } 38 }
  39 + if len(ListProjectModuleFilesRequest.SortByFileType) == 0 {
  40 + ListProjectModuleFilesRequest.SortByFileType = "ASC"
  41 + }
30 if err != nil { 42 if err != nil {
31 return err 43 return err
32 } 44 }
@@ -133,4 +133,5 @@ var errmessge ErrorMap = map[int]string{ @@ -133,4 +133,5 @@ var errmessge ErrorMap = map[int]string{
133 type RequestHeader struct { 133 type RequestHeader struct {
134 UserId int64 //UserId 唯一标识 134 UserId int64 //UserId 唯一标识
135 UserName string 135 UserName string
  136 + BodyKeys []string
136 } 137 }