作者 yangfu

重构

正在显示 100 个修改的文件 包含 204 行增加364 行删除

要显示太多修改。

为保证性能只显示 100 of 100+ 个文件。

package access
package service
import (
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/access/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/access/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/access"
)
type AccessService struct {
}
func (svr *AccessService) CreateAccess(header *protocol.RequestHeader, request *protocolx.CreateAccessRequest) (rsp interface{}, err error) {
func (svr *AccessService) CreateAccess(header *protocol.RequestHeader, request *command.CreateAccessRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.CreateAccessResponse{}
rsp = &command.CreateAccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -47,11 +48,11 @@ func (svr *AccessService) CreateAccess(header *protocol.RequestHeader, request *
return
}
func (svr *AccessService) UpdateAccess(header *protocol.RequestHeader, request *protocolx.UpdateAccessRequest) (rsp interface{}, err error) {
func (svr *AccessService) UpdateAccess(header *protocol.RequestHeader, request *command.UpdateAccessRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.UpdateAccessResponse{}
rsp = &command.UpdateAccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -78,11 +79,11 @@ func (svr *AccessService) UpdateAccess(header *protocol.RequestHeader, request *
return
}
func (svr *AccessService) GetAccess(header *protocol.RequestHeader, request *protocolx.GetAccessRequest) (rsp interface{}, err error) {
func (svr *AccessService) GetAccess(header *protocol.RequestHeader, request *query.GetAccessRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.GetAccessResponse{}
rsp = &query.GetAccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -104,11 +105,11 @@ func (svr *AccessService) GetAccess(header *protocol.RequestHeader, request *pro
return
}
func (svr *AccessService) DeleteAccess(header *protocol.RequestHeader, request *protocolx.DeleteAccessRequest) (rsp interface{}, err error) {
func (svr *AccessService) DeleteAccess(header *protocol.RequestHeader, request *command.DeleteAccessRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.DeleteAccessResponse{}
rsp = &command.DeleteAccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -133,11 +134,11 @@ func (svr *AccessService) DeleteAccess(header *protocol.RequestHeader, request *
return
}
func (svr *AccessService) ListAccess(header *protocol.RequestHeader, request *protocolx.ListAccessRequest) (rsp interface{}, err error) {
func (svr *AccessService) ListAccess(header *protocol.RequestHeader, request *query.ListAccessRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.ListAccessResponse{}
rsp = &query.ListAccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ...
package auth
package query
import "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
... ...
package auth
package service
import (
"encoding/json"
... ... @@ -7,25 +7,26 @@ import (
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/cache"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/auth/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/cachex"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/auth"
"time"
)
type AuthService struct {
}
func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx.LoginRequest) (rsp *protocolx.LoginResponse, err error) {
func (svr *AuthService) Login(header *protocol.RequestHeader, request *command.LoginRequest) (rsp *command.LoginResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
UserRepository, _ = factory.CreateUserRepository(transactionContext)
)
rsp = &protocolx.LoginResponse{}
rsp = &command.LoginResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -63,11 +64,11 @@ func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx
return
}
func (svr *AuthService) Logout(header *protocol.RequestHeader, request *protocolx.LogoutRequest) (rsp *protocolx.LogoutResponse, err error) {
func (svr *AuthService) Logout(header *protocol.RequestHeader, request *command.LogoutRequest) (rsp *command.LogoutResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.LogoutResponse{}
rsp = &command.LogoutResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -83,12 +84,12 @@ func (svr *AuthService) Logout(header *protocol.RequestHeader, request *protocol
return
}
func (svr *AuthService) Refresh(header *protocol.RequestHeader, request *protocolx.RefreshRequest) (rsp interface{}, err error) {
func (svr *AuthService) Refresh(header *protocol.RequestHeader, request *command.RefreshRequest) (rsp interface{}, err error) {
var (
//transactionContext, _ = factory.CreateTransactionContext(nil)
)
//transactionContext.SetTransactionClose()
rsp = &protocolx.RefreshResponse{}
rsp = &command.RefreshResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -108,13 +109,13 @@ func (svr *AuthService) Refresh(header *protocol.RequestHeader, request *protoco
return
}
log.Debug(claim.Username, claim.Password, time.Unix(claim.ExpiresAt, 0))
rsp, err = svr.Login(header, &protocolx.LoginRequest{UserName: (claim.AddData["Phone"]).(string), Password: claim.Password})
rsp, err = svr.Login(header, &command.LoginRequest{UserName: (claim.AddData["Phone"]).(string), Password: claim.Password})
//err = transactionContext.CommitTransaction()
return
}
func (svr *AuthService) Profile(header *protocol.RequestHeader, request *protocolx.ProfileRequest) (rsp interface{}, err error) {
func (svr *AuthService) Profile(header *protocol.RequestHeader, request *command.ProfileRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
UserRepository, _ = factory.CreateUserRepository(transactionContext)
... ... @@ -122,7 +123,7 @@ func (svr *AuthService) Profile(header *protocol.RequestHeader, request *protoco
RoleAccessDao, _ = dao.NewRoleAccessDao(transactionContext)
AccessRepository, _ = factory.CreateAccessRepository(transactionContext)
)
rsp = &protocolx.ProfileResponse{}
rsp = &command.ProfileResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -167,11 +168,11 @@ func (svr *AuthService) Profile(header *protocol.RequestHeader, request *protoco
return
}
func (svr *AuthService) CaptchaInit(header *protocol.RequestHeader, request *protocolx.CaptchaInitRequest) (rsp interface{}, err error) {
func (svr *AuthService) CaptchaInit(header *protocol.RequestHeader, request *query.CaptchaInitRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.CaptchaInitResponse{}
rsp = &query.CaptchaInitResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -203,12 +204,12 @@ func (svr *AuthService) CaptchaInit(header *protocol.RequestHeader, request *pro
return
}
func (svr *AuthService) ChangePassword(header *protocol.RequestHeader, request *protocolx.ChangePasswordRequest) (rsp *protocolx.ChangePasswordResponse, err error) {
func (svr *AuthService) ChangePassword(header *protocol.RequestHeader, request *command.ChangePasswordRequest) (rsp *command.ChangePasswordResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
UserRepository, _ = factory.CreateUserRepository(transactionContext)
)
rsp = &protocolx.ChangePasswordResponse{}
rsp = &command.ChangePasswordResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ...
package client_version
package query
import (
"fmt"
... ... @@ -9,11 +9,13 @@ type ListClientVersionRequest struct {
Offset int `json:"offset"`
Limit int `json:"limit"`
SearchByText string `json:"projectName,omitempty"` //按名称搜索
SortByCreateTime string `json:"sortByCreateTime`
}
func (ListClientVersionRequest *ListClientVersionRequest) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(ListClientVersionRequest)
ListClientVersionRequest.SortByCreateTime = "desc"
if err != nil {
return err
}
... ...
package client_version
package service
import (
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/clientVersion/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/clientVersion/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/client_version"
"time"
)
type ClientVersionService struct {
}
func (svr *ClientVersionService) CreateClientVersion(header *protocol.RequestHeader, request *protocolx.CreateClientVersionRequest) (rsp interface{}, err error) {
func (svr *ClientVersionService) CreateClientVersion(header *protocol.RequestHeader, request *command.CreateClientVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.CreateClientVersionResponse{}
rsp = &command.CreateClientVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -50,11 +51,11 @@ func (svr *ClientVersionService) CreateClientVersion(header *protocol.RequestHea
return
}
func (svr *ClientVersionService) UpdateClientVersion(header *protocol.RequestHeader, request *protocolx.UpdateClientVersionRequest) (rsp interface{}, err error) {
func (svr *ClientVersionService) UpdateClientVersion(header *protocol.RequestHeader, request *command.UpdateClientVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.UpdateClientVersionResponse{}
rsp = &command.UpdateClientVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -82,11 +83,11 @@ func (svr *ClientVersionService) UpdateClientVersion(header *protocol.RequestHea
return
}
func (svr *ClientVersionService) GetClientVersion(header *protocol.RequestHeader, request *protocolx.GetClientVersionRequest) (rsp interface{}, err error) {
func (svr *ClientVersionService) GetClientVersion(header *protocol.RequestHeader, request *query.GetClientVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.GetClientVersionResponse{}
rsp = &query.GetClientVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -109,11 +110,11 @@ func (svr *ClientVersionService) GetClientVersion(header *protocol.RequestHeader
return
}
func (svr *ClientVersionService) DeleteClientVersion(header *protocol.RequestHeader, request *protocolx.DeleteClientVersionRequest) (rsp interface{}, err error) {
func (svr *ClientVersionService) DeleteClientVersion(header *protocol.RequestHeader, request *command.DeleteClientVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.DeleteClientVersionResponse{}
rsp = &command.DeleteClientVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -139,11 +140,11 @@ func (svr *ClientVersionService) DeleteClientVersion(header *protocol.RequestHea
return
}
func (svr *ClientVersionService) ListClientVersion(header *protocol.RequestHeader, request *protocolx.ListClientVersionRequest) (rsp interface{}, err error) {
func (svr *ClientVersionService) ListClientVersion(header *protocol.RequestHeader, request *query.ListClientVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.ListClientVersionResponse{}
rsp = &query.ListClientVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ...
package menu
import (
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/menu"
"time"
)
type MenuService struct {
}
func (svr *MenuService) CreateMenu(header *protocol.RequestHeader, request *protocolx.CreateMenuRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.CreateMenuResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
if err = transactionContext.StartTransaction(); err != nil {
log.Error(err)
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
newMenu := &domain.Menu{
MenuName: request.MenuName,
MenuCode: request.MenuCode,
Icon: request.Icon,
Sort: request.Sort,
Hidden: request.Hidden,
CreatedTime: time.Now(),
UpdateTime: time.Now(),
}
var MenuRepository, _ = factory.CreateMenuRepository(transactionContext)
if m, err := MenuRepository.Save(newMenu); err != nil {
return nil, err
} else {
rsp = m
}
err = transactionContext.CommitTransaction()
return
}
func (svr *MenuService) UpdateMenu(header *protocol.RequestHeader, request *protocolx.UpdateMenuRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.UpdateMenuResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
if err = transactionContext.StartTransaction(); err != nil {
log.Error(err)
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
var MenuRepository, _ = factory.CreateMenuRepository(transactionContext)
var menu *domain.Menu
if menu, err = MenuRepository.FindOne(common.ObjectToMap(request)); err != nil {
return
}
if err = menu.Update(common.ObjectToMap(request)); err != nil {
return
}
if menu, err = MenuRepository.Save(menu); err != nil {
return
}
err = transactionContext.CommitTransaction()
return
}
func (svr *MenuService) GetMenu(header *protocol.RequestHeader, request *protocolx.GetMenuRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.GetMenuResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
if err = transactionContext.StartTransaction(); err != nil {
log.Error(err)
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
var MenuRepository, _ = factory.CreateMenuRepository(transactionContext)
var menu *domain.Menu
if menu, err = MenuRepository.FindOne(common.ObjectToMap(request)); err != nil {
return
}
rsp = menu
err = transactionContext.CommitTransaction()
return
}
func (svr *MenuService) DeleteMenu(header *protocol.RequestHeader, request *protocolx.DeleteMenuRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.DeleteMenuResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
if err = transactionContext.StartTransaction(); err != nil {
log.Error(err)
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
var MenuRepository, _ = factory.CreateMenuRepository(transactionContext)
var menu *domain.Menu
if menu, err = MenuRepository.FindOne(common.ObjectToMap(request)); err != nil {
return
}
if menu, err = MenuRepository.Remove(menu); err != nil {
return
}
rsp = menu
err = transactionContext.CommitTransaction()
return
}
func (svr *MenuService) ListMenu(header *protocol.RequestHeader, request *protocolx.ListMenuRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.ListMenuResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
if err = transactionContext.StartTransaction(); err != nil {
log.Error(err)
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
var MenuRepository, _ = factory.CreateMenuRepository(transactionContext)
var menu []*domain.Menu
var total int64
if total, menu, err = MenuRepository.Find(common.ObjectToMap(request)); err != nil {
return
}
rsp = map[string]interface{}{
"total": total,
"list": menu,
}
err = transactionContext.CommitTransaction()
return
}
func NewMenuService(options map[string]interface{}) *MenuService {
svr := &MenuService{}
return svr
}
package operator_log
package service
import (
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/operatorLog/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/operatorLog/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/operator_log"
)
type OperatorLogService struct {
}
func (svr *OperatorLogService) CreateOperatorLog(header *protocol.RequestHeader, request *protocolx.CreateOperatorLogRequest) (rsp interface{}, err error) {
func (svr *OperatorLogService) CreateOperatorLog(header *protocol.RequestHeader, request *command.CreateOperatorLogRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.CreateOperatorLogResponse{}
rsp = &command.CreateOperatorLogResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -45,11 +46,11 @@ func (svr *OperatorLogService) CreateOperatorLog(header *protocol.RequestHeader,
return
}
func (svr *OperatorLogService) UpdateOperatorLog(header *protocol.RequestHeader, request *protocolx.UpdateOperatorLogRequest) (rsp interface{}, err error) {
func (svr *OperatorLogService) UpdateOperatorLog(header *protocol.RequestHeader, request *command.UpdateOperatorLogRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.UpdateOperatorLogResponse{}
rsp = &command.UpdateOperatorLogResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -77,11 +78,11 @@ func (svr *OperatorLogService) UpdateOperatorLog(header *protocol.RequestHeader,
return
}
func (svr *OperatorLogService) GetOperatorLog(header *protocol.RequestHeader, request *protocolx.GetOperatorLogRequest) (rsp interface{}, err error) {
func (svr *OperatorLogService) GetOperatorLog(header *protocol.RequestHeader, request *query.GetOperatorLogRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.GetOperatorLogResponse{}
rsp = &query.GetOperatorLogResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -104,11 +105,11 @@ func (svr *OperatorLogService) GetOperatorLog(header *protocol.RequestHeader, re
return
}
func (svr *OperatorLogService) DeleteOperatorLog(header *protocol.RequestHeader, request *protocolx.DeleteOperatorLogRequest) (rsp interface{}, err error) {
func (svr *OperatorLogService) DeleteOperatorLog(header *protocol.RequestHeader, request *command.DeleteOperatorLogRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.DeleteOperatorLogResponse{}
rsp = &command.DeleteOperatorLogResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -134,11 +135,11 @@ func (svr *OperatorLogService) DeleteOperatorLog(header *protocol.RequestHeader,
return
}
func (svr *OperatorLogService) ListOperatorLog(header *protocol.RequestHeader, request *protocolx.ListOperatorLogRequest) (rsp interface{}, err error) {
func (svr *OperatorLogService) ListOperatorLog(header *protocol.RequestHeader, request *query.ListOperatorLogRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.ListOperatorLogResponse{}
rsp = &query.ListOperatorLogResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ...
package project_module
package service
import (
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModule/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModule/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/project_module"
"time"
)
type ProjectModuleService struct {
}
func (svr *ProjectModuleService) CreateProjectModule(header *protocol.RequestHeader, request *protocolx.CreateProjectModuleRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleService) CreateProjectModule(header *protocol.RequestHeader, request *command.CreateProjectModuleRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
ProjectModuleVersionRepository, _ = factory.CreateProjectModuleVersionRepository(transactionContext)
)
rsp = &protocolx.CreateProjectModuleResponse{}
rsp = &command.CreateProjectModuleResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -65,11 +66,11 @@ func (svr *ProjectModuleService) CreateProjectModule(header *protocol.RequestHea
return
}
func (svr *ProjectModuleService) UpdateProjectModule(header *protocol.RequestHeader, request *protocolx.UpdateProjectModuleRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleService) UpdateProjectModule(header *protocol.RequestHeader, request *command.UpdateProjectModuleRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.UpdateProjectModuleResponse{}
rsp = &command.UpdateProjectModuleResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -103,11 +104,11 @@ func (svr *ProjectModuleService) UpdateProjectModule(header *protocol.RequestHea
return
}
func (svr *ProjectModuleService) GetProjectModule(header *protocol.RequestHeader, request *protocolx.GetProjectModuleRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleService) GetProjectModule(header *protocol.RequestHeader, request *query.GetProjectModuleRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.GetProjectModuleResponse{}
rsp = &query.GetProjectModuleResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -131,11 +132,11 @@ func (svr *ProjectModuleService) GetProjectModule(header *protocol.RequestHeader
return
}
func (svr *ProjectModuleService) DeleteProjectModule(header *protocol.RequestHeader, request *protocolx.DeleteProjectModuleRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleService) DeleteProjectModule(header *protocol.RequestHeader, request *command.DeleteProjectModuleRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.DeleteProjectModuleResponse{}
rsp = &command.DeleteProjectModuleResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -164,7 +165,7 @@ func (svr *ProjectModuleService) DeleteProjectModule(header *protocol.RequestHea
return
}
func (svr *ProjectModuleService) ListProjectModule(header *protocol.RequestHeader, request *protocolx.ListProjectModuleRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleService) ListProjectModule(header *protocol.RequestHeader, request *query.ListProjectModuleRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
... ...
package project_module_files
package service
import (
"bytes"
... ... @@ -6,11 +6,12 @@ import (
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModuleFiles/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModuleFiles/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/project_module_files"
"path/filepath"
"strconv"
"strings"
... ... @@ -20,12 +21,12 @@ import (
type ProjectModuleFilesService struct {
}
func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.CreateProjectModuleFilesRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol.RequestHeader, request *command.CreateProjectModuleFilesRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
ProjectModuleVersion, _ = factory.CreateProjectModuleVersionRepository(transactionContext)
)
rsp = &protocolx.CreateProjectModuleFilesResponse{}
rsp = &command.CreateProjectModuleFilesResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -63,12 +64,12 @@ func (svr *ProjectModuleFilesService) CreateProjectModuleFiles(header *protocol.
return
}
func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.UpdateProjectModuleFilesRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.RequestHeader, request *command.UpdateProjectModuleFilesRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
ProjectModuleFilesDao, _ = dao.NewProjectModuleFilesDao(transactionContext)
)
rsp = &protocolx.UpdateProjectModuleFilesResponse{}
rsp = &command.UpdateProjectModuleFilesResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -134,11 +135,11 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.
return
}
func (svr *ProjectModuleFilesService) GetProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.GetProjectModuleFilesRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleFilesService) GetProjectModuleFiles(header *protocol.RequestHeader, request *query.GetProjectModuleFilesRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.GetProjectModuleFilesResponse{}
rsp = &query.GetProjectModuleFilesResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -160,11 +161,11 @@ func (svr *ProjectModuleFilesService) GetProjectModuleFiles(header *protocol.Req
return
}
func (svr *ProjectModuleFilesService) DeleteProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.DeleteProjectModuleFilesRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleFilesService) DeleteProjectModuleFiles(header *protocol.RequestHeader, request *command.DeleteProjectModuleFilesRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.DeleteProjectModuleFilesResponse{}
rsp = &command.DeleteProjectModuleFilesResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -196,11 +197,11 @@ func (svr *ProjectModuleFilesService) DeleteProjectModuleFiles(header *protocol.
return
}
func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.RequestHeader, request *protocolx.ListProjectModuleFilesRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.RequestHeader, request *query.ListProjectModuleFilesRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.ListProjectModuleFilesResponse{}
rsp = &query.ListProjectModuleFilesResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -252,12 +253,12 @@ func (svr *ProjectModuleFilesService) ListProjectModuleFiles(header *protocol.Re
return
}
func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, request *protocolx.ImportRequest) (rsp *protocolx.ImportResponse, err error) {
func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, request *command.ImportRequest) (rsp *command.ImportResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
ProjectModuleVersion, _ = factory.CreateProjectModuleVersionRepository(transactionContext)
)
rsp = &protocolx.ImportResponse{}
rsp = &command.ImportResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -325,11 +326,11 @@ func (svr *ProjectModuleFilesService) Import(header *protocol.RequestHeader, req
// ReviseTag
// 修订标签
func (svr *ProjectModuleFilesService) ReviseTag(header *protocol.RequestHeader, request *protocolx.ReviseTagRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleFilesService) ReviseTag(header *protocol.RequestHeader, request *command.ReviseTagRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.ReviseTagResponse{}
rsp = &command.ReviseTagResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -427,11 +428,11 @@ func (svr *ProjectModuleFilesService) mkdirF(fileDir string, mid, vid, pid int64
func (svr *ProjectModuleFilesService) traverseModuleFiles(files []*domain.ProjectModuleFiles) interface{} {
retSlice := make([]*protocolx.ModuleFiles, 0)
retSlice := make([]*query.ModuleFiles, 0)
for i := range files {
if files[i].ParentId == 0 {
retSlice = append(retSlice, &protocolx.ModuleFiles{ModuleFile: protocolx.NewModuleFile(files[i]), List: make([]*protocolx.ModuleFiles, 0)})
retSlice = append(retSlice, &query.ModuleFiles{ModuleFile: query.NewModuleFile(files[i]), List: make([]*query.ModuleFiles, 0)})
continue
}
traverse(retSlice, files[i])
... ... @@ -439,17 +440,17 @@ func (svr *ProjectModuleFilesService) traverseModuleFiles(files []*domain.Projec
return retSlice
}
func traverse(list []*protocolx.ModuleFiles, file *domain.ProjectModuleFiles) {
func traverse(list []*query.ModuleFiles, file *domain.ProjectModuleFiles) {
for i := range list {
if list[i].Id == file.ParentId {
list[i].List = append(list[i].List, &protocolx.ModuleFiles{ModuleFile: protocolx.NewModuleFile(file), List: make([]*protocolx.ModuleFiles, 0)})
list[i].List = append(list[i].List, &query.ModuleFiles{ModuleFile: query.NewModuleFile(file), List: make([]*query.ModuleFiles, 0)})
return
}
traverse(list[i].List, file)
}
return
}
func changeLog(request *protocolx.UpdateProjectModuleFilesRequest, old *domain.ProjectModuleFiles) string {
func changeLog(request *command.UpdateProjectModuleFilesRequest, old *domain.ProjectModuleFiles) string {
buf := bytes.NewBuffer(nil)
if len(request.FileName) > 0 && request.FileName != old.FileName {
buf.WriteString("【文件名】修改为:" + request.FileName + "\n")
... ...
package project_module_version
package service
import (
"fmt"
"github.com/tiptok/gocomm/common"
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModuleVersion/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/projectModuleVersion/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/project_module_version"
"strings"
"time"
)
... ... @@ -17,11 +18,11 @@ import (
type ProjectModuleVersionService struct {
}
func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *protocol.RequestHeader, request *protocolx.CreateProjectModuleVersionRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *protocol.RequestHeader, request *command.CreateProjectModuleVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.CreateProjectModuleVersionResponse{}
rsp = &command.CreateProjectModuleVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -72,11 +73,11 @@ func (svr *ProjectModuleVersionService) CreateProjectModuleVersion(header *proto
return
}
func (svr *ProjectModuleVersionService) UpdateProjectModuleVersion(header *protocol.RequestHeader, request *protocolx.UpdateProjectModuleVersionRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleVersionService) UpdateProjectModuleVersion(header *protocol.RequestHeader, request *command.UpdateProjectModuleVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.UpdateProjectModuleVersionResponse{}
rsp = &command.UpdateProjectModuleVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -112,11 +113,11 @@ func (svr *ProjectModuleVersionService) UpdateProjectModuleVersion(header *proto
return
}
func (svr *ProjectModuleVersionService) GetProjectModuleVersion(header *protocol.RequestHeader, request *protocolx.GetProjectModuleVersionRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleVersionService) GetProjectModuleVersion(header *protocol.RequestHeader, request *query.GetProjectModuleVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.GetProjectModuleVersionResponse{}
rsp = &query.GetProjectModuleVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -140,11 +141,11 @@ func (svr *ProjectModuleVersionService) GetProjectModuleVersion(header *protocol
return
}
func (svr *ProjectModuleVersionService) DeleteProjectModuleVersion(header *protocol.RequestHeader, request *protocolx.DeleteProjectModuleVersionRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleVersionService) DeleteProjectModuleVersion(header *protocol.RequestHeader, request *command.DeleteProjectModuleVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.DeleteProjectModuleVersionResponse{}
rsp = &command.DeleteProjectModuleVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ... @@ -175,11 +176,11 @@ func (svr *ProjectModuleVersionService) DeleteProjectModuleVersion(header *proto
return
}
func (svr *ProjectModuleVersionService) ListProjectModuleVersion(header *protocol.RequestHeader, request *protocolx.ListProjectModuleVersionRequest) (rsp interface{}, err error) {
func (svr *ProjectModuleVersionService) ListProjectModuleVersion(header *protocol.RequestHeader, request *query.ListProjectModuleVersionRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.ListProjectModuleVersionResponse{}
rsp = &query.ListProjectModuleVersionResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ...
package rbac
package service
import (
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/rbac/command"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/rbac/query"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/rbac"
)
type RbacService struct {
}
func (svr *RbacService) Access(header *protocol.RequestHeader, request *protocolx.AccessRequest) (rsp interface{}, err error) {
func (svr *RbacService) Access(header *protocol.RequestHeader, request *query.AccessRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
)
rsp = &protocolx.AccessResponse{}
rsp = &query.AccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -53,14 +54,14 @@ func (svr *RbacService) Access(header *protocol.RequestHeader, request *protocol
return
}
func (svr *RbacService) RoleAccess(header *protocol.RequestHeader, request *protocolx.RoleAccessRequest) (rsp interface{}, err error) {
func (svr *RbacService) RoleAccess(header *protocol.RequestHeader, request *query.RoleAccessRequest) (rsp interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
RoleAccessDao, _ = dao.NewRoleAccessDao(transactionContext)
RoleRepository, _ = factory.CreateRoleRepository(transactionContext)
role *domain.Role
)
rsp = &protocolx.RoleAccessResponse{}
rsp = &query.RoleAccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
return
... ... @@ -89,14 +90,14 @@ func (svr *RbacService) RoleAccess(header *protocol.RequestHeader, request *prot
return
}
func (svr *RbacService) SetRoleAccess(header *protocol.RequestHeader, request *protocolx.SetRoleAccessRequest) (rsp *protocolx.SetRoleAccessResponse, err error) {
func (svr *RbacService) SetRoleAccess(header *protocol.RequestHeader, request *command.SetRoleAccessRequest) (rsp *command.SetRoleAccessResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
AccessRepository, _ = factory.CreateAccessRepository(transactionContext)
RoleRepository, _ = factory.CreateRoleRepository(transactionContext)
RoleAccessDao, _ = dao.NewRoleAccessDao(transactionContext)
)
rsp = &protocolx.SetRoleAccessResponse{}
rsp = &command.SetRoleAccessResponse{}
if err = request.ValidateCommand(); err != nil {
err = protocol.NewCustomMessage(2, err.Error())
}
... ...