作者 yangfu

权限验证、重置密码修改

... ... @@ -10,13 +10,15 @@ import (
type ResetPasswordCommand struct {
// 手机号码
// Phone string `cname:"手机号码" json:"phone" valid:"Required"`
Phone string `cname:"手机号码" json:"phone"`
// 密码
Password string `cname:"密码" json:"newPassword"`
// 密码
RepeatNewPassword string `cname:"密码" json:"repeatNewPassword" valid:"Required"`
// 密码
SmsCodeIdentity string `cname:"密码" json:"smsCodeIdentity" valid:"Required"`
SmsCodeIdentity string `cname:"密码" json:"smsCodeIdentity"`
// 1:smsCodeIdentity 验证码凭证 2:smsCode 验证
SmsCode string `cname:"密码" json:"smsCode"`
}
func (resetPasswordCommand *ResetPasswordCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -409,17 +409,27 @@ func (svr AuthService) ResetPassword(resetPasswordCommand *command.ResetPassword
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, "验证码已失效")
var phone = resetPasswordCommand.Phone
if len(resetPasswordCommand.SmsCode) > 0 {
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.CheckSmsCode(resetPasswordCommand.Phone, resetPasswordCommand.SmsCode)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
} else {
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, "验证码已失效")
}
phone = item.Phone
}
// 2.重置密码
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
result, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
Phone: item.Phone,
Phone: phone,
Password: resetPasswordCommand.Password,
})
if err != nil {
... ...
... ... @@ -37,6 +37,7 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti
{"菜单", "menu"},
{"按钮", "button"},
},
"dictCode": "MenuType",
})
case "XTZD-001":
dictionaries = append(dictionaries, map[string]interface{}{
... ... @@ -48,6 +49,7 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti
{"4", "501~1000人"},
{"5", "1000人以上"},
},
"dictCode": "XTZD-001",
})
case "XTZD-002":
dictionaries = append(dictionaries, map[string]interface{}{
... ... @@ -57,6 +59,7 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti
{"2", "电子行业"},
{"3", "纺织业"},
},
"dictCode": "XTZD-002",
})
}
}
... ...
... ... @@ -10,45 +10,6 @@ import (
type PersonCreditAccountService struct {
}
// CreditAccountGet 企业的账期结算明细
//func (srv PersonCreditAccountService) CreditAccountGet(cmd *command.CreditAccountGetCommand) (interface{}, error) {
// gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
// cmd.Operator)
// resultMenu, err := gateway.CreditAccountGet(allied_creation_cooperation.ReqCreditAccountGet{
// CreditAccountId: cmd.CreditAccountId,
// })
// if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
// }
// return resultMenu, nil
//}
//// CreditAccountDelete 企业的账期结算删除
//func (srv PersonCreditAccountService) CreditAccountDelete(cmd *command.CreditAccountGetCommand) (interface{}, error) {
// gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
// cmd.Operator)
// resultMenu, err := gateway.CreditAccountRemove(allied_creation_cooperation.ReqCreditAccountRemove{
// CreditAccountId: cmd.CreditAccountId,
// })
// if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
// }
// return resultMenu, nil
//}
//
//// CreditAccountPay 企业的账期结算支付
//func (srv PersonCreditAccountService) CreditAccountPay(cmd *command.CreditAccountPayCommand) (interface{}, error) {
// gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
// cmd.Operator)
// resultMenu, err := gateway.CreditAccountsPay(allied_creation_cooperation.ReqCreditAccountsPay{
// CreditAccountId: cmd.CreditAccountId,
// })
// if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
// }
// return resultMenu, nil
//}
// CreditAccountPaySearch 企业分红结算支付记录
func (srv PersonCreditAccountService) CreditAccountPaySearch(cmd *command.CreditAccountPaySearchCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
... ...
... ... @@ -105,11 +105,6 @@ func (srv CompanyStatisticsService) IndexStatistics(cmd *command.IndexStatistics
}, nil
}
// CooperationPersonStatistics TODO:共创人员统计(共创人员明细)
func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
return map[string]interface{}{}, nil
}
// GoodsStatistics TODO:产品统计排行榜 年月榜
func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.GoodsStatisticsCommand) (int64, interface{}, error) {
type rankItem struct {
... ... @@ -131,7 +126,7 @@ func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.Go
return 5, items, nil
}
// CooperationDividendsStatistics TODO:公司共创人员列表(分红支出统计)
// CooperationDividendsStatistics TODO:公司共创人员列表
func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (int64, interface{}, error) {
type cooperationDividendItem struct {
CooperationTime int64 `json:"cooperationTime"`
... ... @@ -166,3 +161,8 @@ func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusComm
}
return 5, results, nil
}
// CooperationPersonStatistics TODO:共创人员统计(共创人员明细)
func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
return map[string]interface{}{}, nil
}
... ...
... ... @@ -33,7 +33,7 @@ func init() {
}
filters.SecureKeyMap["token"] = "x-mmm-accesstoken"
//TODO:token验证改为 /v1
web.InsertFilterChain("/v1/app11/*", middleware.CheckAccessToken)
web.InsertFilterChain("/v1/*", middleware.CheckAccessToken)
web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors())
web.InsertFilter("/*", web.BeforeRouter, filters.CreateRequstLogFilter(log.Logger))
web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false))
... ...
... ... @@ -93,12 +93,12 @@ func (controller *BaseController) GetOperator() domain.Operator {
OrgIds: loginToken.OrgIds,
}
// TODO:测试数据后期删除
if op.UserId == 0 {
op.UserId = 1
op.CompanyId = 1
op.OrgId = 1
op.UserBaseId = 1
}
//if op.UserId == 0 {
// op.UserId = 1
// op.CompanyId = 1
// op.OrgId = 1
// op.UserBaseId = 1
//}
// TODO:打印测试日志
log.Logger.Debug("operator " + json.MarshalToString(op))
return op
... ...
... ... @@ -21,16 +21,17 @@ func CheckAccessToken(next web.FilterFunc) web.FilterFunc {
return func(ctx *context.Context) {
tokenStr := ctx.Input.Header("x-mmm-accesstoken")
filterMap := map[string]string{
"/v1/auth/login/pwd": "",
"/v1/auth/login/sms": "",
"/v1/auth/login/qrcode": "",
"/v1/auth/captcha-init": "",
"/v1/auth/qrcode-init": "",
"/v1/auth/sms-code": "",
"/v1/auth/check-sms-code": "",
"/v1/auth/company-sign-up": "",
"/v1/auth/reset-password": "",
"/v1/auth/refresh-token": "",
"/v1/auth/login/pwd": "",
"/v1/auth/login/sms": "",
"/v1/auth/login/qrcode": "",
"/v1/auth/captcha-init": "",
"/v1/auth/qrcode-init": "",
"/v1/auth/sms-code": "",
"/v1/auth/check-sms-code": "",
"/v1/auth/company-sign-up": "",
"/v1/auth/reset-password": "",
"/v1/auth/refresh-token": "",
"/v1/app/cooperation-projects/person/search": "",
}
var err error
if filterUrl, err := url.Parse(ctx.Request.RequestURI); err == nil {
... ...