作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/partnermg into dev

package command
import (
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)
type SaveAdminUserCommand struct {
Id int64 `json:"id"`
// 员工姓名
... ... @@ -13,3 +17,13 @@ type SaveAdminUserCommand struct {
IsUsable bool `json:"isUsable"`
}
func (command SaveAdminUserCommand) ValidateCommand() error {
if len(command.Name) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "用户名称必填")
}
if len(command.Account) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "账号必填")
}
return nil
}
... ...
package command
import "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
//UpdateAdminUserPwdCommand 修改密码
type UpdateAdminUserPwdCommand struct {
Id int64 `json:"id"`
//密码
Password string `json:"password"`
}
func (command UpdateAdminUserPwdCommand) ValidateCommand() error {
if len(command.Password) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "密码必填")
}
return nil
}
... ...
... ... @@ -49,6 +49,9 @@ func (adminUserSrv AdminUserService) GetAdminUser(getAdminUserQuery *query.GetAd
}
func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdminUserCommand) (*domain.AdminUser, error) {
if err := saveUserCmd.ValidateCommand(); err != nil {
return nil, lib.ThrowError(lib.ARG_ERROR, err.Error())
}
//实际业务
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -192,6 +195,9 @@ func (adminUserSrv AdminUserService) PageListAdminUser(listAdminUserQuery *query
}
func (adminUserSrv AdminUserService) UpdateAdminPassword(updatecmd command.UpdateAdminUserPwdCommand) error {
if err := updatecmd.ValidateCommand(); err != nil {
return lib.ThrowError(lib.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
... ...