合并分支 'test' 到 'master'
Test 查看合并请求 !7
正在显示
52 个修改的文件
包含
3440 行增加
和
35 行删除
@@ -101,6 +101,8 @@ spec: | @@ -101,6 +101,8 @@ spec: | ||
101 | value: "8082" | 101 | value: "8082" |
102 | - name: SERVICE_ENV | 102 | - name: SERVICE_ENV |
103 | value: "dev" | 103 | value: "dev" |
104 | + - name: GROUP_UP_BLOCK_CHAIN | ||
105 | + value: "allied_creation_message_dev" | ||
104 | - name: REDIS_HOST | 106 | - name: REDIS_HOST |
105 | valueFrom: | 107 | valueFrom: |
106 | configMapKeyRef: | 108 | configMapKeyRef: |
@@ -105,6 +105,8 @@ spec: | @@ -105,6 +105,8 @@ spec: | ||
105 | value: "8082" | 105 | value: "8082" |
106 | - name: SERVICE_ENV | 106 | - name: SERVICE_ENV |
107 | value: "test" | 107 | value: "test" |
108 | + - name: GROUP_UP_BLOCK_CHAIN | ||
109 | + value: "allied_creation_message_test" | ||
108 | - name: REDIS_HOST | 110 | - name: REDIS_HOST |
109 | valueFrom: | 111 | valueFrom: |
110 | configMapKeyRef: | 112 | configMapKeyRef: |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "github.com/linmadan/egglib-go/log/logrus" | 6 | "github.com/linmadan/egglib-go/log/logrus" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" |
8 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" | 8 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/area" | ||
9 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg" | 10 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg" |
10 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/redis" | 11 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/redis" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" |
@@ -30,6 +31,7 @@ func main() { | @@ -30,6 +31,7 @@ func main() { | ||
30 | log.Logger.AddHook(bw) | 31 | log.Logger.AddHook(bw) |
31 | 32 | ||
32 | goqueue.SetUp() | 33 | goqueue.SetUp() |
34 | + area.SetUp() | ||
33 | 35 | ||
34 | log.Logger.Info("server start!") | 36 | log.Logger.Info("server start!") |
35 | web.Run() | 37 | web.Run() |
@@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
5 | "reflect" | 6 | "reflect" |
6 | "strings" | 7 | "strings" |
7 | 8 | ||
@@ -21,6 +22,15 @@ type CompanySignUpCommand struct { | @@ -21,6 +22,15 @@ type CompanySignUpCommand struct { | ||
21 | IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"` | 22 | IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"` |
22 | // 密码 | 23 | // 密码 |
23 | Password string `cname:"密码" json:"password" valid:"Required"` | 24 | Password string `cname:"密码" json:"password" valid:"Required"` |
25 | + | ||
26 | + // 法人 | ||
27 | + LegalPerson string `cname:"法人" json:"legalPerson" valid:"Required"` | ||
28 | + // 社会信用代码 | ||
29 | + SocialCreditCode string `cname:"社会信用代码" json:"socialCreditCode" valid:"Required"` | ||
30 | + // 营业执照所在地 | ||
31 | + BusinessLicenseAddress domain.BusinessLicenseAddress `cname:"营业执照所在地" json:"businessLicenseAddress" valid:"Required"` | ||
32 | + // 营业执照-附件 | ||
33 | + BusinessLicenseAttachments []domain.Attachment `cname:"营业执照-附件" json:"businessLicenseAttachments" valid:"Required"` | ||
24 | } | 34 | } |
25 | 35 | ||
26 | func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) { | 36 | func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) { |
@@ -45,6 +45,12 @@ func (authService *AuthService) CompanySignUp(companySignUpCommand *command.Comp | @@ -45,6 +45,12 @@ func (authService *AuthService) CompanySignUp(companySignUpCommand *command.Comp | ||
45 | Address: "", | 45 | Address: "", |
46 | IndustryCategory: companySignUpCommand.IndustryCategory, | 46 | IndustryCategory: companySignUpCommand.IndustryCategory, |
47 | RegisteredTime: time.Now(), | 47 | RegisteredTime: time.Now(), |
48 | + Legal: domain.Legal{ | ||
49 | + LegalPerson: companySignUpCommand.LegalPerson, | ||
50 | + SocialCreditCode: companySignUpCommand.SocialCreditCode, | ||
51 | + BusinessLicenseAddress: companySignUpCommand.BusinessLicenseAddress, | ||
52 | + BusinessLicenseAttachments: companySignUpCommand.BusinessLicenseAttachments, | ||
53 | + }, | ||
48 | } | 54 | } |
49 | userInfo := &domain.UserInfo{ | 55 | userInfo := &domain.UserInfo{ |
50 | UserName: companySignUpCommand.Contacts, | 56 | UserName: companySignUpCommand.Contacts, |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type AuditCompanyCommand struct { | ||
12 | + // 企业id | ||
13 | + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"` | ||
14 | + // 审核状态 | ||
15 | + Status int `cname:"审核状态" json:"status" valid:"Required"` | ||
16 | + // 备注 | ||
17 | + Remark string `cname:"备注" json:"remark" valid:"Required"` | ||
18 | +} | ||
19 | + | ||
20 | +func (updateCompanyCommand *AuditCompanyCommand) Valid(validation *validation.Validation) { | ||
21 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
22 | +} | ||
23 | + | ||
24 | +func (updateCompanyCommand *AuditCompanyCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(updateCompanyCommand) | ||
27 | + if err != nil { | ||
28 | + return err | ||
29 | + } | ||
30 | + if !b { | ||
31 | + elem := reflect.TypeOf(updateCompanyCommand).Elem() | ||
32 | + for _, validErr := range valid.Errors { | ||
33 | + field, isExist := elem.FieldByName(validErr.Field) | ||
34 | + if isExist { | ||
35 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
36 | + } else { | ||
37 | + return fmt.Errorf(validErr.Message) | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + return nil | ||
42 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type EnableCompanyCommand struct { | ||
12 | + // 企业id | ||
13 | + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"` | ||
14 | + // 审核状态 | ||
15 | + Status int `cname:"审核状态" json:"status" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (updateCompanyCommand *EnableCompanyCommand) Valid(validation *validation.Validation) { | ||
19 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | +} | ||
21 | + | ||
22 | +func (updateCompanyCommand *EnableCompanyCommand) ValidateCommand() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(updateCompanyCommand) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + elem := reflect.TypeOf(updateCompanyCommand).Elem() | ||
30 | + for _, validErr := range valid.Errors { | ||
31 | + field, isExist := elem.FieldByName(validErr.Field) | ||
32 | + if isExist { | ||
33 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
34 | + } else { | ||
35 | + return fmt.Errorf(validErr.Message) | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | + return nil | ||
40 | +} |
@@ -10,9 +10,13 @@ import ( | @@ -10,9 +10,13 @@ import ( | ||
10 | 10 | ||
11 | type ListCompanyQuery struct { | 11 | type ListCompanyQuery struct { |
12 | // 查询偏离量 | 12 | // 查询偏离量 |
13 | - Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | 13 | + Offset int `cname:"查询偏离量" json:"offset,omitempty"` |
14 | // 查询限制 | 14 | // 查询限制 |
15 | - Limit int `cname:"查询限制" json:"limit" valid:"Required"` | 15 | + Limit int `cname:"查询限制" json:"limit,omitempty"` |
16 | + // 状态 | ||
17 | + Status int `cname:"状态" json:"status,omitempty"` | ||
18 | + // 企业名称 | ||
19 | + CompanyName string `cname:"企业名称" json:"companyName,omitempty"` | ||
16 | } | 20 | } |
17 | 21 | ||
18 | func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) { | 22 | func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) { |
@@ -10,6 +10,7 @@ import ( | @@ -10,6 +10,7 @@ import ( | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" |
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/common" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/common" |
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils" | ||
13 | "strconv" | 14 | "strconv" |
14 | ) | 15 | ) |
15 | 16 | ||
@@ -113,7 +114,7 @@ func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCo | @@ -113,7 +114,7 @@ func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCo | ||
113 | } else { | 114 | } else { |
114 | companyRepository = value | 115 | companyRepository = value |
115 | } | 116 | } |
116 | - if count, companys, err := companyRepository.Find(tool_funs.SimpleStructToMap(listCompanyQuery)); err != nil { | 117 | + if count, companys, err := companyRepository.Find(utils.ObjectToMap(listCompanyQuery)); err != nil { |
117 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 118 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
118 | } else { | 119 | } else { |
119 | if err := transactionContext.CommitTransaction(); err != nil { | 120 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -279,6 +280,92 @@ func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *comman | @@ -279,6 +280,92 @@ func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *comman | ||
279 | } | 280 | } |
280 | } | 281 | } |
281 | 282 | ||
283 | +// 审核企业 | ||
284 | +func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyCommand) (interface{}, error) { | ||
285 | + if err := cmd.ValidateCommand(); err != nil { | ||
286 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
287 | + } | ||
288 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
289 | + if err != nil { | ||
290 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
291 | + } | ||
292 | + if err := transactionContext.StartTransaction(); err != nil { | ||
293 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
294 | + } | ||
295 | + defer func() { | ||
296 | + transactionContext.RollbackTransaction() | ||
297 | + }() | ||
298 | + var companyRepository domain.CompanyRepository | ||
299 | + if value, err := factory.CreateCompanyRepository(map[string]interface{}{ | ||
300 | + "transactionContext": transactionContext, | ||
301 | + }); err != nil { | ||
302 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
303 | + } else { | ||
304 | + companyRepository = value | ||
305 | + } | ||
306 | + company, err := companyRepository.FindOne(map[string]interface{}{"companyId": cmd.CompanyId}) | ||
307 | + if err != nil { | ||
308 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
309 | + } | ||
310 | + if company == nil { | ||
311 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(cmd.CompanyId))) | ||
312 | + } | ||
313 | + if err := company.Audit(cmd.Status, cmd.Remark); err != nil { | ||
314 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
315 | + } | ||
316 | + if company, err := companyRepository.Save(company); err != nil { | ||
317 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
318 | + } else { | ||
319 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
320 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
321 | + } | ||
322 | + return company, nil | ||
323 | + } | ||
324 | +} | ||
325 | + | ||
326 | +// 禁用启用企业 | ||
327 | +func (companyService *CompanyService) EnableCompany(cmd *command.EnableCompanyCommand) (interface{}, error) { | ||
328 | + if err := cmd.ValidateCommand(); err != nil { | ||
329 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
330 | + } | ||
331 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
332 | + if err != nil { | ||
333 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
334 | + } | ||
335 | + if err := transactionContext.StartTransaction(); err != nil { | ||
336 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
337 | + } | ||
338 | + defer func() { | ||
339 | + transactionContext.RollbackTransaction() | ||
340 | + }() | ||
341 | + var companyRepository domain.CompanyRepository | ||
342 | + if value, err := factory.CreateCompanyRepository(map[string]interface{}{ | ||
343 | + "transactionContext": transactionContext, | ||
344 | + }); err != nil { | ||
345 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
346 | + } else { | ||
347 | + companyRepository = value | ||
348 | + } | ||
349 | + company, err := companyRepository.FindOne(map[string]interface{}{"companyId": cmd.CompanyId}) | ||
350 | + if err != nil { | ||
351 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
352 | + } | ||
353 | + if company == nil { | ||
354 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(cmd.CompanyId))) | ||
355 | + } | ||
356 | + if err := company.Enable(cmd.Status); err != nil { | ||
357 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
358 | + } | ||
359 | + if company, err := companyRepository.Save(company); err != nil { | ||
360 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
361 | + } else { | ||
362 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
363 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
364 | + } | ||
365 | + return company, nil | ||
366 | + } | ||
367 | +} | ||
368 | + | ||
282 | // 更新自定义菜单 | 369 | // 更新自定义菜单 |
283 | func (companyService *CompanyService) UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand *command.UpdateCompanyCustomizeMenusCommand) (interface{}, error) { | 370 | func (companyService *CompanyService) UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand *command.UpdateCompanyCustomizeMenusCommand) (interface{}, error) { |
284 | if err := updateCompanyCustomizeMenusCommand.ValidateCommand(); err != nil { | 371 | if err := updateCompanyCustomizeMenusCommand.ValidateCommand(); err != nil { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | +) | ||
11 | + | ||
12 | +type CreateAdminUserCommand struct { | ||
13 | + OperateInfo *domain.OperateInfo `json:"-"` | ||
14 | + // 企业id | ||
15 | + CompanyId int64 `cname:"企业id" json:"companyId"` | ||
16 | + // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加) | ||
17 | + UserType int `cname:"用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)" json:"userType" valid:"Required"` | ||
18 | + // 用户编号 企业内标识 | ||
19 | + UserCode string `cname:"用户编号 企业内标识" json:"userCode"` | ||
20 | + // 组织机构 | ||
21 | + OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty"` | ||
22 | + // 所属部门 | ||
23 | + DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty"` | ||
24 | + // 用户关联的组织 | ||
25 | + UserOrg []int64 `cname:"用户关联的组织" json:"userOrg,omitempty"` | ||
26 | + // 用户关联的角色 | ||
27 | + UserRole []int64 `cname:"用户关联的角色" json:"userRole,omitempty"` | ||
28 | + // 共创公司 | ||
29 | + CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"` | ||
30 | + // 共创到期时间 (yyyy-MM-dd) | ||
31 | + CooperationDeadline time.Time `cname:"共创到期时间 (yyyy-MM-dd)" json:"cooperationDeadline,omitempty"` | ||
32 | + // 启用状态(启用:1 禁用:2) | ||
33 | + EnableStatus int `cname:"启用状态(启用:1 禁用:2)" json:"enableStatus,omitempty" valid:"Required"` | ||
34 | + // 密码 | ||
35 | + Password string `cname:"密码" json:"password" valid:"Required"` | ||
36 | + // 用户姓名 | ||
37 | + UserName string `cname:"用户姓名" json:"userName" valid:"Required"` | ||
38 | + // 手机号码 | ||
39 | + Phone string `cname:"手机号码" json:"phone" valid:"Required"` | ||
40 | + // 头像 | ||
41 | + Avatar string `cname:"头像" json:"avatar"` | ||
42 | + // 邮箱 | ||
43 | + Email string `cname:"邮箱" json:"email"` | ||
44 | + | ||
45 | + // 运营管理扩展 | ||
46 | + // 部门 | ||
47 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
48 | +} | ||
49 | + | ||
50 | +func (createUserCommand *CreateAdminUserCommand) Valid(validation *validation.Validation) { | ||
51 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
52 | +} | ||
53 | + | ||
54 | +func (createUserCommand *CreateAdminUserCommand) ValidateCommand() error { | ||
55 | + valid := validation.Validation{} | ||
56 | + b, err := valid.Valid(createUserCommand) | ||
57 | + if err != nil { | ||
58 | + return err | ||
59 | + } | ||
60 | + if !b { | ||
61 | + elem := reflect.TypeOf(createUserCommand).Elem() | ||
62 | + for _, validErr := range valid.Errors { | ||
63 | + field, isExist := elem.FieldByName(validErr.Field) | ||
64 | + if isExist { | ||
65 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
66 | + } else { | ||
67 | + return fmt.Errorf(validErr.Message) | ||
68 | + } | ||
69 | + } | ||
70 | + } | ||
71 | + return nil | ||
72 | +} |
@@ -41,6 +41,14 @@ type CreateUserCommand struct { | @@ -41,6 +41,14 @@ type CreateUserCommand struct { | ||
41 | Avatar string `cname:"头像" json:"avatar"` | 41 | Avatar string `cname:"头像" json:"avatar"` |
42 | // 邮箱 | 42 | // 邮箱 |
43 | Email string `cname:"邮箱" json:"email"` | 43 | Email string `cname:"邮箱" json:"email"` |
44 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
45 | + EmployeeType int `cname:"员工类型" json:"employeeType" valid:"Required"` | ||
46 | + // IC卡号 | ||
47 | + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"` | ||
48 | + | ||
49 | + // 运营管理扩展 | ||
50 | + // 部门 | ||
51 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
44 | } | 52 | } |
45 | 53 | ||
46 | func (createUserCommand *CreateUserCommand) Valid(validation *validation.Validation) { | 54 | func (createUserCommand *CreateUserCommand) Valid(validation *validation.Validation) { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + "time" | ||
9 | + | ||
10 | + "github.com/beego/beego/v2/core/validation" | ||
11 | +) | ||
12 | + | ||
13 | +type UpdateAdminUserCommand struct { | ||
14 | + OperateInfo *domain.OperateInfo `json:"-"` | ||
15 | + // 用户Id 用户唯一标识 | ||
16 | + UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"` | ||
17 | + // 组织机构 | ||
18 | + OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty"` | ||
19 | + // 所属部门 | ||
20 | + DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty"` | ||
21 | + // 用户关联的组织 | ||
22 | + UserOrg []int64 `cname:"用户关联的组织" json:"userOrg,omitempty"` | ||
23 | + // 用户关联的角色 | ||
24 | + UserRole []int64 `cname:"用户关联的角色" json:"userRole,omitempty"` | ||
25 | + // 共创公司 | ||
26 | + CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"` | ||
27 | + // 共创到期时间 (yyyy-MM-dd) | ||
28 | + CooperationDeadline time.Time `cname:"共创到期时间 (yyyy-MM-dd)" json:"cooperationDeadline,omitempty"` | ||
29 | + // 启用状态(启用:1 禁用:2) | ||
30 | + EnableStatus int `cname:"启用状态(启用:1 禁用:2)" json:"enableStatus,omitempty"` | ||
31 | + // 用户姓名 | ||
32 | + UserName string `cname:"用户姓名" json:"userName" valid:"Required"` | ||
33 | + // 手机号码 | ||
34 | + Phone string `cname:"手机号码" json:"phone" valid:"Required"` | ||
35 | + // 头像 | ||
36 | + Avatar string `cname:"头像" json:"avatar"` | ||
37 | + // 邮箱 | ||
38 | + Email string `cname:"邮箱" json:"email"` | ||
39 | + | ||
40 | + // 运营管理扩展 | ||
41 | + // 部门 | ||
42 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
43 | +} | ||
44 | + | ||
45 | +func (updateUserCommand *UpdateAdminUserCommand) Valid(validation *validation.Validation) { | ||
46 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
47 | +} | ||
48 | + | ||
49 | +func (updateUserCommand *UpdateAdminUserCommand) ValidateCommand() error { | ||
50 | + valid := validation.Validation{} | ||
51 | + b, err := valid.Valid(updateUserCommand) | ||
52 | + if err != nil { | ||
53 | + return err | ||
54 | + } | ||
55 | + if !b { | ||
56 | + elem := reflect.TypeOf(updateUserCommand).Elem() | ||
57 | + for _, validErr := range valid.Errors { | ||
58 | + field, isExist := elem.FieldByName(validErr.Field) | ||
59 | + if isExist { | ||
60 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
61 | + } else { | ||
62 | + return fmt.Errorf(validErr.Message) | ||
63 | + } | ||
64 | + } | ||
65 | + } | ||
66 | + return nil | ||
67 | +} |
@@ -36,6 +36,14 @@ type UpdateUserCommand struct { | @@ -36,6 +36,14 @@ type UpdateUserCommand struct { | ||
36 | Avatar string `cname:"头像" json:"avatar"` | 36 | Avatar string `cname:"头像" json:"avatar"` |
37 | // 邮箱 | 37 | // 邮箱 |
38 | Email string `cname:"邮箱" json:"email"` | 38 | Email string `cname:"邮箱" json:"email"` |
39 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
40 | + EmployeeType int `name:"员工类型" json:"employeeType" valid:"Required"` | ||
41 | + // IC卡号 | ||
42 | + IcCardNumber string `json:"icCardNumber,omitempty"` | ||
43 | + | ||
44 | + // 运营管理扩展 | ||
45 | + // 部门 | ||
46 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
39 | } | 47 | } |
40 | 48 | ||
41 | func (updateUserCommand *UpdateUserCommand) Valid(validation *validation.Validation) { | 49 | func (updateUserCommand *UpdateUserCommand) Valid(validation *validation.Validation) { |
@@ -73,7 +73,15 @@ func (dto *UserDto) LoadDto(user *domain.User, company *domain.Company) error { | @@ -73,7 +73,15 @@ func (dto *UserDto) LoadDto(user *domain.User, company *domain.Company) error { | ||
73 | dto.UserInfo = &domain.UserInfo{ | 73 | dto.UserInfo = &domain.UserInfo{ |
74 | UserName: user.Ext.UserName, | 74 | UserName: user.Ext.UserName, |
75 | Phone: user.Ext.Phone, | 75 | Phone: user.Ext.Phone, |
76 | + IcCardNumber: user.Ext.IcCardNumber, | ||
77 | + EmployeeType: user.Ext.EmployeeType, | ||
76 | } | 78 | } |
79 | + } else { | ||
80 | + dto.UserInfo.IcCardNumber = user.Ext.IcCardNumber | ||
81 | + dto.UserInfo.EmployeeType = user.Ext.EmployeeType | ||
82 | + } | ||
83 | + if dto.UserInfo.EmployeeType == 0 { | ||
84 | + dto.UserInfo.EmployeeType = 1 | ||
77 | } | 85 | } |
78 | if len(dto.UserRole) == 0 { | 86 | if len(dto.UserRole) == 0 { |
79 | dto.UserRole = make([]*domain.Role, 0) | 87 | dto.UserRole = make([]*domain.Role, 0) |
@@ -41,6 +41,12 @@ type ListUserQuery struct { | @@ -41,6 +41,12 @@ type ListUserQuery struct { | ||
41 | EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"` | 41 | EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"` |
42 | // 状态(1:启用 2:禁用 3:注销) | 42 | // 状态(1:启用 2:禁用 3:注销) |
43 | InEnableStatus []int `cname:"状态(1:启用 2:禁用 3:注销)" json:"inEnableStatus,omitempty"` | 43 | InEnableStatus []int `cname:"状态(1:启用 2:禁用 3:注销)" json:"inEnableStatus,omitempty"` |
44 | + // 在企业范围内 | ||
45 | + InCompanyIds []int64 `cname:"在企业范围内" json:"inCompanyIds,omitempty"` | ||
46 | + // 用户编号 企业内标识 | ||
47 | + UserCode string `cname:"用户编号" json:"userCode,omitempty"` | ||
48 | + // IC卡号 | ||
49 | + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"` | ||
44 | } | 50 | } |
45 | 51 | ||
46 | func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) { | 52 | func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) { |
@@ -273,6 +273,9 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | @@ -273,6 +273,9 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | ||
273 | Ext: &domain.Ext{ | 273 | Ext: &domain.Ext{ |
274 | Phone: createUserCommand.Phone, | 274 | Phone: createUserCommand.Phone, |
275 | UserName: createUserCommand.UserName, | 275 | UserName: createUserCommand.UserName, |
276 | + DepName: createUserCommand.DepartmentName, | ||
277 | + IcCardNumber: createUserCommand.IcCardNumber, | ||
278 | + EmployeeType: createUserCommand.EmployeeType, | ||
276 | }, | 279 | }, |
277 | CreatedAt: time.Now(), | 280 | CreatedAt: time.Now(), |
278 | UpdatedAt: time.Now(), | 281 | UpdatedAt: time.Now(), |
@@ -536,10 +539,12 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | @@ -536,10 +539,12 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | ||
536 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) | 539 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) |
537 | _, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId) | 540 | _, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId) |
538 | _, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId) | 541 | _, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId) |
539 | - if dep != nil && org != nil && company != nil && userBase != nil { | 542 | + if dep != nil && org != nil && company != nil { |
540 | user.Department = dep.ConvDep() | 543 | user.Department = dep.ConvDep() |
541 | user.Organization = org.CloneSample() | 544 | user.Organization = org.CloneSample() |
542 | user.Company = company.CloneSample() | 545 | user.Company = company.CloneSample() |
546 | + } | ||
547 | + if userBase != nil { | ||
543 | user.UserInfo = userBase.UserInfo | 548 | user.UserInfo = userBase.UserInfo |
544 | user.Favorite = userBase.Favorite | 549 | user.Favorite = userBase.Favorite |
545 | } | 550 | } |
@@ -702,7 +707,7 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | @@ -702,7 +707,7 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | ||
702 | defer func() { | 707 | defer func() { |
703 | transactionContext.RollbackTransaction() | 708 | transactionContext.RollbackTransaction() |
704 | }() | 709 | }() |
705 | - _, user, err := factory.FastPgUser(transactionContext, updateUserCommand.UserId, factory.WithDataAuthRequired(), factory.WithOperator(updateUserCommand.OperateInfo)) | 710 | + _, user, err := factory.FastPgUser(transactionContext, updateUserCommand.UserId, factory.WithOperator(updateUserCommand.OperateInfo)) //, factory.WithDataAuthRequired() |
706 | if err != nil { | 711 | if err != nil { |
707 | return nil, err | 712 | return nil, err |
708 | } | 713 | } |
@@ -724,7 +729,10 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | @@ -724,7 +729,10 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | ||
724 | Phone: updateUserCommand.Phone, | 729 | Phone: updateUserCommand.Phone, |
725 | Avatar: updateUserCommand.Avatar, | 730 | Avatar: updateUserCommand.Avatar, |
726 | Email: updateUserCommand.Email, | 731 | Email: updateUserCommand.Email, |
732 | + DepartmentName: updateUserCommand.DepartmentName, | ||
727 | } | 733 | } |
734 | + user.Ext.EmployeeType = updateUserCommand.EmployeeType | ||
735 | + user.Ext.IcCardNumber = updateUserCommand.IcCardNumber | ||
728 | 736 | ||
729 | updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{ | 737 | updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{ |
730 | "transactionContext": transactionContext, | 738 | "transactionContext": transactionContext, |
@@ -853,6 +861,123 @@ func (userService *UserService) UpdateFavorite(updateFavoriteCommand *command.Up | @@ -853,6 +861,123 @@ func (userService *UserService) UpdateFavorite(updateFavoriteCommand *command.Up | ||
853 | return struct{}{}, nil | 861 | return struct{}{}, nil |
854 | } | 862 | } |
855 | 863 | ||
864 | +// 创建 | ||
865 | +func (userService *UserService) CreateAdminUser(createUserCommand *command.CreateAdminUserCommand) (interface{}, error) { | ||
866 | + if err := createUserCommand.ValidateCommand(); err != nil { | ||
867 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
868 | + } | ||
869 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
870 | + if err != nil { | ||
871 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
872 | + } | ||
873 | + if err := transactionContext.StartTransaction(); err != nil { | ||
874 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
875 | + } | ||
876 | + defer func() { | ||
877 | + transactionContext.RollbackTransaction() | ||
878 | + }() | ||
879 | + nweUserInfo := &domain.UserInfo{ | ||
880 | + UserName: createUserCommand.UserName, | ||
881 | + Phone: createUserCommand.Phone, | ||
882 | + Avatar: createUserCommand.Avatar, | ||
883 | + Email: createUserCommand.Email, | ||
884 | + DepartmentName: createUserCommand.DepartmentName, | ||
885 | + } | ||
886 | + var sampleUserOrg = make([]*domain.Org, 0) | ||
887 | + var sampleUserRole = make([]*domain.Role, 0) | ||
888 | + newUser := &domain.User{ | ||
889 | + CompanyId: createUserCommand.CompanyId, | ||
890 | + UserType: createUserCommand.UserType, | ||
891 | + UserCode: createUserCommand.UserCode, | ||
892 | + OrganizationId: createUserCommand.OrganizationId, | ||
893 | + DepartmentId: createUserCommand.DepartmentId, | ||
894 | + UserOrg: sampleUserOrg, | ||
895 | + UserRole: sampleUserRole, | ||
896 | + FavoriteMenus: []string{}, | ||
897 | + //CooperationInfo: &domain.CooperationInfo{}, | ||
898 | + UserInfo: nweUserInfo, | ||
899 | + EnableStatus: createUserCommand.EnableStatus, | ||
900 | + Ext: &domain.Ext{ | ||
901 | + Phone: createUserCommand.Phone, | ||
902 | + UserName: createUserCommand.UserName, | ||
903 | + DepName: createUserCommand.DepartmentName, | ||
904 | + }, | ||
905 | + CreatedAt: time.Now(), | ||
906 | + UpdatedAt: time.Now(), | ||
907 | + } | ||
908 | + var user *domain.User | ||
909 | + createUserService, _ := factory.CreatePgCreateUserService(map[string]interface{}{ | ||
910 | + "transactionContext": transactionContext, | ||
911 | + }) | ||
912 | + if user, err = createUserService.CreateUser(nil, newUser, createUserCommand.Password); err != nil { | ||
913 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
914 | + } | ||
915 | + userDto := &dto.UserDto{} | ||
916 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
917 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
918 | + } | ||
919 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
920 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
921 | + } | ||
922 | + return userDto, nil | ||
923 | +} | ||
924 | + | ||
925 | +// 更新 | ||
926 | +func (userService *UserService) UpdateAdminUser(updateUserCommand *command.UpdateAdminUserCommand) (interface{}, error) { | ||
927 | + if err := updateUserCommand.ValidateCommand(); err != nil { | ||
928 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
929 | + } | ||
930 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
931 | + if err != nil { | ||
932 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
933 | + } | ||
934 | + if err := transactionContext.StartTransaction(); err != nil { | ||
935 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
936 | + } | ||
937 | + defer func() { | ||
938 | + transactionContext.RollbackTransaction() | ||
939 | + }() | ||
940 | + _, user, err := factory.FastPgUser(transactionContext, updateUserCommand.UserId, factory.WithDataAuthRequired(), factory.WithOperator(updateUserCommand.OperateInfo)) | ||
941 | + if err != nil { | ||
942 | + return nil, err | ||
943 | + } | ||
944 | + user.DepartmentId = updateUserCommand.DepartmentId | ||
945 | + user.OrganizationId = updateUserCommand.OrganizationId | ||
946 | + var userOrg = make([]*domain.Org, 0) | ||
947 | + for i := range updateUserCommand.UserOrg { | ||
948 | + userOrg = append(userOrg, &domain.Org{OrgId: updateUserCommand.UserOrg[i]}) | ||
949 | + } | ||
950 | + user.UserOrg = userOrg | ||
951 | + var userRole = make([]*domain.Role, 0) | ||
952 | + for i := range updateUserCommand.UserRole { | ||
953 | + userRole = append(userRole, &domain.Role{RoleId: updateUserCommand.UserRole[i]}) | ||
954 | + } | ||
955 | + user.UserRole = userRole | ||
956 | + | ||
957 | + userInfo := &domain.UserInfo{ | ||
958 | + UserName: updateUserCommand.UserName, | ||
959 | + Phone: updateUserCommand.Phone, | ||
960 | + Avatar: updateUserCommand.Avatar, | ||
961 | + Email: updateUserCommand.Email, | ||
962 | + DepartmentName: updateUserCommand.DepartmentName, | ||
963 | + } | ||
964 | + | ||
965 | + updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{ | ||
966 | + "transactionContext": transactionContext, | ||
967 | + }) | ||
968 | + if user, err = updateUserService.UpdateUser(nil, user, userInfo, user.EnableStatus); err != nil { | ||
969 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
970 | + } | ||
971 | + userDto := &dto.UserDto{} | ||
972 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
973 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
974 | + } | ||
975 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
976 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
977 | + } | ||
978 | + return userDto, nil | ||
979 | +} | ||
980 | + | ||
856 | func NewUserService(options map[string]interface{}) *UserService { | 981 | func NewUserService(options map[string]interface{}) *UserService { |
857 | newUserService := &UserService{} | 982 | newUserService := &UserService{} |
858 | return newUserService | 983 | return newUserService |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type BatchEnableCommand struct { | ||
13 | + OperateInfo *domain.OperateInfo `json:"-"` | ||
14 | + UserBaseIds []int64 `cname:"用户id列表" json:"userBaseIds" valid:"Required"` | ||
15 | + // 启用状态(启用:1 禁用:2 注销:3) | ||
16 | + EnableStatus int `cname:"启用状态(启用:1 禁用:2 注销:3)" json:"enableStatus" valid:"Required"` | ||
17 | +} | ||
18 | + | ||
19 | +func (batchEnableCommand *BatchEnableCommand) Valid(validation *validation.Validation) { | ||
20 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
21 | + if !(batchEnableCommand.EnableStatus == int(domain.UserStatusEnable) || batchEnableCommand.EnableStatus == int(domain.UserStatusDisable)) { | ||
22 | + validation.SetError("CustomValid", "非法启用状态") | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +func (batchEnableCommand *BatchEnableCommand) ValidateCommand() error { | ||
27 | + valid := validation.Validation{} | ||
28 | + b, err := valid.Valid(batchEnableCommand) | ||
29 | + if err != nil { | ||
30 | + return err | ||
31 | + } | ||
32 | + if !b { | ||
33 | + elem := reflect.TypeOf(batchEnableCommand).Elem() | ||
34 | + for _, validErr := range valid.Errors { | ||
35 | + field, isExist := elem.FieldByName(validErr.Field) | ||
36 | + if isExist { | ||
37 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
38 | + } else { | ||
39 | + return fmt.Errorf(validErr.Message) | ||
40 | + } | ||
41 | + } | ||
42 | + } | ||
43 | + return nil | ||
44 | +} |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
7 | + | ||
8 | +type UserBaseDto struct { | ||
9 | + // 用户基础数据id | ||
10 | + UserBaseId int64 `json:"userBaseId,omitempty"` | ||
11 | + // 手机号码 | ||
12 | + //Account string `json:"phone,omitempty"` | ||
13 | + // 最后登录时间 | ||
14 | + LastLogIn string `json:"lastLogIn"` | ||
15 | + // 用户信息 (冗余,数据存在userBase里面) | ||
16 | + UserInfo *domain.UserInfo `json:"userInfo,omitempty"` | ||
17 | + // 账号状态 1:正常 2.禁用 3:注销 | ||
18 | + Status int `json:"status,omitempty"` | ||
19 | + // 推荐人 | ||
20 | + Referer string `json:"referer"` | ||
21 | + // 关联的用户 (冗余) | ||
22 | + // RelatedUsers []int64 `json:"relatedUsers,omitempty"` | ||
23 | + // 用户关联的组织 | ||
24 | + UserOrg []interface{} `json:"userOrg"` | ||
25 | + // 创建时间 | ||
26 | + RegistrationDate string `json:"registrationDate,omitempty"` | ||
27 | +} | ||
28 | + | ||
29 | +func (dto *UserBaseDto) LoadDto(userBase *domain.UserBase, relateUsers []*domain.User) error { | ||
30 | + dto.UserBaseId = userBase.UserBaseId | ||
31 | + //dto.Account = userBase.Account | ||
32 | + dto.LastLogIn = "" | ||
33 | + dto.UserInfo = userBase.UserInfo | ||
34 | + if userBase.Favorite != nil { | ||
35 | + if userBase.Favorite.LastLogInAt > 0 { | ||
36 | + t := time.Unix(userBase.Favorite.LastLogInAt, 0) | ||
37 | + dto.LastLogIn = t.Format("2006-01-02 15:04:05") | ||
38 | + } | ||
39 | + dto.Referer = userBase.Favorite.Referer | ||
40 | + } | ||
41 | + dto.Status = userBase.Status | ||
42 | + for i := range relateUsers { | ||
43 | + dto.UserOrg = append(dto.UserOrg, map[string]interface{}{ | ||
44 | + "orgId": relateUsers[i].OrganizationId, | ||
45 | + "orgName": relateUsers[i].Ext.OrgName, | ||
46 | + }) | ||
47 | + } | ||
48 | + dto.RegistrationDate = userBase.CreatedAt.Format("2006-01-02") | ||
49 | + return nil | ||
50 | +} |
pkg/application/userbase/query/list_user.go
0 → 100644
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type ListUserQuery struct { | ||
13 | + OperateInfo *domain.OperateInfo `json:"-"` | ||
14 | + // 查询偏离量 | ||
15 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
16 | + // 查询限制 | ||
17 | + Limit int `cname:"查询限制" json:"limit"` | ||
18 | + // 用户姓名 | ||
19 | + UserName string `cname:"用户姓名" json:"userName,omitempty"` | ||
20 | + // 在用户列表内 | ||
21 | + InUserBaseIds []int64 `cname:"用户姓名" json:"inUserBaseIds,omitempty"` | ||
22 | + // 所属组织 | ||
23 | + OrgName string `cname:"所属组织" json:"orgName,omitempty"` | ||
24 | + // 关闭查询限制 | ||
25 | + DisableLimit bool `cname:"关闭查询限制" json:"disableLimit,omitempty"` | ||
26 | + | ||
27 | + // 获取组织 | ||
28 | + FetchOrgBelong bool `cname:"获取组织" json:"fetchOrgBelong,omitempty"` | ||
29 | +} | ||
30 | + | ||
31 | +func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) { | ||
32 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
33 | +} | ||
34 | + | ||
35 | +func (listUserQuery *ListUserQuery) ValidateQuery() error { | ||
36 | + valid := validation.Validation{} | ||
37 | + b, err := valid.Valid(listUserQuery) | ||
38 | + if err != nil { | ||
39 | + return err | ||
40 | + } | ||
41 | + if !b { | ||
42 | + elem := reflect.TypeOf(listUserQuery).Elem() | ||
43 | + for _, validErr := range valid.Errors { | ||
44 | + field, isExist := elem.FieldByName(validErr.Field) | ||
45 | + if isExist { | ||
46 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
47 | + } else { | ||
48 | + return fmt.Errorf(validErr.Message) | ||
49 | + } | ||
50 | + } | ||
51 | + } | ||
52 | + return nil | ||
53 | +} |
pkg/application/userbase/service/userbase.go
0 → 100644
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/command" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/dto" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/query" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils" | ||
11 | +) | ||
12 | + | ||
13 | +type UserBaseService struct { | ||
14 | +} | ||
15 | + | ||
16 | +// 返回列表 | ||
17 | +func (userService *UserBaseService) SearchUser(listUserQuery *query.ListUserQuery) (interface{}, error) { | ||
18 | + if err := listUserQuery.ValidateQuery(); err != nil { | ||
19 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
20 | + } | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + transactionContext.RollbackTransaction() | ||
30 | + }() | ||
31 | + var count int64 | ||
32 | + var userBases []*domain.UserBase | ||
33 | + userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0) | ||
34 | + userRepository, _, _ := factory.FastPgUser(transactionContext, 0) | ||
35 | + _, users, err := userRepository.Find(map[string]interface{}{ | ||
36 | + "limit": listUserQuery.Limit, | ||
37 | + "offset": listUserQuery.Offset, | ||
38 | + "orgName": listUserQuery.OrgName, | ||
39 | + "userName": listUserQuery.UserName, | ||
40 | + "distinctOnUserBaseId": true, | ||
41 | + }) | ||
42 | + if err != nil { | ||
43 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
44 | + } | ||
45 | + var result = make([]*dto.UserBaseDto, 0) | ||
46 | + if len(users) > 0 { | ||
47 | + var userBaseIds []int64 | ||
48 | + for i := range users { | ||
49 | + userBaseIds = append(userBaseIds, users[i].UserBaseId) | ||
50 | + } | ||
51 | + listUserQuery.InUserBaseIds = userBaseIds | ||
52 | + queryOptions := utils.ObjectToMap(listUserQuery) | ||
53 | + count, userBases, err = userBaseRepository.Find(queryOptions) | ||
54 | + if err != nil { | ||
55 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
56 | + } | ||
57 | + | ||
58 | + for i := range userBases { | ||
59 | + u := userBases[i] | ||
60 | + var relateUsers []*domain.User | ||
61 | + if listUserQuery.FetchOrgBelong && len(u.RelatedUsers) > 0 { | ||
62 | + for i := range u.RelatedUsers { | ||
63 | + relateUser, _ := userRepository.FindOne(map[string]interface{}{"userId": u.RelatedUsers[i]}) | ||
64 | + if relateUser != nil { | ||
65 | + relateUsers = append(relateUsers, relateUser) | ||
66 | + } | ||
67 | + } | ||
68 | + } | ||
69 | + userBaseDto := &dto.UserBaseDto{} | ||
70 | + userBaseDto.LoadDto(u, relateUsers) | ||
71 | + result = append(result, userBaseDto) | ||
72 | + } | ||
73 | + } | ||
74 | + | ||
75 | + return map[string]interface{}{ | ||
76 | + "count": count, | ||
77 | + "users": result, | ||
78 | + }, nil | ||
79 | +} | ||
80 | + | ||
81 | +// 批量修改启用状态 | ||
82 | +func (userService *UserBaseService) BatchEnable(batchEnableCommand *command.BatchEnableCommand) (interface{}, error) { | ||
83 | + if err := batchEnableCommand.ValidateCommand(); err != nil { | ||
84 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
85 | + } | ||
86 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
87 | + if err != nil { | ||
88 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
89 | + } | ||
90 | + if err := transactionContext.StartTransaction(); err != nil { | ||
91 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
92 | + } | ||
93 | + defer func() { | ||
94 | + transactionContext.RollbackTransaction() | ||
95 | + }() | ||
96 | + userRepository, _, err := factory.FastPgUserBase(transactionContext, 0) | ||
97 | + if err != nil { | ||
98 | + return nil, err | ||
99 | + } | ||
100 | + | ||
101 | + for i := 0; i < len(batchEnableCommand.UserBaseIds); i++ { | ||
102 | + if user, err := userRepository.FindOne(map[string]interface{}{"userBaseId": batchEnableCommand.UserBaseIds[i]}); err != nil { | ||
103 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
104 | + } else { | ||
105 | + if err := user.SetEnableStatus(batchEnableCommand.EnableStatus); err != nil { | ||
106 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
107 | + } | ||
108 | + if _, err := userRepository.Save(user); err != nil { | ||
109 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
110 | + } | ||
111 | + } | ||
112 | + } | ||
113 | + | ||
114 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
115 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
116 | + } | ||
117 | + return struct{}{}, nil | ||
118 | +} | ||
119 | + | ||
120 | +func NewUserBaseService(options map[string]interface{}) *UserBaseService { | ||
121 | + newUserService := &UserBaseService{} | ||
122 | + return newUserService | ||
123 | +} |
@@ -9,18 +9,26 @@ var ( | @@ -9,18 +9,26 @@ var ( | ||
9 | TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage" | 9 | TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage" |
10 | // kafka topic up_block_chain | 10 | // kafka topic up_block_chain |
11 | TOPIC_UP_BLOCK_CHAIN = "allied_creation_message" | 11 | TOPIC_UP_BLOCK_CHAIN = "allied_creation_message" |
12 | + // 区块链消息 消费组 | ||
13 | + GROUP_UP_BLOCK_CHAIN = "allied_creation_message" | ||
12 | // 是否启用日志收集 (本地不启用) | 14 | // 是否启用日志收集 (本地不启用) |
13 | ENABLE_KAFKA_LOG = false | 15 | ENABLE_KAFKA_LOG = false |
14 | ) | 16 | ) |
15 | 17 | ||
16 | func init() { | 18 | func init() { |
17 | - //if os.Getenv("KAFKA_HOST") != "" { | ||
18 | - // POSTGRESQL_HOST = os.Getenv("KAFKA_HOST") | ||
19 | - //} | 19 | + if os.Getenv("KAFKA_HOST") != "" { |
20 | + KAFKA_HOST = os.Getenv("KAFKA_HOST") | ||
21 | + } | ||
20 | //if os.Getenv("TOPIC_LOG_STASH") != "" { | 22 | //if os.Getenv("TOPIC_LOG_STASH") != "" { |
21 | // POSTGRESQL_PORT = os.Getenv("TOPIC_LOG_STASH") | 23 | // POSTGRESQL_PORT = os.Getenv("TOPIC_LOG_STASH") |
22 | //} | 24 | //} |
23 | if os.Getenv("ENABLE_KAFKA_LOG") != "" { | 25 | if os.Getenv("ENABLE_KAFKA_LOG") != "" { |
24 | ENABLE_KAFKA_LOG = true | 26 | ENABLE_KAFKA_LOG = true |
25 | } | 27 | } |
28 | + if os.Getenv("TOPIC_UP_BLOCK_CHAIN") != "" { | ||
29 | + TOPIC_UP_BLOCK_CHAIN = os.Getenv("TOPIC_UP_BLOCK_CHAIN") | ||
30 | + } | ||
31 | + if os.Getenv("GROUP_UP_BLOCK_CHAIN") != "" { | ||
32 | + GROUP_UP_BLOCK_CHAIN = os.Getenv("GROUP_UP_BLOCK_CHAIN") | ||
33 | + } | ||
26 | } | 34 | } |
pkg/domain/attachment.go
0 → 100644
@@ -6,11 +6,12 @@ import ( | @@ -6,11 +6,12 @@ import ( | ||
6 | "time" | 6 | "time" |
7 | ) | 7 | ) |
8 | 8 | ||
9 | -// 公司状态状态 1:已注册 2:待认证 3:已认证 | 9 | +// 公司状态状态 1:已注册 2:已通过 3:已拒绝 4:禁用 |
10 | const ( | 10 | const ( |
11 | CompanyRegistered = iota + 1 | 11 | CompanyRegistered = iota + 1 |
12 | - CompanyUnauthenticated | ||
13 | CompanyAuthenticated | 12 | CompanyAuthenticated |
13 | + CompanyUnauthenticated | ||
14 | + CompanyUnAvailable | ||
14 | ) | 15 | ) |
15 | 16 | ||
16 | // 企业信息 (base) | 17 | // 企业信息 (base) |
@@ -21,7 +22,7 @@ type Company struct { | @@ -21,7 +22,7 @@ type Company struct { | ||
21 | CompanyConfig *CompanyConfig `json:"companyConfig"` | 22 | CompanyConfig *CompanyConfig `json:"companyConfig"` |
22 | // 企业基本信息 | 23 | // 企业基本信息 |
23 | CompanyInfo *CompanyInfo `json:"companyInfo"` | 24 | CompanyInfo *CompanyInfo `json:"companyInfo"` |
24 | - // 公司状态 1:已注册 2:待认证 3:已认证 | 25 | + // 公司状态 1:已注册(待审核) 2:已通过 3:已拒绝 |
25 | Status int `json:"status"` | 26 | Status int `json:"status"` |
26 | // 创建时间 | 27 | // 创建时间 |
27 | CreatedAt time.Time `json:"createdAt"` | 28 | CreatedAt time.Time `json:"createdAt"` |
@@ -102,6 +103,36 @@ func (company *Company) ToCompanyVisible() *CompanyVisible { | @@ -102,6 +103,36 @@ func (company *Company) ToCompanyVisible() *CompanyVisible { | ||
102 | } | 103 | } |
103 | } | 104 | } |
104 | 105 | ||
106 | +// 公司审核 | ||
107 | +func (company *Company) Audit(status int, remark string) error { | ||
108 | + if company.Status != CompanyRegistered { | ||
109 | + return fmt.Errorf("公司已审核") | ||
110 | + } | ||
111 | + if !(status == CompanyAuthenticated || status == CompanyUnauthenticated) { | ||
112 | + return fmt.Errorf("审核状态有误") | ||
113 | + } | ||
114 | + company.Status = status | ||
115 | + company.CompanyInfo.Remark = remark | ||
116 | + company.Update(map[string]interface{}{}) | ||
117 | + return nil | ||
118 | +} | ||
119 | + | ||
120 | +// 公司启用禁用 | ||
121 | +func (company *Company) Enable(status int) error { | ||
122 | + if company.Status == CompanyRegistered { | ||
123 | + return fmt.Errorf("公司待审核") | ||
124 | + } | ||
125 | + if company.Status == status { | ||
126 | + return nil | ||
127 | + } | ||
128 | + if !(status == CompanyAuthenticated || status == CompanyUnAvailable) { | ||
129 | + return fmt.Errorf("状态有误 2:启用 4:禁用") | ||
130 | + } | ||
131 | + company.Status = status | ||
132 | + company.Update(map[string]interface{}{}) | ||
133 | + return nil | ||
134 | +} | ||
135 | + | ||
105 | /***** 2.缓存模块 *****/ | 136 | /***** 2.缓存模块 *****/ |
106 | 137 | ||
107 | func (company *Company) CacheKeyFunc() string { | 138 | func (company *Company) CacheKeyFunc() string { |
@@ -14,10 +14,29 @@ type CompanyInfo struct { | @@ -14,10 +14,29 @@ type CompanyInfo struct { | ||
14 | Address string `json:"address,omitempty"` | 14 | Address string `json:"address,omitempty"` |
15 | // 所属行业 | 15 | // 所属行业 |
16 | IndustryCategory string `json:"industryCategory,omitempty"` | 16 | IndustryCategory string `json:"industryCategory,omitempty"` |
17 | - // 联系人 | ||
18 | - //Contacts string `json:"contacts"` | ||
19 | // 注册时间 | 17 | // 注册时间 |
20 | RegisteredTime time.Time `json:"registeredTime,omitempty"` | 18 | RegisteredTime time.Time `json:"registeredTime,omitempty"` |
21 | - // 状态 1:已注册 2:待认证 3:已认证 | ||
22 | - //Status int `json:"status"` | 19 | + // 法律相关 |
20 | + Legal Legal `json:"legal"` | ||
21 | + // 备注信息(审核时使用) | ||
22 | + Remark string `json:"备注"` | ||
23 | +} | ||
24 | + | ||
25 | +// 法律相关 | ||
26 | +type Legal struct { | ||
27 | + // 法人 | ||
28 | + LegalPerson string `json:"legalPerson"` | ||
29 | + // 社会信用代码 | ||
30 | + SocialCreditCode string `json:"socialCreditCode"` | ||
31 | + // 营业执照所在地 | ||
32 | + BusinessLicenseAddress BusinessLicenseAddress `json:"businessLicenseAddress"` | ||
33 | + // 营业执照-附件 | ||
34 | + BusinessLicenseAttachments []Attachment `json:"businessLicenseAttachments"` | ||
35 | +} | ||
36 | + | ||
37 | +// 营业执照所在地 | ||
38 | +type BusinessLicenseAddress struct { | ||
39 | + Province string `json:"province"` | ||
40 | + City string `json:"city"` | ||
41 | + Address string `json:"address"` | ||
23 | } | 42 | } |
@@ -12,4 +12,9 @@ type Ext struct { | @@ -12,4 +12,9 @@ type Ext struct { | ||
12 | DepName string `json:"depName,omitempty"` | 12 | DepName string `json:"depName,omitempty"` |
13 | // 父级部门名称 | 13 | // 父级部门名称 |
14 | ParentDepName string `json:"parentDepName,omitempty"` | 14 | ParentDepName string `json:"parentDepName,omitempty"` |
15 | + | ||
16 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
17 | + EmployeeType int `json:"employeeType,omitempty"` | ||
18 | + // IC卡号 | ||
19 | + IcCardNumber string `json:"icCardNumber,omitempty"` | ||
15 | } | 20 | } |
@@ -15,6 +15,7 @@ const ( | @@ -15,6 +15,7 @@ const ( | ||
15 | UserTypeEmployee = 1 | 15 | UserTypeEmployee = 1 |
16 | UserTypeCooperation = 2 | 16 | UserTypeCooperation = 2 |
17 | UserTypeVisitor = 4 // 游客 | 17 | UserTypeVisitor = 4 // 游客 |
18 | + UserTypeOperationAdmin = 8 // 运营管理员 | ||
18 | UserTypeCompanyAdmin = 1024 | 19 | UserTypeCompanyAdmin = 1024 |
19 | ) | 20 | ) |
20 | 21 | ||
@@ -313,6 +314,10 @@ type BatchAddUserItem struct { | @@ -313,6 +314,10 @@ type BatchAddUserItem struct { | ||
313 | CooperationCompany string `json:"cooperationCompany"` | 314 | CooperationCompany string `json:"cooperationCompany"` |
314 | // 共创到期时间 (yyyy-MM-dd) cooperationDeadline | 315 | // 共创到期时间 (yyyy-MM-dd) cooperationDeadline |
315 | CooperationDeadline string `json:"cooperationDeadline"` | 316 | CooperationDeadline string `json:"cooperationDeadline"` |
317 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
318 | + EmployeeType string `json:"employeeType,omitempty"` | ||
319 | + // IC卡号 | ||
320 | + IcCardNumber string `json:"icCardNumber,omitempty"` | ||
316 | 321 | ||
317 | // 失败理由 | 322 | // 失败理由 |
318 | FailReason string `json:"failReason"` | 323 | FailReason string `json:"failReason"` |
@@ -327,3 +332,16 @@ func (item *BatchAddUserItem) Status() int { | @@ -327,3 +332,16 @@ func (item *BatchAddUserItem) Status() int { | ||
327 | } | 332 | } |
328 | return 1 | 333 | return 1 |
329 | } | 334 | } |
335 | + | ||
336 | +func (item *BatchAddUserItem) GetEmployeeType() int { | ||
337 | + if item.EmployeeType == "固定" { | ||
338 | + return 1 | ||
339 | + } | ||
340 | + if item.EmployeeType == "派遣" { | ||
341 | + return 2 | ||
342 | + } | ||
343 | + if item.EmployeeType == "临时" { | ||
344 | + return 3 | ||
345 | + } | ||
346 | + return 1 | ||
347 | +} |
@@ -45,6 +45,7 @@ type UserBase struct { | @@ -45,6 +45,7 @@ type UserBase struct { | ||
45 | type Favorite struct { | 45 | type Favorite struct { |
46 | OrgItems []int64 `json:"orgItems"` | 46 | OrgItems []int64 `json:"orgItems"` |
47 | Referer string `json:"referer"` | 47 | Referer string `json:"referer"` |
48 | + LastLogInAt int64 `json:"lastLogInAt"` | ||
48 | } | 49 | } |
49 | 50 | ||
50 | type UserBaseRepository interface { | 51 | type UserBaseRepository interface { |
@@ -145,8 +146,8 @@ func (userBase *UserBase) CheckAccountPassword(account, password string) error { | @@ -145,8 +146,8 @@ func (userBase *UserBase) CheckAccountPassword(account, password string) error { | ||
145 | // account 账号 (手机号) | 146 | // account 账号 (手机号) |
146 | // password 密码(sha1) | 147 | // password 密码(sha1) |
147 | func (userBase *UserBase) ResetPassword(account, password string) error { | 148 | func (userBase *UserBase) ResetPassword(account, password string) error { |
148 | - if userBase.Status != int(UserStatusEnable) { | ||
149 | - return fmt.Errorf("该用户不存在") | 149 | + if userBase.Status == int(UserStatusDestroy) { |
150 | + return fmt.Errorf("该用户已注销") | ||
150 | } | 151 | } |
151 | if !strings.EqualFold(account, userBase.Account) { | 152 | if !strings.EqualFold(account, userBase.Account) { |
152 | return fmt.Errorf("该用户不存在") | 153 | return fmt.Errorf("该用户不存在") |
@@ -263,6 +264,32 @@ func (userBase *UserBase) removeFavorite(items []int64, code int64) ([]int64, er | @@ -263,6 +264,32 @@ func (userBase *UserBase) removeFavorite(items []int64, code int64) ([]int64, er | ||
263 | return newItems, nil | 264 | return newItems, nil |
264 | } | 265 | } |
265 | 266 | ||
267 | +// LastLogIn 更新最后一次登录时间 | ||
268 | +// | ||
269 | +// t 时间 | ||
270 | +func (userBase *UserBase) LastLogIn(t time.Time) error { | ||
271 | + if userBase.Favorite == nil { | ||
272 | + userBase.Favorite = NewFavorite() | ||
273 | + } | ||
274 | + userBase.Favorite.LastLogInAt = t.Unix() | ||
275 | + return nil | ||
276 | +} | ||
277 | + | ||
278 | +func (user *UserBase) SetEnableStatus(status int) error { | ||
279 | + userStatus := UserStatus(user.Status) | ||
280 | + if userStatus == UserStatusDestroy { | ||
281 | + return fmt.Errorf("账号已注销") | ||
282 | + } | ||
283 | + if user.Status == status { | ||
284 | + return nil //fmt.Errorf("重复设置状态") | ||
285 | + } | ||
286 | + if !(status == int(UserStatusEnable) || status == int(UserStatusDisable)) { | ||
287 | + return fmt.Errorf("非法启用状态") | ||
288 | + } | ||
289 | + user.Status = status | ||
290 | + return nil | ||
291 | +} | ||
292 | + | ||
266 | /***** 2.缓存模块 *****/ | 293 | /***** 2.缓存模块 *****/ |
267 | 294 | ||
268 | func (m *UserBase) CacheKeyFunc() string { | 295 | func (m *UserBase) CacheKeyFunc() string { |
@@ -11,5 +11,12 @@ type UserInfo struct { | @@ -11,5 +11,12 @@ type UserInfo struct { | ||
11 | // 邮箱 | 11 | // 邮箱 |
12 | Email string `json:"email,omitempty"` | 12 | Email string `json:"email,omitempty"` |
13 | 13 | ||
14 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
15 | + EmployeeType int `json:"employeeType,omitempty"` | ||
16 | + // IC卡号 | ||
17 | + IcCardNumber string `json:"icCardNumber,omitempty"` | ||
18 | + | ||
14 | Referer string `json:"-"` | 19 | Referer string `json:"-"` |
20 | + // 部门 | ||
21 | + DepartmentName string `cname:"部门" json:"-"` | ||
15 | } | 22 | } |
pkg/infrastructure/area/area.go
0 → 100644
1 | +package area | ||
2 | + | ||
3 | +import ( | ||
4 | + _ "embed" | ||
5 | + "encoding/json" | ||
6 | +) | ||
7 | + | ||
8 | +type ProvinceCity struct { | ||
9 | + Provinces []*Province | ||
10 | + Cities []*City | ||
11 | + ProvincesCity map[string][]*City | ||
12 | +} | ||
13 | + | ||
14 | +func (p *ProvinceCity) LoadProvincesCity(provinces []*Province, cities []*City) { | ||
15 | + p.Provinces = provinces | ||
16 | + p.Cities = cities | ||
17 | + for i := range provinces { | ||
18 | + p.ProvincesCity[provinces[i].Province] = make([]*City, 0) | ||
19 | + } | ||
20 | + for i := range cities { | ||
21 | + if _, ok := p.ProvincesCity[cities[i].Province]; ok { | ||
22 | + p.ProvincesCity[cities[i].Province] = append(p.ProvincesCity[cities[i].Province], cities[i]) | ||
23 | + } | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +var DefaultProvinceCity *ProvinceCity | ||
28 | + | ||
29 | +// data source :https://github.com/uiwjs/province-city-china/tree/gh-pages | ||
30 | + | ||
31 | +//go:embed city.json | ||
32 | +var city []byte | ||
33 | + | ||
34 | +//go:embed province.json | ||
35 | +var province []byte | ||
36 | + | ||
37 | +func SetUp() { | ||
38 | + DefaultProvinceCity = &ProvinceCity{ | ||
39 | + Provinces: make([]*Province, 0), | ||
40 | + Cities: make([]*City, 0), | ||
41 | + ProvincesCity: make(map[string][]*City), | ||
42 | + } | ||
43 | + var cities []*City = make([]*City, 0) | ||
44 | + var provinces []*Province = make([]*Province, 0) | ||
45 | + err := json.Unmarshal(city, &cities) | ||
46 | + if err != nil { | ||
47 | + panic(err) | ||
48 | + } | ||
49 | + err = json.Unmarshal(province, &provinces) | ||
50 | + if err != nil { | ||
51 | + panic(err) | ||
52 | + } | ||
53 | + DefaultProvinceCity.LoadProvincesCity(provinces, cities) | ||
54 | +} | ||
55 | + | ||
56 | +/* | ||
57 | +eg: | ||
58 | +{ | ||
59 | + "code": "130100", | ||
60 | + "name": "石家庄市", | ||
61 | + "province": "13", | ||
62 | + "city": "01" | ||
63 | +} | ||
64 | +*/ | ||
65 | +type City struct { | ||
66 | + Code string `json:"code"` | ||
67 | + Name string `json:"name"` | ||
68 | + Province string `json:"province"` | ||
69 | + City string `json:"city"` | ||
70 | +} | ||
71 | + | ||
72 | +/* | ||
73 | +eg: | ||
74 | +{ | ||
75 | + "code": "110000", | ||
76 | + "name": "北京市", | ||
77 | + "province": "11" | ||
78 | +} | ||
79 | +*/ | ||
80 | +type Province struct { | ||
81 | + Code string `json:"code"` | ||
82 | + Name string `json:"name"` | ||
83 | + Province string `json:"province"` | ||
84 | +} | ||
85 | + | ||
86 | +func Provinces() []*Province { | ||
87 | + return DefaultProvinceCity.Provinces | ||
88 | +} | ||
89 | + | ||
90 | +func Cities() []*City { | ||
91 | + return DefaultProvinceCity.Cities | ||
92 | +} | ||
93 | + | ||
94 | +func ProvinceCities(provinceCode string) []*City { | ||
95 | + if v, ok := DefaultProvinceCity.ProvincesCity[provinceCode]; ok { | ||
96 | + return v | ||
97 | + } | ||
98 | + return []*City{} | ||
99 | +} |
pkg/infrastructure/area/city.json
0 → 100644
1 | +[ | ||
2 | + { | ||
3 | + "code": "130100", | ||
4 | + "name": "石家庄市", | ||
5 | + "province": "13", | ||
6 | + "city": "01" | ||
7 | + }, | ||
8 | + { | ||
9 | + "code": "130200", | ||
10 | + "name": "唐山市", | ||
11 | + "province": "13", | ||
12 | + "city": "02" | ||
13 | + }, | ||
14 | + { | ||
15 | + "code": "130300", | ||
16 | + "name": "秦皇岛市", | ||
17 | + "province": "13", | ||
18 | + "city": "03" | ||
19 | + }, | ||
20 | + { | ||
21 | + "code": "130400", | ||
22 | + "name": "邯郸市", | ||
23 | + "province": "13", | ||
24 | + "city": "04" | ||
25 | + }, | ||
26 | + { | ||
27 | + "code": "130500", | ||
28 | + "name": "邢台市", | ||
29 | + "province": "13", | ||
30 | + "city": "05" | ||
31 | + }, | ||
32 | + { | ||
33 | + "code": "130600", | ||
34 | + "name": "保定市", | ||
35 | + "province": "13", | ||
36 | + "city": "06" | ||
37 | + }, | ||
38 | + { | ||
39 | + "code": "130700", | ||
40 | + "name": "张家口市", | ||
41 | + "province": "13", | ||
42 | + "city": "07" | ||
43 | + }, | ||
44 | + { | ||
45 | + "code": "130800", | ||
46 | + "name": "承德市", | ||
47 | + "province": "13", | ||
48 | + "city": "08" | ||
49 | + }, | ||
50 | + { | ||
51 | + "code": "130900", | ||
52 | + "name": "沧州市", | ||
53 | + "province": "13", | ||
54 | + "city": "09" | ||
55 | + }, | ||
56 | + { | ||
57 | + "code": "131000", | ||
58 | + "name": "廊坊市", | ||
59 | + "province": "13", | ||
60 | + "city": "10" | ||
61 | + }, | ||
62 | + { | ||
63 | + "code": "131100", | ||
64 | + "name": "衡水市", | ||
65 | + "province": "13", | ||
66 | + "city": "11" | ||
67 | + }, | ||
68 | + { | ||
69 | + "code": "140100", | ||
70 | + "name": "太原市", | ||
71 | + "province": "14", | ||
72 | + "city": "01" | ||
73 | + }, | ||
74 | + { | ||
75 | + "code": "140200", | ||
76 | + "name": "大同市", | ||
77 | + "province": "14", | ||
78 | + "city": "02" | ||
79 | + }, | ||
80 | + { | ||
81 | + "code": "140300", | ||
82 | + "name": "阳泉市", | ||
83 | + "province": "14", | ||
84 | + "city": "03" | ||
85 | + }, | ||
86 | + { | ||
87 | + "code": "140400", | ||
88 | + "name": "长治市", | ||
89 | + "province": "14", | ||
90 | + "city": "04" | ||
91 | + }, | ||
92 | + { | ||
93 | + "code": "140500", | ||
94 | + "name": "晋城市", | ||
95 | + "province": "14", | ||
96 | + "city": "05" | ||
97 | + }, | ||
98 | + { | ||
99 | + "code": "140600", | ||
100 | + "name": "朔州市", | ||
101 | + "province": "14", | ||
102 | + "city": "06" | ||
103 | + }, | ||
104 | + { | ||
105 | + "code": "140700", | ||
106 | + "name": "晋中市", | ||
107 | + "province": "14", | ||
108 | + "city": "07" | ||
109 | + }, | ||
110 | + { | ||
111 | + "code": "140800", | ||
112 | + "name": "运城市", | ||
113 | + "province": "14", | ||
114 | + "city": "08" | ||
115 | + }, | ||
116 | + { | ||
117 | + "code": "140900", | ||
118 | + "name": "忻州市", | ||
119 | + "province": "14", | ||
120 | + "city": "09" | ||
121 | + }, | ||
122 | + { | ||
123 | + "code": "141000", | ||
124 | + "name": "临汾市", | ||
125 | + "province": "14", | ||
126 | + "city": "10" | ||
127 | + }, | ||
128 | + { | ||
129 | + "code": "141100", | ||
130 | + "name": "吕梁市", | ||
131 | + "province": "14", | ||
132 | + "city": "11" | ||
133 | + }, | ||
134 | + { | ||
135 | + "code": "150100", | ||
136 | + "name": "呼和浩特市", | ||
137 | + "province": "15", | ||
138 | + "city": "01" | ||
139 | + }, | ||
140 | + { | ||
141 | + "code": "150200", | ||
142 | + "name": "包头市", | ||
143 | + "province": "15", | ||
144 | + "city": "02" | ||
145 | + }, | ||
146 | + { | ||
147 | + "code": "150300", | ||
148 | + "name": "乌海市", | ||
149 | + "province": "15", | ||
150 | + "city": "03" | ||
151 | + }, | ||
152 | + { | ||
153 | + "code": "150400", | ||
154 | + "name": "赤峰市", | ||
155 | + "province": "15", | ||
156 | + "city": "04" | ||
157 | + }, | ||
158 | + { | ||
159 | + "code": "150500", | ||
160 | + "name": "通辽市", | ||
161 | + "province": "15", | ||
162 | + "city": "05" | ||
163 | + }, | ||
164 | + { | ||
165 | + "code": "150600", | ||
166 | + "name": "鄂尔多斯市", | ||
167 | + "province": "15", | ||
168 | + "city": "06" | ||
169 | + }, | ||
170 | + { | ||
171 | + "code": "150700", | ||
172 | + "name": "呼伦贝尔市", | ||
173 | + "province": "15", | ||
174 | + "city": "07" | ||
175 | + }, | ||
176 | + { | ||
177 | + "code": "150800", | ||
178 | + "name": "巴彦淖尔市", | ||
179 | + "province": "15", | ||
180 | + "city": "08" | ||
181 | + }, | ||
182 | + { | ||
183 | + "code": "150900", | ||
184 | + "name": "乌兰察布市", | ||
185 | + "province": "15", | ||
186 | + "city": "09" | ||
187 | + }, | ||
188 | + { | ||
189 | + "code": "152200", | ||
190 | + "name": "兴安盟", | ||
191 | + "province": "15", | ||
192 | + "city": "22" | ||
193 | + }, | ||
194 | + { | ||
195 | + "code": "152500", | ||
196 | + "name": "锡林郭勒盟", | ||
197 | + "province": "15", | ||
198 | + "city": "25" | ||
199 | + }, | ||
200 | + { | ||
201 | + "code": "152900", | ||
202 | + "name": "阿拉善盟", | ||
203 | + "province": "15", | ||
204 | + "city": "29" | ||
205 | + }, | ||
206 | + { | ||
207 | + "code": "210100", | ||
208 | + "name": "沈阳市", | ||
209 | + "province": "21", | ||
210 | + "city": "01" | ||
211 | + }, | ||
212 | + { | ||
213 | + "code": "210200", | ||
214 | + "name": "大连市", | ||
215 | + "province": "21", | ||
216 | + "city": "02" | ||
217 | + }, | ||
218 | + { | ||
219 | + "code": "210300", | ||
220 | + "name": "鞍山市", | ||
221 | + "province": "21", | ||
222 | + "city": "03" | ||
223 | + }, | ||
224 | + { | ||
225 | + "code": "210400", | ||
226 | + "name": "抚顺市", | ||
227 | + "province": "21", | ||
228 | + "city": "04" | ||
229 | + }, | ||
230 | + { | ||
231 | + "code": "210500", | ||
232 | + "name": "本溪市", | ||
233 | + "province": "21", | ||
234 | + "city": "05" | ||
235 | + }, | ||
236 | + { | ||
237 | + "code": "210600", | ||
238 | + "name": "丹东市", | ||
239 | + "province": "21", | ||
240 | + "city": "06" | ||
241 | + }, | ||
242 | + { | ||
243 | + "code": "210700", | ||
244 | + "name": "锦州市", | ||
245 | + "province": "21", | ||
246 | + "city": "07" | ||
247 | + }, | ||
248 | + { | ||
249 | + "code": "210800", | ||
250 | + "name": "营口市", | ||
251 | + "province": "21", | ||
252 | + "city": "08" | ||
253 | + }, | ||
254 | + { | ||
255 | + "code": "210900", | ||
256 | + "name": "阜新市", | ||
257 | + "province": "21", | ||
258 | + "city": "09" | ||
259 | + }, | ||
260 | + { | ||
261 | + "code": "211000", | ||
262 | + "name": "辽阳市", | ||
263 | + "province": "21", | ||
264 | + "city": "10" | ||
265 | + }, | ||
266 | + { | ||
267 | + "code": "211100", | ||
268 | + "name": "盘锦市", | ||
269 | + "province": "21", | ||
270 | + "city": "11" | ||
271 | + }, | ||
272 | + { | ||
273 | + "code": "211200", | ||
274 | + "name": "铁岭市", | ||
275 | + "province": "21", | ||
276 | + "city": "12" | ||
277 | + }, | ||
278 | + { | ||
279 | + "code": "211300", | ||
280 | + "name": "朝阳市", | ||
281 | + "province": "21", | ||
282 | + "city": "13" | ||
283 | + }, | ||
284 | + { | ||
285 | + "code": "211400", | ||
286 | + "name": "葫芦岛市", | ||
287 | + "province": "21", | ||
288 | + "city": "14" | ||
289 | + }, | ||
290 | + { | ||
291 | + "code": "220100", | ||
292 | + "name": "长春市", | ||
293 | + "province": "22", | ||
294 | + "city": "01" | ||
295 | + }, | ||
296 | + { | ||
297 | + "code": "220200", | ||
298 | + "name": "吉林市", | ||
299 | + "province": "22", | ||
300 | + "city": "02" | ||
301 | + }, | ||
302 | + { | ||
303 | + "code": "220300", | ||
304 | + "name": "四平市", | ||
305 | + "province": "22", | ||
306 | + "city": "03" | ||
307 | + }, | ||
308 | + { | ||
309 | + "code": "220400", | ||
310 | + "name": "辽源市", | ||
311 | + "province": "22", | ||
312 | + "city": "04" | ||
313 | + }, | ||
314 | + { | ||
315 | + "code": "220500", | ||
316 | + "name": "通化市", | ||
317 | + "province": "22", | ||
318 | + "city": "05" | ||
319 | + }, | ||
320 | + { | ||
321 | + "code": "220600", | ||
322 | + "name": "白山市", | ||
323 | + "province": "22", | ||
324 | + "city": "06" | ||
325 | + }, | ||
326 | + { | ||
327 | + "code": "220700", | ||
328 | + "name": "松原市", | ||
329 | + "province": "22", | ||
330 | + "city": "07" | ||
331 | + }, | ||
332 | + { | ||
333 | + "code": "220800", | ||
334 | + "name": "白城市", | ||
335 | + "province": "22", | ||
336 | + "city": "08" | ||
337 | + }, | ||
338 | + { | ||
339 | + "code": "222400", | ||
340 | + "name": "延边朝鲜族自治州", | ||
341 | + "province": "22", | ||
342 | + "city": "24" | ||
343 | + }, | ||
344 | + { | ||
345 | + "code": "230100", | ||
346 | + "name": "哈尔滨市", | ||
347 | + "province": "23", | ||
348 | + "city": "01" | ||
349 | + }, | ||
350 | + { | ||
351 | + "code": "230200", | ||
352 | + "name": "齐齐哈尔市", | ||
353 | + "province": "23", | ||
354 | + "city": "02" | ||
355 | + }, | ||
356 | + { | ||
357 | + "code": "230300", | ||
358 | + "name": "鸡西市", | ||
359 | + "province": "23", | ||
360 | + "city": "03" | ||
361 | + }, | ||
362 | + { | ||
363 | + "code": "230400", | ||
364 | + "name": "鹤岗市", | ||
365 | + "province": "23", | ||
366 | + "city": "04" | ||
367 | + }, | ||
368 | + { | ||
369 | + "code": "230500", | ||
370 | + "name": "双鸭山市", | ||
371 | + "province": "23", | ||
372 | + "city": "05" | ||
373 | + }, | ||
374 | + { | ||
375 | + "code": "230600", | ||
376 | + "name": "大庆市", | ||
377 | + "province": "23", | ||
378 | + "city": "06" | ||
379 | + }, | ||
380 | + { | ||
381 | + "code": "230700", | ||
382 | + "name": "伊春市", | ||
383 | + "province": "23", | ||
384 | + "city": "07" | ||
385 | + }, | ||
386 | + { | ||
387 | + "code": "230800", | ||
388 | + "name": "佳木斯市", | ||
389 | + "province": "23", | ||
390 | + "city": "08" | ||
391 | + }, | ||
392 | + { | ||
393 | + "code": "230900", | ||
394 | + "name": "七台河市", | ||
395 | + "province": "23", | ||
396 | + "city": "09" | ||
397 | + }, | ||
398 | + { | ||
399 | + "code": "231000", | ||
400 | + "name": "牡丹江市", | ||
401 | + "province": "23", | ||
402 | + "city": "10" | ||
403 | + }, | ||
404 | + { | ||
405 | + "code": "231100", | ||
406 | + "name": "黑河市", | ||
407 | + "province": "23", | ||
408 | + "city": "11" | ||
409 | + }, | ||
410 | + { | ||
411 | + "code": "231200", | ||
412 | + "name": "绥化市", | ||
413 | + "province": "23", | ||
414 | + "city": "12" | ||
415 | + }, | ||
416 | + { | ||
417 | + "code": "232700", | ||
418 | + "name": "大兴安岭地区", | ||
419 | + "province": "23", | ||
420 | + "city": "27" | ||
421 | + }, | ||
422 | + { | ||
423 | + "code": "320100", | ||
424 | + "name": "南京市", | ||
425 | + "province": "32", | ||
426 | + "city": "01" | ||
427 | + }, | ||
428 | + { | ||
429 | + "code": "320200", | ||
430 | + "name": "无锡市", | ||
431 | + "province": "32", | ||
432 | + "city": "02" | ||
433 | + }, | ||
434 | + { | ||
435 | + "code": "320300", | ||
436 | + "name": "徐州市", | ||
437 | + "province": "32", | ||
438 | + "city": "03" | ||
439 | + }, | ||
440 | + { | ||
441 | + "code": "320400", | ||
442 | + "name": "常州市", | ||
443 | + "province": "32", | ||
444 | + "city": "04" | ||
445 | + }, | ||
446 | + { | ||
447 | + "code": "320500", | ||
448 | + "name": "苏州市", | ||
449 | + "province": "32", | ||
450 | + "city": "05" | ||
451 | + }, | ||
452 | + { | ||
453 | + "code": "320600", | ||
454 | + "name": "南通市", | ||
455 | + "province": "32", | ||
456 | + "city": "06" | ||
457 | + }, | ||
458 | + { | ||
459 | + "code": "320700", | ||
460 | + "name": "连云港市", | ||
461 | + "province": "32", | ||
462 | + "city": "07" | ||
463 | + }, | ||
464 | + { | ||
465 | + "code": "320800", | ||
466 | + "name": "淮安市", | ||
467 | + "province": "32", | ||
468 | + "city": "08" | ||
469 | + }, | ||
470 | + { | ||
471 | + "code": "320900", | ||
472 | + "name": "盐城市", | ||
473 | + "province": "32", | ||
474 | + "city": "09" | ||
475 | + }, | ||
476 | + { | ||
477 | + "code": "321000", | ||
478 | + "name": "扬州市", | ||
479 | + "province": "32", | ||
480 | + "city": "10" | ||
481 | + }, | ||
482 | + { | ||
483 | + "code": "321100", | ||
484 | + "name": "镇江市", | ||
485 | + "province": "32", | ||
486 | + "city": "11" | ||
487 | + }, | ||
488 | + { | ||
489 | + "code": "321200", | ||
490 | + "name": "泰州市", | ||
491 | + "province": "32", | ||
492 | + "city": "12" | ||
493 | + }, | ||
494 | + { | ||
495 | + "code": "321300", | ||
496 | + "name": "宿迁市", | ||
497 | + "province": "32", | ||
498 | + "city": "13" | ||
499 | + }, | ||
500 | + { | ||
501 | + "code": "330100", | ||
502 | + "name": "杭州市", | ||
503 | + "province": "33", | ||
504 | + "city": "01" | ||
505 | + }, | ||
506 | + { | ||
507 | + "code": "330200", | ||
508 | + "name": "宁波市", | ||
509 | + "province": "33", | ||
510 | + "city": "02" | ||
511 | + }, | ||
512 | + { | ||
513 | + "code": "330300", | ||
514 | + "name": "温州市", | ||
515 | + "province": "33", | ||
516 | + "city": "03" | ||
517 | + }, | ||
518 | + { | ||
519 | + "code": "330400", | ||
520 | + "name": "嘉兴市", | ||
521 | + "province": "33", | ||
522 | + "city": "04" | ||
523 | + }, | ||
524 | + { | ||
525 | + "code": "330500", | ||
526 | + "name": "湖州市", | ||
527 | + "province": "33", | ||
528 | + "city": "05" | ||
529 | + }, | ||
530 | + { | ||
531 | + "code": "330600", | ||
532 | + "name": "绍兴市", | ||
533 | + "province": "33", | ||
534 | + "city": "06" | ||
535 | + }, | ||
536 | + { | ||
537 | + "code": "330700", | ||
538 | + "name": "金华市", | ||
539 | + "province": "33", | ||
540 | + "city": "07" | ||
541 | + }, | ||
542 | + { | ||
543 | + "code": "330800", | ||
544 | + "name": "衢州市", | ||
545 | + "province": "33", | ||
546 | + "city": "08" | ||
547 | + }, | ||
548 | + { | ||
549 | + "code": "330900", | ||
550 | + "name": "舟山市", | ||
551 | + "province": "33", | ||
552 | + "city": "09" | ||
553 | + }, | ||
554 | + { | ||
555 | + "code": "331000", | ||
556 | + "name": "台州市", | ||
557 | + "province": "33", | ||
558 | + "city": "10" | ||
559 | + }, | ||
560 | + { | ||
561 | + "code": "331100", | ||
562 | + "name": "丽水市", | ||
563 | + "province": "33", | ||
564 | + "city": "11" | ||
565 | + }, | ||
566 | + { | ||
567 | + "code": "340100", | ||
568 | + "name": "合肥市", | ||
569 | + "province": "34", | ||
570 | + "city": "01" | ||
571 | + }, | ||
572 | + { | ||
573 | + "code": "340200", | ||
574 | + "name": "芜湖市", | ||
575 | + "province": "34", | ||
576 | + "city": "02" | ||
577 | + }, | ||
578 | + { | ||
579 | + "code": "340300", | ||
580 | + "name": "蚌埠市", | ||
581 | + "province": "34", | ||
582 | + "city": "03" | ||
583 | + }, | ||
584 | + { | ||
585 | + "code": "340400", | ||
586 | + "name": "淮南市", | ||
587 | + "province": "34", | ||
588 | + "city": "04" | ||
589 | + }, | ||
590 | + { | ||
591 | + "code": "340500", | ||
592 | + "name": "马鞍山市", | ||
593 | + "province": "34", | ||
594 | + "city": "05" | ||
595 | + }, | ||
596 | + { | ||
597 | + "code": "340600", | ||
598 | + "name": "淮北市", | ||
599 | + "province": "34", | ||
600 | + "city": "06" | ||
601 | + }, | ||
602 | + { | ||
603 | + "code": "340700", | ||
604 | + "name": "铜陵市", | ||
605 | + "province": "34", | ||
606 | + "city": "07" | ||
607 | + }, | ||
608 | + { | ||
609 | + "code": "340800", | ||
610 | + "name": "安庆市", | ||
611 | + "province": "34", | ||
612 | + "city": "08" | ||
613 | + }, | ||
614 | + { | ||
615 | + "code": "341000", | ||
616 | + "name": "黄山市", | ||
617 | + "province": "34", | ||
618 | + "city": "10" | ||
619 | + }, | ||
620 | + { | ||
621 | + "code": "341100", | ||
622 | + "name": "滁州市", | ||
623 | + "province": "34", | ||
624 | + "city": "11" | ||
625 | + }, | ||
626 | + { | ||
627 | + "code": "341200", | ||
628 | + "name": "阜阳市", | ||
629 | + "province": "34", | ||
630 | + "city": "12" | ||
631 | + }, | ||
632 | + { | ||
633 | + "code": "341300", | ||
634 | + "name": "宿州市", | ||
635 | + "province": "34", | ||
636 | + "city": "13" | ||
637 | + }, | ||
638 | + { | ||
639 | + "code": "341500", | ||
640 | + "name": "六安市", | ||
641 | + "province": "34", | ||
642 | + "city": "15" | ||
643 | + }, | ||
644 | + { | ||
645 | + "code": "341600", | ||
646 | + "name": "亳州市", | ||
647 | + "province": "34", | ||
648 | + "city": "16" | ||
649 | + }, | ||
650 | + { | ||
651 | + "code": "341700", | ||
652 | + "name": "池州市", | ||
653 | + "province": "34", | ||
654 | + "city": "17" | ||
655 | + }, | ||
656 | + { | ||
657 | + "code": "341800", | ||
658 | + "name": "宣城市", | ||
659 | + "province": "34", | ||
660 | + "city": "18" | ||
661 | + }, | ||
662 | + { | ||
663 | + "code": "350100", | ||
664 | + "name": "福州市", | ||
665 | + "province": "35", | ||
666 | + "city": "01" | ||
667 | + }, | ||
668 | + { | ||
669 | + "code": "350200", | ||
670 | + "name": "厦门市", | ||
671 | + "province": "35", | ||
672 | + "city": "02" | ||
673 | + }, | ||
674 | + { | ||
675 | + "code": "350300", | ||
676 | + "name": "莆田市", | ||
677 | + "province": "35", | ||
678 | + "city": "03" | ||
679 | + }, | ||
680 | + { | ||
681 | + "code": "350400", | ||
682 | + "name": "三明市", | ||
683 | + "province": "35", | ||
684 | + "city": "04" | ||
685 | + }, | ||
686 | + { | ||
687 | + "code": "350500", | ||
688 | + "name": "泉州市", | ||
689 | + "province": "35", | ||
690 | + "city": "05" | ||
691 | + }, | ||
692 | + { | ||
693 | + "code": "350600", | ||
694 | + "name": "漳州市", | ||
695 | + "province": "35", | ||
696 | + "city": "06" | ||
697 | + }, | ||
698 | + { | ||
699 | + "code": "350700", | ||
700 | + "name": "南平市", | ||
701 | + "province": "35", | ||
702 | + "city": "07" | ||
703 | + }, | ||
704 | + { | ||
705 | + "code": "350800", | ||
706 | + "name": "龙岩市", | ||
707 | + "province": "35", | ||
708 | + "city": "08" | ||
709 | + }, | ||
710 | + { | ||
711 | + "code": "350900", | ||
712 | + "name": "宁德市", | ||
713 | + "province": "35", | ||
714 | + "city": "09" | ||
715 | + }, | ||
716 | + { | ||
717 | + "code": "360100", | ||
718 | + "name": "南昌市", | ||
719 | + "province": "36", | ||
720 | + "city": "01" | ||
721 | + }, | ||
722 | + { | ||
723 | + "code": "360200", | ||
724 | + "name": "景德镇市", | ||
725 | + "province": "36", | ||
726 | + "city": "02" | ||
727 | + }, | ||
728 | + { | ||
729 | + "code": "360300", | ||
730 | + "name": "萍乡市", | ||
731 | + "province": "36", | ||
732 | + "city": "03" | ||
733 | + }, | ||
734 | + { | ||
735 | + "code": "360400", | ||
736 | + "name": "九江市", | ||
737 | + "province": "36", | ||
738 | + "city": "04" | ||
739 | + }, | ||
740 | + { | ||
741 | + "code": "360500", | ||
742 | + "name": "新余市", | ||
743 | + "province": "36", | ||
744 | + "city": "05" | ||
745 | + }, | ||
746 | + { | ||
747 | + "code": "360600", | ||
748 | + "name": "鹰潭市", | ||
749 | + "province": "36", | ||
750 | + "city": "06" | ||
751 | + }, | ||
752 | + { | ||
753 | + "code": "360700", | ||
754 | + "name": "赣州市", | ||
755 | + "province": "36", | ||
756 | + "city": "07" | ||
757 | + }, | ||
758 | + { | ||
759 | + "code": "360800", | ||
760 | + "name": "吉安市", | ||
761 | + "province": "36", | ||
762 | + "city": "08" | ||
763 | + }, | ||
764 | + { | ||
765 | + "code": "360900", | ||
766 | + "name": "宜春市", | ||
767 | + "province": "36", | ||
768 | + "city": "09" | ||
769 | + }, | ||
770 | + { | ||
771 | + "code": "361000", | ||
772 | + "name": "抚州市", | ||
773 | + "province": "36", | ||
774 | + "city": "10" | ||
775 | + }, | ||
776 | + { | ||
777 | + "code": "361100", | ||
778 | + "name": "上饶市", | ||
779 | + "province": "36", | ||
780 | + "city": "11" | ||
781 | + }, | ||
782 | + { | ||
783 | + "code": "370100", | ||
784 | + "name": "济南市", | ||
785 | + "province": "37", | ||
786 | + "city": "01" | ||
787 | + }, | ||
788 | + { | ||
789 | + "code": "370200", | ||
790 | + "name": "青岛市", | ||
791 | + "province": "37", | ||
792 | + "city": "02" | ||
793 | + }, | ||
794 | + { | ||
795 | + "code": "370300", | ||
796 | + "name": "淄博市", | ||
797 | + "province": "37", | ||
798 | + "city": "03" | ||
799 | + }, | ||
800 | + { | ||
801 | + "code": "370400", | ||
802 | + "name": "枣庄市", | ||
803 | + "province": "37", | ||
804 | + "city": "04" | ||
805 | + }, | ||
806 | + { | ||
807 | + "code": "370500", | ||
808 | + "name": "东营市", | ||
809 | + "province": "37", | ||
810 | + "city": "05" | ||
811 | + }, | ||
812 | + { | ||
813 | + "code": "370600", | ||
814 | + "name": "烟台市", | ||
815 | + "province": "37", | ||
816 | + "city": "06" | ||
817 | + }, | ||
818 | + { | ||
819 | + "code": "370700", | ||
820 | + "name": "潍坊市", | ||
821 | + "province": "37", | ||
822 | + "city": "07" | ||
823 | + }, | ||
824 | + { | ||
825 | + "code": "370800", | ||
826 | + "name": "济宁市", | ||
827 | + "province": "37", | ||
828 | + "city": "08" | ||
829 | + }, | ||
830 | + { | ||
831 | + "code": "370900", | ||
832 | + "name": "泰安市", | ||
833 | + "province": "37", | ||
834 | + "city": "09" | ||
835 | + }, | ||
836 | + { | ||
837 | + "code": "371000", | ||
838 | + "name": "威海市", | ||
839 | + "province": "37", | ||
840 | + "city": "10" | ||
841 | + }, | ||
842 | + { | ||
843 | + "code": "371100", | ||
844 | + "name": "日照市", | ||
845 | + "province": "37", | ||
846 | + "city": "11" | ||
847 | + }, | ||
848 | + { | ||
849 | + "code": "371300", | ||
850 | + "name": "临沂市", | ||
851 | + "province": "37", | ||
852 | + "city": "13" | ||
853 | + }, | ||
854 | + { | ||
855 | + "code": "371400", | ||
856 | + "name": "德州市", | ||
857 | + "province": "37", | ||
858 | + "city": "14" | ||
859 | + }, | ||
860 | + { | ||
861 | + "code": "371500", | ||
862 | + "name": "聊城市", | ||
863 | + "province": "37", | ||
864 | + "city": "15" | ||
865 | + }, | ||
866 | + { | ||
867 | + "code": "371600", | ||
868 | + "name": "滨州市", | ||
869 | + "province": "37", | ||
870 | + "city": "16" | ||
871 | + }, | ||
872 | + { | ||
873 | + "code": "371700", | ||
874 | + "name": "菏泽市", | ||
875 | + "province": "37", | ||
876 | + "city": "17" | ||
877 | + }, | ||
878 | + { | ||
879 | + "code": "410100", | ||
880 | + "name": "郑州市", | ||
881 | + "province": "41", | ||
882 | + "city": "01" | ||
883 | + }, | ||
884 | + { | ||
885 | + "code": "410200", | ||
886 | + "name": "开封市", | ||
887 | + "province": "41", | ||
888 | + "city": "02" | ||
889 | + }, | ||
890 | + { | ||
891 | + "code": "410300", | ||
892 | + "name": "洛阳市", | ||
893 | + "province": "41", | ||
894 | + "city": "03" | ||
895 | + }, | ||
896 | + { | ||
897 | + "code": "410400", | ||
898 | + "name": "平顶山市", | ||
899 | + "province": "41", | ||
900 | + "city": "04" | ||
901 | + }, | ||
902 | + { | ||
903 | + "code": "410500", | ||
904 | + "name": "安阳市", | ||
905 | + "province": "41", | ||
906 | + "city": "05" | ||
907 | + }, | ||
908 | + { | ||
909 | + "code": "410600", | ||
910 | + "name": "鹤壁市", | ||
911 | + "province": "41", | ||
912 | + "city": "06" | ||
913 | + }, | ||
914 | + { | ||
915 | + "code": "410700", | ||
916 | + "name": "新乡市", | ||
917 | + "province": "41", | ||
918 | + "city": "07" | ||
919 | + }, | ||
920 | + { | ||
921 | + "code": "410800", | ||
922 | + "name": "焦作市", | ||
923 | + "province": "41", | ||
924 | + "city": "08" | ||
925 | + }, | ||
926 | + { | ||
927 | + "code": "410900", | ||
928 | + "name": "濮阳市", | ||
929 | + "province": "41", | ||
930 | + "city": "09" | ||
931 | + }, | ||
932 | + { | ||
933 | + "code": "411000", | ||
934 | + "name": "许昌市", | ||
935 | + "province": "41", | ||
936 | + "city": "10" | ||
937 | + }, | ||
938 | + { | ||
939 | + "code": "411100", | ||
940 | + "name": "漯河市", | ||
941 | + "province": "41", | ||
942 | + "city": "11" | ||
943 | + }, | ||
944 | + { | ||
945 | + "code": "411200", | ||
946 | + "name": "三门峡市", | ||
947 | + "province": "41", | ||
948 | + "city": "12" | ||
949 | + }, | ||
950 | + { | ||
951 | + "code": "411300", | ||
952 | + "name": "南阳市", | ||
953 | + "province": "41", | ||
954 | + "city": "13" | ||
955 | + }, | ||
956 | + { | ||
957 | + "code": "411400", | ||
958 | + "name": "商丘市", | ||
959 | + "province": "41", | ||
960 | + "city": "14" | ||
961 | + }, | ||
962 | + { | ||
963 | + "code": "411500", | ||
964 | + "name": "信阳市", | ||
965 | + "province": "41", | ||
966 | + "city": "15" | ||
967 | + }, | ||
968 | + { | ||
969 | + "code": "411600", | ||
970 | + "name": "周口市", | ||
971 | + "province": "41", | ||
972 | + "city": "16" | ||
973 | + }, | ||
974 | + { | ||
975 | + "code": "411700", | ||
976 | + "name": "驻马店市", | ||
977 | + "province": "41", | ||
978 | + "city": "17" | ||
979 | + }, | ||
980 | + { | ||
981 | + "code": "420100", | ||
982 | + "name": "武汉市", | ||
983 | + "province": "42", | ||
984 | + "city": "01" | ||
985 | + }, | ||
986 | + { | ||
987 | + "code": "420200", | ||
988 | + "name": "黄石市", | ||
989 | + "province": "42", | ||
990 | + "city": "02" | ||
991 | + }, | ||
992 | + { | ||
993 | + "code": "420300", | ||
994 | + "name": "十堰市", | ||
995 | + "province": "42", | ||
996 | + "city": "03" | ||
997 | + }, | ||
998 | + { | ||
999 | + "code": "420500", | ||
1000 | + "name": "宜昌市", | ||
1001 | + "province": "42", | ||
1002 | + "city": "05" | ||
1003 | + }, | ||
1004 | + { | ||
1005 | + "code": "420600", | ||
1006 | + "name": "襄阳市", | ||
1007 | + "province": "42", | ||
1008 | + "city": "06" | ||
1009 | + }, | ||
1010 | + { | ||
1011 | + "code": "420700", | ||
1012 | + "name": "鄂州市", | ||
1013 | + "province": "42", | ||
1014 | + "city": "07" | ||
1015 | + }, | ||
1016 | + { | ||
1017 | + "code": "420800", | ||
1018 | + "name": "荆门市", | ||
1019 | + "province": "42", | ||
1020 | + "city": "08" | ||
1021 | + }, | ||
1022 | + { | ||
1023 | + "code": "420900", | ||
1024 | + "name": "孝感市", | ||
1025 | + "province": "42", | ||
1026 | + "city": "09" | ||
1027 | + }, | ||
1028 | + { | ||
1029 | + "code": "421000", | ||
1030 | + "name": "荆州市", | ||
1031 | + "province": "42", | ||
1032 | + "city": "10" | ||
1033 | + }, | ||
1034 | + { | ||
1035 | + "code": "421100", | ||
1036 | + "name": "黄冈市", | ||
1037 | + "province": "42", | ||
1038 | + "city": "11" | ||
1039 | + }, | ||
1040 | + { | ||
1041 | + "code": "421200", | ||
1042 | + "name": "咸宁市", | ||
1043 | + "province": "42", | ||
1044 | + "city": "12" | ||
1045 | + }, | ||
1046 | + { | ||
1047 | + "code": "421300", | ||
1048 | + "name": "随州市", | ||
1049 | + "province": "42", | ||
1050 | + "city": "13" | ||
1051 | + }, | ||
1052 | + { | ||
1053 | + "code": "422800", | ||
1054 | + "name": "恩施土家族苗族自治州", | ||
1055 | + "province": "42", | ||
1056 | + "city": "28" | ||
1057 | + }, | ||
1058 | + { | ||
1059 | + "code": "430100", | ||
1060 | + "name": "长沙市", | ||
1061 | + "province": "43", | ||
1062 | + "city": "01" | ||
1063 | + }, | ||
1064 | + { | ||
1065 | + "code": "430200", | ||
1066 | + "name": "株洲市", | ||
1067 | + "province": "43", | ||
1068 | + "city": "02" | ||
1069 | + }, | ||
1070 | + { | ||
1071 | + "code": "430300", | ||
1072 | + "name": "湘潭市", | ||
1073 | + "province": "43", | ||
1074 | + "city": "03" | ||
1075 | + }, | ||
1076 | + { | ||
1077 | + "code": "430400", | ||
1078 | + "name": "衡阳市", | ||
1079 | + "province": "43", | ||
1080 | + "city": "04" | ||
1081 | + }, | ||
1082 | + { | ||
1083 | + "code": "430500", | ||
1084 | + "name": "邵阳市", | ||
1085 | + "province": "43", | ||
1086 | + "city": "05" | ||
1087 | + }, | ||
1088 | + { | ||
1089 | + "code": "430600", | ||
1090 | + "name": "岳阳市", | ||
1091 | + "province": "43", | ||
1092 | + "city": "06" | ||
1093 | + }, | ||
1094 | + { | ||
1095 | + "code": "430700", | ||
1096 | + "name": "常德市", | ||
1097 | + "province": "43", | ||
1098 | + "city": "07" | ||
1099 | + }, | ||
1100 | + { | ||
1101 | + "code": "430800", | ||
1102 | + "name": "张家界市", | ||
1103 | + "province": "43", | ||
1104 | + "city": "08" | ||
1105 | + }, | ||
1106 | + { | ||
1107 | + "code": "430900", | ||
1108 | + "name": "益阳市", | ||
1109 | + "province": "43", | ||
1110 | + "city": "09" | ||
1111 | + }, | ||
1112 | + { | ||
1113 | + "code": "431000", | ||
1114 | + "name": "郴州市", | ||
1115 | + "province": "43", | ||
1116 | + "city": "10" | ||
1117 | + }, | ||
1118 | + { | ||
1119 | + "code": "431100", | ||
1120 | + "name": "永州市", | ||
1121 | + "province": "43", | ||
1122 | + "city": "11" | ||
1123 | + }, | ||
1124 | + { | ||
1125 | + "code": "431200", | ||
1126 | + "name": "怀化市", | ||
1127 | + "province": "43", | ||
1128 | + "city": "12" | ||
1129 | + }, | ||
1130 | + { | ||
1131 | + "code": "431300", | ||
1132 | + "name": "娄底市", | ||
1133 | + "province": "43", | ||
1134 | + "city": "13" | ||
1135 | + }, | ||
1136 | + { | ||
1137 | + "code": "433100", | ||
1138 | + "name": "湘西土家族苗族自治州", | ||
1139 | + "province": "43", | ||
1140 | + "city": "31" | ||
1141 | + }, | ||
1142 | + { | ||
1143 | + "code": "440100", | ||
1144 | + "name": "广州市", | ||
1145 | + "province": "44", | ||
1146 | + "city": "01" | ||
1147 | + }, | ||
1148 | + { | ||
1149 | + "code": "440200", | ||
1150 | + "name": "韶关市", | ||
1151 | + "province": "44", | ||
1152 | + "city": "02" | ||
1153 | + }, | ||
1154 | + { | ||
1155 | + "code": "440300", | ||
1156 | + "name": "深圳市", | ||
1157 | + "province": "44", | ||
1158 | + "city": "03" | ||
1159 | + }, | ||
1160 | + { | ||
1161 | + "code": "440400", | ||
1162 | + "name": "珠海市", | ||
1163 | + "province": "44", | ||
1164 | + "city": "04" | ||
1165 | + }, | ||
1166 | + { | ||
1167 | + "code": "440500", | ||
1168 | + "name": "汕头市", | ||
1169 | + "province": "44", | ||
1170 | + "city": "05" | ||
1171 | + }, | ||
1172 | + { | ||
1173 | + "code": "440600", | ||
1174 | + "name": "佛山市", | ||
1175 | + "province": "44", | ||
1176 | + "city": "06" | ||
1177 | + }, | ||
1178 | + { | ||
1179 | + "code": "440700", | ||
1180 | + "name": "江门市", | ||
1181 | + "province": "44", | ||
1182 | + "city": "07" | ||
1183 | + }, | ||
1184 | + { | ||
1185 | + "code": "440800", | ||
1186 | + "name": "湛江市", | ||
1187 | + "province": "44", | ||
1188 | + "city": "08" | ||
1189 | + }, | ||
1190 | + { | ||
1191 | + "code": "440900", | ||
1192 | + "name": "茂名市", | ||
1193 | + "province": "44", | ||
1194 | + "city": "09" | ||
1195 | + }, | ||
1196 | + { | ||
1197 | + "code": "441200", | ||
1198 | + "name": "肇庆市", | ||
1199 | + "province": "44", | ||
1200 | + "city": "12" | ||
1201 | + }, | ||
1202 | + { | ||
1203 | + "code": "441300", | ||
1204 | + "name": "惠州市", | ||
1205 | + "province": "44", | ||
1206 | + "city": "13" | ||
1207 | + }, | ||
1208 | + { | ||
1209 | + "code": "441400", | ||
1210 | + "name": "梅州市", | ||
1211 | + "province": "44", | ||
1212 | + "city": "14" | ||
1213 | + }, | ||
1214 | + { | ||
1215 | + "code": "441500", | ||
1216 | + "name": "汕尾市", | ||
1217 | + "province": "44", | ||
1218 | + "city": "15" | ||
1219 | + }, | ||
1220 | + { | ||
1221 | + "code": "441600", | ||
1222 | + "name": "河源市", | ||
1223 | + "province": "44", | ||
1224 | + "city": "16" | ||
1225 | + }, | ||
1226 | + { | ||
1227 | + "code": "441700", | ||
1228 | + "name": "阳江市", | ||
1229 | + "province": "44", | ||
1230 | + "city": "17" | ||
1231 | + }, | ||
1232 | + { | ||
1233 | + "code": "441800", | ||
1234 | + "name": "清远市", | ||
1235 | + "province": "44", | ||
1236 | + "city": "18" | ||
1237 | + }, | ||
1238 | + { | ||
1239 | + "code": "441900", | ||
1240 | + "name": "东莞市", | ||
1241 | + "province": "44", | ||
1242 | + "city": "19" | ||
1243 | + }, | ||
1244 | + { | ||
1245 | + "code": "442000", | ||
1246 | + "name": "中山市", | ||
1247 | + "province": "44", | ||
1248 | + "city": "20" | ||
1249 | + }, | ||
1250 | + { | ||
1251 | + "code": "445100", | ||
1252 | + "name": "潮州市", | ||
1253 | + "province": "44", | ||
1254 | + "city": "51" | ||
1255 | + }, | ||
1256 | + { | ||
1257 | + "code": "445200", | ||
1258 | + "name": "揭阳市", | ||
1259 | + "province": "44", | ||
1260 | + "city": "52" | ||
1261 | + }, | ||
1262 | + { | ||
1263 | + "code": "445300", | ||
1264 | + "name": "云浮市", | ||
1265 | + "province": "44", | ||
1266 | + "city": "53" | ||
1267 | + }, | ||
1268 | + { | ||
1269 | + "code": "450100", | ||
1270 | + "name": "南宁市", | ||
1271 | + "province": "45", | ||
1272 | + "city": "01" | ||
1273 | + }, | ||
1274 | + { | ||
1275 | + "code": "450200", | ||
1276 | + "name": "柳州市", | ||
1277 | + "province": "45", | ||
1278 | + "city": "02" | ||
1279 | + }, | ||
1280 | + { | ||
1281 | + "code": "450300", | ||
1282 | + "name": "桂林市", | ||
1283 | + "province": "45", | ||
1284 | + "city": "03" | ||
1285 | + }, | ||
1286 | + { | ||
1287 | + "code": "450400", | ||
1288 | + "name": "梧州市", | ||
1289 | + "province": "45", | ||
1290 | + "city": "04" | ||
1291 | + }, | ||
1292 | + { | ||
1293 | + "code": "450500", | ||
1294 | + "name": "北海市", | ||
1295 | + "province": "45", | ||
1296 | + "city": "05" | ||
1297 | + }, | ||
1298 | + { | ||
1299 | + "code": "450600", | ||
1300 | + "name": "防城港市", | ||
1301 | + "province": "45", | ||
1302 | + "city": "06" | ||
1303 | + }, | ||
1304 | + { | ||
1305 | + "code": "450700", | ||
1306 | + "name": "钦州市", | ||
1307 | + "province": "45", | ||
1308 | + "city": "07" | ||
1309 | + }, | ||
1310 | + { | ||
1311 | + "code": "450800", | ||
1312 | + "name": "贵港市", | ||
1313 | + "province": "45", | ||
1314 | + "city": "08" | ||
1315 | + }, | ||
1316 | + { | ||
1317 | + "code": "450900", | ||
1318 | + "name": "玉林市", | ||
1319 | + "province": "45", | ||
1320 | + "city": "09" | ||
1321 | + }, | ||
1322 | + { | ||
1323 | + "code": "451000", | ||
1324 | + "name": "百色市", | ||
1325 | + "province": "45", | ||
1326 | + "city": "10" | ||
1327 | + }, | ||
1328 | + { | ||
1329 | + "code": "451100", | ||
1330 | + "name": "贺州市", | ||
1331 | + "province": "45", | ||
1332 | + "city": "11" | ||
1333 | + }, | ||
1334 | + { | ||
1335 | + "code": "451200", | ||
1336 | + "name": "河池市", | ||
1337 | + "province": "45", | ||
1338 | + "city": "12" | ||
1339 | + }, | ||
1340 | + { | ||
1341 | + "code": "451300", | ||
1342 | + "name": "来宾市", | ||
1343 | + "province": "45", | ||
1344 | + "city": "13" | ||
1345 | + }, | ||
1346 | + { | ||
1347 | + "code": "451400", | ||
1348 | + "name": "崇左市", | ||
1349 | + "province": "45", | ||
1350 | + "city": "14" | ||
1351 | + }, | ||
1352 | + { | ||
1353 | + "code": "460100", | ||
1354 | + "name": "海口市", | ||
1355 | + "province": "46", | ||
1356 | + "city": "01" | ||
1357 | + }, | ||
1358 | + { | ||
1359 | + "code": "460200", | ||
1360 | + "name": "三亚市", | ||
1361 | + "province": "46", | ||
1362 | + "city": "02" | ||
1363 | + }, | ||
1364 | + { | ||
1365 | + "code": "460300", | ||
1366 | + "name": "三沙市", | ||
1367 | + "province": "46", | ||
1368 | + "city": "03" | ||
1369 | + }, | ||
1370 | + { | ||
1371 | + "code": "460400", | ||
1372 | + "name": "儋州市", | ||
1373 | + "province": "46", | ||
1374 | + "city": "04" | ||
1375 | + }, | ||
1376 | + { | ||
1377 | + "code": "510100", | ||
1378 | + "name": "成都市", | ||
1379 | + "province": "51", | ||
1380 | + "city": "01" | ||
1381 | + }, | ||
1382 | + { | ||
1383 | + "code": "510300", | ||
1384 | + "name": "自贡市", | ||
1385 | + "province": "51", | ||
1386 | + "city": "03" | ||
1387 | + }, | ||
1388 | + { | ||
1389 | + "code": "510400", | ||
1390 | + "name": "攀枝花市", | ||
1391 | + "province": "51", | ||
1392 | + "city": "04" | ||
1393 | + }, | ||
1394 | + { | ||
1395 | + "code": "510500", | ||
1396 | + "name": "泸州市", | ||
1397 | + "province": "51", | ||
1398 | + "city": "05" | ||
1399 | + }, | ||
1400 | + { | ||
1401 | + "code": "510600", | ||
1402 | + "name": "德阳市", | ||
1403 | + "province": "51", | ||
1404 | + "city": "06" | ||
1405 | + }, | ||
1406 | + { | ||
1407 | + "code": "510700", | ||
1408 | + "name": "绵阳市", | ||
1409 | + "province": "51", | ||
1410 | + "city": "07" | ||
1411 | + }, | ||
1412 | + { | ||
1413 | + "code": "510800", | ||
1414 | + "name": "广元市", | ||
1415 | + "province": "51", | ||
1416 | + "city": "08" | ||
1417 | + }, | ||
1418 | + { | ||
1419 | + "code": "510900", | ||
1420 | + "name": "遂宁市", | ||
1421 | + "province": "51", | ||
1422 | + "city": "09" | ||
1423 | + }, | ||
1424 | + { | ||
1425 | + "code": "511000", | ||
1426 | + "name": "内江市", | ||
1427 | + "province": "51", | ||
1428 | + "city": "10" | ||
1429 | + }, | ||
1430 | + { | ||
1431 | + "code": "511100", | ||
1432 | + "name": "乐山市", | ||
1433 | + "province": "51", | ||
1434 | + "city": "11" | ||
1435 | + }, | ||
1436 | + { | ||
1437 | + "code": "511300", | ||
1438 | + "name": "南充市", | ||
1439 | + "province": "51", | ||
1440 | + "city": "13" | ||
1441 | + }, | ||
1442 | + { | ||
1443 | + "code": "511400", | ||
1444 | + "name": "眉山市", | ||
1445 | + "province": "51", | ||
1446 | + "city": "14" | ||
1447 | + }, | ||
1448 | + { | ||
1449 | + "code": "511500", | ||
1450 | + "name": "宜宾市", | ||
1451 | + "province": "51", | ||
1452 | + "city": "15" | ||
1453 | + }, | ||
1454 | + { | ||
1455 | + "code": "511600", | ||
1456 | + "name": "广安市", | ||
1457 | + "province": "51", | ||
1458 | + "city": "16" | ||
1459 | + }, | ||
1460 | + { | ||
1461 | + "code": "511700", | ||
1462 | + "name": "达州市", | ||
1463 | + "province": "51", | ||
1464 | + "city": "17" | ||
1465 | + }, | ||
1466 | + { | ||
1467 | + "code": "511800", | ||
1468 | + "name": "雅安市", | ||
1469 | + "province": "51", | ||
1470 | + "city": "18" | ||
1471 | + }, | ||
1472 | + { | ||
1473 | + "code": "511900", | ||
1474 | + "name": "巴中市", | ||
1475 | + "province": "51", | ||
1476 | + "city": "19" | ||
1477 | + }, | ||
1478 | + { | ||
1479 | + "code": "512000", | ||
1480 | + "name": "资阳市", | ||
1481 | + "province": "51", | ||
1482 | + "city": "20" | ||
1483 | + }, | ||
1484 | + { | ||
1485 | + "code": "513200", | ||
1486 | + "name": "阿坝藏族羌族自治州", | ||
1487 | + "province": "51", | ||
1488 | + "city": "32" | ||
1489 | + }, | ||
1490 | + { | ||
1491 | + "code": "513300", | ||
1492 | + "name": "甘孜藏族自治州", | ||
1493 | + "province": "51", | ||
1494 | + "city": "33" | ||
1495 | + }, | ||
1496 | + { | ||
1497 | + "code": "513400", | ||
1498 | + "name": "凉山彝族自治州", | ||
1499 | + "province": "51", | ||
1500 | + "city": "34" | ||
1501 | + }, | ||
1502 | + { | ||
1503 | + "code": "520100", | ||
1504 | + "name": "贵阳市", | ||
1505 | + "province": "52", | ||
1506 | + "city": "01" | ||
1507 | + }, | ||
1508 | + { | ||
1509 | + "code": "520200", | ||
1510 | + "name": "六盘水市", | ||
1511 | + "province": "52", | ||
1512 | + "city": "02" | ||
1513 | + }, | ||
1514 | + { | ||
1515 | + "code": "520300", | ||
1516 | + "name": "遵义市", | ||
1517 | + "province": "52", | ||
1518 | + "city": "03" | ||
1519 | + }, | ||
1520 | + { | ||
1521 | + "code": "520400", | ||
1522 | + "name": "安顺市", | ||
1523 | + "province": "52", | ||
1524 | + "city": "04" | ||
1525 | + }, | ||
1526 | + { | ||
1527 | + "code": "520500", | ||
1528 | + "name": "毕节市", | ||
1529 | + "province": "52", | ||
1530 | + "city": "05" | ||
1531 | + }, | ||
1532 | + { | ||
1533 | + "code": "520600", | ||
1534 | + "name": "铜仁市", | ||
1535 | + "province": "52", | ||
1536 | + "city": "06" | ||
1537 | + }, | ||
1538 | + { | ||
1539 | + "code": "522300", | ||
1540 | + "name": "黔西南布依族苗族自治州", | ||
1541 | + "province": "52", | ||
1542 | + "city": "23" | ||
1543 | + }, | ||
1544 | + { | ||
1545 | + "code": "522600", | ||
1546 | + "name": "黔东南苗族侗族自治州", | ||
1547 | + "province": "52", | ||
1548 | + "city": "26" | ||
1549 | + }, | ||
1550 | + { | ||
1551 | + "code": "522700", | ||
1552 | + "name": "黔南布依族苗族自治州", | ||
1553 | + "province": "52", | ||
1554 | + "city": "27" | ||
1555 | + }, | ||
1556 | + { | ||
1557 | + "code": "530100", | ||
1558 | + "name": "昆明市", | ||
1559 | + "province": "53", | ||
1560 | + "city": "01" | ||
1561 | + }, | ||
1562 | + { | ||
1563 | + "code": "530300", | ||
1564 | + "name": "曲靖市", | ||
1565 | + "province": "53", | ||
1566 | + "city": "03" | ||
1567 | + }, | ||
1568 | + { | ||
1569 | + "code": "530400", | ||
1570 | + "name": "玉溪市", | ||
1571 | + "province": "53", | ||
1572 | + "city": "04" | ||
1573 | + }, | ||
1574 | + { | ||
1575 | + "code": "530500", | ||
1576 | + "name": "保山市", | ||
1577 | + "province": "53", | ||
1578 | + "city": "05" | ||
1579 | + }, | ||
1580 | + { | ||
1581 | + "code": "530600", | ||
1582 | + "name": "昭通市", | ||
1583 | + "province": "53", | ||
1584 | + "city": "06" | ||
1585 | + }, | ||
1586 | + { | ||
1587 | + "code": "530700", | ||
1588 | + "name": "丽江市", | ||
1589 | + "province": "53", | ||
1590 | + "city": "07" | ||
1591 | + }, | ||
1592 | + { | ||
1593 | + "code": "530800", | ||
1594 | + "name": "普洱市", | ||
1595 | + "province": "53", | ||
1596 | + "city": "08" | ||
1597 | + }, | ||
1598 | + { | ||
1599 | + "code": "530900", | ||
1600 | + "name": "临沧市", | ||
1601 | + "province": "53", | ||
1602 | + "city": "09" | ||
1603 | + }, | ||
1604 | + { | ||
1605 | + "code": "532300", | ||
1606 | + "name": "楚雄彝族自治州", | ||
1607 | + "province": "53", | ||
1608 | + "city": "23" | ||
1609 | + }, | ||
1610 | + { | ||
1611 | + "code": "532500", | ||
1612 | + "name": "红河哈尼族彝族自治州", | ||
1613 | + "province": "53", | ||
1614 | + "city": "25" | ||
1615 | + }, | ||
1616 | + { | ||
1617 | + "code": "532600", | ||
1618 | + "name": "文山壮族苗族自治州", | ||
1619 | + "province": "53", | ||
1620 | + "city": "26" | ||
1621 | + }, | ||
1622 | + { | ||
1623 | + "code": "532800", | ||
1624 | + "name": "西双版纳傣族自治州", | ||
1625 | + "province": "53", | ||
1626 | + "city": "28" | ||
1627 | + }, | ||
1628 | + { | ||
1629 | + "code": "532900", | ||
1630 | + "name": "大理白族自治州", | ||
1631 | + "province": "53", | ||
1632 | + "city": "29" | ||
1633 | + }, | ||
1634 | + { | ||
1635 | + "code": "533100", | ||
1636 | + "name": "德宏傣族景颇族自治州", | ||
1637 | + "province": "53", | ||
1638 | + "city": "31" | ||
1639 | + }, | ||
1640 | + { | ||
1641 | + "code": "533300", | ||
1642 | + "name": "怒江傈僳族自治州", | ||
1643 | + "province": "53", | ||
1644 | + "city": "33" | ||
1645 | + }, | ||
1646 | + { | ||
1647 | + "code": "533400", | ||
1648 | + "name": "迪庆藏族自治州", | ||
1649 | + "province": "53", | ||
1650 | + "city": "34" | ||
1651 | + }, | ||
1652 | + { | ||
1653 | + "code": "540100", | ||
1654 | + "name": "拉萨市", | ||
1655 | + "province": "54", | ||
1656 | + "city": "01" | ||
1657 | + }, | ||
1658 | + { | ||
1659 | + "code": "540200", | ||
1660 | + "name": "日喀则市", | ||
1661 | + "province": "54", | ||
1662 | + "city": "02" | ||
1663 | + }, | ||
1664 | + { | ||
1665 | + "code": "540300", | ||
1666 | + "name": "昌都市", | ||
1667 | + "province": "54", | ||
1668 | + "city": "03" | ||
1669 | + }, | ||
1670 | + { | ||
1671 | + "code": "540400", | ||
1672 | + "name": "林芝市", | ||
1673 | + "province": "54", | ||
1674 | + "city": "04" | ||
1675 | + }, | ||
1676 | + { | ||
1677 | + "code": "540500", | ||
1678 | + "name": "山南市", | ||
1679 | + "province": "54", | ||
1680 | + "city": "05" | ||
1681 | + }, | ||
1682 | + { | ||
1683 | + "code": "540600", | ||
1684 | + "name": "那曲市", | ||
1685 | + "province": "54", | ||
1686 | + "city": "06" | ||
1687 | + }, | ||
1688 | + { | ||
1689 | + "code": "542500", | ||
1690 | + "name": "阿里地区", | ||
1691 | + "province": "54", | ||
1692 | + "city": "25" | ||
1693 | + }, | ||
1694 | + { | ||
1695 | + "code": "610100", | ||
1696 | + "name": "西安市", | ||
1697 | + "province": "61", | ||
1698 | + "city": "01" | ||
1699 | + }, | ||
1700 | + { | ||
1701 | + "code": "610200", | ||
1702 | + "name": "铜川市", | ||
1703 | + "province": "61", | ||
1704 | + "city": "02" | ||
1705 | + }, | ||
1706 | + { | ||
1707 | + "code": "610300", | ||
1708 | + "name": "宝鸡市", | ||
1709 | + "province": "61", | ||
1710 | + "city": "03" | ||
1711 | + }, | ||
1712 | + { | ||
1713 | + "code": "610400", | ||
1714 | + "name": "咸阳市", | ||
1715 | + "province": "61", | ||
1716 | + "city": "04" | ||
1717 | + }, | ||
1718 | + { | ||
1719 | + "code": "610500", | ||
1720 | + "name": "渭南市", | ||
1721 | + "province": "61", | ||
1722 | + "city": "05" | ||
1723 | + }, | ||
1724 | + { | ||
1725 | + "code": "610600", | ||
1726 | + "name": "延安市", | ||
1727 | + "province": "61", | ||
1728 | + "city": "06" | ||
1729 | + }, | ||
1730 | + { | ||
1731 | + "code": "610700", | ||
1732 | + "name": "汉中市", | ||
1733 | + "province": "61", | ||
1734 | + "city": "07" | ||
1735 | + }, | ||
1736 | + { | ||
1737 | + "code": "610800", | ||
1738 | + "name": "榆林市", | ||
1739 | + "province": "61", | ||
1740 | + "city": "08" | ||
1741 | + }, | ||
1742 | + { | ||
1743 | + "code": "610900", | ||
1744 | + "name": "安康市", | ||
1745 | + "province": "61", | ||
1746 | + "city": "09" | ||
1747 | + }, | ||
1748 | + { | ||
1749 | + "code": "611000", | ||
1750 | + "name": "商洛市", | ||
1751 | + "province": "61", | ||
1752 | + "city": "10" | ||
1753 | + }, | ||
1754 | + { | ||
1755 | + "code": "620100", | ||
1756 | + "name": "兰州市", | ||
1757 | + "province": "62", | ||
1758 | + "city": "01" | ||
1759 | + }, | ||
1760 | + { | ||
1761 | + "code": "620200", | ||
1762 | + "name": "嘉峪关市", | ||
1763 | + "province": "62", | ||
1764 | + "city": "02" | ||
1765 | + }, | ||
1766 | + { | ||
1767 | + "code": "620300", | ||
1768 | + "name": "金昌市", | ||
1769 | + "province": "62", | ||
1770 | + "city": "03" | ||
1771 | + }, | ||
1772 | + { | ||
1773 | + "code": "620400", | ||
1774 | + "name": "白银市", | ||
1775 | + "province": "62", | ||
1776 | + "city": "04" | ||
1777 | + }, | ||
1778 | + { | ||
1779 | + "code": "620500", | ||
1780 | + "name": "天水市", | ||
1781 | + "province": "62", | ||
1782 | + "city": "05" | ||
1783 | + }, | ||
1784 | + { | ||
1785 | + "code": "620600", | ||
1786 | + "name": "武威市", | ||
1787 | + "province": "62", | ||
1788 | + "city": "06" | ||
1789 | + }, | ||
1790 | + { | ||
1791 | + "code": "620700", | ||
1792 | + "name": "张掖市", | ||
1793 | + "province": "62", | ||
1794 | + "city": "07" | ||
1795 | + }, | ||
1796 | + { | ||
1797 | + "code": "620800", | ||
1798 | + "name": "平凉市", | ||
1799 | + "province": "62", | ||
1800 | + "city": "08" | ||
1801 | + }, | ||
1802 | + { | ||
1803 | + "code": "620900", | ||
1804 | + "name": "酒泉市", | ||
1805 | + "province": "62", | ||
1806 | + "city": "09" | ||
1807 | + }, | ||
1808 | + { | ||
1809 | + "code": "621000", | ||
1810 | + "name": "庆阳市", | ||
1811 | + "province": "62", | ||
1812 | + "city": "10" | ||
1813 | + }, | ||
1814 | + { | ||
1815 | + "code": "621100", | ||
1816 | + "name": "定西市", | ||
1817 | + "province": "62", | ||
1818 | + "city": "11" | ||
1819 | + }, | ||
1820 | + { | ||
1821 | + "code": "621200", | ||
1822 | + "name": "陇南市", | ||
1823 | + "province": "62", | ||
1824 | + "city": "12" | ||
1825 | + }, | ||
1826 | + { | ||
1827 | + "code": "622900", | ||
1828 | + "name": "临夏回族自治州", | ||
1829 | + "province": "62", | ||
1830 | + "city": "29" | ||
1831 | + }, | ||
1832 | + { | ||
1833 | + "code": "623000", | ||
1834 | + "name": "甘南藏族自治州", | ||
1835 | + "province": "62", | ||
1836 | + "city": "30" | ||
1837 | + }, | ||
1838 | + { | ||
1839 | + "code": "630100", | ||
1840 | + "name": "西宁市", | ||
1841 | + "province": "63", | ||
1842 | + "city": "01" | ||
1843 | + }, | ||
1844 | + { | ||
1845 | + "code": "630200", | ||
1846 | + "name": "海东市", | ||
1847 | + "province": "63", | ||
1848 | + "city": "02" | ||
1849 | + }, | ||
1850 | + { | ||
1851 | + "code": "632200", | ||
1852 | + "name": "海北藏族自治州", | ||
1853 | + "province": "63", | ||
1854 | + "city": "22" | ||
1855 | + }, | ||
1856 | + { | ||
1857 | + "code": "632300", | ||
1858 | + "name": "黄南藏族自治州", | ||
1859 | + "province": "63", | ||
1860 | + "city": "23" | ||
1861 | + }, | ||
1862 | + { | ||
1863 | + "code": "632500", | ||
1864 | + "name": "海南藏族自治州", | ||
1865 | + "province": "63", | ||
1866 | + "city": "25" | ||
1867 | + }, | ||
1868 | + { | ||
1869 | + "code": "632600", | ||
1870 | + "name": "果洛藏族自治州", | ||
1871 | + "province": "63", | ||
1872 | + "city": "26" | ||
1873 | + }, | ||
1874 | + { | ||
1875 | + "code": "632700", | ||
1876 | + "name": "玉树藏族自治州", | ||
1877 | + "province": "63", | ||
1878 | + "city": "27" | ||
1879 | + }, | ||
1880 | + { | ||
1881 | + "code": "632800", | ||
1882 | + "name": "海西蒙古族藏族自治州", | ||
1883 | + "province": "63", | ||
1884 | + "city": "28" | ||
1885 | + }, | ||
1886 | + { | ||
1887 | + "code": "640100", | ||
1888 | + "name": "银川市", | ||
1889 | + "province": "64", | ||
1890 | + "city": "01" | ||
1891 | + }, | ||
1892 | + { | ||
1893 | + "code": "640200", | ||
1894 | + "name": "石嘴山市", | ||
1895 | + "province": "64", | ||
1896 | + "city": "02" | ||
1897 | + }, | ||
1898 | + { | ||
1899 | + "code": "640300", | ||
1900 | + "name": "吴忠市", | ||
1901 | + "province": "64", | ||
1902 | + "city": "03" | ||
1903 | + }, | ||
1904 | + { | ||
1905 | + "code": "640400", | ||
1906 | + "name": "固原市", | ||
1907 | + "province": "64", | ||
1908 | + "city": "04" | ||
1909 | + }, | ||
1910 | + { | ||
1911 | + "code": "640500", | ||
1912 | + "name": "中卫市", | ||
1913 | + "province": "64", | ||
1914 | + "city": "05" | ||
1915 | + }, | ||
1916 | + { | ||
1917 | + "code": "650100", | ||
1918 | + "name": "乌鲁木齐市", | ||
1919 | + "province": "65", | ||
1920 | + "city": "01" | ||
1921 | + }, | ||
1922 | + { | ||
1923 | + "code": "650200", | ||
1924 | + "name": "克拉玛依市", | ||
1925 | + "province": "65", | ||
1926 | + "city": "02" | ||
1927 | + }, | ||
1928 | + { | ||
1929 | + "code": "650400", | ||
1930 | + "name": "吐鲁番市", | ||
1931 | + "province": "65", | ||
1932 | + "city": "04" | ||
1933 | + }, | ||
1934 | + { | ||
1935 | + "code": "650500", | ||
1936 | + "name": "哈密市", | ||
1937 | + "province": "65", | ||
1938 | + "city": "05" | ||
1939 | + }, | ||
1940 | + { | ||
1941 | + "code": "652300", | ||
1942 | + "name": "昌吉回族自治州", | ||
1943 | + "province": "65", | ||
1944 | + "city": "23" | ||
1945 | + }, | ||
1946 | + { | ||
1947 | + "code": "652700", | ||
1948 | + "name": "博尔塔拉蒙古自治州", | ||
1949 | + "province": "65", | ||
1950 | + "city": "27" | ||
1951 | + }, | ||
1952 | + { | ||
1953 | + "code": "652800", | ||
1954 | + "name": "巴音郭楞蒙古自治州", | ||
1955 | + "province": "65", | ||
1956 | + "city": "28" | ||
1957 | + }, | ||
1958 | + { | ||
1959 | + "code": "652900", | ||
1960 | + "name": "阿克苏地区", | ||
1961 | + "province": "65", | ||
1962 | + "city": "29" | ||
1963 | + }, | ||
1964 | + { | ||
1965 | + "code": "653000", | ||
1966 | + "name": "克孜勒苏柯尔克孜自治州", | ||
1967 | + "province": "65", | ||
1968 | + "city": "30" | ||
1969 | + }, | ||
1970 | + { | ||
1971 | + "code": "653100", | ||
1972 | + "name": "喀什地区", | ||
1973 | + "province": "65", | ||
1974 | + "city": "31" | ||
1975 | + }, | ||
1976 | + { | ||
1977 | + "code": "653200", | ||
1978 | + "name": "和田地区", | ||
1979 | + "province": "65", | ||
1980 | + "city": "32" | ||
1981 | + }, | ||
1982 | + { | ||
1983 | + "code": "654000", | ||
1984 | + "name": "伊犁哈萨克自治州", | ||
1985 | + "province": "65", | ||
1986 | + "city": "40" | ||
1987 | + }, | ||
1988 | + { | ||
1989 | + "code": "654200", | ||
1990 | + "name": "塔城地区", | ||
1991 | + "province": "65", | ||
1992 | + "city": "42" | ||
1993 | + }, | ||
1994 | + { | ||
1995 | + "code": "654300", | ||
1996 | + "name": "阿勒泰地区", | ||
1997 | + "province": "65", | ||
1998 | + "city": "43" | ||
1999 | + }, | ||
2000 | + { | ||
2001 | + "code": "429000", | ||
2002 | + "name": "省直辖县级行政区划", | ||
2003 | + "province": "42", | ||
2004 | + "city": "90" | ||
2005 | + }, | ||
2006 | + | ||
2007 | + | ||
2008 | + { | ||
2009 | + "code": "110000", | ||
2010 | + "name": "北京市", | ||
2011 | + "province": "11", | ||
2012 | + "city": "01" | ||
2013 | + }, | ||
2014 | + { | ||
2015 | + "code": "120000", | ||
2016 | + "name": "天津市", | ||
2017 | + "province": "12", | ||
2018 | + "city": "01" | ||
2019 | + }, | ||
2020 | + { | ||
2021 | + "code": "310000", | ||
2022 | + "name": "上海市", | ||
2023 | + "province": "31", | ||
2024 | + "city": "01" | ||
2025 | + }, | ||
2026 | + { | ||
2027 | + "code": "500000", | ||
2028 | + "name": "重庆市", | ||
2029 | + "province": "50", | ||
2030 | + "city": "01" | ||
2031 | + }, | ||
2032 | + { | ||
2033 | + "code": "810000", | ||
2034 | + "name": "香港特别行政区", | ||
2035 | + "province": "81", | ||
2036 | + "city": "01" | ||
2037 | + }, | ||
2038 | + { | ||
2039 | + "code": "820000", | ||
2040 | + "name": "澳门特别行政区", | ||
2041 | + "province": "82", | ||
2042 | + "city": "01" | ||
2043 | + }, | ||
2044 | + { | ||
2045 | + "code": "710000", | ||
2046 | + "name": "中国台湾", | ||
2047 | + "province": "71", | ||
2048 | + "city": "01" | ||
2049 | + } | ||
2050 | +] |
pkg/infrastructure/area/province.json
0 → 100644
1 | +[ | ||
2 | + { | ||
3 | + "code": "110000", | ||
4 | + "name": "北京", | ||
5 | + "province": "11" | ||
6 | + }, | ||
7 | + { | ||
8 | + "code": "120000", | ||
9 | + "name": "天津", | ||
10 | + "province": "12" | ||
11 | + }, | ||
12 | + { | ||
13 | + "code": "130000", | ||
14 | + "name": "河北省", | ||
15 | + "province": "13" | ||
16 | + }, | ||
17 | + { | ||
18 | + "code": "140000", | ||
19 | + "name": "山西省", | ||
20 | + "province": "14" | ||
21 | + }, | ||
22 | + { | ||
23 | + "code": "150000", | ||
24 | + "name": "内蒙古自治区", | ||
25 | + "province": "15" | ||
26 | + }, | ||
27 | + { | ||
28 | + "code": "210000", | ||
29 | + "name": "辽宁省", | ||
30 | + "province": "21" | ||
31 | + }, | ||
32 | + { | ||
33 | + "code": "220000", | ||
34 | + "name": "吉林省", | ||
35 | + "province": "22" | ||
36 | + }, | ||
37 | + { | ||
38 | + "code": "230000", | ||
39 | + "name": "黑龙江省", | ||
40 | + "province": "23" | ||
41 | + }, | ||
42 | + { | ||
43 | + "code": "310000", | ||
44 | + "name": "上海", | ||
45 | + "province": "31" | ||
46 | + }, | ||
47 | + { | ||
48 | + "code": "320000", | ||
49 | + "name": "江苏省", | ||
50 | + "province": "32" | ||
51 | + }, | ||
52 | + { | ||
53 | + "code": "330000", | ||
54 | + "name": "浙江省", | ||
55 | + "province": "33" | ||
56 | + }, | ||
57 | + { | ||
58 | + "code": "340000", | ||
59 | + "name": "安徽省", | ||
60 | + "province": "34" | ||
61 | + }, | ||
62 | + { | ||
63 | + "code": "350000", | ||
64 | + "name": "福建省", | ||
65 | + "province": "35" | ||
66 | + }, | ||
67 | + { | ||
68 | + "code": "360000", | ||
69 | + "name": "江西省", | ||
70 | + "province": "36" | ||
71 | + }, | ||
72 | + { | ||
73 | + "code": "370000", | ||
74 | + "name": "山东省", | ||
75 | + "province": "37" | ||
76 | + }, | ||
77 | + { | ||
78 | + "code": "410000", | ||
79 | + "name": "河南省", | ||
80 | + "province": "41" | ||
81 | + }, | ||
82 | + { | ||
83 | + "code": "420000", | ||
84 | + "name": "湖北省", | ||
85 | + "province": "42" | ||
86 | + }, | ||
87 | + { | ||
88 | + "code": "430000", | ||
89 | + "name": "湖南省", | ||
90 | + "province": "43" | ||
91 | + }, | ||
92 | + { | ||
93 | + "code": "440000", | ||
94 | + "name": "广东省", | ||
95 | + "province": "44" | ||
96 | + }, | ||
97 | + { | ||
98 | + "code": "450000", | ||
99 | + "name": "广西壮族自治区", | ||
100 | + "province": "45" | ||
101 | + }, | ||
102 | + { | ||
103 | + "code": "460000", | ||
104 | + "name": "海南省", | ||
105 | + "province": "46" | ||
106 | + }, | ||
107 | + { | ||
108 | + "code": "500000", | ||
109 | + "name": "重庆", | ||
110 | + "province": "50" | ||
111 | + }, | ||
112 | + { | ||
113 | + "code": "510000", | ||
114 | + "name": "四川省", | ||
115 | + "province": "51" | ||
116 | + }, | ||
117 | + { | ||
118 | + "code": "520000", | ||
119 | + "name": "贵州省", | ||
120 | + "province": "52" | ||
121 | + }, | ||
122 | + { | ||
123 | + "code": "530000", | ||
124 | + "name": "云南省", | ||
125 | + "province": "53" | ||
126 | + }, | ||
127 | + { | ||
128 | + "code": "540000", | ||
129 | + "name": "西藏自治区", | ||
130 | + "province": "54" | ||
131 | + }, | ||
132 | + { | ||
133 | + "code": "610000", | ||
134 | + "name": "陕西省", | ||
135 | + "province": "61" | ||
136 | + }, | ||
137 | + { | ||
138 | + "code": "620000", | ||
139 | + "name": "甘肃省", | ||
140 | + "province": "62" | ||
141 | + }, | ||
142 | + { | ||
143 | + "code": "630000", | ||
144 | + "name": "青海省", | ||
145 | + "province": "63" | ||
146 | + }, | ||
147 | + { | ||
148 | + "code": "640000", | ||
149 | + "name": "宁夏回族自治区", | ||
150 | + "province": "64" | ||
151 | + }, | ||
152 | + { | ||
153 | + "code": "650000", | ||
154 | + "name": "新疆维吾尔自治区", | ||
155 | + "province": "65" | ||
156 | + }, | ||
157 | + { | ||
158 | + "code": "710000", | ||
159 | + "name": "台湾", | ||
160 | + "province": "71" | ||
161 | + }, | ||
162 | + { | ||
163 | + "code": "810000", | ||
164 | + "name": "香港", | ||
165 | + "province": "81" | ||
166 | + }, | ||
167 | + { | ||
168 | + "code": "820000", | ||
169 | + "name": "澳门", | ||
170 | + "province": "82" | ||
171 | + } | ||
172 | +] |
@@ -109,7 +109,7 @@ func TestBSNBlockChain_UpToChain(t *testing.T) { | @@ -109,7 +109,7 @@ func TestBSNBlockChain_UpToChain(t *testing.T) { | ||
109 | PublicKey: pubKey, | 109 | PublicKey: pubKey, |
110 | PrivatePem: priK, | 110 | PrivatePem: priK, |
111 | } | 111 | } |
112 | - options := NewUpToChainOptions("table", "2", "149848948").WithDesc("desc") | 112 | + options := NewUpToChainOptions("table", "2", "149848948000").WithDesc("desc") |
113 | rsp, err := bc.UpToChain(options) | 113 | rsp, err := bc.UpToChain(options) |
114 | if err != nil { | 114 | if err != nil { |
115 | t.Fatal(err) | 115 | t.Fatal(err) |
@@ -142,6 +142,8 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | @@ -142,6 +142,8 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | ||
142 | Phone: user.Phone, | 142 | Phone: user.Phone, |
143 | UserName: user.UserName, | 143 | UserName: user.UserName, |
144 | OrgName: org.OrgName, | 144 | OrgName: org.OrgName, |
145 | + EmployeeType: user.GetEmployeeType(), | ||
146 | + IcCardNumber: user.IcCardNumber, | ||
145 | }, | 147 | }, |
146 | CreatedAt: time.Now(), | 148 | CreatedAt: time.Now(), |
147 | UpdatedAt: time.Now(), | 149 | UpdatedAt: time.Now(), |
@@ -202,6 +204,12 @@ func (ptr *PgBatchAddUserService) preCheck2(user *domain.BatchAddUserItem) error | @@ -202,6 +204,12 @@ func (ptr *PgBatchAddUserService) preCheck2(user *domain.BatchAddUserItem) error | ||
202 | if len(user.Phone) == 0 || len(user.Phone) != 11 { | 204 | if len(user.Phone) == 0 || len(user.Phone) != 11 { |
203 | return fmt.Errorf("导入的手机号不是有效手机号") | 205 | return fmt.Errorf("导入的手机号不是有效手机号") |
204 | } | 206 | } |
207 | + if len(user.EmployeeType) == 0 { | ||
208 | + return fmt.Errorf("导入的员工类型为空值") | ||
209 | + } | ||
210 | + if !(user.EmployeeType == "固定" || user.EmployeeType == "派遣" || user.EmployeeType == "临时") { | ||
211 | + return fmt.Errorf("导入的员工类型有误") | ||
212 | + } | ||
205 | return nil | 213 | return nil |
206 | } | 214 | } |
207 | 215 |
@@ -26,6 +26,9 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho | @@ -26,6 +26,9 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho | ||
26 | } | 26 | } |
27 | 27 | ||
28 | var err error | 28 | var err error |
29 | + var company *domain.Company | ||
30 | + companyRepository, _ := repository.NewCompanyRepository(s.transactionContext) | ||
31 | + | ||
29 | // 1.检查账号是否被注册过,一个手机号只能注册一家企业 | 32 | // 1.检查账号是否被注册过,一个手机号只能注册一家企业 |
30 | var userBase *domain.UserBase | 33 | var userBase *domain.UserBase |
31 | userBaseRepository, _ := repository.NewUserBaseRepository(s.transactionContext) | 34 | userBaseRepository, _ := repository.NewUserBaseRepository(s.transactionContext) |
@@ -33,17 +36,20 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho | @@ -33,17 +36,20 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho | ||
33 | userRepository, _ := repository.NewUserRepository(s.transactionContext) | 36 | userRepository, _ := repository.NewUserRepository(s.transactionContext) |
34 | if _, users, _ := userRepository.Find(map[string]interface{}{"userBaseId": userBase.UserBaseId}); len(users) > 0 { | 37 | if _, users, _ := userRepository.Find(map[string]interface{}{"userBaseId": userBase.UserBaseId}); len(users) > 0 { |
35 | for i := 0; i < len(users); i++ { | 38 | for i := 0; i < len(users); i++ { |
36 | - if users[i].UserType&domain.RoleTypeAdmin > 0 { | 39 | + if users[i].UserType&domain.RoleTypeAdmin > 0 && users[i].Company != nil { |
40 | + if company, err = companyRepository.FindOne(map[string]interface{}{"companyId": users[i].Company.CompanyId}); err != nil { | ||
41 | + return nil, err | ||
42 | + } else if company.Status != domain.CompanyUnauthenticated { | ||
37 | return nil, fmt.Errorf("该手机号已注册") | 43 | return nil, fmt.Errorf("该手机号已注册") |
38 | } | 44 | } |
39 | } | 45 | } |
40 | } | 46 | } |
41 | } | 47 | } |
48 | + } | ||
42 | 49 | ||
43 | // 2.企业名称检查 | 50 | // 2.企业名称检查 |
44 | - var company *domain.Company | ||
45 | - companyRepository, _ := repository.NewCompanyRepository(s.transactionContext) | ||
46 | - if company, err = companyRepository.FindOne(map[string]interface{}{"companyName": companyInfo.CompanyName}); err != nil && err != domain.ErrorNotFound { | 51 | + |
52 | + if company, err = companyRepository.FindOne(map[string]interface{}{"companyName": companyInfo.CompanyName, "statusNotIn": []int{domain.CompanyUnauthenticated}}); err != nil && err != domain.ErrorNotFound { | ||
47 | return nil, fmt.Errorf("该企业已经注册") | 53 | return nil, fmt.Errorf("该企业已经注册") |
48 | } else if company != nil && company.CompanyInfo.CompanyName == companyInfo.CompanyName { | 54 | } else if company != nil && company.CompanyInfo.CompanyName == companyInfo.CompanyName { |
49 | return nil, fmt.Errorf("该企业已经注册") | 55 | return nil, fmt.Errorf("该企业已经注册") |
@@ -57,7 +57,7 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain | @@ -57,7 +57,7 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain | ||
57 | // 普通账号需要验证 | 57 | // 普通账号需要验证 |
58 | // 1.用户编号唯一验证 用户编号在该企业内已存在,请重新输入 | 58 | // 1.用户编号唯一验证 用户编号在该企业内已存在,请重新输入 |
59 | // 2.当前企业内手机号唯一 手机号在该企业内已存在,请重新输入 | 59 | // 2.当前企业内手机号唯一 手机号在该企业内已存在,请重新输入 |
60 | - if newUser.UserType&(domain.UserTypeCompanyAdmin|domain.UserTypeVisitor) == 0 { | 60 | + if newUser.UserType&(domain.UserTypeCompanyAdmin|domain.UserTypeVisitor|domain.UserTypeOperationAdmin) == 0 { |
61 | if user, err = userRepository.FindOne(map[string]interface{}{"companyId": newUser.CompanyId, "organizationId": newUser.OrganizationId, "userCode": newUser.UserCode}); err == nil && user != nil { | 61 | if user, err = userRepository.FindOne(map[string]interface{}{"companyId": newUser.CompanyId, "organizationId": newUser.OrganizationId, "userCode": newUser.UserCode}); err == nil && user != nil { |
62 | return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入") | 62 | return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入") |
63 | } | 63 | } |
@@ -68,6 +68,13 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain | @@ -68,6 +68,13 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain | ||
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | + // 判断企业内IC卡号唯一 | ||
72 | + if len(newUser.Ext.IcCardNumber) > 0 { | ||
73 | + if u, e := userRepository.FindOne(map[string]interface{}{"companyId": newUser.CompanyId, "icCardNumber": newUser.Ext.IcCardNumber}); e == nil && u != nil { | ||
74 | + return nil, fmt.Errorf("IC卡号在该企业内已存在,请重新输入") | ||
75 | + } | ||
76 | + } | ||
77 | + | ||
71 | // 3.建账号 | 78 | // 3.建账号 |
72 | if userBase == nil { | 79 | if userBase == nil { |
73 | createUserAccountService, _ := NewPgCreateUserAccountService(ptr.transactionContext) | 80 | createUserAccountService, _ := NewPgCreateUserAccountService(ptr.transactionContext) |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/im" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/im" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/repository" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/repository" |
10 | + "time" | ||
10 | ) | 11 | ) |
11 | 12 | ||
12 | // PgImService 网易云信IM服务 | 13 | // PgImService 网易云信IM服务 |
@@ -53,6 +54,7 @@ func (ptr *PgImService) InitOrUpdateUserIMInfo(userId int64, flag int) (*domain. | @@ -53,6 +54,7 @@ func (ptr *PgImService) InitOrUpdateUserIMInfo(userId int64, flag int) (*domain. | ||
53 | userBase.Im.CsAccountId = fmt.Sprintf("%v", getRandomCustomerAccount(userId)) | 54 | userBase.Im.CsAccountId = fmt.Sprintf("%v", getRandomCustomerAccount(userId)) |
54 | } | 55 | } |
55 | userBase.Im.ImToken = checkImResponse.ImToken | 56 | userBase.Im.ImToken = checkImResponse.ImToken |
57 | + userBase.LastLogIn(time.Now()) | ||
56 | if userBase, err = userBaseRepository.Save(userBase); err != nil { | 58 | if userBase, err = userBaseRepository.Save(userBase); err != nil { |
57 | 59 | ||
58 | } | 60 | } |
@@ -19,19 +19,19 @@ type PgRoleAccessMenusService struct { | @@ -19,19 +19,19 @@ type PgRoleAccessMenusService struct { | ||
19 | // | 19 | // |
20 | // options 数据参数 | 20 | // options 数据参数 |
21 | // data 需要验证权限的数据 | 21 | // data 需要验证权限的数据 |
22 | -func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleId []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) { | 22 | +func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleIds []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) { |
23 | var err error | 23 | var err error |
24 | var menus []*domain.Menu | 24 | var menus []*domain.Menu |
25 | menuIdSet := hashset.New() | 25 | menuIdSet := hashset.New() |
26 | - if len(roleId) == 0 { | 26 | + if len(roleIds) == 0 { |
27 | return menus, nil | 27 | return menus, nil |
28 | } | 28 | } |
29 | 29 | ||
30 | // 1.角色有权限的菜单列表 | 30 | // 1.角色有权限的菜单列表 |
31 | roleRepository, _ := repository.NewRoleRepository(ptr.transactionContext) | 31 | roleRepository, _ := repository.NewRoleRepository(ptr.transactionContext) |
32 | - for i := range roleId { | 32 | + for i := range roleIds { |
33 | var role *domain.Role | 33 | var role *domain.Role |
34 | - if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleId[i]}); role == nil { | 34 | + if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleIds[i]}); role == nil { |
35 | continue | 35 | continue |
36 | } | 36 | } |
37 | // 只要当前登录组织的有权限菜单 | 37 | // 只要当前登录组织的有权限菜单 |
@@ -80,6 +80,13 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do | @@ -80,6 +80,13 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do | ||
80 | return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入") | 80 | return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入") |
81 | } | 81 | } |
82 | 82 | ||
83 | + // 判断企业内IC卡号唯一 | ||
84 | + if len(user.Ext.IcCardNumber) > 0 { | ||
85 | + if u, e := userRepository.FindOne(map[string]interface{}{"companyId": user.CompanyId, "icCardNumber": user.Ext.IcCardNumber}); e == nil && u != nil && u.UserId != user.UserId { | ||
86 | + return nil, fmt.Errorf("IC卡号在该企业内已存在,请重新输入") | ||
87 | + } | ||
88 | + } | ||
89 | + | ||
83 | user.UserRole = userRole | 90 | user.UserRole = userRole |
84 | user.UserOrg = userOrg | 91 | user.UserOrg = userOrg |
85 | if org != nil { | 92 | if org != nil { |
@@ -87,9 +94,13 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do | @@ -87,9 +94,13 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do | ||
87 | } | 94 | } |
88 | if dep != nil { | 95 | if dep != nil { |
89 | user.Ext.DepName = dep.OrgName | 96 | user.Ext.DepName = dep.OrgName |
97 | + } else { | ||
98 | + user.Ext.DepName = userInfo.DepartmentName | ||
90 | } | 99 | } |
91 | user.Ext.Phone = userBase.UserInfo.Phone | 100 | user.Ext.Phone = userBase.UserInfo.Phone |
92 | user.Ext.UserName = userBase.UserInfo.UserName | 101 | user.Ext.UserName = userBase.UserInfo.UserName |
102 | + //user.Ext.EmployeeType = userInfo.EmployeeType | ||
103 | + //user.Ext.IcCardNumber = userInfo.IcCardNumber | ||
93 | user.UpdatedAt = time.Now() | 104 | user.UpdatedAt = time.Now() |
94 | if err = user.SetEnableStatus(enableStatus); err != nil { | 105 | if err = user.SetEnableStatus(enableStatus); err != nil { |
95 | return nil, err | 106 | return nil, err |
@@ -13,8 +13,8 @@ type Company struct { | @@ -13,8 +13,8 @@ type Company struct { | ||
13 | CompanyConfig *domain.CompanyConfig `comment:"企业配置信息"` | 13 | CompanyConfig *domain.CompanyConfig `comment:"企业配置信息"` |
14 | // 企业基本信息 | 14 | // 企业基本信息 |
15 | CompanyInfo *domain.CompanyInfo `comment:"企业基本信息"` | 15 | CompanyInfo *domain.CompanyInfo `comment:"企业基本信息"` |
16 | - // 公司状态 1:已注册 2:待认证 3:已认证 | ||
17 | - Status int `comment:"公司状态 1:已注册 2:待认证 3:已认证"` | 16 | + // 公司状态 1:已注册(待审核) 2:已通过 3:已拒绝 |
17 | + Status int `comment:"公司状态 1:已注册(待审核) 2:已通过 3:已拒绝"` | ||
18 | // 创建时间 | 18 | // 创建时间 |
19 | CreatedAt time.Time `comment:"创建时间"` | 19 | CreatedAt time.Time `comment:"创建时间"` |
20 | // 更新时间 | 20 | // 更新时间 |
@@ -122,6 +122,9 @@ func (repository *CompanyRepository) FindOne(queryOptions map[string]interface{} | @@ -122,6 +122,9 @@ func (repository *CompanyRepository) FindOne(queryOptions map[string]interface{} | ||
122 | if v, ok := queryOptions["companyName"]; ok { | 122 | if v, ok := queryOptions["companyName"]; ok { |
123 | query.Where(fmt.Sprintf(`company_info @>'{"companyName":"%v"}'`, v)) | 123 | query.Where(fmt.Sprintf(`company_info @>'{"companyName":"%v"}'`, v)) |
124 | } | 124 | } |
125 | + if v, ok := queryOptions["statusNotIn"]; ok { | ||
126 | + query.Where("status not in (?)", pg.In(v)) | ||
127 | + } | ||
125 | if err := query.First(); err != nil { | 128 | if err := query.First(); err != nil { |
126 | if err.Error() == "pg: no rows in result set" { | 129 | if err.Error() == "pg: no rows in result set" { |
127 | return nil, domain.ErrorNotFound | 130 | return nil, domain.ErrorNotFound |
@@ -150,6 +153,10 @@ func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) ( | @@ -150,6 +153,10 @@ func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) ( | ||
150 | companys := make([]*domain.Company, 0) | 153 | companys := make([]*domain.Company, 0) |
151 | query := sqlbuilder.BuildQuery(tx.Model(&companyModels), queryOptions) | 154 | query := sqlbuilder.BuildQuery(tx.Model(&companyModels), queryOptions) |
152 | query.SetOffsetAndLimit(20) | 155 | query.SetOffsetAndLimit(20) |
156 | + query.SetWhereByQueryOption("status =?", "status") | ||
157 | + if v, ok := queryOptions["companyName"]; ok && len(v.(string)) > 0 { | ||
158 | + query.Where("company_info->>'companyName' like ?", fmt.Sprintf("%%%v%%", v)) | ||
159 | + } | ||
153 | query.SetOrderDirect("company_id", "DESC") | 160 | query.SetOrderDirect("company_id", "DESC") |
154 | if count, err := query.SelectAndCount(); err != nil { | 161 | if count, err := query.SelectAndCount(); err != nil { |
155 | return 0, companys, err | 162 | return 0, companys, err |
@@ -172,7 +172,10 @@ func (repository *UserBaseRepository) Find(queryOptions map[string]interface{}) | @@ -172,7 +172,10 @@ func (repository *UserBaseRepository) Find(queryOptions map[string]interface{}) | ||
172 | var userBaseModels []*models.UserBase | 172 | var userBaseModels []*models.UserBase |
173 | userBases := make([]*domain.UserBase, 0) | 173 | userBases := make([]*domain.UserBase, 0) |
174 | query := sqlbuilder.BuildQuery(tx.Model(&userBaseModels), queryOptions) | 174 | query := sqlbuilder.BuildQuery(tx.Model(&userBaseModels), queryOptions) |
175 | - query.SetOffsetAndLimit(20) | 175 | + query.SetOffsetAndLimit(20) //InUserBaseIds |
176 | + if v, ok := queryOptions["inUserBaseIds"]; ok && len(v.([]int64)) > 0 { | ||
177 | + query.Where(`user_base_id in (?)`, pg.In(v)) | ||
178 | + } | ||
176 | query.SetOrderDirect("user_base_id", "DESC") | 179 | query.SetOrderDirect("user_base_id", "DESC") |
177 | if count, err := query.SelectAndCount(); err != nil { | 180 | if count, err := query.SelectAndCount(); err != nil { |
178 | return 0, userBases, err | 181 | return 0, userBases, err |
@@ -169,6 +169,7 @@ func (repository *UserRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -169,6 +169,7 @@ func (repository *UserRepository) FindOne(queryOptions map[string]interface{}) ( | ||
169 | query.SetWhereByQueryOption("user_code = ?", "userCode") | 169 | query.SetWhereByQueryOption("user_code = ?", "userCode") |
170 | query.SetWhereByQueryOption("user_id != ?", "notEqualUserId") | 170 | query.SetWhereByQueryOption("user_id != ?", "notEqualUserId") |
171 | query.SetWhereByQueryOption("user_type & ? > 0", "userType") | 171 | query.SetWhereByQueryOption("user_type & ? > 0", "userType") |
172 | + query.SetWhereByQueryOption("ext->>'icCardNumber'=?", "icCardNumber") | ||
172 | if err := query.First(); err != nil { | 173 | if err := query.First(); err != nil { |
173 | if err.Error() == "pg: no rows in result set" { | 174 | if err.Error() == "pg: no rows in result set" { |
174 | return nil, fmt.Errorf("没有此资源") | 175 | return nil, fmt.Errorf("没有此资源") |
@@ -196,11 +197,21 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int | @@ -196,11 +197,21 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int | ||
196 | var userModels []*models.User | 197 | var userModels []*models.User |
197 | users := make([]*domain.User, 0) | 198 | users := make([]*domain.User, 0) |
198 | query := sqlbuilder.BuildQuery(tx.Model(&userModels), queryOptions) | 199 | query := sqlbuilder.BuildQuery(tx.Model(&userModels), queryOptions) |
200 | + | ||
201 | + if v, ok := queryOptions["distinctOnUserBaseId"]; ok && (v.(bool)) { | ||
202 | + query.DistinctOn("user_base_id") | ||
203 | + query.Order("user_base_id desc") | ||
204 | + } | ||
199 | query.SetWhereByQueryOption("company_id=?", "companyId") | 205 | query.SetWhereByQueryOption("company_id=?", "companyId") |
200 | query.SetWhereByQueryOption("organization_id=?", "organizationId") | 206 | query.SetWhereByQueryOption("organization_id=?", "organizationId") |
201 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int64)) > 0 { | 207 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int64)) > 0 { |
202 | query.Where(`organization_id in (?)`, pg.In(v)) | 208 | query.Where(`organization_id in (?)`, pg.In(v)) |
203 | } | 209 | } |
210 | + if v, ok := queryOptions["inCompanyIds"]; ok && len(v.([]int64)) > 0 { | ||
211 | + query.Where(`company_id in (?)`, pg.In(v)) | ||
212 | + } | ||
213 | + query.SetWhereByQueryOption("user_code = ?", "userCode") | ||
214 | + query.SetWhereByQueryOption("ext->>'icCardNumber' = ?", "icCardNumber") | ||
204 | query.SetWhereByQueryOption("user_base_id=?", "userBaseId") | 215 | query.SetWhereByQueryOption("user_base_id=?", "userBaseId") |
205 | query.SetWhereByQueryOption("(user_type & ?)>0", "userType") | 216 | query.SetWhereByQueryOption("(user_type & ?)>0", "userType") |
206 | query.SetWhereByQueryOption("enable_status=?", "enableStatus") | 217 | query.SetWhereByQueryOption("enable_status=?", "enableStatus") |
@@ -211,13 +222,16 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int | @@ -211,13 +222,16 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int | ||
211 | if v, ok := queryOptions["depName"]; ok && len(v.(string)) > 0 { | 222 | if v, ok := queryOptions["depName"]; ok && len(v.(string)) > 0 { |
212 | query.Where(fmt.Sprintf(`ext->>'depName' like '%%%v%%'`, v)) | 223 | query.Where(fmt.Sprintf(`ext->>'depName' like '%%%v%%'`, v)) |
213 | } | 224 | } |
225 | + if v, ok := queryOptions["orgName"]; ok && len(v.(string)) > 0 { | ||
226 | + query.Where(fmt.Sprintf(`ext->>'orgName' like '%%%v%%'`, v)) | ||
227 | + } | ||
214 | if v, ok := queryOptions["userName"]; ok && len(v.(string)) > 0 { | 228 | if v, ok := queryOptions["userName"]; ok && len(v.(string)) > 0 { |
215 | query.Where(fmt.Sprintf(`ext->>'userName' like '%%%v%%'`, v)) | 229 | query.Where(fmt.Sprintf(`ext->>'userName' like '%%%v%%'`, v)) |
216 | } | 230 | } |
217 | if v, ok := queryOptions["cooperationCompany"]; ok && len(v.(string)) > 0 { | 231 | if v, ok := queryOptions["cooperationCompany"]; ok && len(v.(string)) > 0 { |
218 | query.Where(fmt.Sprintf(`cooperation_info->>'cooperationCompany' like '%%%v%%'`, v)) | 232 | query.Where(fmt.Sprintf(`cooperation_info->>'cooperationCompany' like '%%%v%%'`, v)) |
219 | } | 233 | } |
220 | - query.SetOffsetAndLimit(20) | 234 | + query.SetOffsetAndLimit(domain.MaxQueryRow) |
221 | query.SetOrderDirect("user_id", "DESC") | 235 | query.SetOrderDirect("user_id", "DESC") |
222 | if count, err := query.SelectAndCount(); err != nil { | 236 | if count, err := query.SelectAndCount(); err != nil { |
223 | return 0, users, err | 237 | return 0, users, err |
1 | +package controllers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/web/beego" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/area" | ||
6 | +) | ||
7 | + | ||
8 | +type AreaController struct { | ||
9 | + beego.BaseController | ||
10 | +} | ||
11 | + | ||
12 | +func (controller *AreaController) ProvinceList() { | ||
13 | + data := area.Provinces() | ||
14 | + controller.Response(map[string]interface{}{ | ||
15 | + "provinces": data, | ||
16 | + }, nil) | ||
17 | +} | ||
18 | + | ||
19 | +func (controller *AreaController) ProvinceCities() { | ||
20 | + code := controller.GetString(":code") | ||
21 | + data := area.ProvinceCities(code) | ||
22 | + controller.Response(map[string]interface{}{ | ||
23 | + "cities": data, | ||
24 | + }, nil) | ||
25 | +} |
@@ -29,6 +29,26 @@ func (controller *CompanyController) UpdateCompany() { | @@ -29,6 +29,26 @@ func (controller *CompanyController) UpdateCompany() { | ||
29 | controller.Response(data, err) | 29 | controller.Response(data, err) |
30 | } | 30 | } |
31 | 31 | ||
32 | +func (controller *CompanyController) AuditCompany() { | ||
33 | + companyService := service.NewCompanyService(nil) | ||
34 | + updateCompanyCommand := &command.AuditCompanyCommand{} | ||
35 | + controller.Unmarshal(updateCompanyCommand) | ||
36 | + companyId, _ := controller.GetInt64(":companyId") | ||
37 | + updateCompanyCommand.CompanyId = companyId | ||
38 | + data, err := companyService.AuditCompany(updateCompanyCommand) | ||
39 | + controller.Response(data, err) | ||
40 | +} | ||
41 | + | ||
42 | +func (controller *CompanyController) EnableCompany() { | ||
43 | + companyService := service.NewCompanyService(nil) | ||
44 | + updateCompanyCommand := &command.EnableCompanyCommand{} | ||
45 | + controller.Unmarshal(updateCompanyCommand) | ||
46 | + companyId, _ := controller.GetInt64(":companyId") | ||
47 | + updateCompanyCommand.CompanyId = companyId | ||
48 | + data, err := companyService.EnableCompany(updateCompanyCommand) | ||
49 | + controller.Response(data, err) | ||
50 | +} | ||
51 | + | ||
32 | func (controller *CompanyController) GetCompany() { | 52 | func (controller *CompanyController) GetCompany() { |
33 | companyService := service.NewCompanyService(nil) | 53 | companyService := service.NewCompanyService(nil) |
34 | getCompanyQuery := &query.GetCompanyQuery{} | 54 | getCompanyQuery := &query.GetCompanyQuery{} |
@@ -51,6 +71,7 @@ func (controller *CompanyController) RemoveCompany() { | @@ -51,6 +71,7 @@ func (controller *CompanyController) RemoveCompany() { | ||
51 | func (controller *CompanyController) ListCompany() { | 71 | func (controller *CompanyController) ListCompany() { |
52 | companyService := service.NewCompanyService(nil) | 72 | companyService := service.NewCompanyService(nil) |
53 | listCompanyQuery := &query.ListCompanyQuery{} | 73 | listCompanyQuery := &query.ListCompanyQuery{} |
74 | + controller.Unmarshal(listCompanyQuery) | ||
54 | data, err := companyService.ListCompany(listCompanyQuery) | 75 | data, err := companyService.ListCompany(listCompanyQuery) |
55 | controller.Response(data, err) | 76 | controller.Response(data, err) |
56 | } | 77 | } |
1 | +package controllers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/web/beego" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/query" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/service" | ||
8 | +) | ||
9 | + | ||
10 | +type UserBaseController struct { | ||
11 | + beego.BaseController | ||
12 | +} | ||
13 | + | ||
14 | +func (controller *UserBaseController) SearchUser() { | ||
15 | + userService := service.NewUserBaseService(nil) | ||
16 | + listUserQuery := &query.ListUserQuery{} | ||
17 | + Must(controller.Unmarshal(listUserQuery)) | ||
18 | + listUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController) | ||
19 | + data, err := userService.SearchUser(listUserQuery) | ||
20 | + controller.Response(data, err) | ||
21 | +} | ||
22 | + | ||
23 | +func (controller *UserBaseController) BatchEnable() { | ||
24 | + userService := service.NewUserBaseService(nil) | ||
25 | + batchEnableCommand := &command.BatchEnableCommand{} | ||
26 | + controller.Unmarshal(batchEnableCommand) | ||
27 | + batchEnableCommand.OperateInfo = ParseOperateInfo(controller.BaseController) | ||
28 | + data, err := userService.BatchEnable(batchEnableCommand) | ||
29 | + controller.Response(data, err) | ||
30 | +} |
@@ -159,3 +159,23 @@ func (controller *UserController) SearchUser() { | @@ -159,3 +159,23 @@ func (controller *UserController) SearchUser() { | ||
159 | data, err := userService.ListUser(listUserQuery) | 159 | data, err := userService.ListUser(listUserQuery) |
160 | controller.Response(data, err) | 160 | controller.Response(data, err) |
161 | } | 161 | } |
162 | + | ||
163 | +func (controller *UserController) CreateAdminUser() { | ||
164 | + userService := service.NewUserService(nil) | ||
165 | + createUserCommand := &command.CreateAdminUserCommand{} | ||
166 | + Must(controller.Unmarshal(createUserCommand)) | ||
167 | + createUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController) | ||
168 | + data, err := userService.CreateAdminUser(createUserCommand) | ||
169 | + controller.Response(data, err) | ||
170 | +} | ||
171 | + | ||
172 | +func (controller *UserController) UpdateAdminUser() { | ||
173 | + userService := service.NewUserService(nil) | ||
174 | + updateUserCommand := &command.UpdateAdminUserCommand{} | ||
175 | + Must(controller.Unmarshal(updateUserCommand)) | ||
176 | + userId, _ := controller.GetInt64(":userId") | ||
177 | + updateUserCommand.UserId = userId | ||
178 | + updateUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController) | ||
179 | + data, err := userService.UpdateAdminUser(updateUserCommand) | ||
180 | + controller.Response(data, err) | ||
181 | +} |
pkg/port/beego/routers/area_router.go
0 → 100644
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego/controllers" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + web.Router("/area/province", &controllers.AreaController{}, "Get:ProvinceList") | ||
10 | + web.Router("/area/province/:code/cities", &controllers.AreaController{}, "Get:ProvinceCities") | ||
11 | +} |
@@ -14,6 +14,9 @@ func init() { | @@ -14,6 +14,9 @@ func init() { | ||
14 | web.Router("/company/:companyId/customize-menus/", &controllers.CompanyController{}, "Get:ListCompanyCustomizeMenus") | 14 | web.Router("/company/:companyId/customize-menus/", &controllers.CompanyController{}, "Get:ListCompanyCustomizeMenus") |
15 | web.Router("/company/:companyId/customize-menus", &controllers.CompanyController{}, "Put:UpdateCompanyCustomizeMenus") | 15 | web.Router("/company/:companyId/customize-menus", &controllers.CompanyController{}, "Put:UpdateCompanyCustomizeMenus") |
16 | 16 | ||
17 | + web.Router("/company/:companyId/audit", &controllers.CompanyController{}, "Post:AuditCompany") | ||
18 | + web.Router("/company/:companyId/enable", &controllers.CompanyController{}, "Post:EnableCompany") | ||
19 | + | ||
17 | // 适配web | 20 | // 适配web |
18 | //web.Router("/v1/web/menus/search", &controllers.CompanyController{}, "Post:SearchCompanyCustomizeMenus") | 21 | //web.Router("/v1/web/menus/search", &controllers.CompanyController{}, "Post:SearchCompanyCustomizeMenus") |
19 | //web.Router("/v1/web/menus", &controllers.CompanyController{}, "Put:AdapterUpdateCompanyCustomizeMenus") | 22 | //web.Router("/v1/web/menus", &controllers.CompanyController{}, "Put:AdapterUpdateCompanyCustomizeMenus") |
pkg/port/beego/routers/user_base_router.go
0 → 100644
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego/controllers" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + //web.Router("/user/", &controllers.UserController{}, "Post:CreateUser") | ||
10 | + //web.Router("/user/:userId", &controllers.UserController{}, "Put:UpdateUser") | ||
11 | + //web.Router("/user/:userId", &controllers.UserController{}, "Get:GetUser") | ||
12 | + //web.Router("/user/:userId", &controllers.UserController{}, "Delete:RemoveUser") | ||
13 | + web.Router("/user-base/search", &controllers.UserBaseController{}, "Post:SearchUser") | ||
14 | + //web.Router("/user/:userId/access-menus", &controllers.UserController{}, "Get:GetUserAccessMenus") | ||
15 | + //web.Router("/user/:userId/profile", &controllers.UserController{}, "Get:GetUserProfile") | ||
16 | + //web.Router("/user/batch-add", &controllers.UserController{}, "Post:BatchAdd") | ||
17 | + //web.Router("/user/batch-add2", &controllers.UserController{}, "Post:BatchAdd2") | ||
18 | + web.Router("/user-base/batch-enable", &controllers.UserBaseController{}, "Post:BatchEnable") | ||
19 | + //web.Router("/user/batch-reset-password", &controllers.UserController{}, "Post:BatchResetPassword") | ||
20 | + //web.Router("/user/:userId/base-info", &controllers.UserController{}, "Put:UpdateUsersBase") | ||
21 | + //web.Router("/user/cooperator", &controllers.UserController{}, "Post:CreateCooperator") | ||
22 | + //web.Router("/user/cooperator/:userId", &controllers.UserController{}, "Put:UpdateCooperator") | ||
23 | +} |
@@ -20,4 +20,7 @@ func init() { | @@ -20,4 +20,7 @@ func init() { | ||
20 | web.Router("/user/:userId/base-info", &controllers.UserController{}, "Put:UpdateUsersBase") | 20 | web.Router("/user/:userId/base-info", &controllers.UserController{}, "Put:UpdateUsersBase") |
21 | web.Router("/user/cooperator", &controllers.UserController{}, "Post:CreateCooperator") | 21 | web.Router("/user/cooperator", &controllers.UserController{}, "Post:CreateCooperator") |
22 | web.Router("/user/cooperator/:userId", &controllers.UserController{}, "Put:UpdateCooperator") | 22 | web.Router("/user/cooperator/:userId", &controllers.UserController{}, "Put:UpdateCooperator") |
23 | + | ||
24 | + web.Router("/admin-user/", &controllers.UserController{}, "Post:CreateAdminUser") | ||
25 | + web.Router("/admin-user/:userId", &controllers.UserController{}, "Put:UpdateAdminUser") | ||
23 | } | 26 | } |
@@ -12,10 +12,10 @@ import ( | @@ -12,10 +12,10 @@ import ( | ||
12 | 12 | ||
13 | func SetUp() { | 13 | func SetUp() { |
14 | go func() { | 14 | go func() { |
15 | - q := kq.MustNewQueue(NewConfig(constant.TOPIC_UP_BLOCK_CHAIN, constant.TOPIC_UP_BLOCK_CHAIN, 2), kq.WithHandle(FilterTopicHandler("up_block_chain", UpToChainHandler))) | 15 | + q := kq.MustNewQueue(NewConfig(constant.TOPIC_UP_BLOCK_CHAIN, constant.GROUP_UP_BLOCK_CHAIN, 1), kq.WithHandle(FilterTopicHandler("up_block_chain", UpToChainHandler))) |
16 | defer func() { | 16 | defer func() { |
17 | q.Stop() | 17 | q.Stop() |
18 | - log.Logger.Info(fmt.Sprintf("goqueue:%v stop!", constant.TOPIC_UP_BLOCK_CHAIN)) | 18 | + log.Logger.Info(fmt.Sprintf("goqueue:%v stop!", constant.GROUP_UP_BLOCK_CHAIN)) |
19 | }() | 19 | }() |
20 | q.Start() | 20 | q.Start() |
21 | }() | 21 | }() |
@@ -38,7 +38,7 @@ func NewConfig(topic, group string, consumers int) kq.KqConf { | @@ -38,7 +38,7 @@ func NewConfig(topic, group string, consumers int) kq.KqConf { | ||
38 | Offset: "first", | 38 | Offset: "first", |
39 | Conns: 1, | 39 | Conns: 1, |
40 | Consumers: consumers, | 40 | Consumers: consumers, |
41 | - Processors: 4, | 41 | + Processors: 1, |
42 | MinBytes: 10200, | 42 | MinBytes: 10200, |
43 | MaxBytes: 10485760, | 43 | MaxBytes: 10485760, |
44 | } | 44 | } |
@@ -10,11 +10,11 @@ import ( | @@ -10,11 +10,11 @@ import ( | ||
10 | ) | 10 | ) |
11 | 11 | ||
12 | func UpToChainHandler(k, v string) error { | 12 | func UpToChainHandler(k, v string) error { |
13 | - log.Logger.Debug(fmt.Sprintf("%s", v), map[string]interface{}{"handler": "UptoChain"}) | ||
14 | blockChainService := service.NewBlockChainService(nil) | 13 | blockChainService := service.NewBlockChainService(nil) |
15 | upChainCommand := &command.UpChainCommand{} | 14 | upChainCommand := &command.UpChainCommand{} |
16 | err := json.UnmarshalFromString(v, upChainCommand) | 15 | err := json.UnmarshalFromString(v, upChainCommand) |
17 | if err != nil { | 16 | if err != nil { |
17 | + log.Logger.Error(err.Error(), map[string]interface{}{"info": "UpToChainHandler 解析json错误", "data": v}) | ||
18 | return err | 18 | return err |
19 | } | 19 | } |
20 | _, err = blockChainService.UpChain(upChainCommand) | 20 | _, err = blockChainService.UpChain(upChainCommand) |
@@ -26,9 +26,12 @@ func FilterTopicHandler(topic string, handler func(string, string) error) func(s | @@ -26,9 +26,12 @@ func FilterTopicHandler(topic string, handler func(string, string) error) func(s | ||
26 | raw := &RawData{} | 26 | raw := &RawData{} |
27 | err := json.UnmarshalFromString(v, raw) | 27 | err := json.UnmarshalFromString(v, raw) |
28 | if err != nil { | 28 | if err != nil { |
29 | + log.Logger.Error("【GoQueue】消息解析错误:"+err.Error(), map[string]interface{}{"info": "FilterTopicHandler 解析json错误", "data": v}) | ||
29 | return err | 30 | return err |
30 | } | 31 | } |
32 | + log.Logger.Debug(fmt.Sprintf("【GoQueue】收到消息 Topic:%s", raw.Topic), map[string]interface{}{"data": v}) | ||
31 | if raw.Topic != topic { | 33 | if raw.Topic != topic { |
34 | + log.Logger.Debug(fmt.Sprintf("【GoQueue】 topic not equal get:%v want:%v", raw.Topic, topic), map[string]interface{}{"data": v}) | ||
32 | return nil | 35 | return nil |
33 | } | 36 | } |
34 | return handler(k, string(raw.Data)) | 37 | return handler(k, string(raw.Data)) |
-
请 注册 或 登录 后发表评论