作者 tangxuhui
正在显示 30 个修改的文件 包含 1198 行增加1 行删除
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"github.com/beego/beego/v2/core/validation"
)
type UserInfoCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (userInfoCommand *UserInfoCommand) Valid(validation *validation.Validation) {
}
func (userInfoCommand *UserInfoCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(userInfoCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"github.com/beego/beego/v2/core/validation"
)
type UserMenusCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (userMenusCommand *UserMenusCommand) Valid(validation *validation.Validation) {
}
func (userMenusCommand *UserMenusCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(userMenusCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type UserOrgCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (userOrgCommand *UserOrgCommand) Valid(validation *validation.Validation) {
}
func (userOrgCommand *UserOrgCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(userOrgCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -326,3 +326,77 @@ loopUser1:
"expiresIn": currentAccess.AccessExpired - nowTime,
}, nil
}
//GetUserMenus 获取用户信息
func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userInfoCommand.Operator)
resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
UserId: int(userInfoCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var user = map[string]interface{}{
"userId": resultUser.UserId,
"userInfo": map[string]interface{}{
"userName": resultUser.UserInfo.UserName,
"userPhone": resultUser.UserInfo.Phone,
"userAvatar": resultUser.UserInfo.Avatar,
},
"department": resultUser.Department,
"company": map[string]interface{}{
"companyId": resultUser.Company.CompanyId,
"companyName": resultUser.Company.CompanyName,
"logo": resultUser.Company.Log,
},
"im": resultUser.IM,
"org": resultUser.Org,
}
return map[string]interface{}{
"user": user,
}, nil
}
//GetUserMenus 获取用户菜单
func (srv AuthService) GetUserMenus(userMenusCommand *command.UserMenusCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
//GetUserMenus 获取用户组织
func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(userOrgCommand.Operator)
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Offset: 0,
Limit: 100,
UserBaseId: userOrgCommand.Operator.UserBaseId,
UserType: domain.UserTypeEmployee,
EnableStatus: domain.UserStatusEnable,
PullRealTime: true,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var res = make([]interface{}, 0)
for i := range result.Users {
for j := range result.Users[i].UserOrg {
org := result.Users[i].UserOrg[j]
res = append(res, map[string]interface{}{
"orgId": org.OrgID,
"orgName": org.OrgName,
})
}
}
return res, nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type DividendsStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *DividendsStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *DividendsStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type GetDividendContractsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *GetDividendContractsCommand) Valid(validation *validation.Validation) {
}
func (cmd *GetDividendContractsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type SearchDividendsEstimatesCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *SearchDividendsEstimatesCommand) Valid(validation *validation.Validation) {
}
func (cmd *SearchDividendsEstimatesCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type CooperationDividendsStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *CooperationDividendsStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *CooperationDividendsStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type CooperationPersonStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *CooperationPersonStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *CooperationPersonStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type GoodsStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *GoodsStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *GoodsStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type IndexStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *IndexStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *IndexStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 企业端分红服务
type CompanyDividendsService struct {
}
// IndexStatistics TODO:企业的合约列表(分红信息按合约划分)
func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *command.GetDividendContractsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:企业的合约统计(分红统计)
func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:企业的合约明细列表(分红预算信息)
func (srv CompanyStatisticsService) SearchDividendsEstimates(userMenusCommand *command.SearchDividendsEstimatesCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 企业端统计
type CompanyStatisticsService struct {
}
// IndexStatistics TODO:首页统计 (入口页面统计数据)
func (srv CompanyStatisticsService) IndexStatistics(userMenusCommand *command.IndexStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:共创人员统计(共创人员明细)
func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:产品统计排行榜 年月榜
func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.GoodsStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:共创分红支出统计
func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"time"
"github.com/beego/beego/v2/core/validation"
)
type CreateCompanyCommand struct {
// 企业名称
CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
// 规模
Scale string `cname:"规模" json:"scale" valid:"Required"`
// 公司Logo地址
Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
// 公司地址
Address string `cname:"公司地址" json:"address" valid:"Required"`
// 所属行业
IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
// 联系人
Contacts string `cname:"联系人" json:"contacts" valid:"Required"`
// 注册时间
RegisteredTime time.Time `cname:"注册时间" json:"registeredTime,omitempty"`
// 注册状态 1:已注册 2:待认证 3:已认证
Status int `cname:"注册状态 1:已注册 2:待认证 3:已认证" json:"status,omitempty"`
}
func (createCompanyCommand *CreateCompanyCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createCompanyCommand *CreateCompanyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createCompanyCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(createCompanyCommand).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 ListCompanyCustomizeMenusCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
// 菜单类别 web app
MenuCategory string `cname:"菜单类别" json:"menuCategory,omitempty" valid:"Required"`
}
func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
}
func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(listCompanyCustomizeMenusCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listCompanyCustomizeMenusCommand).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 RemoveCompanyCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
}
func (removeCompanyCommand *RemoveCompanyCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeCompanyCommand *RemoveCompanyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeCompanyCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeCompanyCommand).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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UpdateCompanyCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 企业名称
CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
// 公司地址
Address string `cname:"公司地址" json:"address" valid:"Required"`
// 系统名称
SystemName string `cname:"系统名称" json:"systemName" valid:"Required"`
// 公司Logo地址
Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
}
func (updateCompanyCommand *UpdateCompanyCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateCompanyCommand *UpdateCompanyCommand) 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 UpdateCompanyCustomizeMenusCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
// 菜单编号
MenuId int64 `cname:"菜单编号" json:"menuId" valid:"Required"`
// 菜单名称
//MenuName string `cname:"菜单名称" json:"menuName" valid:"Required"`
// 菜单别名
MenuAlias string `cname:"菜单别名" json:"menuAlias" valid:"Required"`
// 排序
Sort int `cname:"排序" json:"sort" valid:"Required"`
}
func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateCompanyCustomizeMenusCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateCompanyCustomizeMenusCommand).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 query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type GetCompanyQuery struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
}
func (getCompanyQuery *GetCompanyQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getCompanyQuery *GetCompanyQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getCompanyQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(getCompanyQuery).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 query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ListCompanyQuery struct {
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
// 查询限制
Limit int `cname:"查询限制" json:"limit" valid:"Required"`
}
func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listCompanyQuery *ListCompanyQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listCompanyQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listCompanyQuery).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-gateway/pkg/application/web/company/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 企业
type CompanyService struct {
}
// 创建企业
func (companyService *CompanyService) CreateCompany(createCompanyCommand *command.CreateCompanyCommand) (interface{}, error) {
return nil, nil
}
// 返回企业
func (companyService *CompanyService) GetCompany(getCompanyQuery *query.GetCompanyQuery) (interface{}, error) {
return nil, nil
}
// 返回企业列表
func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCompanyQuery) (interface{}, error) {
return nil, nil
}
// 返回自定义菜单列表(匹配有设置的菜单)
func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand *command.ListCompanyCustomizeMenusCommand) (interface{}, error) {
return nil, nil
}
// 移除企业
func (companyService *CompanyService) RemoveCompany(removeCompanyCommand *command.RemoveCompanyCommand) (interface{}, error) {
return nil, nil
}
// 更新企业
func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *command.UpdateCompanyCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(updateCompanyCommand.Operator)
_, err := creationUserGateway.CompanyUpdate(allied_creation_user.ReqCompanyUpdate{
CompanyId: updateCompanyCommand.Operator.CompanyId,
CompanyName: updateCompanyCommand.CompanyName,
Address: updateCompanyCommand.Address,
SystemName: updateCompanyCommand.SystemName,
Logo: updateCompanyCommand.Logo,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return updateCompanyCommand, nil
}
// 更新自定义菜单
func (companyService *CompanyService) UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand *command.UpdateCompanyCustomizeMenusCommand) (interface{}, error) {
return nil, nil
}
func NewCompanyService(options map[string]interface{}) *CompanyService {
newCompanyService := &CompanyService{}
return newCompanyService
}
... ...
package domain
/***** 1.用户模块 *****/
// 用户类型
const (
UserTypeEmployee = 1
UserTypeCooperation = 2
UserTypeCompanyAdmin = 1024
)
// 用户状态
const (
UserStatusEnable int = 1
UserStatusDisable int = 2
UserStatusDestroy int = 3
)
/***** 2.菜单模块 *****/
// 菜单启用状态 结合用户菜单权限
const (
MenuStatusEnable = 1 // 菜单启用
MenuStatusDisable = 2 // 菜单禁用
)
// 菜单公开状态
const (
MenuPublic = 1 // 菜单公开
MenuPrivate = 2 // 菜单未公开
)
const (
WebMenuCode = "web"
AppMenuCode = "app"
)
/***** 3.组织模块 *****/
const (
IsOrgFlag = 1 // 标记为组织
IsNotOrgFlag = 2 // 标记为非组织
)
const (
OrgStatusEnable = 1
OrgStatusDisable = 2
)
... ...
... ... @@ -12,7 +12,11 @@ type (
//更新企业
type (
ReqCompanyUpdate struct {
CompanyId int64
CompanyId int64
CompanyName string `json:"companyName"`
Address string `json:"address"`
SystemName string `json:"systemName"`
Logo string `json:"logo"`
}
DataCompanyUpdate struct {
... ...
... ... @@ -31,6 +31,9 @@ type UserDetail struct {
IndustryCategory string `json:"industryCategory"`
RegisteredTime time.Time `json:"registeredTime"`
Status int64 `json:"status"`
Log string `json:"log"`
Address string `json:"address"`
SystemName string `json:"systemName"`
} `json:"company,omitempty"`
Org *struct {
OrgId int `json:"orgId"`
... ... @@ -55,6 +58,11 @@ type UserDetail struct {
DeletedAt time.Time `json:"deletedAt"`
OrgName string `json:"orgName"`
} `json:"userOrg"`
IM struct {
Accid string `json:"accid"`
ImToken string `json:"imToken"`
CsAccountID string `json:"csAccountId"`
} `json:"im"`
}
//搜索用户列表
... ... @@ -64,6 +72,8 @@ type (
Offset int `json:"offset"`
// 查询限制
Limit int `json:"limit"`
// 用户基础id
UserBaseId int64 ` json:"userBaseId"`
// 企业id
CompanyId int64 ` json:"companyId"`
// 组织ID
... ... @@ -84,6 +94,8 @@ type (
InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"`
// 实时拉取数据 (获取最新的)
PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"`
// 状态(1:启用 2:禁用 3:注销)
EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"`
}
//DataUserSearch 搜索用户列表
... ...
... ... @@ -44,3 +44,42 @@ func (controller *AuthController) RefreshAuthAccessToken() {
data, err := authService.RefreshAuthAccessToken(refreshTokenCmd)
controller.Response(data, err)
}
func (controller *AuthController) GetUserInfo() {
authService := service.AuthService{}
userInfoCommand := &command.UserInfoCommand{}
err := controller.Unmarshal(userInfoCommand)
if err != nil {
controller.Response(nil, err)
return
}
userInfoCommand.Operator = controller.GetOperator()
data, err := authService.GetUserInfo(userInfoCommand)
controller.Response(data, err)
}
func (controller *AuthController) GetUserMenus() {
authService := service.AuthService{}
userMenusCommand := &command.UserMenusCommand{}
err := controller.Unmarshal(userMenusCommand)
if err != nil {
controller.Response(nil, err)
return
}
userMenusCommand.Operator = controller.GetOperator()
data, err := authService.GetUserMenus(userMenusCommand)
controller.Response(data, err)
}
func (controller *AuthController) GetUserOrg() {
authService := service.AuthService{}
userOrgCommand := &command.UserOrgCommand{}
err := controller.Unmarshal(userOrgCommand)
if err != nil {
controller.Response(nil, err)
return
}
userOrgCommand.Operator = controller.GetOperator()
data, err := authService.GetUserOrg(userOrgCommand)
controller.Response(data, err)
}
... ...
package mobile_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/service"
)
// Controller
type CooperationController struct {
baseController
}
/***** CompanyDividends 企业端分红 *****/
func (controller *CooperationController) GetDividendContracts() {
svr := service.CompanyStatisticsService{}
cmd := &command.GetDividendContractsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.GetDividendContracts(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) DividendsStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.DividendsStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.DividendsStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) SearchDividendsEstimates() {
svr := service.CompanyStatisticsService{}
cmd := &command.SearchDividendsEstimatesCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchDividendsEstimates(cmd)
controller.Response(data, err)
}
/***** CompanyStatistics 企业端统计 *****/
func (controller *CooperationController) IndexStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.IndexStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.IndexStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) CooperationPersonStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.CooperationPersonStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.CooperationPersonStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) GoodsStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.GoodsStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.GoodsStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) CooperationDividendsStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.CooperationDividendsStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.CooperationDividendsStatistics(cmd)
controller.Response(data, err)
}
... ...
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/service"
)
type CompanyController struct {
baseController
}
func (controller *CompanyController) CreateCompany() {
companyService := service.NewCompanyService(nil)
createCompanyCommand := &command.CreateCompanyCommand{}
controller.Unmarshal(createCompanyCommand)
data, err := companyService.CreateCompany(createCompanyCommand)
controller.Response(data, err)
}
func (controller *CompanyController) UpdateCompany() {
companyService := service.NewCompanyService(nil)
updateCompanyCommand := &command.UpdateCompanyCommand{}
controller.Unmarshal(updateCompanyCommand)
updateCompanyCommand.Operator = controller.GetOperator()
data, err := companyService.UpdateCompany(updateCompanyCommand)
controller.Response(data, err)
}
func (controller *CompanyController) GetCompany() {
companyService := service.NewCompanyService(nil)
getCompanyQuery := &query.GetCompanyQuery{}
companyId, _ := controller.GetInt64(":companyId")
getCompanyQuery.CompanyId = companyId
data, err := companyService.GetCompany(getCompanyQuery)
controller.Response(data, err)
}
func (controller *CompanyController) RemoveCompany() {
companyService := service.NewCompanyService(nil)
removeCompanyCommand := &command.RemoveCompanyCommand{}
controller.Unmarshal(removeCompanyCommand)
companyId, _ := controller.GetInt64(":companyId")
removeCompanyCommand.CompanyId = companyId
data, err := companyService.RemoveCompany(removeCompanyCommand)
controller.Response(data, err)
}
func (controller *CompanyController) ListCompany() {
companyService := service.NewCompanyService(nil)
listCompanyQuery := &query.ListCompanyQuery{}
data, err := companyService.ListCompany(listCompanyQuery)
controller.Response(data, err)
}
func (controller *CompanyController) ListCompanyCustomizeMenus() {
companyService := service.NewCompanyService(nil)
listCompanyCustomizeMenusCommand := &command.ListCompanyCustomizeMenusCommand{}
controller.Unmarshal(listCompanyCustomizeMenusCommand)
companyId, _ := controller.GetInt64(":companyId")
listCompanyCustomizeMenusCommand.CompanyId = companyId
listCompanyCustomizeMenusCommand.MenuCategory = controller.GetString("menuCategory")
data, err := companyService.ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand)
controller.Response(data, err)
}
func (controller *CompanyController) UpdateCompanyCustomizeMenus() {
companyService := service.NewCompanyService(nil)
updateCompanyCustomizeMenusCommand := &command.UpdateCompanyCustomizeMenusCommand{}
controller.Unmarshal(updateCompanyCustomizeMenusCommand)
companyId, _ := controller.GetInt64(":companyId")
updateCompanyCustomizeMenusCommand.CompanyId = companyId
data, err := companyService.UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand)
controller.Response(data, err)
}
... ...
... ... @@ -11,4 +11,8 @@ func init() {
web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login")
web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken")
web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken")
web.Router("/v1/app/auth/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
web.Router("/v1/app/auth/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/app/auth/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg")
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
)
// router
func init() {
/***** CompanyDividends 企业端分红 *****/
web.Router("/v1/app/cooperation/company/dividends/contracts", &mobile_client.CooperationController{}, "Get:GetDividendContracts")
web.Router("/v1/app/cooperation/company/dividends/sum", &mobile_client.CooperationController{}, "Post:DividendsStatistics")
web.Router("/v1/app/cooperation/company/dividends-estimates/search", &mobile_client.CooperationController{}, "Post:SearchDividendsEstimates")
/***** CompanyStatistics 企业端统计 *****/
web.Router("/v1/app/cooperation/index", &mobile_client.CooperationController{}, "Get:IndexStatistics")
web.Router("/v1/app/cooperation/person/statistics", &mobile_client.CooperationController{}, "Post:CooperationPersonStatistics")
web.Router("/v1/app/cooperation/goods/statistics", &mobile_client.CooperationController{}, "Post:GoodsStatistics")
web.Router("/v1/app/cooperation-dividends-statistics/statistics", &mobile_client.CooperationController{}, "Post:CooperationDividendsStatistics")
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
)
func init() {
//web.Router("/company/", &web_client.CompanyController{}, "Post:CreateCompany")
web.Router("/v1/web/company/", &web_client.CompanyController{}, "Put:UpdateCompany")
//web.Router("/company/:companyId", &web_client.CompanyController{}, "Get:GetCompany")
//web.Router("/company/:companyId", &web_client.CompanyController{}, "Delete:RemoveCompany")
//web.Router("/company/search", &web_client.CompanyController{}, "Post:ListCompany")
//web.Router("/company/:companyId/customize-menus/", &web_client.CompanyController{}, "Get:ListCompanyCustomizeMenus")
//web.Router("/company/:companyId/customize-menus", &web_client.CompanyController{}, "Put:UpdateCompanyCustomizeMenus")
}
... ...