作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev

# Conflicts:
#	lastupdate.tmp
{"F:\\go\\src\\allied-creation\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627702781113454000}
\ No newline at end of file
{"F:\\go\\src\\allied-creation\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627719981417605200}
\ No newline at end of file
... ...
... ... @@ -2,11 +2,14 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"github.com/beego/beego/v2/core/validation"
)
type MenuFavoriteCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 企业id
CompanyId int64 `json:"companyId" valid:"Required"`
// 对应菜单的id
... ...
... ... @@ -10,12 +10,12 @@ import (
type MenuUpdateCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 企业id
CompanyId int64 `json:"companyId" valid:"Required"`
// 菜单编号
MenuId int64 `json:"menuId" valid:"Required"`
// 菜单名称
MenuName string `json:"menuName" valid:"Required"`
// 菜单名称
MenuAlias string `json:"menuAlias" valid:"Required"`
// 排序
Sort int `json:"sort" valid:"Required"`
}
... ...
... ... @@ -10,6 +10,8 @@ import (
type MenuListQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 菜单类别 web app
MenuCategory string `json:"menuCategory"`
}
func (menuListQuery *MenuListQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -13,8 +13,17 @@ type MenuService struct {
// 设置收藏菜单
func (menuService *MenuService) MenuFavorite(menuFavoriteCommand *command.MenuFavoriteCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
menuFavoriteCommand.Operator.CompanyId,
menuFavoriteCommand.Operator.OrgId,
menuFavoriteCommand.Operator.UserId)
result, err := creationUserGateway.CompanyGetCustomizeMenus(allied_creation_user.ReqCompanyGetCustomizeMenus{
CompanyId: menuFavoriteCommand.Operator.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// 返回菜单列表
... ... @@ -24,12 +33,15 @@ func (menuService *MenuService) MenuList(menuListQuery *query.MenuListQuery) (in
menuListQuery.Operator.OrgId,
menuListQuery.Operator.UserId)
result, err := creationUserGateway.CompanyGetCustomizeMenus(allied_creation_user.ReqCompanyGetCustomizeMenus{
CompanyId: menuListQuery.Operator.CompanyId,
CompanyId: menuListQuery.Operator.CompanyId,
MenuCategory: menuListQuery.MenuCategory,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
return map[string]interface{}{
"menus": result.Menus,
}, nil
}
// 更新菜单
... ... @@ -39,8 +51,8 @@ func (menuService *MenuService) MenuUpdate(menuUpdateCommand *command.MenuUpdate
menuUpdateCommand.Operator.OrgId,
menuUpdateCommand.Operator.UserId)
_, err := creationUserGateway.CompanySetCustomizeMenus(allied_creation_user.ReqCompanySetCustomizeMenus{
CompanyId: menuUpdateCommand.CompanyId,
MenuAlias: menuUpdateCommand.MenuName,
CompanyId: menuUpdateCommand.Operator.CompanyId,
MenuAlias: menuUpdateCommand.MenuAlias,
MenuId: int(menuUpdateCommand.MenuId),
Sort: menuUpdateCommand.Sort,
})
... ...
... ... @@ -127,11 +127,13 @@ func (orgsService *OrgsService) OrgUpdate(orgUpdateCommand *command.OrgUpdateCom
orgUpdateCommand.Operator.OrgId,
orgUpdateCommand.Operator.UserId)
parentId, _ := strconv.Atoi(orgUpdateCommand.ParentId)
_, err := creationUserGateway.OrgCreate(allied_creation_user.ReqOrgCreate{
orgId, _ := strconv.Atoi(orgUpdateCommand.OrgId)
_, err := creationUserGateway.OrgUpdate(allied_creation_user.ReqOrgUpdate{
OrgId: int64(orgId),
IsOrg: orgUpdateCommand.IsOrg,
OrgCode: orgUpdateCommand.OrgCode,
OrgName: orgUpdateCommand.OrgName,
ParentId: parentId,
ParentId: int64(parentId),
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -10,7 +10,7 @@ import (
type CompanyUserResetPasswordCommand struct {
//操作人
Operator domain.Operator `json:"-"`
UsersIds []string `json:"usersIds" valid:"Required"`
UserIds []string `json:"userIds" valid:"Required"`
}
func (companyUserResetPasswordCommand *CompanyUserResetPasswordCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -11,9 +11,9 @@ type CooperationUserAddCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersCode string `json:"usersCode" valid:"Required"`
UsersCode string `json:"userCode" valid:"Required"`
// 用户姓名
UsersName string `json:"usersName" valid:"Required"`
UsersName string `json:"userName" valid:"Required"`
// 共创公司
CooperationCompany string `json:"cooperationCompany" valid:"Required"`
// 共创公司到期时间
... ...
... ... @@ -11,7 +11,7 @@ type CooperationUserEnableCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//用户id
UsersIds []string `json:"usersIds,omitempty"`
UsersIds []string `json:"userIds,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus,omitempty"`
}
... ...
... ... @@ -10,7 +10,7 @@ import (
type CooperationUserResetPasswordCommand struct {
//操作人
Operator domain.Operator `json:"-"`
UsersIds []int64 `json:"usersIds" valid:"Required"`
UserIds []string `json:"userIds" valid:"Required"`
}
func (cooperationUserResetPasswordCommand *CooperationUserResetPasswordCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -11,11 +11,11 @@ type CooperationUserUpdateCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersId int64 `json:"usersId" valid:"Required"`
UserId int64 `json:"userId" valid:"Required"`
// 用户编号
UsersCode string `json:"usersCode" valid:"Required"`
UserCode string `json:"userCode" valid:"Required"`
// 用户姓名
UsersName string `json:"usersName" valid:"Required"`
UserName string `json:"userName" valid:"Required"`
// 共创公司
CooperationCompany string `json:"cooperationCompany" valid:"Required"`
// 共创公司到期时间
... ... @@ -23,7 +23,7 @@ type CooperationUserUpdateCommand struct {
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus" valid:"Required"`
// 邮箱
Email string `json:"email" valid:"Required"`
Email string `json:"email"`
//头像
Avatar string `json:"avatar"`
... ...
... ... @@ -76,7 +76,7 @@ type CooperationUserInfo struct {
type CooperationUserItem struct {
CooperationCompany string `json:"cooperationCompany"`
UserId string `json:"userId"`
CooperationDeadline int64 `json:"cooperationDeadline"`
CooperationDeadline string `json:"cooperationDeadline"`
Phone string `json:"phone"`
EnableStatus int `json:"enableStatus"`
UserCode string `json:"userCode"`
... ...
... ... @@ -210,8 +210,8 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw
companyUserResetPasswordCommand.Operator.OrgId,
companyUserResetPasswordCommand.Operator.UserId)
var userIds []int64
for i := range companyUserResetPasswordCommand.UsersIds {
id, _ := strconv.Atoi(companyUserResetPasswordCommand.UsersIds[i])
for i := range companyUserResetPasswordCommand.UserIds {
id, _ := strconv.Atoi(companyUserResetPasswordCommand.UserIds[i])
userIds = append(userIds, int64(id))
}
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
... ... @@ -274,8 +274,9 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *
cooperationUserAddCommand.Operator.OrgId,
cooperationUserAddCommand.Operator.UserId)
result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
CompanyId: cooperationUserAddCommand.Operator.CompanyId,
CooperationCompany: cooperationUserAddCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserAddCommand.CooperationDeadline, 0),
CooperationDeadline: time.Unix(cooperationUserAddCommand.CooperationDeadline/1000, 0),
Email: cooperationUserAddCommand.Email,
EnableStatus: cooperationUserAddCommand.EnableStatus,
UserCode: cooperationUserAddCommand.UsersCode,
... ... @@ -360,6 +361,7 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *
CooperationCompany: cooperationUserListQuery.CooperationCompany,
DepName: "",
Phone: "",
UserType: 2,
})
var (
listData []dto.CooperationUserItem
... ... @@ -370,7 +372,7 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *
item = dto.CooperationUserItem{
CooperationCompany: v.CooperationInfo.CooperationCompany,
UserId: strconv.Itoa(v.UserId),
CooperationDeadline: v.CooperationInfo.CooperationDeadline.Unix(),
CooperationDeadline: v.CooperationInfo.CooperationDeadline.Format("2006-01-02"),
Phone: v.UserInfo.Phone,
EnableStatus: v.EnableStatus,
UserCode: v.UserCode,
... ... @@ -389,14 +391,20 @@ func (usersService *UsersService) CooperationUserResetPassword(cooperationUserRe
cooperationUserResetPasswordCommand.Operator.CompanyId,
cooperationUserResetPasswordCommand.Operator.OrgId,
cooperationUserResetPasswordCommand.Operator.UserId)
var userIds []int64
for i := range cooperationUserResetPasswordCommand.UserIds {
id, _ := strconv.Atoi(cooperationUserResetPasswordCommand.UserIds[i])
userIds = append(userIds, int64(id))
}
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "", //TODO 填充密码
UserIds: cooperationUserResetPasswordCommand.UsersIds,
Password: "123456", //TODO 填充密码
UserIds: userIds,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return cooperationUserResetPasswordCommand, err
// TODO:返回消息提示 密码重置成功,初始密码为TL123456!
return "123456", err
}
// 编辑共创用户信息
... ... @@ -406,13 +414,13 @@ func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCom
cooperationUserUpdateCommand.Operator.OrgId,
cooperationUserUpdateCommand.Operator.UserId)
_, err := creationUserGateway.CooperatorUserUpdate(allied_creation_user.ReqUpdateCooperatorUser{
UserId: cooperationUserUpdateCommand.UsersId,
UserId: cooperationUserUpdateCommand.UserId,
CooperationCompany: cooperationUserUpdateCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserUpdateCommand.CooperationDeadline, 0),
Email: cooperationUserUpdateCommand.Email,
EnableStatus: cooperationUserUpdateCommand.EnableStatus,
UserCode: cooperationUserUpdateCommand.UsersCode,
UserName: cooperationUserUpdateCommand.UsersName,
UserCode: cooperationUserUpdateCommand.UserCode,
UserName: cooperationUserUpdateCommand.UserName,
Avatar: cooperationUserUpdateCommand.Avatar,
OrgId: cooperationUserUpdateCommand.Operator.OrgId,
Phone: cooperationUserUpdateCommand.Phone,
... ...
... ... @@ -197,7 +197,7 @@ func (gateway HttplibAlliedCreationUser) CompanySearch(param ReqCompanySearch) (
// CompanyGetCustomizeMenus 返回自定义菜单列表
func (gateway HttplibAlliedCreationUser) CompanyGetCustomizeMenus(param ReqCompanyGetCustomizeMenus) (*DataCompanyGetCustomizeMenus, error) {
url := gateway.baseUrL + "/company/" + strconv.FormatInt(param.CompanyId, 10) + "/customize-menus"
url := gateway.baseUrL + "/company/" + strconv.FormatInt(param.CompanyId, 10) + "/customize-menus?menuCategory=" + param.MenuCategory
method := "get"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向用户模块请求数据:返回自定义菜单列表。", map[string]interface{}{
... ...
... ... @@ -63,7 +63,9 @@ type (
//返回自定义菜单列表
type (
ReqCompanyGetCustomizeMenus struct {
CompanyId int64
CompanyId int64 `json:"companyId"`
// 菜单类别 web app
MenuCategory string `cname:"菜单类别" json:"menuCategory,omitempty"`
}
DataCompanyGetCustomizeMenus struct {
... ...
... ... @@ -19,6 +19,14 @@ type (
type (
ReqOrgUpdate struct {
OrgId int64
// 组织编码
OrgCode string `cname:"组织编码" json:"orgCode"`
// 组织名称
OrgName string `cname:"组织名称" json:"orgName"`
// 是否是组织(是:1 不是:2)
IsOrg int `cname:"是否是组织(是:1 不是:2)" json:"isOrg"`
// 父级ID
ParentId int64 `cname:"父级ID" json:"parentId" valid:"Required"`
}
DataOrgUpdate struct {
... ...
... ... @@ -211,6 +211,8 @@ type (
//创建共创用户
type (
ReqCreateCooperatorUser struct {
// 企业ID
CompanyId int64 `cname:"企业ID" json:"companyId"`
// 共创公司
CooperationCompany string ` json:"cooperationCompany"`
// 共创到期时间
... ...
... ... @@ -13,6 +13,7 @@ type MenuController struct {
func (controller *MenuController) MenuList() {
menuService := service.NewMenuService(nil)
menuListQuery := &query.MenuListQuery{}
controller.Unmarshal(menuListQuery)
menuListQuery.Operator = controller.GetOperator()
data, err := menuService.MenuList(menuListQuery)
controller.Response(data, err)
... ... @@ -31,6 +32,7 @@ func (controller *MenuController) MenuFavorite() {
menuService := service.NewMenuService(nil)
menuFavoriteCommand := &command.MenuFavoriteCommand{}
controller.Unmarshal(menuFavoriteCommand)
menuFavoriteCommand.Operator = controller.GetOperator()
data, err := menuService.MenuFavorite(menuFavoriteCommand)
controller.Response(data, err)
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/service"
"strconv"
)
type UsersController struct {
... ... @@ -78,6 +79,8 @@ func (controller *UsersController) CooperationUserUpdate() {
usersService := service.NewUsersService(nil)
cooperationUserUpdateCommand := &command.CooperationUserUpdateCommand{}
controller.Unmarshal(cooperationUserUpdateCommand)
userId := controller.GetString(":userId")
cooperationUserUpdateCommand.UserId, _ = strconv.ParseInt(userId, 10, 64)
cooperationUserUpdateCommand.Operator = controller.GetOperator()
data, err := usersService.CooperationUserUpdate(cooperationUserUpdateCommand)
controller.Response(data, err)
... ...
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("/v1/web/menus/search", &web_client.MenuController{}, "Post:MenuList")
web.Router("/v1/web/menus", &web_client.MenuController{}, "Put:MenuUpdate")
web.Router("/v1/web/menus/favorite", &web_client.MenuController{}, "Put:MenuFavorite")
}
... ...
... ... @@ -13,7 +13,7 @@ func init() {
web.Router("/v1/web/users/company-user/enable", &web_client.UsersController{}, "Put:CompanyUserEnable")
web.Router("/v1/web/users/company-user/reset-password", &web_client.UsersController{}, "Put:CompanyUserResetPassword")
web.Router("/v1/web/users/cooperation-user", &web_client.UsersController{}, "Post:CooperationUserAdd")
web.Router("/v1/web/users/cooperation-user", &web_client.UsersController{}, "Put:CooperationUserUpdate")
web.Router("/v1/web/users/cooperation-user/:userId", &web_client.UsersController{}, "Put:CooperationUserUpdate")
web.Router("/v1/web/users/cooperation-user/search", &web_client.UsersController{}, "Post:CooperationUserList")
web.Router("/v1/web/users/cooperation-user/:userId", &web_client.UsersController{}, "Get:CooperationUserGet")
web.Router("/v1/web/users/cooperation-user/enable", &web_client.UsersController{}, "Put:CooperationUserEnable")
... ...