branch fix bug
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.查询操作不使用事务
正在显示
16 个修改的文件
包含
78 行增加
和
33 行删除
@@ -4,10 +4,10 @@ go 1.15 | @@ -4,10 +4,10 @@ go 1.15 | ||
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2 | 6 | github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2 |
7 | + //github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2 | ||
7 | github.com/astaxie/beego v1.12.2 | 8 | github.com/astaxie/beego v1.12.2 |
8 | github.com/dgrijalva/jwt-go v3.2.0+incompatible | 9 | github.com/dgrijalva/jwt-go v3.2.0+incompatible |
9 | github.com/go-pg/pg/v10 v10.0.0-beta.2 | 10 | github.com/go-pg/pg/v10 v10.0.0-beta.2 |
10 | - //github.com/tal-tech/go-zero v1.0.11 | ||
11 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 | 11 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 |
12 | github.com/stretchr/testify v1.5.1 | 12 | github.com/stretchr/testify v1.5.1 |
13 | //github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e | 13 | //github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e |
@@ -156,7 +156,7 @@ func (svr *AuthService) Profile(header *protocol.RequestHeader, request *protoco | @@ -156,7 +156,7 @@ func (svr *AuthService) Profile(header *protocol.RequestHeader, request *protoco | ||
156 | _, accesses, _ := AccessRepository.Find(map[string]interface{}{}) | 156 | _, accesses, _ := AccessRepository.Find(map[string]interface{}{}) |
157 | rspMap["menus"] = accesses | 157 | rspMap["menus"] = accesses |
158 | } else { | 158 | } else { |
159 | - accessIds, _ := RoleAccessDao.GetRoleAccess(user.Roles...) | 159 | + accessIds, _ := RoleAccessDao.GetRoleAccess((domain.Roles(roles)).RoleIds()...) |
160 | if len(accessIds) > 0 { | 160 | if len(accessIds) > 0 { |
161 | _, accesses, _ := AccessRepository.Find(map[string]interface{}{"inAccessIds": accessIds}) | 161 | _, accesses, _ := AccessRepository.Find(map[string]interface{}{"inAccessIds": accessIds}) |
162 | rspMap["menus"] = accesses | 162 | rspMap["menus"] = accesses |
@@ -55,7 +55,7 @@ func (svr *ProjectModuleService) CreateProjectModule(header *protocol.RequestHea | @@ -55,7 +55,7 @@ func (svr *ProjectModuleService) CreateProjectModule(header *protocol.RequestHea | ||
55 | ProjectModuleId: newProjectModule.Id, | 55 | ProjectModuleId: newProjectModule.Id, |
56 | Version: "latest", | 56 | Version: "latest", |
57 | Description: "latest version", | 57 | Description: "latest version", |
58 | - Status: 0, | 58 | + Status: domain.StatusNormal, |
59 | CreateTime: time.Now(), | 59 | CreateTime: time.Now(), |
60 | UpdateTime: time.Now(), | 60 | UpdateTime: time.Now(), |
61 | }); err != nil { | 61 | }); err != nil { |
@@ -89,7 +89,7 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol. | @@ -89,7 +89,7 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol. | ||
89 | } | 89 | } |
90 | var oldProjectModuleFiles = *projectModuleFiles | 90 | var oldProjectModuleFiles = *projectModuleFiles |
91 | oldFileName = projectModuleFiles.FileName | 91 | oldFileName = projectModuleFiles.FileName |
92 | - if err = projectModuleFiles.Update(common.ObjectToMap(request)); err != nil { | 92 | + if err = projectModuleFiles.Update(utils.LoadCustomFieldToMap(request, header.BodyKeys...)); err != nil { |
93 | return | 93 | return |
94 | } | 94 | } |
95 | 95 | ||
@@ -353,7 +353,10 @@ func (svr *ProjectModuleFilesService) ReviseTag(header *protocol.RequestHeader, | @@ -353,7 +353,10 @@ func (svr *ProjectModuleFilesService) ReviseTag(header *protocol.RequestHeader, | ||
353 | if len(request.Tag) == 0 { | 353 | if len(request.Tag) == 0 { |
354 | if lastProjectModuleFiles, e := ProjectModuleFilesRepository.FindOne(map[string]interface{}{ | 354 | if lastProjectModuleFiles, e := ProjectModuleFilesRepository.FindOne(map[string]interface{}{ |
355 | "projectModuleId": projectModuleFiles.ProjectModuleId, | 355 | "projectModuleId": projectModuleFiles.ProjectModuleId, |
356 | - "projectModuleVersionId": projectModuleFiles.ProjectModuleVersionId, "path": projectModuleFiles.Path, "orderByTag": "DESC"}); e == nil { | 356 | + "projectModuleVersionId": projectModuleFiles.ProjectModuleVersionId, "path": projectModuleFiles.Path, |
357 | + //"orderByTag": "DESC", | ||
358 | + "sortById": "DESC", | ||
359 | + }); e == nil { | ||
357 | lastTag = lastProjectModuleFiles.Tag | 360 | lastTag = lastProjectModuleFiles.Tag |
358 | } | 361 | } |
359 | } | 362 | } |
@@ -36,7 +36,7 @@ func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *proto | @@ -36,7 +36,7 @@ func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *proto | ||
36 | newProjectModuleVersion := &domain.ProjectModuleVersion{ | 36 | newProjectModuleVersion := &domain.ProjectModuleVersion{ |
37 | Version: strings.TrimSpace(request.Version), | 37 | Version: strings.TrimSpace(request.Version), |
38 | Description: request.Description, | 38 | Description: request.Description, |
39 | - Status: 0, | 39 | + Status: domain.StatusNormal, |
40 | CreateTime: time.Now(), | 40 | CreateTime: time.Now(), |
41 | UpdateTime: time.Now(), | 41 | UpdateTime: time.Now(), |
42 | } | 42 | } |
@@ -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), "status": 0}); e == nil { | 53 | + if _, e := ProjectModuleVersionRepository.FindOne(map[string]interface{}{"projectModuleId": srcVersion.ProjectModuleId, "version": strings.TrimSpace(request.Version), "status": domain.StatusNormal}); 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 | } |
@@ -162,7 +162,7 @@ func (svr *ProjectModuleVersionService) DeleteProjectModuleVersion(header *proto | @@ -162,7 +162,7 @@ func (svr *ProjectModuleVersionService) DeleteProjectModuleVersion(header *proto | ||
162 | err = protocol.NewCustomMessage(1, "版本信息不存在") | 162 | err = protocol.NewCustomMessage(1, "版本信息不存在") |
163 | return | 163 | return |
164 | } | 164 | } |
165 | - if projectModuleVersion.Status == 1 { | 165 | + if projectModuleVersion.Status == domain.StatusDelete { |
166 | err = protocol.NewCustomMessage(1, "已删除") | 166 | err = protocol.NewCustomMessage(1, "已删除") |
167 | return | 167 | return |
168 | } | 168 | } |
@@ -194,7 +194,7 @@ func (svr *ProjectModuleVersionService) ListProjectModuleVersion(header *protoco | @@ -194,7 +194,7 @@ func (svr *ProjectModuleVersionService) ListProjectModuleVersion(header *protoco | ||
194 | var ProjectModuleVersionRepository, _ = factory.CreateProjectModuleVersionRepository(transactionContext) | 194 | var ProjectModuleVersionRepository, _ = factory.CreateProjectModuleVersionRepository(transactionContext) |
195 | var projectModuleVersion []*domain.ProjectModuleVersion | 195 | var projectModuleVersion []*domain.ProjectModuleVersion |
196 | var total int64 | 196 | var total int64 |
197 | - if total, projectModuleVersion, err = ProjectModuleVersionRepository.Find(map[string]interface{}{"projectModuleId": request.ProjectModuleId, "status": 0}); err != nil { | 197 | + if total, projectModuleVersion, err = ProjectModuleVersionRepository.Find(map[string]interface{}{"projectModuleId": request.ProjectModuleId, "status": domain.StatusNormal}); err != nil { |
198 | return | 198 | return |
199 | } | 199 | } |
200 | rsp = map[string]interface{}{ | 200 | rsp = map[string]interface{}{ |
@@ -115,11 +115,7 @@ func (svr *RbacService) SetRoleAccess(header *protocol.RequestHeader, request *p | @@ -115,11 +115,7 @@ func (svr *RbacService) SetRoleAccess(header *protocol.RequestHeader, request *p | ||
115 | } | 115 | } |
116 | 116 | ||
117 | var accessMap = make(map[int64]*domain.Access) | 117 | var accessMap = make(map[int64]*domain.Access) |
118 | - _, access, e := AccessRepository.Find(map[string]interface{}{"inAccessIds": request.AccessIds}) | ||
119 | - if e != nil { | ||
120 | - err = e | ||
121 | - return | ||
122 | - } | 118 | + _, access, _ := AccessRepository.Find(map[string]interface{}{"inAccessIds": request.AccessIds}) |
123 | for _, v := range access { | 119 | for _, v := range access { |
124 | accessMap[v.Id] = v | 120 | accessMap[v.Id] = v |
125 | } | 121 | } |
@@ -96,7 +96,8 @@ func (svr *UserService) UpdateUser(header *protocol.RequestHeader, request *prot | @@ -96,7 +96,8 @@ func (svr *UserService) UpdateUser(header *protocol.RequestHeader, request *prot | ||
96 | return | 96 | return |
97 | } | 97 | } |
98 | } | 98 | } |
99 | - if err = user.Update(common.ObjectToMap(request)); err != nil { | 99 | + // common.ObjectToMap(request) |
100 | + if err = user.Update(utils.LoadCustomFieldToMap(request, header.BodyKeys...)); err != nil { | ||
100 | err = application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 101 | err = application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
101 | return | 102 | return |
102 | } | 103 | } |
@@ -136,11 +137,13 @@ func (svr *UserService) GetUser(header *protocol.RequestHeader, request *protoco | @@ -136,11 +137,13 @@ func (svr *UserService) GetUser(header *protocol.RequestHeader, request *protoco | ||
136 | return | 137 | return |
137 | } | 138 | } |
138 | retMap := map[string]interface{}{"id": user.Id, "name": user.Name, "phone": user.Phone, "adminType": user.AdminType, "status": user.Status} | 139 | retMap := map[string]interface{}{"id": user.Id, "name": user.Name, "phone": user.Phone, "adminType": user.AdminType, "status": user.Status} |
139 | - if len(user.Roles) > 0 { | ||
140 | - if _, roles, e := RoleRepository.Find(map[string]interface{}{"inRoleIds": user.Roles}); len(roles) > 0 && e == nil { | ||
141 | - retMap["roles"] = utils.LoadCustomField(roles, "Id", "RoleName") | 140 | + var roles []*domain.Role |
141 | + for _, v := range user.Roles { | ||
142 | + if role, e := RoleRepository.FindOne(map[string]interface{}{"id": v}); e == nil { | ||
143 | + roles = append(roles, role) | ||
142 | } | 144 | } |
143 | } | 145 | } |
146 | + retMap["roles"] = utils.LoadCustomField(roles, "Id", "RoleName") | ||
144 | rsp = map[string]interface{}{"user": retMap} | 147 | rsp = map[string]interface{}{"user": retMap} |
145 | if err = transactionContext.CommitTransaction(); err != nil { | 148 | if err = transactionContext.CommitTransaction(); err != nil { |
146 | err = application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 149 | err = application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -202,25 +205,31 @@ func (svr *UserService) ListUser(header *protocol.RequestHeader, request *protoc | @@ -202,25 +205,31 @@ func (svr *UserService) ListUser(header *protocol.RequestHeader, request *protoc | ||
202 | transactionContext.RollbackTransaction() | 205 | transactionContext.RollbackTransaction() |
203 | }() | 206 | }() |
204 | 207 | ||
205 | - _, roles, _ := RoleRepository.Find(map[string]interface{}{}) | ||
206 | - roleMap := domain.Roles(roles).RoleMap() | ||
207 | getRoles := func(roleIds []int64) string { | 208 | getRoles := func(roleIds []int64) string { |
208 | if len(roleIds) == 0 { | 209 | if len(roleIds) == 0 { |
209 | return "" | 210 | return "" |
210 | } | 211 | } |
211 | - var role []string | 212 | + var roles []string |
213 | + var mapRoles = make(map[int64]*domain.Role) | ||
212 | for _, id := range roleIds { | 214 | for _, id := range roleIds { |
213 | - if v, ok := roleMap[id]; ok { | ||
214 | - role = append(role, v.RoleName) | 215 | + if _, ok := mapRoles[id]; ok { |
216 | + continue | ||
217 | + } | ||
218 | + if roleItem, _ := RoleRepository.FindOne(map[string]interface{}{"id": id}); roleItem != nil { | ||
219 | + roles = append(roles, roleItem.RoleName) | ||
220 | + } else { | ||
221 | + mapRoles[id] = nil | ||
215 | } | 222 | } |
223 | + continue | ||
216 | } | 224 | } |
217 | - return strings.Join(role, ",") | 225 | + return strings.Join(roles, ",") |
218 | } | 226 | } |
219 | 227 | ||
228 | + // TODO:可优化,每次只查询 user.id 列表 ,通过缓存查询user对象 | ||
220 | var UserRepository, _ = factory.CreateUserRepository(transactionContext) | 229 | var UserRepository, _ = factory.CreateUserRepository(transactionContext) |
221 | var user []*domain.Users | 230 | var user []*domain.Users |
222 | var total int64 | 231 | var total int64 |
223 | - if total, user, err = UserRepository.Find(map[string]interface{}{"offset": (request.PageNumber - 1) * request.PageSize, "limit": request.PageSize, "searchByText": request.SearchByText, "sortById": "DESC"}); err != nil { | 232 | + if total, user, err = UserRepository.Find(common.ObjectToMap(request)); err != nil { |
224 | err = application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 233 | err = application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
225 | return | 234 | return |
226 | } | 235 | } |
@@ -12,7 +12,7 @@ type ProjectModuleVersion struct { | @@ -12,7 +12,7 @@ type ProjectModuleVersion struct { | ||
12 | Version string `json:"version"` | 12 | Version string `json:"version"` |
13 | // 项目描述信息 | 13 | // 项目描述信息 |
14 | Description string `json:"description"` | 14 | Description string `json:"description"` |
15 | - // 状态 0:正常 1:删除 | 15 | + // 状态 1:正常 2:删除 |
16 | Status int `json:"status"` | 16 | Status int `json:"status"` |
17 | // 创建时间 | 17 | // 创建时间 |
18 | CreateTime time.Time `json:"createTime"` | 18 | CreateTime time.Time `json:"createTime"` |
@@ -48,5 +48,5 @@ func (m *ProjectModuleVersion) Update(data map[string]interface{}) error { | @@ -48,5 +48,5 @@ func (m *ProjectModuleVersion) Update(data map[string]interface{}) error { | ||
48 | } | 48 | } |
49 | 49 | ||
50 | func (m *ProjectModuleVersion) SetStatusDelete() { | 50 | func (m *ProjectModuleVersion) SetStatusDelete() { |
51 | - m.Status = 1 | 51 | + m.Status = StatusDelete |
52 | } | 52 | } |
@@ -51,6 +51,13 @@ func (roles Roles) RoleMap() map[int64]*Role { | @@ -51,6 +51,13 @@ func (roles Roles) RoleMap() map[int64]*Role { | ||
51 | } | 51 | } |
52 | return retMap | 52 | return retMap |
53 | } | 53 | } |
54 | +func (roles Roles) RoleIds() []int64 { | ||
55 | + var ids []int64 | ||
56 | + for _, v := range roles { | ||
57 | + ids = append(ids, v.Id) | ||
58 | + } | ||
59 | + return ids | ||
60 | +} | ||
54 | 61 | ||
55 | //func(roles Roles)RolesWithMap(roleMap map[int64]*Role,roleIds []int64)string{ | 62 | //func(roles Roles)RolesWithMap(roleMap map[int64]*Role,roleIds []int64)string{ |
56 | // var role []string | 63 | // var role []string |
@@ -13,7 +13,7 @@ type ProjectModuleVersion struct { | @@ -13,7 +13,7 @@ type ProjectModuleVersion struct { | ||
13 | Version string | 13 | Version string |
14 | // 项目描述信息 | 14 | // 项目描述信息 |
15 | Description string | 15 | Description string |
16 | - // 状态 0:正常 1:删除 | 16 | + // 状态 1:正常 2:删除 |
17 | Status int | 17 | Status int |
18 | // 创建时间 | 18 | // 创建时间 |
19 | CreateTime time.Time | 19 | CreateTime time.Time |
@@ -17,7 +17,7 @@ func (repository *ProjectModuleFilesRepository) Save(dm *domain.ProjectModuleFil | @@ -17,7 +17,7 @@ func (repository *ProjectModuleFilesRepository) Save(dm *domain.ProjectModuleFil | ||
17 | var ( | 17 | var ( |
18 | err error | 18 | err error |
19 | m = &models.ProjectModuleFiles{} | 19 | m = &models.ProjectModuleFiles{} |
20 | - tx = repository.transactionContext.PgTx | 20 | + tx = repository.transactionContext.PgDd |
21 | ) | 21 | ) |
22 | if err = common.GobModelTransform(m, dm); err != nil { | 22 | if err = common.GobModelTransform(m, dm); err != nil { |
23 | return nil, err | 23 | return nil, err |
@@ -58,6 +58,7 @@ func (repository *ProjectModuleFilesRepository) FindOne(queryOptions map[string] | @@ -58,6 +58,7 @@ func (repository *ProjectModuleFilesRepository) FindOne(queryOptions map[string] | ||
58 | query.SetWhere("path = ?", "path") | 58 | query.SetWhere("path = ?", "path") |
59 | 59 | ||
60 | query.SetOrder("tag", "orderByTag") | 60 | query.SetOrder("tag", "orderByTag") |
61 | + query.SetOrder("id", "sortById") | ||
61 | if err := query.First(); err != nil { | 62 | if err := query.First(); err != nil { |
62 | return nil, fmt.Errorf("query row not found") | 63 | return nil, fmt.Errorf("query row not found") |
63 | } | 64 | } |
@@ -78,6 +79,8 @@ func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]int | @@ -78,6 +79,8 @@ func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]int | ||
78 | SetOrder("update_time", "sortByUpdateTime"). | 79 | SetOrder("update_time", "sortByUpdateTime"). |
79 | SetOrder("parent_id", "sortByParentId"). | 80 | SetOrder("parent_id", "sortByParentId"). |
80 | SetOrder("file_type", "sortByFileType"). | 81 | SetOrder("file_type", "sortByFileType"). |
82 | + SetOrder("file_name", "sortByFileName"). | ||
83 | + //SetOrder("tag", "sortByTag"). | ||
81 | SetOrder("id", "sortById") | 84 | SetOrder("id", "sortById") |
82 | 85 | ||
83 | query.SetWhere("parent_id = ?", "parentId") | 86 | query.SetWhere("parent_id = ?", "parentId") |
@@ -6,6 +6,14 @@ import ( | @@ -6,6 +6,14 @@ import ( | ||
6 | "time" | 6 | "time" |
7 | ) | 7 | ) |
8 | 8 | ||
9 | +func LoadCustomFieldToMap(src interface{}, fields ...string) map[string]interface{} { | ||
10 | + rsp := LoadCustomField(src, fields...) | ||
11 | + if rsp == nil { | ||
12 | + return map[string]interface{}{} | ||
13 | + } | ||
14 | + return rsp.(map[string]interface{}) | ||
15 | +} | ||
16 | + | ||
9 | func LoadCustomField(src interface{}, fields ...string) interface{} { | 17 | func LoadCustomField(src interface{}, fields ...string) interface{} { |
10 | typeSrc := reflect.TypeOf(src) | 18 | typeSrc := reflect.TypeOf(src) |
11 | valueSrc := reflect.ValueOf(src) | 19 | valueSrc := reflect.ValueOf(src) |
@@ -71,5 +71,10 @@ func (controller *BaseController) GetRequestHeader(ctx *context.Context) *protoc | @@ -71,5 +71,10 @@ func (controller *BaseController) GetRequestHeader(ctx *context.Context) *protoc | ||
71 | h.Token = strings.Split(h.Token, " ")[1] | 71 | h.Token = strings.Split(h.Token, " ")[1] |
72 | } | 72 | } |
73 | h.BodyKeys = controller.BodyKeys(true) | 73 | h.BodyKeys = controller.BodyKeys(true) |
74 | + if v := ctx.Request.URL.Query(); len(v) > 0 { | ||
75 | + for k, _ := range v { | ||
76 | + h.BodyKeys = append(h.BodyKeys, common.CamelCase(k, true)) | ||
77 | + } | ||
78 | + } | ||
74 | return h | 79 | return h |
75 | } | 80 | } |
@@ -110,7 +110,9 @@ func (controller *UserController) ListUser() { | @@ -110,7 +110,9 @@ func (controller *UserController) ListUser() { | ||
110 | controller.Resp(msg) | 110 | controller.Resp(msg) |
111 | }() | 111 | }() |
112 | request.PageNumber, _ = controller.GetInt("pageNumber") | 112 | request.PageNumber, _ = controller.GetInt("pageNumber") |
113 | - request.PageSize, _ = controller.GetInt("pageSize") | 113 | + //request.PageSize, _ = controller.GetInt("pageSize") |
114 | + | ||
115 | + request.Offset, request.Limit = controller.GetLimitInfo() | ||
114 | request.SearchByText = controller.GetString("searchByText") | 116 | request.SearchByText = controller.GetString("searchByText") |
115 | header := controller.GetRequestHeader(controller.Ctx) | 117 | header := controller.GetRequestHeader(controller.Ctx) |
116 | data, err := svr.ListUser(header, request) | 118 | data, err := svr.ListUser(header, request) |
@@ -18,6 +18,8 @@ type ListProjectModuleFilesRequest struct { | @@ -18,6 +18,8 @@ type ListProjectModuleFilesRequest struct { | ||
18 | SortById string `json:"sortById,omitempty"` | 18 | SortById string `json:"sortById,omitempty"` |
19 | // 按文件类型 | 19 | // 按文件类型 |
20 | SortByFileType string `json:"sortByFileType,omitempty"` | 20 | SortByFileType string `json:"sortByFileType,omitempty"` |
21 | + // 按文件名 | ||
22 | + SortByFileName string `json:"sortByFileName,omitempty"` | ||
21 | 23 | ||
22 | // 项目模块编号 | 24 | // 项目模块编号 |
23 | ProjectKey string `json:"projectKey,omitempty"` | 25 | ProjectKey string `json:"projectKey,omitempty"` |
@@ -36,6 +38,9 @@ func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateComm | @@ -36,6 +38,9 @@ func (ListProjectModuleFilesRequest *ListProjectModuleFilesRequest) ValidateComm | ||
36 | if len(ListProjectModuleFilesRequest.SortById) == 0 { | 38 | if len(ListProjectModuleFilesRequest.SortById) == 0 { |
37 | ListProjectModuleFilesRequest.SortById = "ASC" | 39 | ListProjectModuleFilesRequest.SortById = "ASC" |
38 | } | 40 | } |
41 | + if len(ListProjectModuleFilesRequest.SortByFileName) == 0 { | ||
42 | + ListProjectModuleFilesRequest.SortByFileName = "ASC" | ||
43 | + } | ||
39 | if len(ListProjectModuleFilesRequest.SortByFileType) == 0 { | 44 | if len(ListProjectModuleFilesRequest.SortByFileType) == 0 { |
40 | ListProjectModuleFilesRequest.SortByFileType = "ASC" | 45 | ListProjectModuleFilesRequest.SortByFileType = "ASC" |
41 | } | 46 | } |
@@ -7,14 +7,21 @@ import ( | @@ -7,14 +7,21 @@ import ( | ||
7 | 7 | ||
8 | type ListUserRequest struct { | 8 | type ListUserRequest struct { |
9 | SearchByText string `json:"searchByText,omitempty"` //按名称搜索 | 9 | SearchByText string `json:"searchByText,omitempty"` //按名称搜索 |
10 | - PageSize int `json:"pageSize" valid:"Required"` | 10 | + //PageSize int `json:"pageSize" valid:"Required"` |
11 | PageNumber int `json:"pageNumber" valid:"Required"` | 11 | PageNumber int `json:"pageNumber" valid:"Required"` |
12 | + | ||
13 | + Offset int `json:"offset"` | ||
14 | + Limit int `json:"limit"` | ||
15 | + SortById string `json:"sortById"` | ||
12 | } | 16 | } |
13 | 17 | ||
14 | func (ListUserRequest *ListUserRequest) ValidateCommand() error { | 18 | func (ListUserRequest *ListUserRequest) ValidateCommand() error { |
15 | valid := validation.Validation{} | 19 | valid := validation.Validation{} |
16 | - if ListUserRequest.PageSize == 0 { | ||
17 | - ListUserRequest.PageSize = 20 | 20 | + //if ListUserRequest.PageSize == 0 { |
21 | + // ListUserRequest.PageSize = 20 | ||
22 | + //} | ||
23 | + if len(ListUserRequest.SortById) == 0 { | ||
24 | + ListUserRequest.SortById = "DESC" | ||
18 | } | 25 | } |
19 | b, err := valid.Valid(ListUserRequest) | 26 | b, err := valid.Valid(ListUserRequest) |
20 | if err != nil { | 27 | if err != nil { |
-
请 注册 或 登录 后发表评论