作者 yangfu

用户基础信息修改

... ... @@ -4,10 +4,9 @@ go 1.16
require (
github.com/beego/beego/v2 v2.0.1
github.com/boombuler/barcode v1.0.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-pg/pg/v10 v10.10.1
github.com/go-redis/redis v6.14.2+incompatible
github.com/google/uuid v1.1.1
github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6
github.com/sony/sonyflake v1.0.0
)
... ...
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:"contacts" 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"
"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
}
... ...
... ... @@ -2,6 +2,7 @@ package service
import (
"errors"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"time"
"github.com/linmadan/egglib-go/core/application"
... ... @@ -342,7 +343,7 @@ loopUser1:
func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userInfoCommand.Operator)
resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
UserId: int(userInfoCommand.Operator.UserId),
})
if err != nil {
... ... @@ -413,3 +414,49 @@ func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (inter
}
return res, nil
}
// CompanySignUp 企业注册
func (srv AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) {
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{})
result, 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 result, 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
}
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ChangePasswordCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 手机号
Phone string `cname:"手机号" json:"phone" valid:"Required"`
// 短信验证码
SmsCode string `cname:"短信验证码" json:"smsCode" valid:"Required"`
// 新密码
NewPassword string `cname:"新密码" json:"newPassword" valid:"Required"`
}
func (phoneAuthChangePasswordCommand *ChangePasswordCommand) Valid(validation *validation.Validation) {
}
func (phoneAuthChangePasswordCommand *ChangePasswordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(phoneAuthChangePasswordCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(phoneAuthChangePasswordCommand).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 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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ResetPhoneCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 短信验证码
SmsCode string `cname:"短信验证码" json:"smsCode" valid:"Required"`
OldPhone string `cname:"" json:"oldPhone" valid:"Required"`
NewPhone string `cname:"" json:"newPhone" valid:"Required"`
}
func (phoneAuthResetPhoneCommand *ResetPhoneCommand) Valid(validation *validation.Validation) {
}
func (phoneAuthResetPhoneCommand *ResetPhoneCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(phoneAuthResetPhoneCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(phoneAuthResetPhoneCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UpdateUserInfoCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 头像
Avatar string `cname:"头像" json:"avatar" valid:"Required"`
// 用户姓名
UserName string `cname:"用户姓名" json:"userName" valid:"Required"`
}
func (phoneAuthResetPhoneCommand *UpdateUserInfoCommand) Valid(validation *validation.Validation) {
}
func (phoneAuthResetPhoneCommand *UpdateUserInfoCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(phoneAuthResetPhoneCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(phoneAuthResetPhoneCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package service
import (
"github.com/google/uuid"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/command"
"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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
type UserService struct {
... ... @@ -18,3 +23,86 @@ func (srv UserService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand
}
return nil
}
//CheckSmsCode 验证手机短信验证码
func (srv UserService) 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
}
//ChangePassword 修改密码
func (srv UserService) ChangePassword(changePasswordCommand *command.ChangePasswordCommand) (interface{}, error) {
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.CheckSmsCode(changePasswordCommand.Phone, changePasswordCommand.SmsCode)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 2.重置密码
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err = creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
Phone: changePasswordCommand.Phone,
Password: changePasswordCommand.NewPassword,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return struct{}{}, nil
}
//ChangePassword 修改密码
func (srv UserService) ChangePhone(resetPhoneCommand *command.ResetPhoneCommand) (interface{}, error) {
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.CheckSmsCode(resetPhoneCommand.NewPhone, resetPhoneCommand.SmsCode)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 2.重置手机号
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err = creationUserGateway.AuthResetPhone(allied_creation_user.ReqAuthResetPhone{
UserId: resetPhoneCommand.Operator.UserId,
OldPhone: resetPhoneCommand.OldPhone,
NewPhone: resetPhoneCommand.NewPhone,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return struct{}{}, nil
}
//UpdateUserInfo 更新用户信息
func (srv UserService) UpdateUserInfo(updateUserInfoCommand *command.UpdateUserInfoCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
user, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
UserId: int(updateUserInfoCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
}
_, err = creationUserGateway.UserUpdateBaseInfo(allied_creation_user.ReqUserUpdateBaseInfo{
UserId: int64(user.UserId),
UserName: updateUserInfoCommand.UserName,
Avatar: updateUserInfoCommand.Avatar,
Phone: user.UserInfo.Phone,
Email: user.UserInfo.Email,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return struct{}{}, nil
}
... ...
... ... @@ -8,6 +8,7 @@ type CompanyUserItem struct {
UserCode string `json:"userCode"`
UserId string `json:"userId"`
UserName string `json:"userName"`
UserType int `json:"userType"`
}
//CompanyUserInfo 用户数据详情
... ...
... ... @@ -27,7 +27,7 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserGetQuery.Operator)
userid, _ := strconv.Atoi(companyUserGetQuery.UsersId)
resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
UserId: userid,
})
if err != nil {
... ... @@ -117,7 +117,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
result, err := creationUserGateway.UserCreate(allied_creation_user.ReqCreateUser{
CompanyId: companyUserAddCommand.Operator.CompanyId,
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType: 1,
UserType: domain.UserTypeEmployee,
UserCode: companyUserAddCommand.UsersCode,
OrganizationId: int64(orgId),
DepartmentId: int64(departmentId),
... ... @@ -197,6 +197,7 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co
UserCode: v.UserCode,
UserId: strconv.Itoa(v.UserId),
UserName: v.UserInfo.UserName,
UserType: v.UserType,
}
listData = append(listData, item)
}
... ... @@ -317,7 +318,7 @@ func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *qu
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserGetQuery.Operator)
userId, _ := strconv.Atoi(cooperationUserGetQuery.UserId)
result, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
result, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
UserId: userId,
})
if err != nil {
... ...
... ... @@ -16,7 +16,7 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081"
var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082"
//通用模块短信服务
var SMS_SERVE_HOST = "http://localhost:8081"
var SMS_SERVE_HOST = "https://sms.fjmaimaimai.com:9897"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
... ...
package cache
import (
"encoding/json"
"time"
)
const phoneCheckExpire = 60 * 5
//短信验证码验证缓存
type PhoneCheckCache struct {
}
func (ca PhoneCheckCache) phoneCheckKey(smsCodeIdentity string) string {
str := KEY_PREFIX + "phone-check:" + smsCodeIdentity
return str
}
func (ca PhoneCheckCache) Add(smsCodeIdentity string, value interface{}) error {
key := ca.phoneCheckKey(smsCodeIdentity)
data, err := json.Marshal(value)
if err != nil {
return err
}
result := clientRedis.Set(key, string(data), time.Duration(phoneCheckExpire*time.Second))
return result.Err()
}
func (ca PhoneCheckCache) Get(smsCodeIdentity string, value interface{}) error {
key := ca.phoneCheckKey(smsCodeIdentity)
result := clientRedis.Get(key)
if result.Err() != nil {
return result.Err()
}
err := json.Unmarshal([]byte(result.Val()), value)
return err
}
type PhoneCheckItem struct {
Phone string `json:"phone"`
SmsCodeIdentity string `json:"smsCodeIdentity"`
Action int `json:"action"`
}
... ...
package pg
import (
"context"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
//_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/pg/models"
"github.com/linmadan/egglib-go/persistent/pg/hooks"
)
var DB *pg.DB
... ... @@ -21,9 +21,11 @@ func init() {
Addr: fmt.Sprintf("%s:%s", constant.POSTGRESQL_HOST, constant.POSTGRESQL_PORT),
})
if !constant.DISABLE_SQL_GENERATE_PRINT {
DB.AddQueryHook(hooks.SqlGeneratePrintHook{})
DB.AddQueryHook(SqlGeneratePrintHook{})
}
m := []interface{}{
&models.LoginAccess{},
}
m := []interface{}{}
if !constant.DISABLE_CREATE_TABLE {
for _, model := range m {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
... ... @@ -37,3 +39,18 @@ func init() {
}
}
}
type SqlGeneratePrintHook struct{}
func (hook SqlGeneratePrintHook) BeforeQuery(c context.Context, q *pg.QueryEvent) (context.Context, error) {
return c, nil
}
func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent) error {
sqlStr, err := q.FormattedQuery()
if err != nil {
return err
}
log.Logger.Debug(string(sqlStr))
return nil
}
... ...
... ... @@ -106,7 +106,7 @@ func (gateway HttplibAlliedCreationUser) UserUpdate(param ReqUpdateUser) (*DataU
}
//UserGet 获取用户
func (gateway HttplibAlliedCreationUser) UserGet(param ReqGateUser) (*DataGateUser, error) {
func (gateway HttplibAlliedCreationUser) UserGet(param ReqGetUser) (*DataGateUser, error) {
url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/user/", param.UserId)
method := "get"
req := gateway.CreateRequest(url, method)
... ... @@ -332,7 +332,7 @@ func (gateway HttplibAlliedCreationUser) UserProfile(param ReqUserProfile) (*Dat
//UserUpdateBaseInfo 更新用户基础数据
func (gateway HttplibAlliedCreationUser) UserUpdateBaseInfo(param ReqUserUpdateBaseInfo) (*DataUserUpdateBaseInfo, error) {
url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/base-info")
method := "get"
method := "put"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:更新用户基础数据。", map[string]interface{}{
... ...
... ... @@ -50,13 +50,23 @@ type (
//重置手机号
type (
ReqAuthResetPhone struct{}
ReqAuthResetPhone struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId"`
OldPhone string `cname:"" json:"oldPhone" valid:"Required"`
NewPhone string `cname:"" json:"newPhone" valid:"Required"`
}
DataAuthResetPhone struct{}
)
//重置密码(忘记密码)
type (
ReqAuthResetPassword struct{}
ReqAuthResetPassword struct {
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
}
DataAuthResetPassword struct{}
)
... ...
... ... @@ -182,7 +182,7 @@ type (
//获取用户
type (
ReqGateUser struct {
ReqGetUser struct {
UserId int `json:"userId"`
}
... ... @@ -293,6 +293,14 @@ type (
type (
ReqUserUpdateBaseInfo struct {
UserId int64 `json:"userId"`
// 用户姓名
UserName string `cname:"用户姓名" json:"userName" valid:"Required"`
// 头像
Avatar string `cname:"头像" json:"avatar" valid:"Required"`
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 邮箱
Email string `cname:"邮箱" json:"email" valid:"Required"`
}
DataUserUpdateBaseInfo struct {
}
... ...
... ... @@ -23,7 +23,7 @@ func NewHttplibHttplibSmsServe() *HttplibSmsServe {
ConnectTimeout: 100 * time.Second,
ReadWriteTimeout: 30 * time.Second,
},
baseUrL: constant.ALLIED_CREATION_USER_HOST,
baseUrL: constant.SMS_SERVE_HOST,
}
}
... ... @@ -65,7 +65,7 @@ func (smsServe HttplibSmsServe) SendSms(phone string) error {
//CheckSmsCode 公共短信验证码服务 校验验证码
func (smsServe HttplibSmsServe) CheckSmsCode(phone string, code string) error {
url := smsServe.baseUrL + "/service/sendSms"
url := smsServe.baseUrL + "/service/checkSmsCode"
method := "post"
req := smsServe.CreateRequest(url, method)
param := map[string]string{
... ...
... ... @@ -83,3 +83,29 @@ func (controller *AuthController) GetUserOrg() {
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)
}
... ...
... ... @@ -11,12 +11,63 @@ type UserController struct {
func (controller *UserController) SendSmsCode() {
authService := service.UserService{}
smsCodeCmd := &command.SendSmsCodeCommand{}
err := controller.Unmarshal(smsCodeCmd)
cmd := &command.SendSmsCodeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
err = authService.SendSmsCaptcha(smsCodeCmd)
err = authService.SendSmsCaptcha(cmd)
controller.Response(nil, err)
}
func (controller *UserController) CheckSmsCode() {
authService := service.UserService{}
cmd := &command.CheckSmsCodeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
data, err := authService.CheckSmsCode(cmd)
controller.Response(data, err)
}
func (controller *UserController) ChangePassword() {
authService := service.UserService{}
cmd := &command.ChangePasswordCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.ChangePassword(cmd)
controller.Response(data, err)
}
func (controller *UserController) ChangePhone() {
authService := service.UserService{}
cmd := &command.ResetPhoneCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.ChangePhone(cmd)
controller.Response(data, err)
}
func (controller *UserController) UpdateUserInfo() {
authService := service.UserService{}
cmd := &command.UpdateUserInfoCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.UpdateUserInfo(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -57,6 +57,18 @@ func (controller *CooperationModeController) RemoveCooperationMode() {
controller.Response(data, err)
}
func (controller *CooperationModeController) SearchCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
listCooperationModeQuery := &query.ListCooperationModeQuery{}
err := controller.Unmarshal(listCooperationModeQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
listCooperationModeQuery.Operator = controller.GetOperator()
cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.returnPageListData(cnt, data, err, listCooperationModeQuery.PageNumber)
}
func (controller *CooperationModeController) ListCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
listCooperationModeQuery := &query.ListCooperationModeQuery{}
... ...
... ... @@ -15,4 +15,7 @@ func init() {
web.Router("/v1/app/user/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
web.Router("/v1/app/user/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/app/user/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg")
web.Router("/v1/app/auth/company-sign-up", &mobile_client.AuthController{}, "Post:CompanySignUp")
web.Router("/v1/app/auth/reset-password", &mobile_client.AuthController{}, "Post:ResetPassword")
}
... ...
... ... @@ -6,5 +6,10 @@ import (
)
func init() {
web.Router("/v1/app/users/smsCode", &mobile_client.UserController{}, "Post:SendSmsCode")
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")
}
... ...
... ... @@ -2,6 +2,7 @@ package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
)
... ... @@ -21,4 +22,6 @@ func init() {
web.Router("/v1/web/users/selector/org", &web_client.UsersController{}, "Post:SelectorCompanyOrg")
web.Router("/v1/web/users/selector/role", &web_client.UsersController{}, "Post:SelectorCompanyRole")
web.Router("/v1/web/users/selector/org/all", &web_client.UsersController{}, "Post:SelectorCompanyOrgAll")
web.Router("/v1/web/auth/users-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
}
... ...