作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !7
正在显示 52 个修改的文件 包含 3440 行增加35 行删除
... ... @@ -101,6 +101,8 @@ spec:
value: "8082"
- name: SERVICE_ENV
value: "dev"
- name: GROUP_UP_BLOCK_CHAIN
value: "allied_creation_message_dev"
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
... ...
... ... @@ -105,6 +105,8 @@ spec:
value: "8082"
- name: SERVICE_ENV
value: "test"
- name: GROUP_UP_BLOCK_CHAIN
value: "allied_creation_message_test"
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
... ...
... ... @@ -6,6 +6,7 @@ import (
"github.com/linmadan/egglib-go/log/logrus"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/area"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/redis"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
... ... @@ -30,6 +31,7 @@ func main() {
log.Logger.AddHook(bw)
goqueue.SetUp()
area.SetUp()
log.Logger.Info("server start!")
web.Run()
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
... ... @@ -21,6 +22,15 @@ type CompanySignUpCommand struct {
IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
// 法人
LegalPerson string `cname:"法人" json:"legalPerson" valid:"Required"`
// 社会信用代码
SocialCreditCode string `cname:"社会信用代码" json:"socialCreditCode" valid:"Required"`
// 营业执照所在地
BusinessLicenseAddress domain.BusinessLicenseAddress `cname:"营业执照所在地" json:"businessLicenseAddress" valid:"Required"`
// 营业执照-附件
BusinessLicenseAttachments []domain.Attachment `cname:"营业执照-附件" json:"businessLicenseAttachments" valid:"Required"`
}
func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -45,6 +45,12 @@ func (authService *AuthService) CompanySignUp(companySignUpCommand *command.Comp
Address: "",
IndustryCategory: companySignUpCommand.IndustryCategory,
RegisteredTime: time.Now(),
Legal: domain.Legal{
LegalPerson: companySignUpCommand.LegalPerson,
SocialCreditCode: companySignUpCommand.SocialCreditCode,
BusinessLicenseAddress: companySignUpCommand.BusinessLicenseAddress,
BusinessLicenseAttachments: companySignUpCommand.BusinessLicenseAttachments,
},
}
userInfo := &domain.UserInfo{
UserName: companySignUpCommand.Contacts,
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type AuditCompanyCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
// 审核状态
Status int `cname:"审核状态" json:"status" valid:"Required"`
// 备注
Remark string `cname:"备注" json:"remark" valid:"Required"`
}
func (updateCompanyCommand *AuditCompanyCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateCompanyCommand *AuditCompanyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateCompanyCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateCompanyCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type EnableCompanyCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
// 审核状态
Status int `cname:"审核状态" json:"status" valid:"Required"`
}
func (updateCompanyCommand *EnableCompanyCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateCompanyCommand *EnableCompanyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateCompanyCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateCompanyCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -10,9 +10,13 @@ import (
type ListCompanyQuery struct {
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
Offset int `cname:"查询偏离量" json:"offset,omitempty"`
// 查询限制
Limit int `cname:"查询限制" json:"limit" valid:"Required"`
Limit int `cname:"查询限制" json:"limit,omitempty"`
// 状态
Status int `cname:"状态" json:"status,omitempty"`
// 企业名称
CompanyName string `cname:"企业名称" json:"companyName,omitempty"`
}
func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -10,6 +10,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/common"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils"
"strconv"
)
... ... @@ -113,7 +114,7 @@ func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCo
} else {
companyRepository = value
}
if count, companys, err := companyRepository.Find(tool_funs.SimpleStructToMap(listCompanyQuery)); err != nil {
if count, companys, err := companyRepository.Find(utils.ObjectToMap(listCompanyQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -279,6 +280,92 @@ func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *comman
}
}
// 审核企业
func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var companyRepository domain.CompanyRepository
if value, err := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyRepository = value
}
company, err := companyRepository.FindOne(map[string]interface{}{"companyId": cmd.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if company == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(cmd.CompanyId)))
}
if err := company.Audit(cmd.Status, cmd.Remark); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if company, err := companyRepository.Save(company); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return company, nil
}
}
// 禁用启用企业
func (companyService *CompanyService) EnableCompany(cmd *command.EnableCompanyCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var companyRepository domain.CompanyRepository
if value, err := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyRepository = value
}
company, err := companyRepository.FindOne(map[string]interface{}{"companyId": cmd.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if company == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(cmd.CompanyId)))
}
if err := company.Enable(cmd.Status); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if company, err := companyRepository.Save(company); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return company, nil
}
}
// 更新自定义菜单
func (companyService *CompanyService) UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand *command.UpdateCompanyCustomizeMenusCommand) (interface{}, error) {
if err := updateCompanyCustomizeMenusCommand.ValidateCommand(); err != nil {
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
"time"
)
type CreateAdminUserCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId"`
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType int `cname:"用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)" json:"userType" valid:"Required"`
// 用户编号 企业内标识
UserCode string `cname:"用户编号 企业内标识" json:"userCode"`
// 组织机构
OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty"`
// 所属部门
DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty"`
// 用户关联的组织
UserOrg []int64 `cname:"用户关联的组织" json:"userOrg,omitempty"`
// 用户关联的角色
UserRole []int64 `cname:"用户关联的角色" json:"userRole,omitempty"`
// 共创公司
CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"`
// 共创到期时间 (yyyy-MM-dd)
CooperationDeadline time.Time `cname:"共创到期时间 (yyyy-MM-dd)" json:"cooperationDeadline,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `cname:"启用状态(启用:1 禁用:2)" json:"enableStatus,omitempty" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
// 用户姓名
UserName string `cname:"用户姓名" json:"userName" valid:"Required"`
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 头像
Avatar string `cname:"头像" json:"avatar"`
// 邮箱
Email string `cname:"邮箱" json:"email"`
// 运营管理扩展
// 部门
DepartmentName string `cname:"部门" json:"departmentName"`
}
func (createUserCommand *CreateAdminUserCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createUserCommand *CreateAdminUserCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createUserCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(createUserCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -41,6 +41,14 @@ type CreateUserCommand struct {
Avatar string `cname:"头像" json:"avatar"`
// 邮箱
Email string `cname:"邮箱" json:"email"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType int `cname:"员工类型" json:"employeeType" valid:"Required"`
// IC卡号
IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"`
// 运营管理扩展
// 部门
DepartmentName string `cname:"部门" json:"departmentName"`
}
func (createUserCommand *CreateUserCommand) Valid(validation *validation.Validation) {
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
"time"
"github.com/beego/beego/v2/core/validation"
)
type UpdateAdminUserCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
// 组织机构
OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty"`
// 所属部门
DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty"`
// 用户关联的组织
UserOrg []int64 `cname:"用户关联的组织" json:"userOrg,omitempty"`
// 用户关联的角色
UserRole []int64 `cname:"用户关联的角色" json:"userRole,omitempty"`
// 共创公司
CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"`
// 共创到期时间 (yyyy-MM-dd)
CooperationDeadline time.Time `cname:"共创到期时间 (yyyy-MM-dd)" json:"cooperationDeadline,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `cname:"启用状态(启用:1 禁用:2)" json:"enableStatus,omitempty"`
// 用户姓名
UserName string `cname:"用户姓名" json:"userName" valid:"Required"`
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 头像
Avatar string `cname:"头像" json:"avatar"`
// 邮箱
Email string `cname:"邮箱" json:"email"`
// 运营管理扩展
// 部门
DepartmentName string `cname:"部门" json:"departmentName"`
}
func (updateUserCommand *UpdateAdminUserCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateUserCommand *UpdateAdminUserCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateUserCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateUserCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -36,6 +36,14 @@ type UpdateUserCommand struct {
Avatar string `cname:"头像" json:"avatar"`
// 邮箱
Email string `cname:"邮箱" json:"email"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType int `name:"员工类型" json:"employeeType" valid:"Required"`
// IC卡号
IcCardNumber string `json:"icCardNumber,omitempty"`
// 运营管理扩展
// 部门
DepartmentName string `cname:"部门" json:"departmentName"`
}
func (updateUserCommand *UpdateUserCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -73,7 +73,15 @@ func (dto *UserDto) LoadDto(user *domain.User, company *domain.Company) error {
dto.UserInfo = &domain.UserInfo{
UserName: user.Ext.UserName,
Phone: user.Ext.Phone,
IcCardNumber: user.Ext.IcCardNumber,
EmployeeType: user.Ext.EmployeeType,
}
} else {
dto.UserInfo.IcCardNumber = user.Ext.IcCardNumber
dto.UserInfo.EmployeeType = user.Ext.EmployeeType
}
if dto.UserInfo.EmployeeType == 0 {
dto.UserInfo.EmployeeType = 1
}
if len(dto.UserRole) == 0 {
dto.UserRole = make([]*domain.Role, 0)
... ...
... ... @@ -41,6 +41,12 @@ type ListUserQuery struct {
EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"`
// 状态(1:启用 2:禁用 3:注销)
InEnableStatus []int `cname:"状态(1:启用 2:禁用 3:注销)" json:"inEnableStatus,omitempty"`
// 在企业范围内
InCompanyIds []int64 `cname:"在企业范围内" json:"inCompanyIds,omitempty"`
// 用户编号 企业内标识
UserCode string `cname:"用户编号" json:"userCode,omitempty"`
// IC卡号
IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"`
}
func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -273,6 +273,9 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser
Ext: &domain.Ext{
Phone: createUserCommand.Phone,
UserName: createUserCommand.UserName,
DepName: createUserCommand.DepartmentName,
IcCardNumber: createUserCommand.IcCardNumber,
EmployeeType: createUserCommand.EmployeeType,
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
... ... @@ -536,10 +539,12 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in
_, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId)
_, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId)
_, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId)
if dep != nil && org != nil && company != nil && userBase != nil {
if dep != nil && org != nil && company != nil {
user.Department = dep.ConvDep()
user.Organization = org.CloneSample()
user.Company = company.CloneSample()
}
if userBase != nil {
user.UserInfo = userBase.UserInfo
user.Favorite = userBase.Favorite
}
... ... @@ -702,7 +707,7 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser
defer func() {
transactionContext.RollbackTransaction()
}()
_, user, err := factory.FastPgUser(transactionContext, updateUserCommand.UserId, factory.WithDataAuthRequired(), factory.WithOperator(updateUserCommand.OperateInfo))
_, user, err := factory.FastPgUser(transactionContext, updateUserCommand.UserId, factory.WithOperator(updateUserCommand.OperateInfo)) //, factory.WithDataAuthRequired()
if err != nil {
return nil, err
}
... ... @@ -724,7 +729,10 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser
Phone: updateUserCommand.Phone,
Avatar: updateUserCommand.Avatar,
Email: updateUserCommand.Email,
DepartmentName: updateUserCommand.DepartmentName,
}
user.Ext.EmployeeType = updateUserCommand.EmployeeType
user.Ext.IcCardNumber = updateUserCommand.IcCardNumber
updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -853,6 +861,123 @@ func (userService *UserService) UpdateFavorite(updateFavoriteCommand *command.Up
return struct{}{}, nil
}
// 创建
func (userService *UserService) CreateAdminUser(createUserCommand *command.CreateAdminUserCommand) (interface{}, error) {
if err := createUserCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
nweUserInfo := &domain.UserInfo{
UserName: createUserCommand.UserName,
Phone: createUserCommand.Phone,
Avatar: createUserCommand.Avatar,
Email: createUserCommand.Email,
DepartmentName: createUserCommand.DepartmentName,
}
var sampleUserOrg = make([]*domain.Org, 0)
var sampleUserRole = make([]*domain.Role, 0)
newUser := &domain.User{
CompanyId: createUserCommand.CompanyId,
UserType: createUserCommand.UserType,
UserCode: createUserCommand.UserCode,
OrganizationId: createUserCommand.OrganizationId,
DepartmentId: createUserCommand.DepartmentId,
UserOrg: sampleUserOrg,
UserRole: sampleUserRole,
FavoriteMenus: []string{},
//CooperationInfo: &domain.CooperationInfo{},
UserInfo: nweUserInfo,
EnableStatus: createUserCommand.EnableStatus,
Ext: &domain.Ext{
Phone: createUserCommand.Phone,
UserName: createUserCommand.UserName,
DepName: createUserCommand.DepartmentName,
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
var user *domain.User
createUserService, _ := factory.CreatePgCreateUserService(map[string]interface{}{
"transactionContext": transactionContext,
})
if user, err = createUserService.CreateUser(nil, newUser, createUserCommand.Password); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
userDto := &dto.UserDto{}
if err := userDto.LoadDto(user, nil); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return userDto, nil
}
// 更新
func (userService *UserService) UpdateAdminUser(updateUserCommand *command.UpdateAdminUserCommand) (interface{}, error) {
if err := updateUserCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
_, user, err := factory.FastPgUser(transactionContext, updateUserCommand.UserId, factory.WithDataAuthRequired(), factory.WithOperator(updateUserCommand.OperateInfo))
if err != nil {
return nil, err
}
user.DepartmentId = updateUserCommand.DepartmentId
user.OrganizationId = updateUserCommand.OrganizationId
var userOrg = make([]*domain.Org, 0)
for i := range updateUserCommand.UserOrg {
userOrg = append(userOrg, &domain.Org{OrgId: updateUserCommand.UserOrg[i]})
}
user.UserOrg = userOrg
var userRole = make([]*domain.Role, 0)
for i := range updateUserCommand.UserRole {
userRole = append(userRole, &domain.Role{RoleId: updateUserCommand.UserRole[i]})
}
user.UserRole = userRole
userInfo := &domain.UserInfo{
UserName: updateUserCommand.UserName,
Phone: updateUserCommand.Phone,
Avatar: updateUserCommand.Avatar,
Email: updateUserCommand.Email,
DepartmentName: updateUserCommand.DepartmentName,
}
updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{
"transactionContext": transactionContext,
})
if user, err = updateUserService.UpdateUser(nil, user, userInfo, user.EnableStatus); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
userDto := &dto.UserDto{}
if err := userDto.LoadDto(user, nil); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return userDto, nil
}
func NewUserService(options map[string]interface{}) *UserService {
newUserService := &UserService{}
return newUserService
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchEnableCommand struct {
OperateInfo *domain.OperateInfo `json:"-"`
UserBaseIds []int64 `cname:"用户id列表" json:"userBaseIds" valid:"Required"`
// 启用状态(启用:1 禁用:2 注销:3)
EnableStatus int `cname:"启用状态(启用:1 禁用:2 注销:3)" json:"enableStatus" valid:"Required"`
}
func (batchEnableCommand *BatchEnableCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
if !(batchEnableCommand.EnableStatus == int(domain.UserStatusEnable) || batchEnableCommand.EnableStatus == int(domain.UserStatusDisable)) {
validation.SetError("CustomValid", "非法启用状态")
}
}
func (batchEnableCommand *BatchEnableCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(batchEnableCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(batchEnableCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"time"
)
type UserBaseDto struct {
// 用户基础数据id
UserBaseId int64 `json:"userBaseId,omitempty"`
// 手机号码
//Account string `json:"phone,omitempty"`
// 最后登录时间
LastLogIn string `json:"lastLogIn"`
// 用户信息 (冗余,数据存在userBase里面)
UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
// 账号状态 1:正常 2.禁用 3:注销
Status int `json:"status,omitempty"`
// 推荐人
Referer string `json:"referer"`
// 关联的用户 (冗余)
// RelatedUsers []int64 `json:"relatedUsers,omitempty"`
// 用户关联的组织
UserOrg []interface{} `json:"userOrg"`
// 创建时间
RegistrationDate string `json:"registrationDate,omitempty"`
}
func (dto *UserBaseDto) LoadDto(userBase *domain.UserBase, relateUsers []*domain.User) error {
dto.UserBaseId = userBase.UserBaseId
//dto.Account = userBase.Account
dto.LastLogIn = ""
dto.UserInfo = userBase.UserInfo
if userBase.Favorite != nil {
if userBase.Favorite.LastLogInAt > 0 {
t := time.Unix(userBase.Favorite.LastLogInAt, 0)
dto.LastLogIn = t.Format("2006-01-02 15:04:05")
}
dto.Referer = userBase.Favorite.Referer
}
dto.Status = userBase.Status
for i := range relateUsers {
dto.UserOrg = append(dto.UserOrg, map[string]interface{}{
"orgId": relateUsers[i].OrganizationId,
"orgName": relateUsers[i].Ext.OrgName,
})
}
dto.RegistrationDate = userBase.CreatedAt.Format("2006-01-02")
return nil
}
... ...
package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ListUserQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset"`
// 查询限制
Limit int `cname:"查询限制" json:"limit"`
// 用户姓名
UserName string `cname:"用户姓名" json:"userName,omitempty"`
// 在用户列表内
InUserBaseIds []int64 `cname:"用户姓名" json:"inUserBaseIds,omitempty"`
// 所属组织
OrgName string `cname:"所属组织" json:"orgName,omitempty"`
// 关闭查询限制
DisableLimit bool `cname:"关闭查询限制" json:"disableLimit,omitempty"`
// 获取组织
FetchOrgBelong bool `cname:"获取组织" json:"fetchOrgBelong,omitempty"`
}
func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listUserQuery *ListUserQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listUserQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listUserQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils"
)
type UserBaseService struct {
}
// 返回列表
func (userService *UserBaseService) SearchUser(listUserQuery *query.ListUserQuery) (interface{}, error) {
if err := listUserQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var count int64
var userBases []*domain.UserBase
userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0)
userRepository, _, _ := factory.FastPgUser(transactionContext, 0)
_, users, err := userRepository.Find(map[string]interface{}{
"limit": listUserQuery.Limit,
"offset": listUserQuery.Offset,
"orgName": listUserQuery.OrgName,
"userName": listUserQuery.UserName,
"distinctOnUserBaseId": true,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var result = make([]*dto.UserBaseDto, 0)
if len(users) > 0 {
var userBaseIds []int64
for i := range users {
userBaseIds = append(userBaseIds, users[i].UserBaseId)
}
listUserQuery.InUserBaseIds = userBaseIds
queryOptions := utils.ObjectToMap(listUserQuery)
count, userBases, err = userBaseRepository.Find(queryOptions)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range userBases {
u := userBases[i]
var relateUsers []*domain.User
if listUserQuery.FetchOrgBelong && len(u.RelatedUsers) > 0 {
for i := range u.RelatedUsers {
relateUser, _ := userRepository.FindOne(map[string]interface{}{"userId": u.RelatedUsers[i]})
if relateUser != nil {
relateUsers = append(relateUsers, relateUser)
}
}
}
userBaseDto := &dto.UserBaseDto{}
userBaseDto.LoadDto(u, relateUsers)
result = append(result, userBaseDto)
}
}
return map[string]interface{}{
"count": count,
"users": result,
}, nil
}
// 批量修改启用状态
func (userService *UserBaseService) BatchEnable(batchEnableCommand *command.BatchEnableCommand) (interface{}, error) {
if err := batchEnableCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
userRepository, _, err := factory.FastPgUserBase(transactionContext, 0)
if err != nil {
return nil, err
}
for i := 0; i < len(batchEnableCommand.UserBaseIds); i++ {
if user, err := userRepository.FindOne(map[string]interface{}{"userBaseId": batchEnableCommand.UserBaseIds[i]}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := user.SetEnableStatus(batchEnableCommand.EnableStatus); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if _, err := userRepository.Save(user); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct{}{}, nil
}
func NewUserBaseService(options map[string]interface{}) *UserBaseService {
newUserService := &UserBaseService{}
return newUserService
}
... ...
... ... @@ -9,18 +9,26 @@ var (
TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage"
// kafka topic up_block_chain
TOPIC_UP_BLOCK_CHAIN = "allied_creation_message"
// 区块链消息 消费组
GROUP_UP_BLOCK_CHAIN = "allied_creation_message"
// 是否启用日志收集 (本地不启用)
ENABLE_KAFKA_LOG = false
)
func init() {
//if os.Getenv("KAFKA_HOST") != "" {
// POSTGRESQL_HOST = os.Getenv("KAFKA_HOST")
//}
if os.Getenv("KAFKA_HOST") != "" {
KAFKA_HOST = os.Getenv("KAFKA_HOST")
}
//if os.Getenv("TOPIC_LOG_STASH") != "" {
// POSTGRESQL_PORT = os.Getenv("TOPIC_LOG_STASH")
//}
if os.Getenv("ENABLE_KAFKA_LOG") != "" {
ENABLE_KAFKA_LOG = true
}
if os.Getenv("TOPIC_UP_BLOCK_CHAIN") != "" {
TOPIC_UP_BLOCK_CHAIN = os.Getenv("TOPIC_UP_BLOCK_CHAIN")
}
if os.Getenv("GROUP_UP_BLOCK_CHAIN") != "" {
GROUP_UP_BLOCK_CHAIN = os.Getenv("GROUP_UP_BLOCK_CHAIN")
}
}
... ...
package domain
// Attachment 附件对象
type Attachment struct {
// 附件文件类型,jpg,pdf
FileType string `json:"fileType"`
// 附件名称
Name string `json:"name"`
// 附件地址
Url string `json:"url"`
// 附件文件大小,保存KB单位
FileSize int64 `json:"fileSize"`
}
... ...
... ... @@ -6,11 +6,12 @@ import (
"time"
)
// 公司状态状态 1:已注册 2:待认证 3:已认证
// 公司状态状态 1:已注册 2:已通过 3:已拒绝 4:禁用
const (
CompanyRegistered = iota + 1
CompanyUnauthenticated
CompanyAuthenticated
CompanyUnauthenticated
CompanyUnAvailable
)
// 企业信息 (base)
... ... @@ -21,7 +22,7 @@ type Company struct {
CompanyConfig *CompanyConfig `json:"companyConfig"`
// 企业基本信息
CompanyInfo *CompanyInfo `json:"companyInfo"`
// 公司状态 1:已注册 2:待认证 3:已认证
// 公司状态 1:已注册(待审核) 2:已通过 3:已拒绝
Status int `json:"status"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
... ... @@ -102,6 +103,36 @@ func (company *Company) ToCompanyVisible() *CompanyVisible {
}
}
// 公司审核
func (company *Company) Audit(status int, remark string) error {
if company.Status != CompanyRegistered {
return fmt.Errorf("公司已审核")
}
if !(status == CompanyAuthenticated || status == CompanyUnauthenticated) {
return fmt.Errorf("审核状态有误")
}
company.Status = status
company.CompanyInfo.Remark = remark
company.Update(map[string]interface{}{})
return nil
}
// 公司启用禁用
func (company *Company) Enable(status int) error {
if company.Status == CompanyRegistered {
return fmt.Errorf("公司待审核")
}
if company.Status == status {
return nil
}
if !(status == CompanyAuthenticated || status == CompanyUnAvailable) {
return fmt.Errorf("状态有误 2:启用 4:禁用")
}
company.Status = status
company.Update(map[string]interface{}{})
return nil
}
/***** 2.缓存模块 *****/
func (company *Company) CacheKeyFunc() string {
... ...
... ... @@ -14,10 +14,29 @@ type CompanyInfo struct {
Address string `json:"address,omitempty"`
// 所属行业
IndustryCategory string `json:"industryCategory,omitempty"`
// 联系人
//Contacts string `json:"contacts"`
// 注册时间
RegisteredTime time.Time `json:"registeredTime,omitempty"`
// 状态 1:已注册 2:待认证 3:已认证
//Status int `json:"status"`
// 法律相关
Legal Legal `json:"legal"`
// 备注信息(审核时使用)
Remark string `json:"备注"`
}
// 法律相关
type Legal struct {
// 法人
LegalPerson string `json:"legalPerson"`
// 社会信用代码
SocialCreditCode string `json:"socialCreditCode"`
// 营业执照所在地
BusinessLicenseAddress BusinessLicenseAddress `json:"businessLicenseAddress"`
// 营业执照-附件
BusinessLicenseAttachments []Attachment `json:"businessLicenseAttachments"`
}
// 营业执照所在地
type BusinessLicenseAddress struct {
Province string `json:"province"`
City string `json:"city"`
Address string `json:"address"`
}
... ...
... ... @@ -12,4 +12,9 @@ type Ext struct {
DepName string `json:"depName,omitempty"`
// 父级部门名称
ParentDepName string `json:"parentDepName,omitempty"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType int `json:"employeeType,omitempty"`
// IC卡号
IcCardNumber string `json:"icCardNumber,omitempty"`
}
... ...
... ... @@ -15,6 +15,7 @@ const (
UserTypeEmployee = 1
UserTypeCooperation = 2
UserTypeVisitor = 4 // 游客
UserTypeOperationAdmin = 8 // 运营管理员
UserTypeCompanyAdmin = 1024
)
... ... @@ -313,6 +314,10 @@ type BatchAddUserItem struct {
CooperationCompany string `json:"cooperationCompany"`
// 共创到期时间 (yyyy-MM-dd) cooperationDeadline
CooperationDeadline string `json:"cooperationDeadline"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType string `json:"employeeType,omitempty"`
// IC卡号
IcCardNumber string `json:"icCardNumber,omitempty"`
// 失败理由
FailReason string `json:"failReason"`
... ... @@ -327,3 +332,16 @@ func (item *BatchAddUserItem) Status() int {
}
return 1
}
func (item *BatchAddUserItem) GetEmployeeType() int {
if item.EmployeeType == "固定" {
return 1
}
if item.EmployeeType == "派遣" {
return 2
}
if item.EmployeeType == "临时" {
return 3
}
return 1
}
... ...
... ... @@ -45,6 +45,7 @@ type UserBase struct {
type Favorite struct {
OrgItems []int64 `json:"orgItems"`
Referer string `json:"referer"`
LastLogInAt int64 `json:"lastLogInAt"`
}
type UserBaseRepository interface {
... ... @@ -145,8 +146,8 @@ func (userBase *UserBase) CheckAccountPassword(account, password string) error {
// account 账号 (手机号)
// password 密码(sha1)
func (userBase *UserBase) ResetPassword(account, password string) error {
if userBase.Status != int(UserStatusEnable) {
return fmt.Errorf("该用户不存在")
if userBase.Status == int(UserStatusDestroy) {
return fmt.Errorf("该用户已注销")
}
if !strings.EqualFold(account, userBase.Account) {
return fmt.Errorf("该用户不存在")
... ... @@ -263,6 +264,32 @@ func (userBase *UserBase) removeFavorite(items []int64, code int64) ([]int64, er
return newItems, nil
}
// LastLogIn 更新最后一次登录时间
//
// t 时间
func (userBase *UserBase) LastLogIn(t time.Time) error {
if userBase.Favorite == nil {
userBase.Favorite = NewFavorite()
}
userBase.Favorite.LastLogInAt = t.Unix()
return nil
}
func (user *UserBase) SetEnableStatus(status int) error {
userStatus := UserStatus(user.Status)
if userStatus == UserStatusDestroy {
return fmt.Errorf("账号已注销")
}
if user.Status == status {
return nil //fmt.Errorf("重复设置状态")
}
if !(status == int(UserStatusEnable) || status == int(UserStatusDisable)) {
return fmt.Errorf("非法启用状态")
}
user.Status = status
return nil
}
/***** 2.缓存模块 *****/
func (m *UserBase) CacheKeyFunc() string {
... ...
... ... @@ -11,5 +11,12 @@ type UserInfo struct {
// 邮箱
Email string `json:"email,omitempty"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType int `json:"employeeType,omitempty"`
// IC卡号
IcCardNumber string `json:"icCardNumber,omitempty"`
Referer string `json:"-"`
// 部门
DepartmentName string `cname:"部门" json:"-"`
}
... ...
package area
import (
_ "embed"
"encoding/json"
)
type ProvinceCity struct {
Provinces []*Province
Cities []*City
ProvincesCity map[string][]*City
}
func (p *ProvinceCity) LoadProvincesCity(provinces []*Province, cities []*City) {
p.Provinces = provinces
p.Cities = cities
for i := range provinces {
p.ProvincesCity[provinces[i].Province] = make([]*City, 0)
}
for i := range cities {
if _, ok := p.ProvincesCity[cities[i].Province]; ok {
p.ProvincesCity[cities[i].Province] = append(p.ProvincesCity[cities[i].Province], cities[i])
}
}
}
var DefaultProvinceCity *ProvinceCity
// data source :https://github.com/uiwjs/province-city-china/tree/gh-pages
//go:embed city.json
var city []byte
//go:embed province.json
var province []byte
func SetUp() {
DefaultProvinceCity = &ProvinceCity{
Provinces: make([]*Province, 0),
Cities: make([]*City, 0),
ProvincesCity: make(map[string][]*City),
}
var cities []*City = make([]*City, 0)
var provinces []*Province = make([]*Province, 0)
err := json.Unmarshal(city, &cities)
if err != nil {
panic(err)
}
err = json.Unmarshal(province, &provinces)
if err != nil {
panic(err)
}
DefaultProvinceCity.LoadProvincesCity(provinces, cities)
}
/*
eg:
{
"code": "130100",
"name": "石家庄市",
"province": "13",
"city": "01"
}
*/
type City struct {
Code string `json:"code"`
Name string `json:"name"`
Province string `json:"province"`
City string `json:"city"`
}
/*
eg:
{
"code": "110000",
"name": "北京市",
"province": "11"
}
*/
type Province struct {
Code string `json:"code"`
Name string `json:"name"`
Province string `json:"province"`
}
func Provinces() []*Province {
return DefaultProvinceCity.Provinces
}
func Cities() []*City {
return DefaultProvinceCity.Cities
}
func ProvinceCities(provinceCode string) []*City {
if v, ok := DefaultProvinceCity.ProvincesCity[provinceCode]; ok {
return v
}
return []*City{}
}
... ...
[
{
"code": "130100",
"name": "石家庄市",
"province": "13",
"city": "01"
},
{
"code": "130200",
"name": "唐山市",
"province": "13",
"city": "02"
},
{
"code": "130300",
"name": "秦皇岛市",
"province": "13",
"city": "03"
},
{
"code": "130400",
"name": "邯郸市",
"province": "13",
"city": "04"
},
{
"code": "130500",
"name": "邢台市",
"province": "13",
"city": "05"
},
{
"code": "130600",
"name": "保定市",
"province": "13",
"city": "06"
},
{
"code": "130700",
"name": "张家口市",
"province": "13",
"city": "07"
},
{
"code": "130800",
"name": "承德市",
"province": "13",
"city": "08"
},
{
"code": "130900",
"name": "沧州市",
"province": "13",
"city": "09"
},
{
"code": "131000",
"name": "廊坊市",
"province": "13",
"city": "10"
},
{
"code": "131100",
"name": "衡水市",
"province": "13",
"city": "11"
},
{
"code": "140100",
"name": "太原市",
"province": "14",
"city": "01"
},
{
"code": "140200",
"name": "大同市",
"province": "14",
"city": "02"
},
{
"code": "140300",
"name": "阳泉市",
"province": "14",
"city": "03"
},
{
"code": "140400",
"name": "长治市",
"province": "14",
"city": "04"
},
{
"code": "140500",
"name": "晋城市",
"province": "14",
"city": "05"
},
{
"code": "140600",
"name": "朔州市",
"province": "14",
"city": "06"
},
{
"code": "140700",
"name": "晋中市",
"province": "14",
"city": "07"
},
{
"code": "140800",
"name": "运城市",
"province": "14",
"city": "08"
},
{
"code": "140900",
"name": "忻州市",
"province": "14",
"city": "09"
},
{
"code": "141000",
"name": "临汾市",
"province": "14",
"city": "10"
},
{
"code": "141100",
"name": "吕梁市",
"province": "14",
"city": "11"
},
{
"code": "150100",
"name": "呼和浩特市",
"province": "15",
"city": "01"
},
{
"code": "150200",
"name": "包头市",
"province": "15",
"city": "02"
},
{
"code": "150300",
"name": "乌海市",
"province": "15",
"city": "03"
},
{
"code": "150400",
"name": "赤峰市",
"province": "15",
"city": "04"
},
{
"code": "150500",
"name": "通辽市",
"province": "15",
"city": "05"
},
{
"code": "150600",
"name": "鄂尔多斯市",
"province": "15",
"city": "06"
},
{
"code": "150700",
"name": "呼伦贝尔市",
"province": "15",
"city": "07"
},
{
"code": "150800",
"name": "巴彦淖尔市",
"province": "15",
"city": "08"
},
{
"code": "150900",
"name": "乌兰察布市",
"province": "15",
"city": "09"
},
{
"code": "152200",
"name": "兴安盟",
"province": "15",
"city": "22"
},
{
"code": "152500",
"name": "锡林郭勒盟",
"province": "15",
"city": "25"
},
{
"code": "152900",
"name": "阿拉善盟",
"province": "15",
"city": "29"
},
{
"code": "210100",
"name": "沈阳市",
"province": "21",
"city": "01"
},
{
"code": "210200",
"name": "大连市",
"province": "21",
"city": "02"
},
{
"code": "210300",
"name": "鞍山市",
"province": "21",
"city": "03"
},
{
"code": "210400",
"name": "抚顺市",
"province": "21",
"city": "04"
},
{
"code": "210500",
"name": "本溪市",
"province": "21",
"city": "05"
},
{
"code": "210600",
"name": "丹东市",
"province": "21",
"city": "06"
},
{
"code": "210700",
"name": "锦州市",
"province": "21",
"city": "07"
},
{
"code": "210800",
"name": "营口市",
"province": "21",
"city": "08"
},
{
"code": "210900",
"name": "阜新市",
"province": "21",
"city": "09"
},
{
"code": "211000",
"name": "辽阳市",
"province": "21",
"city": "10"
},
{
"code": "211100",
"name": "盘锦市",
"province": "21",
"city": "11"
},
{
"code": "211200",
"name": "铁岭市",
"province": "21",
"city": "12"
},
{
"code": "211300",
"name": "朝阳市",
"province": "21",
"city": "13"
},
{
"code": "211400",
"name": "葫芦岛市",
"province": "21",
"city": "14"
},
{
"code": "220100",
"name": "长春市",
"province": "22",
"city": "01"
},
{
"code": "220200",
"name": "吉林市",
"province": "22",
"city": "02"
},
{
"code": "220300",
"name": "四平市",
"province": "22",
"city": "03"
},
{
"code": "220400",
"name": "辽源市",
"province": "22",
"city": "04"
},
{
"code": "220500",
"name": "通化市",
"province": "22",
"city": "05"
},
{
"code": "220600",
"name": "白山市",
"province": "22",
"city": "06"
},
{
"code": "220700",
"name": "松原市",
"province": "22",
"city": "07"
},
{
"code": "220800",
"name": "白城市",
"province": "22",
"city": "08"
},
{
"code": "222400",
"name": "延边朝鲜族自治州",
"province": "22",
"city": "24"
},
{
"code": "230100",
"name": "哈尔滨市",
"province": "23",
"city": "01"
},
{
"code": "230200",
"name": "齐齐哈尔市",
"province": "23",
"city": "02"
},
{
"code": "230300",
"name": "鸡西市",
"province": "23",
"city": "03"
},
{
"code": "230400",
"name": "鹤岗市",
"province": "23",
"city": "04"
},
{
"code": "230500",
"name": "双鸭山市",
"province": "23",
"city": "05"
},
{
"code": "230600",
"name": "大庆市",
"province": "23",
"city": "06"
},
{
"code": "230700",
"name": "伊春市",
"province": "23",
"city": "07"
},
{
"code": "230800",
"name": "佳木斯市",
"province": "23",
"city": "08"
},
{
"code": "230900",
"name": "七台河市",
"province": "23",
"city": "09"
},
{
"code": "231000",
"name": "牡丹江市",
"province": "23",
"city": "10"
},
{
"code": "231100",
"name": "黑河市",
"province": "23",
"city": "11"
},
{
"code": "231200",
"name": "绥化市",
"province": "23",
"city": "12"
},
{
"code": "232700",
"name": "大兴安岭地区",
"province": "23",
"city": "27"
},
{
"code": "320100",
"name": "南京市",
"province": "32",
"city": "01"
},
{
"code": "320200",
"name": "无锡市",
"province": "32",
"city": "02"
},
{
"code": "320300",
"name": "徐州市",
"province": "32",
"city": "03"
},
{
"code": "320400",
"name": "常州市",
"province": "32",
"city": "04"
},
{
"code": "320500",
"name": "苏州市",
"province": "32",
"city": "05"
},
{
"code": "320600",
"name": "南通市",
"province": "32",
"city": "06"
},
{
"code": "320700",
"name": "连云港市",
"province": "32",
"city": "07"
},
{
"code": "320800",
"name": "淮安市",
"province": "32",
"city": "08"
},
{
"code": "320900",
"name": "盐城市",
"province": "32",
"city": "09"
},
{
"code": "321000",
"name": "扬州市",
"province": "32",
"city": "10"
},
{
"code": "321100",
"name": "镇江市",
"province": "32",
"city": "11"
},
{
"code": "321200",
"name": "泰州市",
"province": "32",
"city": "12"
},
{
"code": "321300",
"name": "宿迁市",
"province": "32",
"city": "13"
},
{
"code": "330100",
"name": "杭州市",
"province": "33",
"city": "01"
},
{
"code": "330200",
"name": "宁波市",
"province": "33",
"city": "02"
},
{
"code": "330300",
"name": "温州市",
"province": "33",
"city": "03"
},
{
"code": "330400",
"name": "嘉兴市",
"province": "33",
"city": "04"
},
{
"code": "330500",
"name": "湖州市",
"province": "33",
"city": "05"
},
{
"code": "330600",
"name": "绍兴市",
"province": "33",
"city": "06"
},
{
"code": "330700",
"name": "金华市",
"province": "33",
"city": "07"
},
{
"code": "330800",
"name": "衢州市",
"province": "33",
"city": "08"
},
{
"code": "330900",
"name": "舟山市",
"province": "33",
"city": "09"
},
{
"code": "331000",
"name": "台州市",
"province": "33",
"city": "10"
},
{
"code": "331100",
"name": "丽水市",
"province": "33",
"city": "11"
},
{
"code": "340100",
"name": "合肥市",
"province": "34",
"city": "01"
},
{
"code": "340200",
"name": "芜湖市",
"province": "34",
"city": "02"
},
{
"code": "340300",
"name": "蚌埠市",
"province": "34",
"city": "03"
},
{
"code": "340400",
"name": "淮南市",
"province": "34",
"city": "04"
},
{
"code": "340500",
"name": "马鞍山市",
"province": "34",
"city": "05"
},
{
"code": "340600",
"name": "淮北市",
"province": "34",
"city": "06"
},
{
"code": "340700",
"name": "铜陵市",
"province": "34",
"city": "07"
},
{
"code": "340800",
"name": "安庆市",
"province": "34",
"city": "08"
},
{
"code": "341000",
"name": "黄山市",
"province": "34",
"city": "10"
},
{
"code": "341100",
"name": "滁州市",
"province": "34",
"city": "11"
},
{
"code": "341200",
"name": "阜阳市",
"province": "34",
"city": "12"
},
{
"code": "341300",
"name": "宿州市",
"province": "34",
"city": "13"
},
{
"code": "341500",
"name": "六安市",
"province": "34",
"city": "15"
},
{
"code": "341600",
"name": "亳州市",
"province": "34",
"city": "16"
},
{
"code": "341700",
"name": "池州市",
"province": "34",
"city": "17"
},
{
"code": "341800",
"name": "宣城市",
"province": "34",
"city": "18"
},
{
"code": "350100",
"name": "福州市",
"province": "35",
"city": "01"
},
{
"code": "350200",
"name": "厦门市",
"province": "35",
"city": "02"
},
{
"code": "350300",
"name": "莆田市",
"province": "35",
"city": "03"
},
{
"code": "350400",
"name": "三明市",
"province": "35",
"city": "04"
},
{
"code": "350500",
"name": "泉州市",
"province": "35",
"city": "05"
},
{
"code": "350600",
"name": "漳州市",
"province": "35",
"city": "06"
},
{
"code": "350700",
"name": "南平市",
"province": "35",
"city": "07"
},
{
"code": "350800",
"name": "龙岩市",
"province": "35",
"city": "08"
},
{
"code": "350900",
"name": "宁德市",
"province": "35",
"city": "09"
},
{
"code": "360100",
"name": "南昌市",
"province": "36",
"city": "01"
},
{
"code": "360200",
"name": "景德镇市",
"province": "36",
"city": "02"
},
{
"code": "360300",
"name": "萍乡市",
"province": "36",
"city": "03"
},
{
"code": "360400",
"name": "九江市",
"province": "36",
"city": "04"
},
{
"code": "360500",
"name": "新余市",
"province": "36",
"city": "05"
},
{
"code": "360600",
"name": "鹰潭市",
"province": "36",
"city": "06"
},
{
"code": "360700",
"name": "赣州市",
"province": "36",
"city": "07"
},
{
"code": "360800",
"name": "吉安市",
"province": "36",
"city": "08"
},
{
"code": "360900",
"name": "宜春市",
"province": "36",
"city": "09"
},
{
"code": "361000",
"name": "抚州市",
"province": "36",
"city": "10"
},
{
"code": "361100",
"name": "上饶市",
"province": "36",
"city": "11"
},
{
"code": "370100",
"name": "济南市",
"province": "37",
"city": "01"
},
{
"code": "370200",
"name": "青岛市",
"province": "37",
"city": "02"
},
{
"code": "370300",
"name": "淄博市",
"province": "37",
"city": "03"
},
{
"code": "370400",
"name": "枣庄市",
"province": "37",
"city": "04"
},
{
"code": "370500",
"name": "东营市",
"province": "37",
"city": "05"
},
{
"code": "370600",
"name": "烟台市",
"province": "37",
"city": "06"
},
{
"code": "370700",
"name": "潍坊市",
"province": "37",
"city": "07"
},
{
"code": "370800",
"name": "济宁市",
"province": "37",
"city": "08"
},
{
"code": "370900",
"name": "泰安市",
"province": "37",
"city": "09"
},
{
"code": "371000",
"name": "威海市",
"province": "37",
"city": "10"
},
{
"code": "371100",
"name": "日照市",
"province": "37",
"city": "11"
},
{
"code": "371300",
"name": "临沂市",
"province": "37",
"city": "13"
},
{
"code": "371400",
"name": "德州市",
"province": "37",
"city": "14"
},
{
"code": "371500",
"name": "聊城市",
"province": "37",
"city": "15"
},
{
"code": "371600",
"name": "滨州市",
"province": "37",
"city": "16"
},
{
"code": "371700",
"name": "菏泽市",
"province": "37",
"city": "17"
},
{
"code": "410100",
"name": "郑州市",
"province": "41",
"city": "01"
},
{
"code": "410200",
"name": "开封市",
"province": "41",
"city": "02"
},
{
"code": "410300",
"name": "洛阳市",
"province": "41",
"city": "03"
},
{
"code": "410400",
"name": "平顶山市",
"province": "41",
"city": "04"
},
{
"code": "410500",
"name": "安阳市",
"province": "41",
"city": "05"
},
{
"code": "410600",
"name": "鹤壁市",
"province": "41",
"city": "06"
},
{
"code": "410700",
"name": "新乡市",
"province": "41",
"city": "07"
},
{
"code": "410800",
"name": "焦作市",
"province": "41",
"city": "08"
},
{
"code": "410900",
"name": "濮阳市",
"province": "41",
"city": "09"
},
{
"code": "411000",
"name": "许昌市",
"province": "41",
"city": "10"
},
{
"code": "411100",
"name": "漯河市",
"province": "41",
"city": "11"
},
{
"code": "411200",
"name": "三门峡市",
"province": "41",
"city": "12"
},
{
"code": "411300",
"name": "南阳市",
"province": "41",
"city": "13"
},
{
"code": "411400",
"name": "商丘市",
"province": "41",
"city": "14"
},
{
"code": "411500",
"name": "信阳市",
"province": "41",
"city": "15"
},
{
"code": "411600",
"name": "周口市",
"province": "41",
"city": "16"
},
{
"code": "411700",
"name": "驻马店市",
"province": "41",
"city": "17"
},
{
"code": "420100",
"name": "武汉市",
"province": "42",
"city": "01"
},
{
"code": "420200",
"name": "黄石市",
"province": "42",
"city": "02"
},
{
"code": "420300",
"name": "十堰市",
"province": "42",
"city": "03"
},
{
"code": "420500",
"name": "宜昌市",
"province": "42",
"city": "05"
},
{
"code": "420600",
"name": "襄阳市",
"province": "42",
"city": "06"
},
{
"code": "420700",
"name": "鄂州市",
"province": "42",
"city": "07"
},
{
"code": "420800",
"name": "荆门市",
"province": "42",
"city": "08"
},
{
"code": "420900",
"name": "孝感市",
"province": "42",
"city": "09"
},
{
"code": "421000",
"name": "荆州市",
"province": "42",
"city": "10"
},
{
"code": "421100",
"name": "黄冈市",
"province": "42",
"city": "11"
},
{
"code": "421200",
"name": "咸宁市",
"province": "42",
"city": "12"
},
{
"code": "421300",
"name": "随州市",
"province": "42",
"city": "13"
},
{
"code": "422800",
"name": "恩施土家族苗族自治州",
"province": "42",
"city": "28"
},
{
"code": "430100",
"name": "长沙市",
"province": "43",
"city": "01"
},
{
"code": "430200",
"name": "株洲市",
"province": "43",
"city": "02"
},
{
"code": "430300",
"name": "湘潭市",
"province": "43",
"city": "03"
},
{
"code": "430400",
"name": "衡阳市",
"province": "43",
"city": "04"
},
{
"code": "430500",
"name": "邵阳市",
"province": "43",
"city": "05"
},
{
"code": "430600",
"name": "岳阳市",
"province": "43",
"city": "06"
},
{
"code": "430700",
"name": "常德市",
"province": "43",
"city": "07"
},
{
"code": "430800",
"name": "张家界市",
"province": "43",
"city": "08"
},
{
"code": "430900",
"name": "益阳市",
"province": "43",
"city": "09"
},
{
"code": "431000",
"name": "郴州市",
"province": "43",
"city": "10"
},
{
"code": "431100",
"name": "永州市",
"province": "43",
"city": "11"
},
{
"code": "431200",
"name": "怀化市",
"province": "43",
"city": "12"
},
{
"code": "431300",
"name": "娄底市",
"province": "43",
"city": "13"
},
{
"code": "433100",
"name": "湘西土家族苗族自治州",
"province": "43",
"city": "31"
},
{
"code": "440100",
"name": "广州市",
"province": "44",
"city": "01"
},
{
"code": "440200",
"name": "韶关市",
"province": "44",
"city": "02"
},
{
"code": "440300",
"name": "深圳市",
"province": "44",
"city": "03"
},
{
"code": "440400",
"name": "珠海市",
"province": "44",
"city": "04"
},
{
"code": "440500",
"name": "汕头市",
"province": "44",
"city": "05"
},
{
"code": "440600",
"name": "佛山市",
"province": "44",
"city": "06"
},
{
"code": "440700",
"name": "江门市",
"province": "44",
"city": "07"
},
{
"code": "440800",
"name": "湛江市",
"province": "44",
"city": "08"
},
{
"code": "440900",
"name": "茂名市",
"province": "44",
"city": "09"
},
{
"code": "441200",
"name": "肇庆市",
"province": "44",
"city": "12"
},
{
"code": "441300",
"name": "惠州市",
"province": "44",
"city": "13"
},
{
"code": "441400",
"name": "梅州市",
"province": "44",
"city": "14"
},
{
"code": "441500",
"name": "汕尾市",
"province": "44",
"city": "15"
},
{
"code": "441600",
"name": "河源市",
"province": "44",
"city": "16"
},
{
"code": "441700",
"name": "阳江市",
"province": "44",
"city": "17"
},
{
"code": "441800",
"name": "清远市",
"province": "44",
"city": "18"
},
{
"code": "441900",
"name": "东莞市",
"province": "44",
"city": "19"
},
{
"code": "442000",
"name": "中山市",
"province": "44",
"city": "20"
},
{
"code": "445100",
"name": "潮州市",
"province": "44",
"city": "51"
},
{
"code": "445200",
"name": "揭阳市",
"province": "44",
"city": "52"
},
{
"code": "445300",
"name": "云浮市",
"province": "44",
"city": "53"
},
{
"code": "450100",
"name": "南宁市",
"province": "45",
"city": "01"
},
{
"code": "450200",
"name": "柳州市",
"province": "45",
"city": "02"
},
{
"code": "450300",
"name": "桂林市",
"province": "45",
"city": "03"
},
{
"code": "450400",
"name": "梧州市",
"province": "45",
"city": "04"
},
{
"code": "450500",
"name": "北海市",
"province": "45",
"city": "05"
},
{
"code": "450600",
"name": "防城港市",
"province": "45",
"city": "06"
},
{
"code": "450700",
"name": "钦州市",
"province": "45",
"city": "07"
},
{
"code": "450800",
"name": "贵港市",
"province": "45",
"city": "08"
},
{
"code": "450900",
"name": "玉林市",
"province": "45",
"city": "09"
},
{
"code": "451000",
"name": "百色市",
"province": "45",
"city": "10"
},
{
"code": "451100",
"name": "贺州市",
"province": "45",
"city": "11"
},
{
"code": "451200",
"name": "河池市",
"province": "45",
"city": "12"
},
{
"code": "451300",
"name": "来宾市",
"province": "45",
"city": "13"
},
{
"code": "451400",
"name": "崇左市",
"province": "45",
"city": "14"
},
{
"code": "460100",
"name": "海口市",
"province": "46",
"city": "01"
},
{
"code": "460200",
"name": "三亚市",
"province": "46",
"city": "02"
},
{
"code": "460300",
"name": "三沙市",
"province": "46",
"city": "03"
},
{
"code": "460400",
"name": "儋州市",
"province": "46",
"city": "04"
},
{
"code": "510100",
"name": "成都市",
"province": "51",
"city": "01"
},
{
"code": "510300",
"name": "自贡市",
"province": "51",
"city": "03"
},
{
"code": "510400",
"name": "攀枝花市",
"province": "51",
"city": "04"
},
{
"code": "510500",
"name": "泸州市",
"province": "51",
"city": "05"
},
{
"code": "510600",
"name": "德阳市",
"province": "51",
"city": "06"
},
{
"code": "510700",
"name": "绵阳市",
"province": "51",
"city": "07"
},
{
"code": "510800",
"name": "广元市",
"province": "51",
"city": "08"
},
{
"code": "510900",
"name": "遂宁市",
"province": "51",
"city": "09"
},
{
"code": "511000",
"name": "内江市",
"province": "51",
"city": "10"
},
{
"code": "511100",
"name": "乐山市",
"province": "51",
"city": "11"
},
{
"code": "511300",
"name": "南充市",
"province": "51",
"city": "13"
},
{
"code": "511400",
"name": "眉山市",
"province": "51",
"city": "14"
},
{
"code": "511500",
"name": "宜宾市",
"province": "51",
"city": "15"
},
{
"code": "511600",
"name": "广安市",
"province": "51",
"city": "16"
},
{
"code": "511700",
"name": "达州市",
"province": "51",
"city": "17"
},
{
"code": "511800",
"name": "雅安市",
"province": "51",
"city": "18"
},
{
"code": "511900",
"name": "巴中市",
"province": "51",
"city": "19"
},
{
"code": "512000",
"name": "资阳市",
"province": "51",
"city": "20"
},
{
"code": "513200",
"name": "阿坝藏族羌族自治州",
"province": "51",
"city": "32"
},
{
"code": "513300",
"name": "甘孜藏族自治州",
"province": "51",
"city": "33"
},
{
"code": "513400",
"name": "凉山彝族自治州",
"province": "51",
"city": "34"
},
{
"code": "520100",
"name": "贵阳市",
"province": "52",
"city": "01"
},
{
"code": "520200",
"name": "六盘水市",
"province": "52",
"city": "02"
},
{
"code": "520300",
"name": "遵义市",
"province": "52",
"city": "03"
},
{
"code": "520400",
"name": "安顺市",
"province": "52",
"city": "04"
},
{
"code": "520500",
"name": "毕节市",
"province": "52",
"city": "05"
},
{
"code": "520600",
"name": "铜仁市",
"province": "52",
"city": "06"
},
{
"code": "522300",
"name": "黔西南布依族苗族自治州",
"province": "52",
"city": "23"
},
{
"code": "522600",
"name": "黔东南苗族侗族自治州",
"province": "52",
"city": "26"
},
{
"code": "522700",
"name": "黔南布依族苗族自治州",
"province": "52",
"city": "27"
},
{
"code": "530100",
"name": "昆明市",
"province": "53",
"city": "01"
},
{
"code": "530300",
"name": "曲靖市",
"province": "53",
"city": "03"
},
{
"code": "530400",
"name": "玉溪市",
"province": "53",
"city": "04"
},
{
"code": "530500",
"name": "保山市",
"province": "53",
"city": "05"
},
{
"code": "530600",
"name": "昭通市",
"province": "53",
"city": "06"
},
{
"code": "530700",
"name": "丽江市",
"province": "53",
"city": "07"
},
{
"code": "530800",
"name": "普洱市",
"province": "53",
"city": "08"
},
{
"code": "530900",
"name": "临沧市",
"province": "53",
"city": "09"
},
{
"code": "532300",
"name": "楚雄彝族自治州",
"province": "53",
"city": "23"
},
{
"code": "532500",
"name": "红河哈尼族彝族自治州",
"province": "53",
"city": "25"
},
{
"code": "532600",
"name": "文山壮族苗族自治州",
"province": "53",
"city": "26"
},
{
"code": "532800",
"name": "西双版纳傣族自治州",
"province": "53",
"city": "28"
},
{
"code": "532900",
"name": "大理白族自治州",
"province": "53",
"city": "29"
},
{
"code": "533100",
"name": "德宏傣族景颇族自治州",
"province": "53",
"city": "31"
},
{
"code": "533300",
"name": "怒江傈僳族自治州",
"province": "53",
"city": "33"
},
{
"code": "533400",
"name": "迪庆藏族自治州",
"province": "53",
"city": "34"
},
{
"code": "540100",
"name": "拉萨市",
"province": "54",
"city": "01"
},
{
"code": "540200",
"name": "日喀则市",
"province": "54",
"city": "02"
},
{
"code": "540300",
"name": "昌都市",
"province": "54",
"city": "03"
},
{
"code": "540400",
"name": "林芝市",
"province": "54",
"city": "04"
},
{
"code": "540500",
"name": "山南市",
"province": "54",
"city": "05"
},
{
"code": "540600",
"name": "那曲市",
"province": "54",
"city": "06"
},
{
"code": "542500",
"name": "阿里地区",
"province": "54",
"city": "25"
},
{
"code": "610100",
"name": "西安市",
"province": "61",
"city": "01"
},
{
"code": "610200",
"name": "铜川市",
"province": "61",
"city": "02"
},
{
"code": "610300",
"name": "宝鸡市",
"province": "61",
"city": "03"
},
{
"code": "610400",
"name": "咸阳市",
"province": "61",
"city": "04"
},
{
"code": "610500",
"name": "渭南市",
"province": "61",
"city": "05"
},
{
"code": "610600",
"name": "延安市",
"province": "61",
"city": "06"
},
{
"code": "610700",
"name": "汉中市",
"province": "61",
"city": "07"
},
{
"code": "610800",
"name": "榆林市",
"province": "61",
"city": "08"
},
{
"code": "610900",
"name": "安康市",
"province": "61",
"city": "09"
},
{
"code": "611000",
"name": "商洛市",
"province": "61",
"city": "10"
},
{
"code": "620100",
"name": "兰州市",
"province": "62",
"city": "01"
},
{
"code": "620200",
"name": "嘉峪关市",
"province": "62",
"city": "02"
},
{
"code": "620300",
"name": "金昌市",
"province": "62",
"city": "03"
},
{
"code": "620400",
"name": "白银市",
"province": "62",
"city": "04"
},
{
"code": "620500",
"name": "天水市",
"province": "62",
"city": "05"
},
{
"code": "620600",
"name": "武威市",
"province": "62",
"city": "06"
},
{
"code": "620700",
"name": "张掖市",
"province": "62",
"city": "07"
},
{
"code": "620800",
"name": "平凉市",
"province": "62",
"city": "08"
},
{
"code": "620900",
"name": "酒泉市",
"province": "62",
"city": "09"
},
{
"code": "621000",
"name": "庆阳市",
"province": "62",
"city": "10"
},
{
"code": "621100",
"name": "定西市",
"province": "62",
"city": "11"
},
{
"code": "621200",
"name": "陇南市",
"province": "62",
"city": "12"
},
{
"code": "622900",
"name": "临夏回族自治州",
"province": "62",
"city": "29"
},
{
"code": "623000",
"name": "甘南藏族自治州",
"province": "62",
"city": "30"
},
{
"code": "630100",
"name": "西宁市",
"province": "63",
"city": "01"
},
{
"code": "630200",
"name": "海东市",
"province": "63",
"city": "02"
},
{
"code": "632200",
"name": "海北藏族自治州",
"province": "63",
"city": "22"
},
{
"code": "632300",
"name": "黄南藏族自治州",
"province": "63",
"city": "23"
},
{
"code": "632500",
"name": "海南藏族自治州",
"province": "63",
"city": "25"
},
{
"code": "632600",
"name": "果洛藏族自治州",
"province": "63",
"city": "26"
},
{
"code": "632700",
"name": "玉树藏族自治州",
"province": "63",
"city": "27"
},
{
"code": "632800",
"name": "海西蒙古族藏族自治州",
"province": "63",
"city": "28"
},
{
"code": "640100",
"name": "银川市",
"province": "64",
"city": "01"
},
{
"code": "640200",
"name": "石嘴山市",
"province": "64",
"city": "02"
},
{
"code": "640300",
"name": "吴忠市",
"province": "64",
"city": "03"
},
{
"code": "640400",
"name": "固原市",
"province": "64",
"city": "04"
},
{
"code": "640500",
"name": "中卫市",
"province": "64",
"city": "05"
},
{
"code": "650100",
"name": "乌鲁木齐市",
"province": "65",
"city": "01"
},
{
"code": "650200",
"name": "克拉玛依市",
"province": "65",
"city": "02"
},
{
"code": "650400",
"name": "吐鲁番市",
"province": "65",
"city": "04"
},
{
"code": "650500",
"name": "哈密市",
"province": "65",
"city": "05"
},
{
"code": "652300",
"name": "昌吉回族自治州",
"province": "65",
"city": "23"
},
{
"code": "652700",
"name": "博尔塔拉蒙古自治州",
"province": "65",
"city": "27"
},
{
"code": "652800",
"name": "巴音郭楞蒙古自治州",
"province": "65",
"city": "28"
},
{
"code": "652900",
"name": "阿克苏地区",
"province": "65",
"city": "29"
},
{
"code": "653000",
"name": "克孜勒苏柯尔克孜自治州",
"province": "65",
"city": "30"
},
{
"code": "653100",
"name": "喀什地区",
"province": "65",
"city": "31"
},
{
"code": "653200",
"name": "和田地区",
"province": "65",
"city": "32"
},
{
"code": "654000",
"name": "伊犁哈萨克自治州",
"province": "65",
"city": "40"
},
{
"code": "654200",
"name": "塔城地区",
"province": "65",
"city": "42"
},
{
"code": "654300",
"name": "阿勒泰地区",
"province": "65",
"city": "43"
},
{
"code": "429000",
"name": "省直辖县级行政区划",
"province": "42",
"city": "90"
},
{
"code": "110000",
"name": "北京市",
"province": "11",
"city": "01"
},
{
"code": "120000",
"name": "天津市",
"province": "12",
"city": "01"
},
{
"code": "310000",
"name": "上海市",
"province": "31",
"city": "01"
},
{
"code": "500000",
"name": "重庆市",
"province": "50",
"city": "01"
},
{
"code": "810000",
"name": "香港特别行政区",
"province": "81",
"city": "01"
},
{
"code": "820000",
"name": "澳门特别行政区",
"province": "82",
"city": "01"
},
{
"code": "710000",
"name": "中国台湾",
"province": "71",
"city": "01"
}
]
\ No newline at end of file
... ...
[
{
"code": "110000",
"name": "北京",
"province": "11"
},
{
"code": "120000",
"name": "天津",
"province": "12"
},
{
"code": "130000",
"name": "河北省",
"province": "13"
},
{
"code": "140000",
"name": "山西省",
"province": "14"
},
{
"code": "150000",
"name": "内蒙古自治区",
"province": "15"
},
{
"code": "210000",
"name": "辽宁省",
"province": "21"
},
{
"code": "220000",
"name": "吉林省",
"province": "22"
},
{
"code": "230000",
"name": "黑龙江省",
"province": "23"
},
{
"code": "310000",
"name": "上海",
"province": "31"
},
{
"code": "320000",
"name": "江苏省",
"province": "32"
},
{
"code": "330000",
"name": "浙江省",
"province": "33"
},
{
"code": "340000",
"name": "安徽省",
"province": "34"
},
{
"code": "350000",
"name": "福建省",
"province": "35"
},
{
"code": "360000",
"name": "江西省",
"province": "36"
},
{
"code": "370000",
"name": "山东省",
"province": "37"
},
{
"code": "410000",
"name": "河南省",
"province": "41"
},
{
"code": "420000",
"name": "湖北省",
"province": "42"
},
{
"code": "430000",
"name": "湖南省",
"province": "43"
},
{
"code": "440000",
"name": "广东省",
"province": "44"
},
{
"code": "450000",
"name": "广西壮族自治区",
"province": "45"
},
{
"code": "460000",
"name": "海南省",
"province": "46"
},
{
"code": "500000",
"name": "重庆",
"province": "50"
},
{
"code": "510000",
"name": "四川省",
"province": "51"
},
{
"code": "520000",
"name": "贵州省",
"province": "52"
},
{
"code": "530000",
"name": "云南省",
"province": "53"
},
{
"code": "540000",
"name": "西藏自治区",
"province": "54"
},
{
"code": "610000",
"name": "陕西省",
"province": "61"
},
{
"code": "620000",
"name": "甘肃省",
"province": "62"
},
{
"code": "630000",
"name": "青海省",
"province": "63"
},
{
"code": "640000",
"name": "宁夏回族自治区",
"province": "64"
},
{
"code": "650000",
"name": "新疆维吾尔自治区",
"province": "65"
},
{
"code": "710000",
"name": "台湾",
"province": "71"
},
{
"code": "810000",
"name": "香港",
"province": "81"
},
{
"code": "820000",
"name": "澳门",
"province": "82"
}
]
\ No newline at end of file
... ...
... ... @@ -109,7 +109,7 @@ func TestBSNBlockChain_UpToChain(t *testing.T) {
PublicKey: pubKey,
PrivatePem: priK,
}
options := NewUpToChainOptions("table", "2", "149848948").WithDesc("desc")
options := NewUpToChainOptions("table", "2", "149848948000").WithDesc("desc")
rsp, err := bc.UpToChain(options)
if err != nil {
t.Fatal(err)
... ...
... ... @@ -142,6 +142,8 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
Phone: user.Phone,
UserName: user.UserName,
OrgName: org.OrgName,
EmployeeType: user.GetEmployeeType(),
IcCardNumber: user.IcCardNumber,
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
... ... @@ -202,6 +204,12 @@ func (ptr *PgBatchAddUserService) preCheck2(user *domain.BatchAddUserItem) error
if len(user.Phone) == 0 || len(user.Phone) != 11 {
return fmt.Errorf("导入的手机号不是有效手机号")
}
if len(user.EmployeeType) == 0 {
return fmt.Errorf("导入的员工类型为空值")
}
if !(user.EmployeeType == "固定" || user.EmployeeType == "派遣" || user.EmployeeType == "临时") {
return fmt.Errorf("导入的员工类型有误")
}
return nil
}
... ...
... ... @@ -26,6 +26,9 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho
}
var err error
var company *domain.Company
companyRepository, _ := repository.NewCompanyRepository(s.transactionContext)
// 1.检查账号是否被注册过,一个手机号只能注册一家企业
var userBase *domain.UserBase
userBaseRepository, _ := repository.NewUserBaseRepository(s.transactionContext)
... ... @@ -33,17 +36,20 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho
userRepository, _ := repository.NewUserRepository(s.transactionContext)
if _, users, _ := userRepository.Find(map[string]interface{}{"userBaseId": userBase.UserBaseId}); len(users) > 0 {
for i := 0; i < len(users); i++ {
if users[i].UserType&domain.RoleTypeAdmin > 0 {
if users[i].UserType&domain.RoleTypeAdmin > 0 && users[i].Company != nil {
if company, err = companyRepository.FindOne(map[string]interface{}{"companyId": users[i].Company.CompanyId}); err != nil {
return nil, err
} else if company.Status != domain.CompanyUnauthenticated {
return nil, fmt.Errorf("该手机号已注册")
}
}
}
}
}
// 2.企业名称检查
var company *domain.Company
companyRepository, _ := repository.NewCompanyRepository(s.transactionContext)
if company, err = companyRepository.FindOne(map[string]interface{}{"companyName": companyInfo.CompanyName}); err != nil && err != domain.ErrorNotFound {
if company, err = companyRepository.FindOne(map[string]interface{}{"companyName": companyInfo.CompanyName, "statusNotIn": []int{domain.CompanyUnauthenticated}}); err != nil && err != domain.ErrorNotFound {
return nil, fmt.Errorf("该企业已经注册")
} else if company != nil && company.CompanyInfo.CompanyName == companyInfo.CompanyName {
return nil, fmt.Errorf("该企业已经注册")
... ...
... ... @@ -57,7 +57,7 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain
// 普通账号需要验证
// 1.用户编号唯一验证 用户编号在该企业内已存在,请重新输入
// 2.当前企业内手机号唯一 手机号在该企业内已存在,请重新输入
if newUser.UserType&(domain.UserTypeCompanyAdmin|domain.UserTypeVisitor) == 0 {
if newUser.UserType&(domain.UserTypeCompanyAdmin|domain.UserTypeVisitor|domain.UserTypeOperationAdmin) == 0 {
if user, err = userRepository.FindOne(map[string]interface{}{"companyId": newUser.CompanyId, "organizationId": newUser.OrganizationId, "userCode": newUser.UserCode}); err == nil && user != nil {
return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入")
}
... ... @@ -68,6 +68,13 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain
}
}
// 判断企业内IC卡号唯一
if len(newUser.Ext.IcCardNumber) > 0 {
if u, e := userRepository.FindOne(map[string]interface{}{"companyId": newUser.CompanyId, "icCardNumber": newUser.Ext.IcCardNumber}); e == nil && u != nil {
return nil, fmt.Errorf("IC卡号在该企业内已存在,请重新输入")
}
}
// 3.建账号
if userBase == nil {
createUserAccountService, _ := NewPgCreateUserAccountService(ptr.transactionContext)
... ...
... ... @@ -7,6 +7,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/im"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/repository"
"time"
)
// PgImService 网易云信IM服务
... ... @@ -53,6 +54,7 @@ func (ptr *PgImService) InitOrUpdateUserIMInfo(userId int64, flag int) (*domain.
userBase.Im.CsAccountId = fmt.Sprintf("%v", getRandomCustomerAccount(userId))
}
userBase.Im.ImToken = checkImResponse.ImToken
userBase.LastLogIn(time.Now())
if userBase, err = userBaseRepository.Save(userBase); err != nil {
}
... ...
... ... @@ -19,19 +19,19 @@ type PgRoleAccessMenusService struct {
//
// options 数据参数
// data 需要验证权限的数据
func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleId []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) {
func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleIds []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) {
var err error
var menus []*domain.Menu
menuIdSet := hashset.New()
if len(roleId) == 0 {
if len(roleIds) == 0 {
return menus, nil
}
// 1.角色有权限的菜单列表
roleRepository, _ := repository.NewRoleRepository(ptr.transactionContext)
for i := range roleId {
for i := range roleIds {
var role *domain.Role
if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleId[i]}); role == nil {
if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleIds[i]}); role == nil {
continue
}
// 只要当前登录组织的有权限菜单
... ...
... ... @@ -80,6 +80,13 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do
return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入")
}
// 判断企业内IC卡号唯一
if len(user.Ext.IcCardNumber) > 0 {
if u, e := userRepository.FindOne(map[string]interface{}{"companyId": user.CompanyId, "icCardNumber": user.Ext.IcCardNumber}); e == nil && u != nil && u.UserId != user.UserId {
return nil, fmt.Errorf("IC卡号在该企业内已存在,请重新输入")
}
}
user.UserRole = userRole
user.UserOrg = userOrg
if org != nil {
... ... @@ -87,9 +94,13 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do
}
if dep != nil {
user.Ext.DepName = dep.OrgName
} else {
user.Ext.DepName = userInfo.DepartmentName
}
user.Ext.Phone = userBase.UserInfo.Phone
user.Ext.UserName = userBase.UserInfo.UserName
//user.Ext.EmployeeType = userInfo.EmployeeType
//user.Ext.IcCardNumber = userInfo.IcCardNumber
user.UpdatedAt = time.Now()
if err = user.SetEnableStatus(enableStatus); err != nil {
return nil, err
... ...
... ... @@ -13,8 +13,8 @@ type Company struct {
CompanyConfig *domain.CompanyConfig `comment:"企业配置信息"`
// 企业基本信息
CompanyInfo *domain.CompanyInfo `comment:"企业基本信息"`
// 公司状态 1:已注册 2:待认证 3:已认证
Status int `comment:"公司状态 1:已注册 2:待认证 3:已认证"`
// 公司状态 1:已注册(待审核) 2:已通过 3:已拒绝
Status int `comment:"公司状态 1:已注册(待审核) 2:已通过 3:已拒绝"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 更新时间
... ...
... ... @@ -122,6 +122,9 @@ func (repository *CompanyRepository) FindOne(queryOptions map[string]interface{}
if v, ok := queryOptions["companyName"]; ok {
query.Where(fmt.Sprintf(`company_info @>'{"companyName":"%v"}'`, v))
}
if v, ok := queryOptions["statusNotIn"]; ok {
query.Where("status not in (?)", pg.In(v))
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, domain.ErrorNotFound
... ... @@ -150,6 +153,10 @@ func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) (
companys := make([]*domain.Company, 0)
query := sqlbuilder.BuildQuery(tx.Model(&companyModels), queryOptions)
query.SetOffsetAndLimit(20)
query.SetWhereByQueryOption("status =?", "status")
if v, ok := queryOptions["companyName"]; ok && len(v.(string)) > 0 {
query.Where("company_info->>'companyName' like ?", fmt.Sprintf("%%%v%%", v))
}
query.SetOrderDirect("company_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
return 0, companys, err
... ...
... ... @@ -172,7 +172,10 @@ func (repository *UserBaseRepository) Find(queryOptions map[string]interface{})
var userBaseModels []*models.UserBase
userBases := make([]*domain.UserBase, 0)
query := sqlbuilder.BuildQuery(tx.Model(&userBaseModels), queryOptions)
query.SetOffsetAndLimit(20)
query.SetOffsetAndLimit(20) //InUserBaseIds
if v, ok := queryOptions["inUserBaseIds"]; ok && len(v.([]int64)) > 0 {
query.Where(`user_base_id in (?)`, pg.In(v))
}
query.SetOrderDirect("user_base_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
return 0, userBases, err
... ...
... ... @@ -169,6 +169,7 @@ func (repository *UserRepository) FindOne(queryOptions map[string]interface{}) (
query.SetWhereByQueryOption("user_code = ?", "userCode")
query.SetWhereByQueryOption("user_id != ?", "notEqualUserId")
query.SetWhereByQueryOption("user_type & ? > 0", "userType")
query.SetWhereByQueryOption("ext->>'icCardNumber'=?", "icCardNumber")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
... ... @@ -196,11 +197,21 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int
var userModels []*models.User
users := make([]*domain.User, 0)
query := sqlbuilder.BuildQuery(tx.Model(&userModels), queryOptions)
if v, ok := queryOptions["distinctOnUserBaseId"]; ok && (v.(bool)) {
query.DistinctOn("user_base_id")
query.Order("user_base_id desc")
}
query.SetWhereByQueryOption("company_id=?", "companyId")
query.SetWhereByQueryOption("organization_id=?", "organizationId")
if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int64)) > 0 {
query.Where(`organization_id in (?)`, pg.In(v))
}
if v, ok := queryOptions["inCompanyIds"]; ok && len(v.([]int64)) > 0 {
query.Where(`company_id in (?)`, pg.In(v))
}
query.SetWhereByQueryOption("user_code = ?", "userCode")
query.SetWhereByQueryOption("ext->>'icCardNumber' = ?", "icCardNumber")
query.SetWhereByQueryOption("user_base_id=?", "userBaseId")
query.SetWhereByQueryOption("(user_type & ?)>0", "userType")
query.SetWhereByQueryOption("enable_status=?", "enableStatus")
... ... @@ -211,13 +222,16 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int
if v, ok := queryOptions["depName"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`ext->>'depName' like '%%%v%%'`, v))
}
if v, ok := queryOptions["orgName"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`ext->>'orgName' like '%%%v%%'`, v))
}
if v, ok := queryOptions["userName"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`ext->>'userName' like '%%%v%%'`, v))
}
if v, ok := queryOptions["cooperationCompany"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`cooperation_info->>'cooperationCompany' like '%%%v%%'`, v))
}
query.SetOffsetAndLimit(20)
query.SetOffsetAndLimit(domain.MaxQueryRow)
query.SetOrderDirect("user_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
return 0, users, err
... ...
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/area"
)
type AreaController struct {
beego.BaseController
}
func (controller *AreaController) ProvinceList() {
data := area.Provinces()
controller.Response(map[string]interface{}{
"provinces": data,
}, nil)
}
func (controller *AreaController) ProvinceCities() {
code := controller.GetString(":code")
data := area.ProvinceCities(code)
controller.Response(map[string]interface{}{
"cities": data,
}, nil)
}
... ...
... ... @@ -29,6 +29,26 @@ func (controller *CompanyController) UpdateCompany() {
controller.Response(data, err)
}
func (controller *CompanyController) AuditCompany() {
companyService := service.NewCompanyService(nil)
updateCompanyCommand := &command.AuditCompanyCommand{}
controller.Unmarshal(updateCompanyCommand)
companyId, _ := controller.GetInt64(":companyId")
updateCompanyCommand.CompanyId = companyId
data, err := companyService.AuditCompany(updateCompanyCommand)
controller.Response(data, err)
}
func (controller *CompanyController) EnableCompany() {
companyService := service.NewCompanyService(nil)
updateCompanyCommand := &command.EnableCompanyCommand{}
controller.Unmarshal(updateCompanyCommand)
companyId, _ := controller.GetInt64(":companyId")
updateCompanyCommand.CompanyId = companyId
data, err := companyService.EnableCompany(updateCompanyCommand)
controller.Response(data, err)
}
func (controller *CompanyController) GetCompany() {
companyService := service.NewCompanyService(nil)
getCompanyQuery := &query.GetCompanyQuery{}
... ... @@ -51,6 +71,7 @@ func (controller *CompanyController) RemoveCompany() {
func (controller *CompanyController) ListCompany() {
companyService := service.NewCompanyService(nil)
listCompanyQuery := &query.ListCompanyQuery{}
controller.Unmarshal(listCompanyQuery)
data, err := companyService.ListCompany(listCompanyQuery)
controller.Response(data, err)
}
... ...
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/userbase/service"
)
type UserBaseController struct {
beego.BaseController
}
func (controller *UserBaseController) SearchUser() {
userService := service.NewUserBaseService(nil)
listUserQuery := &query.ListUserQuery{}
Must(controller.Unmarshal(listUserQuery))
listUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.SearchUser(listUserQuery)
controller.Response(data, err)
}
func (controller *UserBaseController) BatchEnable() {
userService := service.NewUserBaseService(nil)
batchEnableCommand := &command.BatchEnableCommand{}
controller.Unmarshal(batchEnableCommand)
batchEnableCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.BatchEnable(batchEnableCommand)
controller.Response(data, err)
}
... ...
... ... @@ -159,3 +159,23 @@ func (controller *UserController) SearchUser() {
data, err := userService.ListUser(listUserQuery)
controller.Response(data, err)
}
func (controller *UserController) CreateAdminUser() {
userService := service.NewUserService(nil)
createUserCommand := &command.CreateAdminUserCommand{}
Must(controller.Unmarshal(createUserCommand))
createUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.CreateAdminUser(createUserCommand)
controller.Response(data, err)
}
func (controller *UserController) UpdateAdminUser() {
userService := service.NewUserService(nil)
updateUserCommand := &command.UpdateAdminUserCommand{}
Must(controller.Unmarshal(updateUserCommand))
userId, _ := controller.GetInt64(":userId")
updateUserCommand.UserId = userId
updateUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.UpdateAdminUser(updateUserCommand)
controller.Response(data, err)
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego/controllers"
)
func init() {
web.Router("/area/province", &controllers.AreaController{}, "Get:ProvinceList")
web.Router("/area/province/:code/cities", &controllers.AreaController{}, "Get:ProvinceCities")
}
... ...
... ... @@ -14,6 +14,9 @@ func init() {
web.Router("/company/:companyId/customize-menus/", &controllers.CompanyController{}, "Get:ListCompanyCustomizeMenus")
web.Router("/company/:companyId/customize-menus", &controllers.CompanyController{}, "Put:UpdateCompanyCustomizeMenus")
web.Router("/company/:companyId/audit", &controllers.CompanyController{}, "Post:AuditCompany")
web.Router("/company/:companyId/enable", &controllers.CompanyController{}, "Post:EnableCompany")
// 适配web
//web.Router("/v1/web/menus/search", &controllers.CompanyController{}, "Post:SearchCompanyCustomizeMenus")
//web.Router("/v1/web/menus", &controllers.CompanyController{}, "Put:AdapterUpdateCompanyCustomizeMenus")
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego/controllers"
)
func init() {
//web.Router("/user/", &controllers.UserController{}, "Post:CreateUser")
//web.Router("/user/:userId", &controllers.UserController{}, "Put:UpdateUser")
//web.Router("/user/:userId", &controllers.UserController{}, "Get:GetUser")
//web.Router("/user/:userId", &controllers.UserController{}, "Delete:RemoveUser")
web.Router("/user-base/search", &controllers.UserBaseController{}, "Post:SearchUser")
//web.Router("/user/:userId/access-menus", &controllers.UserController{}, "Get:GetUserAccessMenus")
//web.Router("/user/:userId/profile", &controllers.UserController{}, "Get:GetUserProfile")
//web.Router("/user/batch-add", &controllers.UserController{}, "Post:BatchAdd")
//web.Router("/user/batch-add2", &controllers.UserController{}, "Post:BatchAdd2")
web.Router("/user-base/batch-enable", &controllers.UserBaseController{}, "Post:BatchEnable")
//web.Router("/user/batch-reset-password", &controllers.UserController{}, "Post:BatchResetPassword")
//web.Router("/user/:userId/base-info", &controllers.UserController{}, "Put:UpdateUsersBase")
//web.Router("/user/cooperator", &controllers.UserController{}, "Post:CreateCooperator")
//web.Router("/user/cooperator/:userId", &controllers.UserController{}, "Put:UpdateCooperator")
}
... ...
... ... @@ -20,4 +20,7 @@ func init() {
web.Router("/user/:userId/base-info", &controllers.UserController{}, "Put:UpdateUsersBase")
web.Router("/user/cooperator", &controllers.UserController{}, "Post:CreateCooperator")
web.Router("/user/cooperator/:userId", &controllers.UserController{}, "Put:UpdateCooperator")
web.Router("/admin-user/", &controllers.UserController{}, "Post:CreateAdminUser")
web.Router("/admin-user/:userId", &controllers.UserController{}, "Put:UpdateAdminUser")
}
... ...
... ... @@ -12,10 +12,10 @@ import (
func SetUp() {
go func() {
q := kq.MustNewQueue(NewConfig(constant.TOPIC_UP_BLOCK_CHAIN, constant.TOPIC_UP_BLOCK_CHAIN, 2), kq.WithHandle(FilterTopicHandler("up_block_chain", UpToChainHandler)))
q := kq.MustNewQueue(NewConfig(constant.TOPIC_UP_BLOCK_CHAIN, constant.GROUP_UP_BLOCK_CHAIN, 1), kq.WithHandle(FilterTopicHandler("up_block_chain", UpToChainHandler)))
defer func() {
q.Stop()
log.Logger.Info(fmt.Sprintf("goqueue:%v stop!", constant.TOPIC_UP_BLOCK_CHAIN))
log.Logger.Info(fmt.Sprintf("goqueue:%v stop!", constant.GROUP_UP_BLOCK_CHAIN))
}()
q.Start()
}()
... ... @@ -38,7 +38,7 @@ func NewConfig(topic, group string, consumers int) kq.KqConf {
Offset: "first",
Conns: 1,
Consumers: consumers,
Processors: 4,
Processors: 1,
MinBytes: 10200,
MaxBytes: 10485760,
}
... ...
... ... @@ -10,11 +10,11 @@ import (
)
func UpToChainHandler(k, v string) error {
log.Logger.Debug(fmt.Sprintf("%s", v), map[string]interface{}{"handler": "UptoChain"})
blockChainService := service.NewBlockChainService(nil)
upChainCommand := &command.UpChainCommand{}
err := json.UnmarshalFromString(v, upChainCommand)
if err != nil {
log.Logger.Error(err.Error(), map[string]interface{}{"info": "UpToChainHandler 解析json错误", "data": v})
return err
}
_, err = blockChainService.UpChain(upChainCommand)
... ... @@ -26,9 +26,12 @@ func FilterTopicHandler(topic string, handler func(string, string) error) func(s
raw := &RawData{}
err := json.UnmarshalFromString(v, raw)
if err != nil {
log.Logger.Error("【GoQueue】消息解析错误:"+err.Error(), map[string]interface{}{"info": "FilterTopicHandler 解析json错误", "data": v})
return err
}
log.Logger.Debug(fmt.Sprintf("【GoQueue】收到消息 Topic:%s", raw.Topic), map[string]interface{}{"data": v})
if raw.Topic != topic {
log.Logger.Debug(fmt.Sprintf("【GoQueue】 topic not equal get:%v want:%v", raw.Topic, topic), map[string]interface{}{"data": v})
return nil
}
return handler(k, string(raw.Data))
... ...