作者 tangxuhui

更新 代码结构

正在显示 37 个修改的文件 包含 851 行增加96 行删除
不能预览此文件类型
  1 +{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego":1627356799005386400}
@@ -2,6 +2,7 @@ package main @@ -2,6 +2,7 @@ package main
2 2
3 import ( 3 import (
4 "github.com/beego/beego/v2/server/web" 4 "github.com/beego/beego/v2/server/web"
  5 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego"
5 ) 6 )
6 7
7 func main() { 8 func main() {
  1 +package query
  2 +
  3 +type GetDictionaryByCodeQuery struct {
  4 + DictCode []string `json:"dictCode"`
  5 +}
  1 +package service
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
  6 +)
  7 +
  8 +type CommonService struct {
  9 +}
  10 +
  11 +func NewCommonService(options map[string]interface{}) *CommonService {
  12 + return &CommonService{}
  13 +}
  14 +
  15 +//GetDictionaryByCode 根据code获取字典数据
  16 +func (dictionaryService *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDictionaryByCodeQuery) (interface{}, error) {
  17 + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic()
  18 + result, err := creationBasicGateway.GetDictionarysByCode(allied_creation_basic.ReqGetDictionaryByCode{
  19 + DictCode: getDictionaryQuery.DictCode,
  20 + })
  21 + if err != nil {
  22 + return nil, err
  23 + }
  24 + return result, nil
  25 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CompanyUserAddCommand struct {
  10 + // 用户编号
  11 + UsersCode string `json:"usersCode" valid:"Required"`
  12 + // 用户姓名
  13 + UsersName string `json:"usersName" valid:"Required"`
  14 + // 组织ID
  15 + OrgId int64 `json:"orgId" valid:"Required"`
  16 + // 部门id
  17 + DepartmentId int64 `json:"departmentId" valid:"Required"`
  18 + // 启用状态(启用:1 禁用:2)
  19 + EnableStatus int `json:"enableStatus" valid:"Required"`
  20 + // 手机号码
  21 + Phone string `json:"phone" valid:"Required"`
  22 + // 邮箱
  23 + Email string `json:"email" valid:"Required"`
  24 + // 关联的组织机构
  25 + UsersOrg []int64 `json:"usersOrg,omitempty"`
  26 + // 关联的用户
  27 + UsersRole []int64 `json:"usersRole,omitempty"`
  28 + // 头像
  29 + Avator string `json:"avator" valid:"Required"`
  30 +}
  31 +
  32 +func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
  33 + validation.SetError("CustomValid", "未实现的自定义认证")
  34 +}
  35 +
  36 +func (companyUserAddCommand *CompanyUserAddCommand) ValidateCommand() error {
  37 + valid := validation.Validation{}
  38 + b, err := valid.Valid(companyUserAddCommand)
  39 + if err != nil {
  40 + return err
  41 + }
  42 + if !b {
  43 + for _, validErr := range valid.Errors {
  44 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  45 + }
  46 + }
  47 + return nil
  48 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CompanyUserEnableCommand struct {
  10 + UsersIds []int64 `json:"usersIds,omitempty"`
  11 + // 启用状态(启用:1 禁用:2)
  12 + EnableStatus int `json:"enableStatus,omitempty"`
  13 +}
  14 +
  15 +func (companyUserEnableCommand *CompanyUserEnableCommand) Valid(validation *validation.Validation) {
  16 + validation.SetError("CustomValid", "未实现的自定义认证")
  17 +}
  18 +
  19 +func (companyUserEnableCommand *CompanyUserEnableCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(companyUserEnableCommand)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CompanyUserResetPasswordCommand struct {
  10 + UsersIds []int64 `json:"usersIds" valid:"Required"`
  11 +}
  12 +
  13 +func (companyUserResetPasswordCommand *CompanyUserResetPasswordCommand) Valid(validation *validation.Validation) {
  14 + validation.SetError("CustomValid", "未实现的自定义认证")
  15 +}
  16 +
  17 +func (companyUserResetPasswordCommand *CompanyUserResetPasswordCommand) ValidateCommand() error {
  18 + valid := validation.Validation{}
  19 + b, err := valid.Valid(companyUserResetPasswordCommand)
  20 + if err != nil {
  21 + return err
  22 + }
  23 + if !b {
  24 + for _, validErr := range valid.Errors {
  25 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  26 + }
  27 + }
  28 + return nil
  29 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CompanyUserUpdateCommand struct {
  10 + UsersId int64 `json:"usersId" valid:"Required"`
  11 + // 用户编号
  12 + UsersCode string `json:"usersCode,omitempty"`
  13 + // 用户名称
  14 + UsersName string `json:"usersName,omitempty"`
  15 + // 组织机构id
  16 + OrganizationId int64 `json:"organizationId,omitempty"`
  17 + // 部门id
  18 + DepartmentId int64 `json:"departmentId,omitempty"`
  19 + // 启用状态(启用:1 禁用:2)
  20 + EnableStatus int `json:"enableStatus,omitempty"`
  21 + // 手机号
  22 + Phone string `json:"phone,omitempty"`
  23 + // 邮箱
  24 + Email string `json:"email,omitempty"`
  25 + // 关联的组织机构
  26 + UsersOrg []int64 `json:"usersOrg,omitempty"`
  27 + // 关联的组织结构
  28 + UsersRole []int64 `json:"usersRole,omitempty"`
  29 + // 头像
  30 + Avator string `json:"avator,omitempty"`
  31 +}
  32 +
  33 +func (companyUserUpdateCommand *CompanyUserUpdateCommand) Valid(validation *validation.Validation) {
  34 + validation.SetError("CustomValid", "未实现的自定义认证")
  35 +}
  36 +
  37 +func (companyUserUpdateCommand *CompanyUserUpdateCommand) ValidateCommand() error {
  38 + valid := validation.Validation{}
  39 + b, err := valid.Valid(companyUserUpdateCommand)
  40 + if err != nil {
  41 + return err
  42 + }
  43 + if !b {
  44 + for _, validErr := range valid.Errors {
  45 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  46 + }
  47 + }
  48 + return nil
  49 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CooperationUserAddCommand struct {
  10 + // 用户编号
  11 + UsersId int64 `json:"usersId" valid:"Required"`
  12 + // 用户编号
  13 + UsersCode string `json:"usersCode" valid:"Required"`
  14 + // 用户姓名
  15 + UsersName string `json:"usersName" valid:"Required"`
  16 + // 共创公司
  17 + CooperationCompany string `json:"cooperationCompany" valid:"Required"`
  18 + // 共创公司到期时间
  19 + CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
  20 + // 启用状态(启用:1 禁用:2)
  21 + EnableStatus int `json:"enableStatus" valid:"Required"`
  22 + // 邮箱
  23 + Email string `json:"email" valid:"Required"`
  24 +}
  25 +
  26 +func (cooperationUserAddCommand *CooperationUserAddCommand) Valid(validation *validation.Validation) {
  27 + validation.SetError("CustomValid", "未实现的自定义认证")
  28 +}
  29 +
  30 +func (cooperationUserAddCommand *CooperationUserAddCommand) ValidateCommand() error {
  31 + valid := validation.Validation{}
  32 + b, err := valid.Valid(cooperationUserAddCommand)
  33 + if err != nil {
  34 + return err
  35 + }
  36 + if !b {
  37 + for _, validErr := range valid.Errors {
  38 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  39 + }
  40 + }
  41 + return nil
  42 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CooperationUserEnableCommand struct {
  10 + UsersIds []int64 `json:"usersIds,omitempty"`
  11 + // 启用状态(启用:1 禁用:2)
  12 + EnableStatus int `json:"enableStatus,omitempty"`
  13 +}
  14 +
  15 +func (cooperationUserEnableCommand *CooperationUserEnableCommand) Valid(validation *validation.Validation) {
  16 + validation.SetError("CustomValid", "未实现的自定义认证")
  17 +}
  18 +
  19 +func (cooperationUserEnableCommand *CooperationUserEnableCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cooperationUserEnableCommand)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CooperationUserResetPasswordCommand struct {
  10 + UsersIds []int64 `json:"usersIds" valid:"Required"`
  11 +}
  12 +
  13 +func (cooperationUserResetPasswordCommand *CooperationUserResetPasswordCommand) Valid(validation *validation.Validation) {
  14 + validation.SetError("CustomValid", "未实现的自定义认证")
  15 +}
  16 +
  17 +func (cooperationUserResetPasswordCommand *CooperationUserResetPasswordCommand) ValidateCommand() error {
  18 + valid := validation.Validation{}
  19 + b, err := valid.Valid(cooperationUserResetPasswordCommand)
  20 + if err != nil {
  21 + return err
  22 + }
  23 + if !b {
  24 + for _, validErr := range valid.Errors {
  25 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  26 + }
  27 + }
  28 + return nil
  29 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CooperationUserUpdateCommand struct {
  10 + // 用户编号
  11 + UsersId int64 `json:"usersId" valid:"Required"`
  12 + // 用户编号
  13 + UsersCode string `json:"usersCode" valid:"Required"`
  14 + // 用户姓名
  15 + UsersName string `json:"usersName" valid:"Required"`
  16 + // 共创公司
  17 + CooperationCompany string `json:"cooperationCompany" valid:"Required"`
  18 + // 共创公司到期时间
  19 + CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
  20 + // 启用状态(启用:1 禁用:2)
  21 + EnableStatus int `json:"enableStatus" valid:"Required"`
  22 + // 邮箱
  23 + Email string `json:"email" valid:"Required"`
  24 +}
  25 +
  26 +func (cooperationUserUpdateCommand *CooperationUserUpdateCommand) Valid(validation *validation.Validation) {
  27 + validation.SetError("CustomValid", "未实现的自定义认证")
  28 +}
  29 +
  30 +func (cooperationUserUpdateCommand *CooperationUserUpdateCommand) ValidateCommand() error {
  31 + valid := validation.Validation{}
  32 + b, err := valid.Valid(cooperationUserUpdateCommand)
  33 + if err != nil {
  34 + return err
  35 + }
  36 + if !b {
  37 + for _, validErr := range valid.Errors {
  38 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  39 + }
  40 + }
  41 + return nil
  42 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CompanyUserGetQuery struct {
  10 + // 用户编号
  11 + UsersId int64 `json:"usersId" valid:"Required"`
  12 +}
  13 +
  14 +func (companyUserGetQuery *CompanyUserGetQuery) Valid(validation *validation.Validation) {
  15 + validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (companyUserGetQuery *CompanyUserGetQuery) ValidateQuery() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(companyUserGetQuery)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CompanyUserListQuery struct {
  10 + // 页码
  11 + PageNumber int `json:"pageNumber"`
  12 + // 每页数量
  13 + PageSize int `json:"pageSize" valid:"Required"`
  14 +}
  15 +
  16 +func (companyUserListQuery *CompanyUserListQuery) Valid(validation *validation.Validation) {
  17 + validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (companyUserListQuery *CompanyUserListQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(companyUserListQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CooperationUserGetQuery struct {
  10 + // 用户编号
  11 + UsersId int64 `json:"usersId" valid:"Required"`
  12 +}
  13 +
  14 +func (cooperationUserGetQuery *CooperationUserGetQuery) Valid(validation *validation.Validation) {
  15 + validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (cooperationUserGetQuery *CooperationUserGetQuery) ValidateQuery() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(cooperationUserGetQuery)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CooperationUserListQuery struct {
  10 + // 查询偏离量
  11 + Offset int `json:"offset" valid:"Required"`
  12 + // 查询限制
  13 + Limit int `json:"limit" valid:"Required"`
  14 +}
  15 +
  16 +func (cooperationUserListQuery *CooperationUserListQuery) Valid(validation *validation.Validation) {
  17 + validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (cooperationUserListQuery *CooperationUserListQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(cooperationUserListQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package service
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query"
  6 +)
  7 +
  8 +// 用户信息
  9 +type UsersService struct {
  10 +}
  11 +
  12 +// 获取公司用户信息
  13 +func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.CompanyUserGetQuery) (interface{}, error) {
  14 +
  15 + return nil, nil
  16 +}
  17 +
  18 +// 创建公司用户信息
  19 +func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.CompanyUserAddCommand) (interface{}, error) {
  20 +
  21 + return nil, nil
  22 +}
  23 +
  24 +// 启用禁用公司用户信息
  25 +func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *command.CompanyUserEnableCommand) (interface{}, error) {
  26 +
  27 + return nil, nil
  28 +}
  29 +
  30 +// 返回公司用户信息列表
  31 +func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (interface{}, error) {
  32 +
  33 + return nil, nil
  34 +}
  35 +
  36 +// 批量重置密码
  37 +func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPasswordCommand *command.CompanyUserResetPasswordCommand) (interface{}, error) {
  38 +
  39 + return nil, nil
  40 +}
  41 +
  42 +// 更新公司用户信息
  43 +func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *command.CompanyUserUpdateCommand) (interface{}, error) {
  44 +
  45 + return nil, nil
  46 +}
  47 +
  48 +// 创建共创用户信息
  49 +func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *command.CooperationUserAddCommand) (interface{}, error) {
  50 +
  51 + return nil, nil
  52 +}
  53 +
  54 +// 启用禁用共创用户信息
  55 +func (usersService *UsersService) CooperationUserEnable(cooperationUserEnableCommand *command.CooperationUserEnableCommand) (interface{}, error) {
  56 + return nil, nil
  57 +}
  58 +
  59 +// 获取共创用户信息
  60 +func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *query.CooperationUserGetQuery) (interface{}, error) {
  61 +
  62 + return nil, nil
  63 +}
  64 +
  65 +// 返回共创用户信息列表
  66 +func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *query.CooperationUserListQuery) (interface{}, error) {
  67 +
  68 + return nil, nil
  69 +}
  70 +
  71 +// 批量重置密码
  72 +func (usersService *UsersService) CooperationUserResetPassword(cooperationUserResetPasswordCommand *command.CooperationUserResetPasswordCommand) (interface{}, error) {
  73 +
  74 + return nil, nil
  75 +}
  76 +
  77 +// 编辑共创用户信息
  78 +func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCommand *command.CooperationUserUpdateCommand) (interface{}, error) {
  79 +
  80 + return nil, nil
  81 +}
  82 +
  83 +func NewUsersService(options map[string]interface{}) *UsersService {
  84 + newUsersService := &UsersService{}
  85 + return newUsersService
  86 +}
@@ -8,6 +8,8 @@ var LOG_LEVEL = "debug" @@ -8,6 +8,8 @@ var LOG_LEVEL = "debug"
8 8
9 var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" 9 var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080"
10 10
  11 +var ALLIED_CREATION_USER_HOST = "http://localhost:8080"
  12 +
11 func init() { 13 func init() {
12 if os.Getenv("LOG_LEVEL") != "" { 14 if os.Getenv("LOG_LEVEL") != "" {
13 LOG_LEVEL = os.Getenv("LOG_LEVEL") 15 LOG_LEVEL = os.Getenv("LOG_LEVEL")
@@ -15,4 +17,7 @@ func init() { @@ -15,4 +17,7 @@ func init() {
15 if os.Getenv("ALLIED_CREATION_BASIC_HOST") != "" { 17 if os.Getenv("ALLIED_CREATION_BASIC_HOST") != "" {
16 ALLIED_CREATION_BASIC_HOST = os.Getenv("ALLIED_CREATION_BASIC_HOST") 18 ALLIED_CREATION_BASIC_HOST = os.Getenv("ALLIED_CREATION_BASIC_HOST")
17 } 19 }
  20 + if os.Getenv("ALLIED_CREATION_USER_HOST") != "" {
  21 + ALLIED_CREATION_USER_HOST = os.Getenv("ALLIED_CREATION_USER_HOST")
  22 + }
18 } 23 }
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// 公司信息
  6 +type CompanyInfo struct {
  7 + // 企业名称
  8 + CompanyName string `json:"companyName"`
  9 + // 规模
  10 + Scale string `json:"scale"`
  11 + // 公司Logo地址
  12 + Logo string `json:"logo"`
  13 + // 地址
  14 + Address string `json:"address"`
  15 + // 所属行业
  16 + IndustryCategory string `json:"industryCategory"`
  17 + // 联系人
  18 + Contacts string `json:"contacts"`
  19 + // 注册时间
  20 + RegistTime time.Time `json:"registTime"`
  21 + // 注册状态 1:已注册 2:待认证 3:已认证
  22 + RegistStatus int `json:"registStatus"`
  23 +}
  1 +package domain
  2 +
  3 +// 部门
  4 +type Department struct {
  5 + // 组织ID
  6 + OrgId int64 `json:"orgId"`
  7 + // 组织名称
  8 + OrgName string `json:"orgName"`
  9 + // 组织编码
  10 + OrgCode string `json:"orgCode"`
  11 + // 父级id
  12 + ParentId int64 `json:"parentId"`
  13 +}
  1 +package domain
  2 +
  3 +// 系统菜单
  4 +type Menu struct {
  5 + // 菜单编号
  6 + MenuId int64 `json:"menuId"`
  7 + // 父级id
  8 + ParentId int64 `json:"parentId"`
  9 + // 菜单名称
  10 + MenuName string `json:"menuName"`
  11 + // 菜单别名
  12 + MenuAlias string `json:"menuAlias"`
  13 + // 菜单编码 SYSTEM_USER_EDIT
  14 + Code string `json:"code"`
  15 + // 菜单类型 (目录catalog、菜单menu、按钮button)
  16 + MenuType string `json:"menuType"`
  17 + // 菜单图标
  18 + Icon string `json:"icon"`
  19 + // 排序
  20 + Sort int `json:"sort"`
  21 + // 菜单说明
  22 + Remark string `json:"remark"`
  23 + // 菜单类别 (web:1、app:2)
  24 + Category string `json:"category"`
  25 +}
  1 +package domain
  2 +
  3 +// 组织organization
  4 +type Orgs struct {
  5 + // 组织ID
  6 + OrgId int64 `json:"orgId"`
  7 + // 企业id
  8 + CompanyId int64 `json:"companyId"`
  9 + // 组织编码
  10 + OrgCode string `json:"orgCode"`
  11 + // 组织名称
  12 + OrgName string `json:"orgName"`
  13 + IsOrg string `json:"isOrg"`
  14 + // 父级id
  15 + ParentId int64 `json:"parentId"`
  16 +}
  1 +package domain
  2 +
  3 +// 区域信息值对象
  4 +type RegionInfo struct {
  5 + // 区域编号
  6 + RegionNumber string `json:"regionNumber"`
  7 + // 区域名称
  8 + RegionName string `json:"regionName"`
  9 +}
  1 +package domain
  2 +
  3 +// 用户基础信息
  4 +type Users struct {
  5 + // 用户id
  6 + UserId string `json:"userId"`
  7 + // 用户基础信息
  8 + UserInfo *UsersBase `json:"userInfo,omitempty"`
  9 + // 用户的组织
  10 + Org *Orgs `json:"org,omitempty"`
  11 + // 用户的部门
  12 + Department *Department `json:"department,omitempty"`
  13 +}
  1 +package domain
  2 +
  3 +// 用户基础信息
  4 +type UsersBase struct {
  5 + // 手机号码
  6 + Phone string `json:"phone"`
  7 + // 共创模式状态,1启用,2禁用
  8 + Status int32 `json:"status"`
  9 + // 用户编号
  10 + UsersCode string `json:"usersCode"`
  11 + // 用户编号
  12 + UsersId int64 `json:"usersId"`
  13 + // 用户姓名
  14 + UsersName string `json:"usersName"`
  15 + // 邮箱
  16 + Email string `json:"email"`
  17 + // 共创公司
  18 + CooperationCompany string `json:"cooperationCompany"`
  19 + // 共创公司到期时间
  20 + CooperationDeadline string `json:"cooperationDeadline"`
  21 +}
1 -package service_gateway 1 +package allied_creation_basic
2 2
3 import ( 3 import (
  4 + "encoding/json"
  5 + "fmt"
4 "time" 6 "time"
5 7
6 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
7 9
8 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
9 ) 12 )
10 13
11 type HttplibAlliedCreationBasic struct { 14 type HttplibAlliedCreationBasic struct {
12 - BaseServiceGateway  
13 - BaseUrL string 15 + service_gateway.BaseServiceGateway
  16 + baseUrL string
14 } 17 }
15 18
16 var alliedCreationBasicClient = &HttplibAlliedCreationBasic{ 19 var alliedCreationBasicClient = &HttplibAlliedCreationBasic{
17 - BaseServiceGateway: BaseServiceGateway{  
18 - connectTimeout: 100 * time.Second,  
19 - readWriteTimeout: 30 * time.Second, 20 + BaseServiceGateway: service_gateway.BaseServiceGateway{
  21 + ConnectTimeout: 100 * time.Second,
  22 + ReadWriteTimeout: 30 * time.Second,
20 }, 23 },
21 - BaseUrL: "", 24 + baseUrL: constant.ALLIED_CREATION_BASIC_HOST,
22 } 25 }
23 26
24 func NewHttplibAlliedCreationBasic() *HttplibAlliedCreationBasic { 27 func NewHttplibAlliedCreationBasic() *HttplibAlliedCreationBasic {
25 return alliedCreationBasicClient 28 return alliedCreationBasicClient
26 } 29 }
27 30
28 -//ReqGetDictionarysByCode 根据code获取字典数据  
29 -type ReqGetDictionarysByCode struct {  
30 - DictCode string `json:"dictCode"`  
31 -}  
32 -  
33 -//DataGetDictionarysByCode 根据code获取字典数据  
34 -type DataGetDictionarysByCode struct {  
35 - Dictionarys []domain.Dictionary `json:"dictionarys"`  
36 -}  
37 -  
38 //GetDictionarysByCode 根据code获取字典数据 31 //GetDictionarysByCode 根据code获取字典数据
39 -func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDictionarysByCode) (*DataGetDictionarysByCode, error) {  
40 - url := gateway.BaseUrL + "/dictionarys/dictionary-code" 32 +func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDictionaryByCode) (*DataGetDictionaryByCode, error) {
  33 + url := gateway.baseUrL + "/dictionarys/dictionary-code"
41 method := "post" 34 method := "post"
42 - req := gateway.createRequest(url, method) 35 + req := gateway.CreateRequest(url, method)
43 //TODO traceID 36 //TODO traceID
44 log.Logger.Debug("向基础模块请求数据:根据code获取字典数据。", map[string]interface{}{ 37 log.Logger.Debug("向基础模块请求数据:根据code获取字典数据。", map[string]interface{}{
45 "api": method + ":" + url, 38 "api": method + ":" + url,
@@ -47,19 +40,22 @@ func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDicti @@ -47,19 +40,22 @@ func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDicti
47 }) 40 })
48 req, err := req.JSONBody(param) 41 req, err := req.JSONBody(param)
49 if err != nil { 42 if err != nil {
50 - return nil, err 43 + return nil, fmt.Errorf("请求字典数据失败:%w", err)
51 } 44 }
52 - var result GatewayResponse  
53 - err = req.ToJSON(&result) 45 +
  46 + byteResult, err := req.Bytes()
54 if err != nil { 47 if err != nil {
55 - return nil, err 48 + return nil, fmt.Errorf("获取字典数据失败:%w", err)
56 } 49 }
57 - var data DataGetDictionarysByCode  
58 - err = gateway.getResponseData(result, &data)  
59 log.Logger.Debug("获取基础模块响应数据:根据code获取字典数据。", map[string]interface{}{ 50 log.Logger.Debug("获取基础模块响应数据:根据code获取字典数据。", map[string]interface{}{
60 - "code": result.Code,  
61 - "msg": result.Msg,  
62 - "data": data, 51 + "result": string(byteResult),
63 }) 52 })
  53 + var result service_gateway.GatewayResponse
  54 + err = json.Unmarshal(byteResult, &result)
  55 + if err != nil {
  56 + return nil, fmt.Errorf("解析字典数据失败:%w", err)
  57 + }
  58 + var data DataGetDictionaryByCode
  59 + err = gateway.GetResponseData(result, &data)
64 return &data, err 60 return &data, err
65 } 61 }
  1 +package allied_creation_basic
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  4 +
  5 +//ReqGetDictionarysByCode 根据code获取字典数据
  6 +type ReqGetDictionaryByCode struct {
  7 + DictCode []string `json:"dictCode"`
  8 +}
  9 +
  10 +//DataGetDictionarysByCode 根据code获取字典数据
  11 +type DataGetDictionaryByCode struct {
  12 + Dictionarys []domain.Dictionary `json:"dictionarys"`
  13 +}
  1 +package allied_creation_user
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "time"
  7 +
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
  11 +)
  12 +
  13 +//HttplibAlliedCreationUser 用户模块
  14 +type HttplibAlliedCreationUser struct {
  15 + service_gateway.BaseServiceGateway
  16 + baseUrL string
  17 +}
  18 +
  19 +var alliedCreationUserClient = &HttplibAlliedCreationUser{
  20 + BaseServiceGateway: service_gateway.BaseServiceGateway{
  21 + ConnectTimeout: 100 * time.Second,
  22 + ReadWriteTimeout: 30 * time.Second,
  23 + },
  24 + baseUrL: constant.ALLIED_CREATION_USER_HOST,
  25 +}
  26 +
  27 +func NewHttplibAlliedCreationUser() *HttplibAlliedCreationUser {
  28 + return alliedCreationUserClient
  29 +}
  30 +
  31 +//UserSearch 搜索用户列表
  32 +func (gateway HttplibAlliedCreationUser) UserSearch(param ReqUserSearch) (*DataUserSearch, error) {
  33 + url := gateway.baseUrL + "/dictionarys/dictionary-code"
  34 + method := "post"
  35 + req := gateway.CreateRequest(url, method)
  36 + //TODO traceID
  37 + log.Logger.Debug("向用户模块请求数据:搜索用户列表。", map[string]interface{}{
  38 + "api": method + ":" + url,
  39 + "param": param,
  40 + })
  41 + req, err := req.JSONBody(param)
  42 + if err != nil {
  43 + return nil, fmt.Errorf("搜索用户列表失败:%w", err)
  44 + }
  45 +
  46 + byteResult, err := req.Bytes()
  47 + if err != nil {
  48 + return nil, fmt.Errorf("获取搜索用户列表失败:%w", err)
  49 + }
  50 + log.Logger.Debug("获取用户模块请求数据:搜索用户列表。", map[string]interface{}{
  51 + "result": string(byteResult),
  52 + })
  53 + var result service_gateway.GatewayResponse
  54 + err = json.Unmarshal(byteResult, &result)
  55 + if err != nil {
  56 + return nil, fmt.Errorf("解析搜索用户列表:%w", err)
  57 + }
  58 + var data DataUserSearch
  59 + err = gateway.GetResponseData(result, &data)
  60 + return &data, err
  61 +}
  1 +package allied_creation_user
  2 +
  3 +import "time"
  4 +
  5 +//ReqUserSearch 搜索用户列表
  6 +type ReqUserSearch struct {
  7 + // 查询偏离量
  8 + Offset int `json:"offset" valid:"Required"`
  9 + // 查询限制
  10 + Limit int `json:"limit" valid:"Required"`
  11 +}
  12 +
  13 +// //DataUserSearch 搜索用户列表
  14 +type DataUserSearch struct {
  15 + Count int `json:"count"`
  16 + Users []struct {
  17 + UserID int `json:"userId"`
  18 + CompanyID int `json:"companyId"`
  19 + UserBaseID int `json:"userBaseId"`
  20 + UserType int `json:"userType"`
  21 + UserCode string `json:"userCode"`
  22 + OrganizationID int `json:"organizationId"`
  23 + DepartmentID int `json:"departmentId"`
  24 + UserOrg []struct {
  25 + OrgID int `json:"orgId"`
  26 + OrgName string `json:"orgName"`
  27 + } `json:"userOrg"`
  28 + UserRole []struct {
  29 + RoleID int `json:"roleId"`
  30 + RoleName string `json:"roleName"`
  31 + Ext struct {
  32 + OrgName string `json:"orgName"`
  33 + } `json:"ext"`
  34 + } `json:"userRole"`
  35 + CooperationInfo struct {
  36 + CooperationCompany string `json:"cooperationCompany"`
  37 + CooperationDeadline time.Time `json:"cooperationDeadline"`
  38 + } `json:"cooperationInfo"`
  39 + EnableStatus int `json:"enableStatus"`
  40 + Ext struct {
  41 + OrgName string `json:"orgName"`
  42 + Phone string `json:"phone"`
  43 + DepName string `json:"depName"`
  44 + } `json:"ext"`
  45 + } `json:"users"`
  46 +}
@@ -8,19 +8,23 @@ import ( @@ -8,19 +8,23 @@ import (
8 "github.com/beego/beego/v2/client/httplib" 8 "github.com/beego/beego/v2/client/httplib"
9 ) 9 )
10 10
11 -//GatewayResponse 统一消息返回格式  
12 -type GatewayResponse struct { 11 +type MessageCode struct {
13 Code int `json:"code"` 12 Code int `json:"code"`
14 Msg string `json:"msg"` 13 Msg string `json:"msg"`
  14 +}
  15 +
  16 +//GatewayResponse 统一消息返回格式
  17 +type GatewayResponse struct {
  18 + MessageCode
15 Data json.RawMessage `json:"data"` 19 Data json.RawMessage `json:"data"`
16 } 20 }
17 21
18 type BaseServiceGateway struct { 22 type BaseServiceGateway struct {
19 - connectTimeout time.Duration  
20 - readWriteTimeout time.Duration 23 + ConnectTimeout time.Duration
  24 + ReadWriteTimeout time.Duration
21 } 25 }
22 26
23 -func (gateway BaseServiceGateway) createRequest(url string, method string) *httplib.BeegoHTTPRequest { 27 +func (gateway BaseServiceGateway) CreateRequest(url string, method string) *httplib.BeegoHTTPRequest {
24 var request *httplib.BeegoHTTPRequest 28 var request *httplib.BeegoHTTPRequest
25 switch method { 29 switch method {
26 case "get": 30 case "get":
@@ -36,10 +40,10 @@ func (gateway BaseServiceGateway) createRequest(url string, method string) *http @@ -36,10 +40,10 @@ func (gateway BaseServiceGateway) createRequest(url string, method string) *http
36 default: 40 default:
37 request = httplib.Get(url) 41 request = httplib.Get(url)
38 } 42 }
39 - return request.SetTimeout(gateway.connectTimeout, gateway.readWriteTimeout) 43 + return request.SetTimeout(gateway.ConnectTimeout, gateway.ReadWriteTimeout)
40 } 44 }
41 45
42 -func (gateway BaseServiceGateway) getResponseData(result GatewayResponse, data interface{}) error { 46 +func (gateway BaseServiceGateway) GetResponseData(result GatewayResponse, data interface{}) error {
43 if result.Code != 0 { 47 if result.Code != 0 {
44 return fmt.Errorf(result.Msg) 48 return fmt.Errorf(result.Msg)
45 } 49 }
@@ -7,8 +7,8 @@ import ( @@ -7,8 +7,8 @@ import (
7 "github.com/beego/beego/v2/server/web" 7 "github.com/beego/beego/v2/server/web"
8 "github.com/linmadan/egglib-go/web/beego/filters" 8 "github.com/linmadan/egglib-go/web/beego/filters"
9 9
10 - //_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/routers"  
11 - . "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
  11 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/routers"
12 ) 12 )
13 13
14 func init() { 14 func init() {
@@ -28,6 +28,6 @@ func init() { @@ -28,6 +28,6 @@ func init() {
28 } 28 }
29 } 29 }
30 web.InsertFilter("/*", web.BeforeExec, filters.AllowCors()) 30 web.InsertFilter("/*", web.BeforeExec, filters.AllowCors())
31 - web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(Logger))  
32 - web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(Logger), web.WithReturnOnOutput(false)) 31 + web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(log.Logger))
  32 + web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false))
33 } 33 }
  1 +package common_controller
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/web/beego"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service"
  7 +)
  8 +
  9 +type CommonController struct {
  10 + beego.BaseController
  11 +}
  12 +
  13 +func (controller *CommonController) GetDictionaryByCode() {
  14 + commonService := service.NewCommonService(nil)
  15 + queryParm := query.GetDictionaryByCodeQuery{}
  16 + _ = controller.Unmarshal(queryParm)
  17 + data, err := commonService.GetDictionaryByCode(&queryParm)
  18 + controller.Response(data, err)
  19 +}
1 -package controllers  
2 -  
3 -import (  
4 - "github.com/linmadan/egglib-go/web/beego"  
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/loginAccess/query"  
6 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/loginAccess/service"  
7 -)  
8 -  
9 -type LoginAccessController struct {  
10 - beego.BaseController  
11 -}  
12 -  
13 -func (controller *LoginAccessController) LoginByAccount() {  
14 - loginAccessService := service.NewLoginAccessService(nil)  
15 - loginByAccountQuery := &query.LoginByAccountQuery{}  
16 - data, err := loginAccessService.LoginByAccount(loginByAccountQuery)  
17 - controller.Response(data, err)  
18 -}  
19 -  
20 -func (controller *LoginAccessController) LoginBySmsCode() {  
21 - loginAccessService := service.NewLoginAccessService(nil)  
22 - loginBySmsCodeQuery := &query.LoginBySmsCodeQuery{}  
23 - data, err := loginAccessService.LoginBySmsCode(loginBySmsCodeQuery)  
24 - controller.Response(data, err)  
25 -}  
26 -  
27 -func (controller *LoginAccessController) LoginByScanQrcode() {  
28 - loginAccessService := service.NewLoginAccessService(nil)  
29 - loginByScanQrcodeQuery := &query.LoginByScanQrcodeQuery{}  
30 - data, err := loginAccessService.LoginByScanQrcode(loginByScanQrcodeQuery)  
31 - controller.Response(data, err)  
32 -}  
33 -  
34 -func (controller *LoginAccessController) GetQrcodeForLogin() {  
35 - loginAccessService := service.NewLoginAccessService(nil)  
36 - getQrcodeForLoginQuery := &query.GetQrcodeForLoginQuery{}  
37 - data, err := loginAccessService.GetQrcodeForLogin(getQrcodeForLoginQuery)  
38 - controller.Response(data, err)  
39 -}  
40 -  
41 -func (controller *LoginAccessController) LoginInfoByAuthCode() {  
42 - loginAccessService := service.NewLoginAccessService(nil)  
43 - loginInfoByAuthCodeQuery := &query.LoginInfoByAuthCodeQuery{}  
44 - data, err := loginAccessService.LoginInfoByAuthCode(loginInfoByAuthCodeQuery)  
45 - controller.Response(data, err)  
46 -}  
@@ -2,13 +2,9 @@ package routers @@ -2,13 +2,9 @@ package routers
2 2
3 import ( 3 import (
4 "github.com/beego/beego/v2/server/web" 4 "github.com/beego/beego/v2/server/web"
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers" 5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/common_controller"
6 ) 6 )
7 7
8 func init() { 8 func init() {
9 - web.Router("/auth/by-account", &controllers.LoginAccessController{}, "Post:LoginByAccount")  
10 - web.Router("/auth/by-smscode", &controllers.LoginAccessController{}, "Post:LoginBySmsCode")  
11 - web.Router("/auth/by-qrcode", &controllers.LoginAccessController{}, "Get:LoginByScanQrcode")  
12 - web.Router("/auth/get-qrcode", &controllers.LoginAccessController{}, "Get:GetQrcodeForLogin")  
13 - web.Router("/auth/profile", &controllers.LoginAccessController{}, "Get:LoginInfoByAuthCode") 9 + web.Router("/common/dictionary/search", &common_controller.CommonController{}, "Post:GetDictionaryByCode")
14 } 10 }