作者 tangxuhui
正在显示 42 个修改的文件 包含 1689 行增加133 行删除
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type AccessTokenCommand struct {
AuthCode string `json:"authCode" valid:"Required"`
SessionMode int `json:"sessionMode"`
}
func (orgAddCommand *AccessTokenCommand) Valid(validation *validation.Validation) {
}
func (orgAddCommand *AccessTokenCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(orgAddCommand)
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"
)
type CheckSmsCodeCommand struct {
Phone string `json:"phone" valid:"Required"`
SmsCode string `json:"smsCode" valid:"Required"`
// [1:登录][2:修改密码][3:找回密码][4:注册][5:修改手机号]
Action int `json:"action" valid:"Required"`
}
func (checkSmsCodeCommand *CheckSmsCodeCommand) Valid(validation *validation.Validation) {
}
func (checkSmsCodeCommand *CheckSmsCodeCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(checkSmsCodeCommand)
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"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type CompanySignUpCommand struct {
// 企业名称
CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
// 联系人
Contacts string `cname:"联系人" json:"userName" valid:"Required"`
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 规模
Scale string `cname:"规模" json:"scale" valid:"Required"`
// 所属行业
IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
// 短信验证码
SmsCode string `cname:"短信验证码" json:"smsCode" valid:"Required"`
}
func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (companySignUpCommand *CompanySignUpCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(companySignUpCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(companySignUpCommand).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"
"github.com/beego/beego/v2/core/validation"
)
type LoginCommand struct {
Phone string `json:"phone" valid:"Required"`
GrantType string `json:"grantType" valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录)
Password string `json:"password"`
Captcha string `json:"captcha"`
SessionMode int `json:"sessionMode"`
}
func (orgAddCommand *LoginCommand) Valid(validation *validation.Validation) {
}
func (orgAddCommand *LoginCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(orgAddCommand)
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"
)
type LoginPwdCommand struct {
Username string `json:"username" valid:"Required"`
Password string `json:"password"`
// 图形验证码操作成功的识别字段,服务端需使用图形验证插件(geetest)提供的验证模块
// 对相应数据进行验证,用以确定该次请求为用户手动操作的正确行为
CaptchaChallenge string `json:"captchaChallenge"`
CaptchaValidate string `json:"captchaValidate"`
CaptchaSeccode string `json:"captchaSeccode"`
SessionMode int `json:"sessionMode"`
}
func (cmd *LoginPwdCommand) Valid(validation *validation.Validation) {
}
func (cmd *LoginPwdCommand) 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"
)
type LoginSmsCommand struct {
Phone string `json:"phone" valid:"Required"`
Code string `json:"code" valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录)
SessionMode int `json:"sessionMode"`
}
func (cmd *LoginSmsCommand) Valid(validation *validation.Validation) {
}
func (cmd *LoginSmsCommand) 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"
)
type RefreshTokenCommand struct {
RefreshToken string `json:"refreshToken" valid:"Required"`
}
func (orgAddCommand *RefreshTokenCommand) Valid(validation *validation.Validation) {
}
func (orgAddCommand *RefreshTokenCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(orgAddCommand)
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"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ResetPasswordCommand struct {
// 手机号码
// Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 密码
Password string `cname:"密码" json:"newPassword"`
// 密码
RepeatNewPassword string `cname:"密码" json:"repeatNewPassword" valid:"Required"`
// 密码
SmsCodeIdentity string `cname:"密码" json:"smsCodeIdentity" valid:"Required"`
}
func (resetPasswordCommand *ResetPasswordCommand) Valid(validation *validation.Validation) {
if len(resetPasswordCommand.Password) == 0 {
validation.Error("登录密码不能为空")
return
}
if resetPasswordCommand.Password != resetPasswordCommand.RepeatNewPassword {
validation.Error("两次密码输入不一致")
return
}
}
func (resetPasswordCommand *ResetPasswordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(resetPasswordCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(resetPasswordCommand).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"
"github.com/beego/beego/v2/core/validation"
)
type SendSmsCodeCommand struct {
Phone string `json:"phone" valid:"Required"`
}
func (orgAddCommand *SendSmsCodeCommand) Valid(validation *validation.Validation) {
}
func (orgAddCommand *SendSmsCodeCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(orgAddCommand)
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 SwitchOrgCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 组织ID
OrgId int64 `json:"orgId,string"`
}
func (switchOrgCommand *SwitchOrgCommand) Valid(validation *validation.Validation) {
}
func (switchOrgCommand *SwitchOrgCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(switchOrgCommand)
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 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
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type GetCompanyOrgsByUserQuery struct {
//操作人
Operator domain.Operator `json:"-"`
Phone string `json:"phone" valid:"Required"` //手机号
}
func (orgAddCommand *GetCompanyOrgsByUserQuery) Valid(validation *validation.Validation) {
}
func (orgAddCommand *GetCompanyOrgsByUserQuery) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(orgAddCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
type QrcodeLoginStatusQuery struct {
Key string `json:"key"`
SessionMode int `json:"sessionMode"`
}
... ...
package service
import (
"github.com/google/uuid"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/auth/dto"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/cache"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/sms_serve"
)
// 组织管理
type AuthService struct {
}
//AuthLogin 用户登录
func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{}, error) {
var (
authCode string
result interface{}
err error
)
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err = creationUserGateway.AuthRefreshIM(allied_creation_user.ReqAuthRefreshIM{
Phone: loginCommand.Phone,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
switch loginCommand.GrantType {
case "signInPassword":
authCode, err = srv.SignInPassword(loginCommand.Phone, loginCommand.Password)
case "signInCaptcha":
authCode, err = srv.SignInCaptcha(loginCommand.Phone, loginCommand.Captcha)
default:
err = application.ThrowError(application.TRANSACTION_ERROR, "登录方式无法解析")
}
result, err = srv.GetAuthAccessToken(&command.AccessTokenCommand{
AuthCode: authCode,
SessionMode: loginCommand.SessionMode,
})
return map[string]interface{}{
"access": result,
}, err
}
//AuthLogin 用户登录
func (srv AuthService) AuthLoginPwd(loginCommand *command.LoginPwdCommand) (interface{}, error) {
if err := loginCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
login := &command.LoginCommand{
GrantType: "signInPassword",
Phone: loginCommand.Username,
Password: loginCommand.Password,
SessionMode: loginCommand.SessionMode,
}
return srv.AuthLogin(login)
}
//AuthLogin 用户登录
func (srv AuthService) AuthLoginSms(loginCommand *command.LoginSmsCommand) (interface{}, error) {
if err := loginCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
login := &command.LoginCommand{
GrantType: "signInCaptcha",
Phone: loginCommand.Phone,
Captcha: loginCommand.Code,
SessionMode: loginCommand.SessionMode,
}
return srv.AuthLogin(login)
}
//SendSmsCaptcha 发送验证码短信
func (srv AuthService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error {
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.SendSms(smsCodeCommand.Phone)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil
}
//SignInPassword 使用账号密码校验
func (srv AuthService) SignInPassword(account string, password string) (string, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err := creationUserGateway.AuthCheckPassword(allied_creation_user.ReqAuthCheckPassword{
Password: password,
Phone: account,
})
if err != nil {
return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := domain.LoginToken{
UserId: 0,
Account: account,
Platform: domain.LoginPlatformApp,
CompanyId: 0,
}
authcode, err := ltoken.GenerateAuthCode()
if err != nil {
return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//result := map[string]string{
// "authCode": authcode,
//}
return authcode, nil
}
//SignInCaptcha 使用手机验证码登录
func (srv AuthService) SignInCaptcha(phone string, captcha string) (string, error) {
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.CheckSmsCode(phone, captcha)
if err != nil {
return "", application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
ltoken := domain.LoginToken{
UserId: 0,
Account: phone,
Platform: domain.LoginPlatformApp,
CompanyId: 0,
}
authcode, err := ltoken.GenerateAuthCode()
if err != nil {
return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return authcode, nil
}
//GetAuthAccessToken 获取令牌Token
func (srv AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessTokenCommand) (interface{}, error) {
if err := accessTokenCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := &domain.LoginToken{}
err := ltoken.ParseToken(accessTokenCommand.AuthCode)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
phone := ltoken.Account
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
userSeachResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
CompanyId: ltoken.CompanyId,
Phone: phone,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if len(userSeachResult.Users) == 0 {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息失败")
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var loginAccessRepository domain.LoginAccessRepository
if loginAccessRepository, err = factory.CreateLoginAccessRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
_, lAccess, err := loginAccessRepository.Find(map[string]interface{}{
"account": phone,
"platform": domain.LoginPlatformApp,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var currentAccess *domain.LoginAccess
if len(lAccess) > 0 {
currentAccess = lAccess[0]
currentAccess.UpdatedTime = time.Now()
} else {
currentAccess = &domain.LoginAccess{
UserBaseId: int64(userSeachResult.Users[0].UserBaseId),
UserId: int64(userSeachResult.Users[0].UserId),
Account: userSeachResult.Users[0].UserInfo.Phone,
Platform: domain.LoginPlatformApp,
OrganizationId: int64(userSeachResult.Users[0].Org.OrgId),
AccessToken: "",
RefreshToken: "",
AccessExpired: 0,
RefreshExpired: 0,
CreatedTime: time.Now(),
UpdatedTime: time.Now(),
}
if userSeachResult.Users[0].Company != nil {
currentAccess.CompanyId = int64(userSeachResult.Users[0].Company.CompanyId)
}
}
//判定当前凭证的companyId,OrganizationId 是否在用户列表中
var currentOrgIsOK bool
loopUser1:
for _, v := range userSeachResult.Users {
if v.Company.CompanyId == int(currentAccess.CompanyId) {
for _, vv := range v.UserOrg {
if vv.OrgID == int(currentAccess.OrganizationId) {
currentOrgIsOK = true
currentAccess.UserId = int64(v.UserId)
currentAccess.UserBaseId = int64(v.UserBaseId)
break loopUser1
}
}
}
}
//记录上一次的登录公司组织信息不可用 ,重置登录记录
//使用找到的第一个可用的公司组织
if !currentOrgIsOK {
loopUser2:
for _, v := range userSeachResult.Users {
currentAccess.CompanyId = int64(v.Company.CompanyId)
for _, vv := range v.UserOrg {
currentAccess.UserId = int64(v.UserId)
currentAccess.UserBaseId = int64(v.UserBaseId)
currentAccess.OrganizationId = int64(vv.OrgID)
currentOrgIsOK = true
break loopUser2
}
}
}
loginToken := domain.LoginToken{
UserId: currentAccess.UserId,
Account: currentAccess.Account,
UserBaseId: currentAccess.UserBaseId,
CompanyId: currentAccess.CompanyId,
OrgId: currentAccess.OrganizationId,
Platform: currentAccess.Platform,
}
accessTokenStr, err := loginToken.GenerateAccessToken()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
currentAccess.AccessToken = accessTokenStr
currentAccess.AccessExpired = loginToken.ExpiresAt
refreshTokenStr, err := loginToken.GenerateRefreshToken()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
currentAccess.RefreshToken = refreshTokenStr
currentAccess.AccessExpired = loginToken.ExpiresAt
//先存数据库
_, err = loginAccessRepository.Save(currentAccess)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//后处理redis缓存
tokenCache := cache.LoginTokenCache{}
tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp)
tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp)
tokenCache.SaveAccessToken(currentAccess)
tokenCache.SaveRefreshToken(currentAccess)
nowTime := time.Now().Unix()
return map[string]interface{}{
"refreshToken": accessTokenStr,
"accessToken": refreshTokenStr,
"expiresIn": currentAccess.AccessExpired - nowTime,
}, nil
}
func (srv AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.RefreshTokenCommand) (interface{}, error) {
if err := refreshTokenCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := domain.LoginToken{}
err := ltoken.ParseToken(refreshTokenCommand.RefreshToken)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "refreshToken 不可用,"+err.Error())
}
token, err := srv.getToken(domain.Operator{}, ltoken)
// phone := ltoken.Account
// creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
// userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
// Phone: phone,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "用户信息获取失败,"+err.Error())
// }
// //判定当前凭证的companyId,OrganizationId 是否在用户列表中
// var currentOrgIsOK bool
//loopUser1:
// for _, v := range userSearchResult.Users {
// if v.Company.CompanyId == int(ltoken.CompanyId) {
// for _, vv := range v.UserOrg {
// if vv.OrgID == int(ltoken.OrgId) {
// currentOrgIsOK = true
// break loopUser1
// }
// }
// }
// }
// if !currentOrgIsOK {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用")
// }
//
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// defer func() {
// transactionContext.RollbackTransaction()
// }()
// var loginAccessRepository domain.LoginAccessRepository
// if loginAccessRepository, err = factory.CreateLoginAccessRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// }); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// _, lAccess, err := loginAccessRepository.Find(map[string]interface{}{
// "account": phone,
// "platform": domain.LoginPlatformApp,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// var currentAccess *domain.LoginAccess
// if len(lAccess) > 0 {
// currentAccess = lAccess[0]
// currentAccess.UpdatedTime = time.Now()
// } else {
// currentAccess = &domain.LoginAccess{
// UserBaseId: ltoken.UserBaseId,
// UserId: ltoken.UserId,
// Account: ltoken.Account,
// Platform: domain.LoginPlatformApp,
// CompanyId: ltoken.CompanyId,
// OrganizationId: ltoken.OrgId,
// AccessToken: "",
// RefreshToken: "",
// AccessExpired: 0,
// RefreshExpired: 0,
// CreatedTime: time.Now(),
// UpdatedTime: time.Now(),
// }
// }
// accessTokenStr, err := ltoken.GenerateAccessToken()
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// currentAccess.AccessToken = accessTokenStr
// currentAccess.AccessExpired = ltoken.ExpiresAt
// refreshTokenStr, err := ltoken.GenerateRefreshToken()
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// currentAccess.RefreshToken = refreshTokenStr
// currentAccess.RefreshExpired = ltoken.ExpiresAt
// //先存数据库
// _, err = loginAccessRepository.Save(currentAccess)
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// //后处理redis缓存
// tokenCache := cache.LoginTokenCache{}
// tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp)
// tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp)
// tokenCache.SaveAccessToken(currentAccess)
// tokenCache.SaveRefreshToken(currentAccess)
// nowTime := time.Now().Unix()
// return map[string]interface{}{
// "refreshToken": accessTokenStr,
// "accessToken": refreshTokenStr,
// "expiresIn": currentAccess.AccessExpired - nowTime,
// }, nil
return token["token"], err
}
//GetUserMenus 获取用户信息
func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (interface{}, error) {
user, err := srv.getUserInfo(userInfoCommand.Operator)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
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 map[string]interface{}{
"orgs": res,
}, nil
}
//OrgSwitch 组织切换
func (srv AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (interface{}, error) {
if err := switchOrgCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := domain.LoginToken{}
err := ltoken.ParseToken(switchOrgCommand.Operator.Token)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "accessToken 不可用,"+err.Error())
}
ltoken.OrgId = switchOrgCommand.OrgId
token, err := srv.getToken(domain.Operator{}, ltoken)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var userId int64
if v, ok := token["userId"]; ok {
if userId, ok = v.(int64); !ok {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "用户不存在")
}
}
user, err := srv.getUserInfo(domain.Operator{UserId: userId})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
switchOrgCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var res = map[string]interface{}{
"user": user,
"accessMenus": resultMenu.Menus,
"token": token["token"],
}
return res, nil
}
// CompanySignUp 企业注册
func (srv AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) {
//TODO:验证码验证测试去掉,后期恢复回来
//smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
//err := smsServeGateway.CheckSmsCode(companySignUpCommand.Phone, companySignUpCommand.SmsCode)
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{
CompanyName: companySignUpCommand.CompanyName,
Phone: companySignUpCommand.Phone,
Password: companySignUpCommand.Password,
Contacts: companySignUpCommand.Contacts,
IndustryCategory: companySignUpCommand.IndustryCategory,
Scale: companySignUpCommand.Scale,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return companySignUpCommand, err
}
// ResetPassword 重置密码(找回密码)
func (srv AuthService) ResetPassword(resetPasswordCommand *command.ResetPasswordCommand) (interface{}, error) {
if err := resetPasswordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
//var phone string
pcc := cache.PhoneCheckCache{}
var item = &cache.PhoneCheckItem{}
if err := pcc.Get(resetPasswordCommand.SmsCodeIdentity, item); err != nil {
log.Logger.Error(err.Error())
return nil, application.ThrowError(application.BUSINESS_ERROR, "验证码已失效")
}
// 2.重置密码
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
result, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
Phone: item.Phone,
Password: resetPasswordCommand.Password,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, err
}
func (srv AuthService) getUserInfo(operator domain.Operator) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
operator)
resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
UserId: int(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,
//"userCode": resultUser.UserInfo.UserCode,
"email": resultUser.UserInfo.Email,
},
"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 user, nil
}
func (srv AuthService) getToken(operator domain.Operator, ltoken domain.LoginToken) (map[string]interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Phone: ltoken.Account,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "用户信息获取失败,"+err.Error())
}
//判定当前凭证的companyId,OrganizationId 是否在用户列表中
var currentOrgIsOK bool
var currentUserId int64
loopUser1:
for _, v := range userSearchResult.Users {
//if v.Company.CompanyId == int(ltoken.CompanyId) {
for _, vv := range v.UserOrg {
if vv.OrgID == int(ltoken.OrgId) {
currentOrgIsOK = true
currentUserId = int64(v.UserId)
break loopUser1
}
}
//}
}
if !currentOrgIsOK {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用")
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var loginAccessRepository domain.LoginAccessRepository
if loginAccessRepository, err = factory.CreateLoginAccessRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
_, lAccess, err := loginAccessRepository.Find(map[string]interface{}{
"account": ltoken.Account,
"platform": domain.LoginPlatformApp,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var currentAccess *domain.LoginAccess
if len(lAccess) > 0 {
currentAccess = lAccess[0]
currentAccess.UpdatedTime = time.Now()
} else {
currentAccess = &domain.LoginAccess{
UserBaseId: ltoken.UserBaseId,
UserId: ltoken.UserId,
Account: ltoken.Account,
Platform: domain.LoginPlatformApp,
CompanyId: ltoken.CompanyId,
OrganizationId: ltoken.OrgId,
AccessToken: "",
RefreshToken: "",
AccessExpired: 0,
RefreshExpired: 0,
CreatedTime: time.Now(),
UpdatedTime: time.Now(),
}
}
accessTokenStr, err := ltoken.GenerateAccessToken()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
currentAccess.AccessToken = accessTokenStr
currentAccess.AccessExpired = ltoken.ExpiresAt
refreshTokenStr, err := ltoken.GenerateRefreshToken()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
currentAccess.RefreshToken = refreshTokenStr
currentAccess.RefreshExpired = ltoken.ExpiresAt
//先存数据库
_, err = loginAccessRepository.Save(currentAccess)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//后处理redis缓存
tokenCache := cache.LoginTokenCache{}
tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp)
tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp)
tokenCache.SaveAccessToken(currentAccess)
tokenCache.SaveRefreshToken(currentAccess)
nowTime := time.Now().Unix()
token := map[string]interface{}{
"refreshToken": accessTokenStr,
"accessToken": refreshTokenStr,
"expiresIn": currentAccess.AccessExpired - nowTime,
}
return map[string]interface{}{
"token": token,
"userId": currentUserId,
}, nil
}
//GetCompanyOrgsByUser 获取登录用户的公司组织列表
func (srv AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUserQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(queryParam.Operator)
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Phone: queryParam.Phone,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var (
companys []dto.CompanyItem
orgs []dto.OrgItem
)
for _, v := range result.Users {
companys = append(companys, dto.CompanyItem{
CompanyId: v.Company.CompanyId,
CompanyName: v.Company.CompanyName,
})
for _, vv := range v.UserOrg {
orgs = append(orgs, dto.OrgItem{
OrganizationId: vv.OrgID,
OrganizationName: vv.OrgName,
CompanyId: v.Company.CompanyId,
})
}
}
data := map[string]interface{}{
"companys": companys,
"organizations": orgs,
}
return data, nil
}
//GetQrcode 获取扫码登录需要的二维码
func (srv AuthService) GetQrcode() (interface{}, error) {
qrmsg := domain.QrcodeMessage{}
_, err := qrmsg.GenerateImageBase64() //imgBase64
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
qrCache := cache.LoginQrcodeCache{}
err = qrCache.Save(qrmsg)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
data := map[string]interface{}{
//"image": imgBase64,
"key": qrmsg.Token,
}
return data, nil
}
//QrcodeLoginStatus 询问扫码登录状态
func (srv AuthService) QrcodeLoginStatus(queryParam *query.QrcodeLoginStatusQuery) (interface{}, error) {
qrmsg := domain.QrcodeMessage{}
err := qrmsg.ParseToken(queryParam.Key)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
qrCache := cache.LoginQrcodeCache{}
qrmsgCache, err := qrCache.Get(qrmsg.Id)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
loginToken := domain.LoginToken{
UserId: qrmsgCache.UserId,
UserBaseId: qrmsgCache.UserBaseId,
Account: qrmsgCache.Account,
Platform: domain.LoginPlatformWeb,
CompanyId: qrmsgCache.CompanyId,
OrgId: qrmsgCache.OrgId,
}
accessToken, err := loginToken.GenerateAccessToken()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
_ = accessToken
//TODO 填充token数据
data := map[string]interface{}{
"isLogin": qrmsgCache.IsLogin,
"access": "",
}
return data, nil
}
//CheckSmsCode 验证手机短信验证码
func (srv AuthService) CheckSmsCode(smsCodeCommand *command.CheckSmsCodeCommand) (interface{}, error) {
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.CheckSmsCode(smsCodeCommand.Phone, smsCodeCommand.SmsCode)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
uid := uuid.New()
pcc := cache.PhoneCheckCache{}
if err := pcc.Add(uid.String(), cache.PhoneCheckItem{
Phone: smsCodeCommand.Phone,
SmsCodeIdentity: uid.String(),
Action: smsCodeCommand.Action,
}); err != nil {
log.Logger.Error(err.Error())
return nil, application.ThrowError(application.BUSINESS_ERROR, "系统错误")
}
return map[string]interface{}{
"smsCodeIdentity": uid.String(),
}, nil
}
... ...
... ... @@ -10,6 +10,12 @@ import (
type CreditAccountSearchCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageNumber"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
// 账期结算支付状态,1待支付,2已支付 0全部
PaymentStatus int32 `json:"paymentStatus"`
}
func (cmd *CreditAccountSearchCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -11,15 +11,15 @@ type UpdateCooperationProjectCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创项目ID
CooperationProjectId string `json:"cooperationProjectId,string" valid:"Required"`
CooperationProjectId string `json:"cooperationProjectId" valid:"Required"`
// 模式编码,唯一确定
//CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"`
CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"`
// 组织ID
OrgId int64 `json:"departmentId,string" valid:"Required"`
// 共创项目名称
CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
// 共创发起人id
CooperationProjectSponsor string `json:"cooperationProjectSponsor,omitempty"`
CooperationProjectSponsor int64 `json:"cooperationProjectSponsor,omitempty"`
// 项目承接对象
CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType,omitempty"`
// 共创项目描述
... ...
... ... @@ -51,10 +51,11 @@ type CooperationProjectInfo struct {
Department domain.Department `json:"department"` //项目发起部门
Status int `json:"status"` //项目状态
CooperationProjectSponsor struct {
UsersId int `json:"usersId"`
UserInfo domain.UserInfo `json:"UserInfo"`
UsersId int `json:"userId,string"`
UserInfo domain.UserInfo `json:"userInfo"`
} `json:"cooperationProjectSponsor"` //共创发起人
Attachment []domain.Attachment `json:"attachment"` //图片附件
Images []string `json:"images"`
}
func ToCooperationProjectInfo(projecetParam *allied_creation_cooperation.CooperationProject) *CooperationProjectInfo {
... ... @@ -70,6 +71,10 @@ func ToCooperationProjectInfo(projecetParam *allied_creation_cooperation.Coopera
Attachment: projecetParam.Attachment,
CooperationProjectDescription: projecetParam.CooperationProjectDescription,
}
for i := range projecetParam.Attachment {
attachment := projecetParam.Attachment[i]
data.Images = append(data.Images, attachment.Url)
}
data.CooperationProjectSponsor.UsersId = projecetParam.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserInfo.UsersId = projecetParam.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserInfo.Phone = projecetParam.CooperationProjectSponsor.UserInfo.Phone
... ...
... ... @@ -73,11 +73,11 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP
})
}
_, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
//CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber,
CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber,
CooperationProjectUndertakerType: updateCooperationProjectCommand.CooperationProjectUndertakerType,
SponsorUid: updateCooperationProjectCommand.CooperationProjectSponsor,
SponsorUid: strconv.Itoa(int(updateCooperationProjectCommand.CooperationProjectSponsor)),
PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)),
CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription,
Attachment: images,
... ...
... ... @@ -40,7 +40,7 @@ type CooperationProjectInfo struct {
UsersId int `json:"userId,string"`
} `json:"userInfo"`
} `json:"cooperationProjectSponsor"` //项目发起人
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerTypes"` //共创合约承接对象,1员工,2共创用户,3公开
Department struct {
DepartmentNumber string `json:"departmentNumber"`
DepartmentId int `json:"departmentId,string,"`
... ...
package domain
import (
"bytes"
"encoding/base64"
"fmt"
"image/png"
"time"
"github.com/boombuler/barcode"
"github.com/boombuler/barcode/qr"
jwt "github.com/dgrijalva/jwt-go"
)
... ... @@ -51,22 +46,22 @@ func (qrmsg *QrcodeMessage) GenerateImageBase64() ([]byte, error) {
qrmsg.Token = str
qrmsg.IsLogin = false
qrCode, err := qr.Encode(str, qr.M, qr.Auto)
if err != nil {
return nil, err
}
qrCode, err = barcode.Scale(qrCode, 200, 200)
if err != nil {
return nil, err
}
var buf bytes.Buffer
err = png.Encode(&buf, qrCode)
if err != nil {
return nil, err
}
var result []byte
base64.StdEncoding.Encode(result, buf.Bytes())
return result, err
//qrCode, err := qr.Encode(str, qr.M, qr.Auto)
//if err != nil {
// return nil, err
//}
//qrCode, err = barcode.Scale(qrCode, 200, 200)
//if err != nil {
// return nil, err
//}
//var buf bytes.Buffer
//err = png.Encode(&buf, qrCode)
//if err != nil {
// return nil, err
//}
//var result []byte
//base64.StdEncoding.Encode(result, buf.Bytes())
return []byte(str), err
}
func (qrmsg *QrcodeMessage) ParseToken(str string) error {
... ...
... ... @@ -2,7 +2,7 @@ package domain
//用户
type UserInfo struct {
UsersName string `json:"usersName"`
UsersName string `json:"userName"`
Phone string `json:"phone"`
UsersId int `json:"userId,string"`
UserCode string `json:"userCode"`
... ...
... ... @@ -24,7 +24,7 @@ func (lq LoginQrcodeCache) Save(qrcode domain.QrcodeMessage) error {
}
key := lq.keyString(qrcode.Id)
bt, _ := json.Marshal(qrcode)
result := clientRedis.Set(key, string(bt), time.Duration(exp))
result := clientRedis.Set(key, string(bt), time.Duration(exp)*time.Second)
return result.Err()
}
... ...
... ... @@ -204,6 +204,11 @@ type (
//UserPhone string `json:"userPhone"`
//Status int `json:"status"`
} `json:"cooperationProjectSponsor"`
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //项目模式
Department struct {
DepartmentID string `json:"departmentId"`
DepartmentName string `json:"departmentName"`
... ...
package controllers
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/service"
)
type AuthController struct {
BaseController
}
func (controller *AuthController) Login() {
authService := service.AuthService{}
loginCmd := &command.LoginCommand{}
Must(controller.Unmarshal(loginCmd))
data, err := authService.AuthLogin(loginCmd)
controller.Response(data, err)
}
func (controller *AuthController) LoginPwd() {
authService := service.AuthService{}
loginCmd := &command.LoginPwdCommand{}
Must(controller.Unmarshal(loginCmd))
data, err := authService.AuthLoginPwd(loginCmd)
controller.Response(data, err)
}
func (controller *AuthController) LoginSms() {
authService := service.AuthService{}
loginCmd := &command.LoginSmsCommand{}
Must(controller.Unmarshal(loginCmd))
data, err := authService.AuthLoginSms(loginCmd)
controller.Response(data, err)
}
func (controller *AuthController) SendSmsCode() {
authService := service.AuthService{}
cmd := &command.SendSmsCodeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
err = authService.SendSmsCaptcha(cmd)
controller.Response(nil, err)
}
func (controller *AuthController) GetAuthAccessToken() {
authService := service.AuthService{}
accessTokenCommand := &command.AccessTokenCommand{}
err := controller.Unmarshal(accessTokenCommand)
if err != nil {
controller.Response(nil, err)
return
}
data, err := authService.GetAuthAccessToken(accessTokenCommand)
controller.Response(data, err)
}
func (controller *AuthController) RefreshAuthAccessToken() {
authService := service.AuthService{}
refreshTokenCmd := &command.RefreshTokenCommand{}
err := controller.Unmarshal(refreshTokenCmd)
if err != nil {
controller.Response(nil, err)
return
}
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)
}
func (controller *AuthController) CompanySignUp() {
authService := service.AuthService{}
userOrgCommand := &command.CompanySignUpCommand{}
err := controller.Unmarshal(userOrgCommand)
if err != nil {
controller.Response(nil, err)
return
}
//userOrgCommand.Operator = controller.GetOperator()
data, err := authService.CompanySignUp(userOrgCommand)
controller.Response(data, err)
}
func (controller *AuthController) ResetPassword() {
authService := service.AuthService{}
userOrgCommand := &command.ResetPasswordCommand{}
err := controller.Unmarshal(userOrgCommand)
if err != nil {
controller.Response(nil, err)
return
}
//userOrgCommand.Operator = controller.GetOperator()
data, err := authService.ResetPassword(userOrgCommand)
controller.Response(data, err)
}
func (controller *AuthController) OrgSwitch() {
authService := service.AuthService{}
cmd := &command.SwitchOrgCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.OrgSwitch(cmd)
controller.Response(data, err)
}
func (controller *AuthController) GetCompanyOrgsByUser() {
authService := service.AuthService{}
cmd := &query.GetCompanyOrgsByUserQuery{}
Must(controller.Unmarshal(cmd))
cmd.Operator = controller.GetOperator()
data, err := authService.GetCompanyOrgsByUser(cmd)
controller.Response(data, err)
}
func (controller *AuthController) GetQrcode() {
authService := service.AuthService{}
data, err := authService.GetQrcode()
controller.Response(data, err)
}
func (controller *AuthController) QrcodeLoginStatus() {
authService := service.AuthService{}
cmd := &query.QrcodeLoginStatusQuery{}
Must(controller.Unmarshal(cmd))
data, err := authService.QrcodeLoginStatus(cmd)
controller.Response(data, err)
}
func (controller *AuthController) CheckSmsCode() {
authService := service.AuthService{}
cmd := &command.CheckSmsCodeCommand{}
Must(controller.Unmarshal(cmd))
data, err := authService.CheckSmsCode(cmd)
controller.Response(data, err)
}
... ...
package mobile_client
package controllers
import (
"github.com/linmadan/egglib-go/utils/json"
... ... @@ -7,11 +7,11 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
type baseController struct {
type BaseController struct {
beego.BaseController
}
func (controller *baseController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
func (controller *BaseController) ReturnPageListData(count int64, data interface{}, err error, pageNumber int) {
dataMap := map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
... ... @@ -22,7 +22,7 @@ func (controller *baseController) returnPageListData(count int64, data interface
controller.Response(dataMap, err)
}
func (controller *baseController) returnListData(count int64, data interface{}, err error) {
func (controller *BaseController) ReturnListData(count int64, data interface{}, err error) {
dataMap := map[string]interface{}{
"total": count,
//"pageNumber": pageNumber,
... ... @@ -31,23 +31,23 @@ func (controller *baseController) returnListData(count int64, data interface{},
controller.Response(dataMap, err)
}
func (controller *baseController) GetUserId() int64 {
func (controller *BaseController) GetUserId() int64 {
return 1
}
func (controller *baseController) GetCompanyId() int64 {
func (controller *BaseController) GetCompanyId() int64 {
return 1
}
func (controller *baseController) GetUserBaseId() int64 {
func (controller *BaseController) GetUserBaseId() int64 {
return 1
}
func (controller *baseController) GetOrgId() int64 {
func (controller *BaseController) GetOrgId() int64 {
return 1
}
func (controller *baseController) GetOperator() domain.Operator {
func (controller *BaseController) GetOperator() domain.Operator {
token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
loginToken := &domain.LoginToken{}
err := loginToken.ParseToken(token)
... ... @@ -73,3 +73,9 @@ func (controller *baseController) GetOperator() domain.Operator {
log.Logger.Debug("operator " + json.MarshalToString(op))
return op
}
func Must(err error) {
if err != nil {
log.Logger.Error(err.Error())
}
}
... ...
package mobile_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
type baseController struct {
controllers.BaseController
}
//func (controller *baseController) ReturnPageListData(count int64, data interface{}, err error, pageNumber int) {
// dataMap := map[string]interface{}{
// "grid": map[string]interface{}{
// "total": count,
// //"pageNumber": pageNumber,
// "list": data,
// },
// }
// controller.Response(dataMap, err)
//}
//
//func (controller *baseController) ReturnListData(count int64, data interface{}, err error) {
// dataMap := map[string]interface{}{
// "total": count,
// //"pageNumber": pageNumber,
// "list": data,
// }
// controller.Response(dataMap, err)
//}
//
//func (controller *baseController) GetUserId() int64 {
// return 1
//}
//
//func (controller *baseController) GetCompanyId() int64 {
// return 1
//}
//
//func (controller *baseController) GetUserBaseId() int64 {
// return 1
//}
//
//func (controller *baseController) GetOrgId() int64 {
// return 1
//}
//
//func (controller *baseController) GetOperator() domain.Operator {
// token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
// loginToken := &domain.LoginToken{}
// err := loginToken.ParseToken(token)
// if err != nil {
// log.Logger.Error(err.Error())
// }
// op := domain.Operator{
// UserId: loginToken.UserId,
// CompanyId: loginToken.CompanyId,
// OrgId: loginToken.OrgId,
// UserBaseId: loginToken.UserBaseId,
// Phone: loginToken.Account,
// Token: token,
// }
// // TODO:测试数据后期删除
// if op.UserId == 0 {
// op.UserId = 9
// op.CompanyId = 23
// op.OrgId = 45
// op.UserBaseId = 5
// }
// // TODO:打印测试日志
// log.Logger.Debug("operator " + json.MarshalToString(op))
// return op
//}
... ...
... ... @@ -3,6 +3,7 @@ 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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
// Controller
... ... @@ -180,6 +181,7 @@ func (controller *CooperationController) UpdateCooperationProject() {
controller.Response(nil, err)
return
}
cmd.CooperationProjectId = controller.GetString(":projectId")
cmd.Operator = controller.GetOperator()
data, err := svr.UpdateCooperationProject(cmd)
controller.Response(data, err)
... ... @@ -208,7 +210,7 @@ func (controller *CooperationController) SearchCooperationProject() {
}
cmd.Operator = controller.GetOperator()
total, data, err := svr.SearchCooperationProject(cmd)
controller.returnPageListData(int64(total), data, err, cmd.PageNumber)
controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
}
func (controller *CooperationController) PersonSearchCooperationProject() {
... ... @@ -230,8 +232,7 @@ func (controller *CooperationController) CreditAccountSearch() {
cmd := &command.CreditAccountSearchCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
log.Logger.Error(err.Error())
}
cmd.Operator = controller.GetOperator()
data, err := svr.CreditAccountSearch(cmd)
... ... @@ -243,8 +244,7 @@ func (controller *CooperationController) CreditAccountGet() {
cmd := &command.CreditAccountGetCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
log.Logger.Error(err.Error())
}
cmd.Operator = controller.GetOperator()
data, err := svr.CreditAccountGet(cmd)
... ... @@ -256,8 +256,7 @@ func (controller *CooperationController) CreditAccountPay() {
cmd := &command.CreditAccountPayCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
log.Logger.Error(err.Error())
}
cmd.Operator = controller.GetOperator()
data, err := svr.CreditAccountPay(cmd)
... ... @@ -269,8 +268,7 @@ func (controller *CooperationController) CreditAccountPaySearch() {
cmd := &command.CreditAccountPaySearchCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
log.Logger.Error(err.Error())
}
cmd.Operator = controller.GetOperator()
data, err := svr.CreditAccountPaySearch(cmd)
... ...
package web_client
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
type baseController struct {
beego.BaseController
}
func (controller *baseController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
dataMap := map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": data,
},
}
controller.Response(dataMap, err)
}
func (controller *baseController) returnListData(count int64, data interface{}, err error) {
dataMap := map[string]interface{}{
"total": count,
"list": data,
}
controller.Response(dataMap, err)
}
func (controller *baseController) GetOperator() domain.Operator {
token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
loginToken := &domain.LoginToken{}
err := loginToken.ParseToken(token)
if err != nil {
log.Logger.Error(err.Error())
}
op := domain.Operator{
UserId: loginToken.UserId,
CompanyId: loginToken.CompanyId,
OrgId: loginToken.OrgId,
UserBaseId: loginToken.UserBaseId,
Phone: loginToken.Account,
Token: token,
}
// TODO:测试数据后期删除
if op.UserId == 0 {
op.UserId = 9
op.CompanyId = 23
op.OrgId = 45
op.UserBaseId = 5
}
return op
}
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
type baseController struct {
controllers.BaseController
}
//func (controller *baseController) ReturnPageListData(count int64, data interface{}, err error, pageNumber int) {
// dataMap := map[string]interface{}{
// "grid": map[string]interface{}{
// "total": count,
// "list": data,
// },
// }
// controller.Response(dataMap, err)
//}
//
//func (controller *baseController) ReturnListData(count int64, data interface{}, err error) {
// dataMap := map[string]interface{}{
// "total": count,
// "list": data,
// }
// controller.Response(dataMap, err)
//}
//
//func (controller *baseController) GetOperator() domain.Operator {
// token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
// loginToken := &domain.LoginToken{}
// err := loginToken.ParseToken(token)
// if err != nil {
// log.Logger.Error(err.Error())
// }
// op := domain.Operator{
// UserId: loginToken.UserId,
// CompanyId: loginToken.CompanyId,
// OrgId: loginToken.OrgId,
// UserBaseId: loginToken.UserBaseId,
// Phone: loginToken.Account,
// Token: token,
// }
// // TODO:测试数据后期删除
// if op.UserId == 0 {
// op.UserId = 9
// op.CompanyId = 23
// op.OrgId = 45
// op.UserBaseId = 5
// }
// return op
//}
... ...
... ... @@ -29,7 +29,7 @@ func (controller *CooperationApplicationController) ListCooperationApplication()
}
listCooperationApplicationQuery.Operator = controller.GetOperator()
cnt, data, err := cooperationApplicationService.ListCooperationApplication(listCooperationApplicationQuery)
controller.returnPageListData(cnt, data, err, listCooperationApplicationQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, listCooperationApplicationQuery.PageNumber)
}
func (controller *CooperationApplicationController) AuditCooperationApplication() {
... ...
... ... @@ -69,7 +69,7 @@ func (controller *CooperationModeController) SearchCooperationMode() {
}
listCooperationModeQuery.Operator = controller.GetOperator()
cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.returnPageListData(cnt, data, err, listCooperationModeQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, listCooperationModeQuery.PageNumber)
}
func (controller *CooperationModeController) ListCooperationMode() {
... ... @@ -83,7 +83,7 @@ func (controller *CooperationModeController) ListCooperationMode() {
listCooperationModeQuery.PageNumber = 1
listCooperationModeQuery.PageSize = 999
cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.returnListData(cnt, data, err)
controller.ReturnListData(cnt, data, err)
}
func (controller *CooperationModeController) EnableCooperationMode() {
... ...
... ... @@ -56,7 +56,7 @@ func (controller *CooperationProjectController) ListCooperationProject() {
}
listCooperationProjectQuery.Operator = controller.GetOperator()
cnt, data, err := cooperationProjectService.ListCooperationProject(listCooperationProjectQuery)
controller.returnPageListData(cnt, data, err, listCooperationProjectQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, listCooperationProjectQuery.PageNumber)
}
func (controller *CooperationProjectController) EndCooperationProject() {
... ...
... ... @@ -66,5 +66,5 @@ func (controller *DividendsOrderController) SearchDividendsOrder() {
}
searchDividendsOrderQuery.Operator = controller.GetOperator()
cnt, data, err := dividendsOrderService.SearchDividendsOrder(searchDividendsOrderQuery)
controller.returnPageListData(int64(cnt), data, err, searchDividendsOrderQuery.PageNumber)
controller.ReturnPageListData(int64(cnt), data, err, searchDividendsOrderQuery.PageNumber)
}
... ...
... ... @@ -68,5 +68,5 @@ func (controller *DividendsReturnedOrderController) SearchDividendsReturnedOrder
}
searchDividendsReturnedOrderQuery.Operator = controller.GetOperator()
cnt, data, err := dividendsReturnedOrderService.SearchDividendsReturnedOrder(searchDividendsReturnedOrderQuery)
controller.returnPageListData(int64(cnt), data, err, searchDividendsReturnedOrderQuery.PageNumber)
controller.ReturnPageListData(int64(cnt), data, err, searchDividendsReturnedOrderQuery.PageNumber)
}
... ...
... ... @@ -20,7 +20,7 @@ func (controller *NoticeSettingController) NoticeSettingList() {
}
noticeSettingListQuery.Operator = controller.GetOperator()
cnt, data, err := noticeSettingService.NoticeSettingList(noticeSettingListQuery)
controller.returnPageListData(cnt, data, err, noticeSettingListQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, noticeSettingListQuery.PageNumber)
}
func (controller *NoticeSettingController) NoticeSettingUpdate() {
... ...
... ... @@ -46,7 +46,7 @@ func (controller *RolesController) RoleList() {
}
roleListQuery.Operator = controller.GetOperator()
cnt, data, err := rolesService.RoleList(roleListQuery)
controller.returnPageListData(cnt, data, err, roleListQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, roleListQuery.PageNumber)
}
func (controller *RolesController) RoleGet() {
... ...
... ... @@ -36,7 +36,7 @@ func (controller *UsersController) CompanyUserList() {
controller.Unmarshal(companyUserListQuery)
companyUserListQuery.Operator = controller.GetOperator()
cnt, data, err := usersService.CompanyUserList(companyUserListQuery)
controller.returnPageListData(cnt, data, err, companyUserListQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, companyUserListQuery.PageNumber)
}
func (controller *UsersController) CompanyUserGet() {
... ... @@ -93,7 +93,7 @@ func (controller *UsersController) CooperationUserList() {
controller.Unmarshal(cooperationUserListQuery)
cooperationUserListQuery.Operator = controller.GetOperator()
cnt, data, err := usersService.CooperationUserList(cooperationUserListQuery)
controller.returnPageListData(cnt, data, err, cooperationUserListQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, cooperationUserListQuery.PageNumber)
}
func (controller *UsersController) CooperationUserGet() {
... ... @@ -131,7 +131,7 @@ func (controller *UsersController) SelectorCompanyOrg() {
controller.Unmarshal(selectorQuery)
selectorQuery.Operator = controller.GetOperator()
cnt, data, err := usersService.SelectorCompanyOrg(selectorQuery)
controller.returnPageListData(cnt, data, err, selectorQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, selectorQuery.PageNumber)
}
//SelectorCompanyRole 角色选择表
... ... @@ -141,7 +141,7 @@ func (controller *UsersController) SelectorCompanyRole() {
controller.Unmarshal(selectorQuery)
selectorQuery.Operator = controller.GetOperator()
cnt, data, err := usersService.SelectorCompanyRole(selectorQuery)
controller.returnPageListData(cnt, data, err, selectorQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, selectorQuery.PageNumber)
}
//CompanyOrgSelector 全组织部门选择表
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
func init() {
//web.Router("/v1/auth/login", &controllers.AuthController{}, "Post:Login")
web.Router("/v1/auth/login/pwd", &controllers.AuthController{}, "Post:LoginPwd")
web.Router("/v1/auth/login/sms", &controllers.AuthController{}, "Post:LoginSms")
web.Router("/v1/auth/login/qrcode", &controllers.AuthController{}, "Post:QrcodeLoginStatus")
web.Router("/v1/auth/qrcode-init", &controllers.AuthController{}, "Post:GetQrcode")
web.Router("/v1/auth/sms-code", &controllers.AuthController{}, "Post:SendSmsCode")
web.Router("/v1/auth/check-sms-code", &controllers.AuthController{}, "Post:CheckSmsCode")
//web.Router("/v1/auth/access-token", &controllers.AuthController{}, "Post:GetAuthAccessToken")
web.Router("/v1/auth/refresh-token", &controllers.AuthController{}, "Post:RefreshAuthAccessToken")
web.Router("/v1/auth/company-sign-up", &controllers.AuthController{}, "Post:CompanySignUp") //公司用户注册
web.Router("/v1/auth/reset-password", &controllers.AuthController{}, "Post:ResetPassword") //公司重置密码
web.Router("/v1/auth/org-switch", &controllers.AuthController{}, "Post:OrgSwitch")
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
)
func init() {
web.Router("/v1/app/auth/smsCode", &mobile_client.UserController{}, "Post:SendSmsCode")
web.Router("/v1/app/auth/check-phone", &mobile_client.UserController{}, "Post:CheckSmsCode")
web.Router("/v1/app/users/change-password", &mobile_client.UserController{}, "Post:ChangePassword")
web.Router("/v1/app/users/change-phone", &mobile_client.UserController{}, "Post:ChangePhone")
web.Router("/v1/app/users/personal", &mobile_client.UserController{}, "Post:UpdateUserInfo")
web.Router("/v1/app/users/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount")
}
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
)
func init() {
web.Router("/v1/user/company-orgs", &controllers.AuthController{}, "Post:GetCompanyOrgsByUser")
web.Router("/v1/user/user-info", &controllers.AuthController{}, "Post:GetUserInfo")
web.Router("/v1/user/user-menu", &controllers.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/user/user-orgs", &controllers.AuthController{}, "Post:GetUserOrg")
web.Router("/v1/user/change-password", &mobile_client.UserController{}, "Post:ChangePassword")
web.Router("/v1/user/change-phone", &mobile_client.UserController{}, "Post:ChangePhone")
web.Router("/v1/user/personal", &mobile_client.UserController{}, "Post:UpdateUserInfo")
web.Router("/v1/user/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount")
}
... ...