作者 yangfu

账号注销、注销记录

... ... @@ -10,7 +10,7 @@ import (
type DestroyAccountCommand struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string" valid:"Required"`
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
}
func (destroyAccountCommand *DestroyAccountCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -10,7 +10,7 @@ import (
type PhoneAuthChangePasswordCommand struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string" valid:"Required"`
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
// 旧密码
OldPassword string `cname:"旧密码" json:"oldPassword" valid:"Required"`
// 新密码
... ...
... ... @@ -72,10 +72,21 @@ func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.De
defer func() {
transactionContext.RollbackTransaction()
}()
accountDestroyService, err := factory.CreatePgAuthAccountDestroyService(map[string]interface{}{
"transactionContext": transactionContext,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.UserId); 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())
}
return nil, nil
return struct{}{}, nil
}
// 修改密码
... ... @@ -93,10 +104,54 @@ func (authService *AuthService) PhoneAuthChangePassword(phoneAuthChangePasswordC
defer func() {
transactionContext.RollbackTransaction()
}()
var userRepository domain.UserRepository
if value, err := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userRepository = value
}
var userBaseId int64
if user, err := userRepository.FindOne(map[string]interface{}{"userId": phoneAuthChangePasswordCommand.UserId}); err != nil {
if err == domain.ErrorNotFound {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
}
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
userBaseId = user.UserBaseId
}
var userBaseRepository domain.UserBaseRepository
if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userBaseRepository = value
}
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userBaseId})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err == domain.ErrorNotFound {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
}
if err := userBase.CheckAccountPassword(userBase.Account, phoneAuthChangePasswordCommand.OldPassword); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := userBase.ResetPassword(userBase.Account, phoneAuthChangePasswordCommand.NewPassword); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if _, err = userBaseRepository.Save(userBase); 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())
}
return nil, nil
return struct {
}{}, nil
}
// 手机账号密码检查
... ... @@ -237,7 +292,7 @@ func (authService *AuthService) RefreshIM(refreshIMCommand *command.RefreshIMCom
return nil, nil
}
// 用户信息 (暂时没有使用)
// 用户信息
func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (interface{}, error) {
if err := userInfoQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ...
... ... @@ -21,3 +21,11 @@ func CreatePgAuthResetPhoneService(options map[string]interface{}) (service.PgAu
}
return domainService.NewPgAuthResetPhoneService(transactionContext)
}
func CreatePgAuthAccountDestroyService(options map[string]interface{}) (service.PgAuthAccountDestroyService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgAuthAccountDestroyService(transactionContext)
}
... ...
... ... @@ -61,3 +61,11 @@ func CreateCustomizeMenuRepository(options map[string]interface{}) (domain.Custo
}
return repository.NewCustomizeMenuRepository(transactionContext)
}
func CreateAccountDestroyRecordRepository(options map[string]interface{}) (domain.AccountDestroyRecordRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewAccountDestroyRecordRepository(transactionContext)
}
... ...
package domain
import (
"fmt"
"time"
)
// 账号注销记录
type AccountDestroyRecord struct {
// 用户基础数据id
UserBaseId int64 `json:"userBaseId,string"`
// 账号注销记录ID
AccountDestroyRecordId int64 `json:"accountDestroyRecordId,string"`
// 注销时间
DestroyTime time.Time `json:"destroyTime"`
// 账号修改后
AccountAfter string `json:"accountAfter"`
// 账号修改前
AccountBefore string `json:"accountBefore"`
}
type AccountDestroyRecordRepository interface {
Save(accountDestroyRecord *AccountDestroyRecord) (*AccountDestroyRecord, error)
Remove(accountDestroyRecord *AccountDestroyRecord) (*AccountDestroyRecord, error)
FindOne(queryOptions map[string]interface{}) (*AccountDestroyRecord, error)
Find(queryOptions map[string]interface{}) (int64, []*AccountDestroyRecord, error)
}
func (accountDestroyRecord *AccountDestroyRecord) Identify() interface{} {
if accountDestroyRecord.AccountDestroyRecordId == 0 {
return nil
}
return accountDestroyRecord.AccountDestroyRecordId
}
func (accountDestroyRecord *AccountDestroyRecord) Update(data map[string]interface{}) error {
//if userBaseId, ok := data["userBaseId"]; ok {
// accountDestroyRecord.UserBaseId = userBaseId.(int64)
//}
//if accountDestroyRecordId, ok := data["accountDestroyRecordId"]; ok {
// accountDestroyRecord.AccountDestroyRecordId = accountDestroyRecordId.(int64)
//}
//if destroyTime, ok := data["destroyTime"]; ok {
// accountDestroyRecord.DestroyTime = destroyTime.(string)
//}
//if accountAfter, ok := data["accountAfter"]; ok {
// accountDestroyRecord.AccountAfter = accountAfter.(string)
//}
//if accountBefore, ok := data["accountBefore"]; ok {
// accountDestroyRecord.AccountBefore = accountBefore.(string)
//}
return nil
}
func NewAccountDestroyRecord(userBaseId int64, num int64, account string) *AccountDestroyRecord {
return &AccountDestroyRecord{
UserBaseId: userBaseId,
DestroyTime: time.Now(),
AccountBefore: account,
AccountAfter: fmt.Sprintf("%v-%v", account, num+1),
}
}
... ...
package service
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
// PgAuthAccountDestroyService 账号注销服务
type PgAuthAccountDestroyService interface {
DestroyAccount(optUser *domain.User, userId int64) error
}
... ...
... ... @@ -155,3 +155,11 @@ func (user *User) Update(data map[string]interface{}) error {
type UserStatus int
/***** 1.基础模块函数 *****/
// DestroyAccount 注销账号
//
// accountAfter 变更后的账号
func (user *User) DestroyAccount(accountAfter string) error {
user.EnableStatus = int(UserStatusDestroy)
user.Ext.Phone = accountAfter
return nil
}
... ...
... ... @@ -136,6 +136,10 @@ func (userBase *UserBase) ResetPassword(account, password string) error {
return nil
}
// ResetPhone 重置手机号
//
// oldPhone 旧手机号
// newPhone 新手机号
func (userBase *UserBase) ResetPhone(oldPhone, newPhone string) error {
if userBase.Status != int(UserStatusEnable) {
return fmt.Errorf("该用户不存在")
... ... @@ -147,3 +151,16 @@ func (userBase *UserBase) ResetPhone(oldPhone, newPhone string) error {
userBase.UserInfo.Phone = newPhone
return nil
}
// DestroyAccount 注销账号
//
// p1 p1_desc
func (userBase *UserBase) DestroyAccount(accountAfter string) error {
if userBase.Status != int(UserStatusEnable) {
return fmt.Errorf("账号已注销")
}
userBase.Status = int(UserStatusDestroy)
userBase.Account = accountAfter
userBase.UserInfo.Phone = accountAfter
return nil
}
... ...
package domainService
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/repository"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
// PgAuthAccountDestroyService 账号注销服务
type PgAuthAccountDestroyService struct {
transactionContext *pgTransaction.TransactionContext
}
func (ptr *PgAuthAccountDestroyService) DestroyAccount(optUser *domain.User, userId int64) error {
// 1.查询账号记录
userRepository, _ := repository.NewUserRepository(ptr.transactionContext)
var userBaseId int64
if user, err := userRepository.FindOne(map[string]interface{}{"userId": userId}); err != nil {
if err == domain.ErrorNotFound {
return fmt.Errorf("该用户不存在")
}
return err
} else {
userBaseId = user.UserBaseId
}
userBaseRepository, _ := repository.NewUserBaseRepository(ptr.transactionContext)
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userBaseId})
if err != nil {
return err
}
if err == domain.ErrorNotFound {
return fmt.Errorf("该用户不存在")
}
// 2.查询历史账号注销记录,生成当前账号的注销记录
accountDestroyRecordRepository, _ := repository.NewAccountDestroyRecordRepository(ptr.transactionContext)
var total int64
if total, _, err = accountDestroyRecordRepository.Find(map[string]interface{}{"accountBefore": userBase.Account}); err != nil {
return err
}
record := domain.NewAccountDestroyRecord(userBase.UserBaseId, total, userBase.Account)
if _, err := accountDestroyRecordRepository.Save(record); err != nil {
return err
}
// 3.注销相关联的账号
for i := 0; i < len(userBase.RelatedUsers); i++ {
userId := userBase.RelatedUsers[i]
if user, _ := userRepository.FindOne(map[string]interface{}{"userId": userId}); user != nil {
user.DestroyAccount(record.AccountAfter)
if _, err := userRepository.Save(user); err != nil {
return err
}
}
}
// 4.注销账号
if err = userBase.DestroyAccount(record.AccountAfter); err != nil {
return err
}
if _, err = userBaseRepository.Save(userBase); err != nil {
return err
}
return nil
}
func NewPgAuthAccountDestroyService(transactionContext *pgTransaction.TransactionContext) (*PgAuthAccountDestroyService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &PgAuthAccountDestroyService{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -36,7 +36,7 @@ func init() {
(*models.Role)(nil),
(*models.User)(nil),
(*models.UserBase)(nil),
//(*models.User)(nil),
(*models.AccountDestroyRecord)(nil),
} {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
Temp: false,
... ...
package models
import "time"
type AccountDestroyRecord struct {
tableName string `comment:"账号注销记录" pg:"users.account_destroy_records,alias:account_destroy_record"`
// 用户基础数据id
UserBaseId int64 `comment:"用户基础数据id"`
// 账号注销记录ID
AccountDestroyRecordId int64 `comment:"账号注销记录ID" pg:"pk:account_destroy_record_id"`
// 注销时间
DestroyTime time.Time `comment:"注销时间"`
// 账号修改后
AccountAfter string `comment:"账号修改后"`
// 账号修改前
AccountBefore string `comment:"账号修改前"`
}
... ...
package transform
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg/models"
)
func TransformToAccountDestroyRecordDomainModelFromPgModels(accountDestroyRecordModel *models.AccountDestroyRecord) (*domain.AccountDestroyRecord, error) {
return &domain.AccountDestroyRecord{
UserBaseId: accountDestroyRecordModel.UserBaseId,
AccountDestroyRecordId: accountDestroyRecordModel.AccountDestroyRecordId,
DestroyTime: accountDestroyRecordModel.DestroyTime,
AccountAfter: accountDestroyRecordModel.AccountAfter,
AccountBefore: accountDestroyRecordModel.AccountBefore,
}, nil
}
... ...
package repository
import (
"fmt"
"github.com/go-pg/pg/v10"
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/linmadan/egglib-go/utils/snowflake"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg/transform"
)
type AccountDestroyRecordRepository struct {
transactionContext *pgTransaction.TransactionContext
}
func (repository *AccountDestroyRecordRepository) nextIdentify() (int64, error) {
IdWorker, err := snowflake.NewIdWorker(1)
if err != nil {
return 0, err
}
id, err := IdWorker.NextId()
return id, err
}
func (repository *AccountDestroyRecordRepository) Save(accountDestroyRecord *domain.AccountDestroyRecord) (*domain.AccountDestroyRecord, error) {
sqlBuildFields := []string{
"user_base_id",
"account_destroy_record_id",
"destroy_time",
"account_after",
"account_before",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "account_destroy_record_id"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "account_destroy_record_id"))
returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "account_destroy_record_id")
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
tx := repository.transactionContext.PgTx
if accountDestroyRecord.Identify() == nil {
accountDestroyRecordId, err := repository.nextIdentify()
if err != nil {
return accountDestroyRecord, err
} else {
accountDestroyRecord.AccountDestroyRecordId = accountDestroyRecordId
}
if _, err := tx.QueryOne(
pg.Scan(
&accountDestroyRecord.UserBaseId,
&accountDestroyRecord.AccountDestroyRecordId,
&accountDestroyRecord.DestroyTime,
&accountDestroyRecord.AccountAfter,
&accountDestroyRecord.AccountBefore,
),
fmt.Sprintf("INSERT INTO users.account_destroy_records (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
accountDestroyRecord.UserBaseId,
accountDestroyRecord.DestroyTime,
accountDestroyRecord.AccountAfter,
accountDestroyRecord.AccountBefore,
); err != nil {
return accountDestroyRecord, err
}
} else {
if _, err := tx.QueryOne(
pg.Scan(
&accountDestroyRecord.UserBaseId,
&accountDestroyRecord.AccountDestroyRecordId,
&accountDestroyRecord.DestroyTime,
&accountDestroyRecord.AccountAfter,
&accountDestroyRecord.AccountBefore,
),
fmt.Sprintf("UPDATE users.account_destroy_records SET %s WHERE account_destroy_record_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
accountDestroyRecord.UserBaseId,
accountDestroyRecord.DestroyTime,
accountDestroyRecord.AccountAfter,
accountDestroyRecord.AccountBefore,
accountDestroyRecord.Identify(),
); err != nil {
return accountDestroyRecord, err
}
}
return accountDestroyRecord, nil
}
func (repository *AccountDestroyRecordRepository) Remove(accountDestroyRecord *domain.AccountDestroyRecord) (*domain.AccountDestroyRecord, error) {
tx := repository.transactionContext.PgTx
accountDestroyRecordModel := new(models.AccountDestroyRecord)
accountDestroyRecordModel.AccountDestroyRecordId = accountDestroyRecord.Identify().(int64)
if _, err := tx.Model(accountDestroyRecordModel).WherePK().Delete(); err != nil {
return accountDestroyRecord, err
}
return accountDestroyRecord, nil
}
func (repository *AccountDestroyRecordRepository) FindOne(queryOptions map[string]interface{}) (*domain.AccountDestroyRecord, error) {
tx := repository.transactionContext.PgTx
accountDestroyRecordModel := new(models.AccountDestroyRecord)
query := sqlbuilder.BuildQuery(tx.Model(accountDestroyRecordModel), queryOptions)
query.SetWhereByQueryOption("account_destroy_record.account_destroy_record_id = ?", "accountDestroyRecordId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
} else {
return nil, err
}
}
if accountDestroyRecordModel.AccountDestroyRecordId == 0 {
return nil, nil
} else {
return transform.TransformToAccountDestroyRecordDomainModelFromPgModels(accountDestroyRecordModel)
}
}
func (repository *AccountDestroyRecordRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.AccountDestroyRecord, error) {
tx := repository.transactionContext.PgTx
var accountDestroyRecordModels []*models.AccountDestroyRecord
accountDestroyRecords := make([]*domain.AccountDestroyRecord, 0)
query := sqlbuilder.BuildQuery(tx.Model(&accountDestroyRecordModels), queryOptions)
query.SetWhereByQueryOption("account_before = ?", "accountBefore")
query.SetOffsetAndLimit(20)
query.SetOrderDirect("account_destroy_record_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
return 0, accountDestroyRecords, err
} else {
for _, accountDestroyRecordModel := range accountDestroyRecordModels {
if accountDestroyRecord, err := transform.TransformToAccountDestroyRecordDomainModelFromPgModels(accountDestroyRecordModel); err != nil {
return 0, accountDestroyRecords, err
} else {
accountDestroyRecords = append(accountDestroyRecords, accountDestroyRecord)
}
}
return int64(count), accountDestroyRecords, nil
}
}
func NewAccountDestroyRecordRepository(transactionContext *pgTransaction.TransactionContext) (*AccountDestroyRecordRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &AccountDestroyRecordRepository{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -11,12 +11,17 @@ import (
)
var _ = Describe("注销账号 (添加用户时重新激活)", func() {
return
var Id int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&Id),
"INSERT INTO s () VALUES () RETURNING _id",
"INSERT INTO \"users\".\"user_base\"(\"user_base_id\", \"user_info\", \"account\", \"password\", \"im\", \"related_user\", \"status\", \"created_at\", \"updated_at\") VALUES (999, '{\"phone\": \"phone\", \"userName\": \"string\"}', 'phone', 'string', '{\"accid\": \"\", \"imToken\": \"\", \"csAccountId\": \"\"}', '{999}', 1, '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08') RETURNING user_base_id;",
)
Expect(err).NotTo(HaveOccurred())
_, err = pG.DB.QueryOne(
pg.Scan(&Id),
"INSERT INTO \"users\".\"user\"(\"user_id\", \"company_id\", \"user_base_id\", \"user_type\", \"user_code\", \"organization_id\", \"department_id\", \"user_org\", \"user_role\", \"favorite_menus\", \"cooperation_info\", \"enable_status\", \"ext\", \"created_at\", \"updated_at\") VALUES (999, 5, 999, 1025, 'ADMIN01', 5, 5, '[{\"orgId\": 5, \"orgName\": \"string1\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"deletedAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[{\"ext\": {\"orgName\": \"string1\"}, \"roleId\": 5, \"roleName\": \"企业管理员\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[]', '{\"cooperationCompany\": \"\", \"cooperationDeadline\": \"0001-01-01T00:00:00Z\"}', 1, '{\"phone\": \"18860183031\", \"depName\": \"string1\", \"orgName\": \"string1\"}', '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08');\n",
)
Expect(err).NotTo(HaveOccurred())
})
... ... @@ -25,7 +30,7 @@ var _ = Describe("注销账号 (添加用户时重新激活)", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userId": 999,
}
httpExpect.POST("/auth/destroy-account").
WithJSON(body).
... ... @@ -40,7 +45,9 @@ var _ = Describe("注销账号 (添加用户时重新激活)", func() {
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM s WHERE true")
_, err := pG.DB.Exec("DELETE FROM users.user_base WHERE user_base_id = 999")
Expect(err).NotTo(HaveOccurred())
_, err = pG.DB.Exec(`DELETE FROM users."user" WHERE user_id = 999`)
Expect(err).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -11,12 +11,17 @@ import (
)
var _ = Describe("修改密码", func() {
return
var Id int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&Id),
"INSERT INTO s () VALUES () RETURNING _id",
"INSERT INTO \"users\".\"user_base\"(\"user_base_id\", \"user_info\", \"account\", \"password\", \"im\", \"related_user\", \"status\", \"created_at\", \"updated_at\") VALUES (999, '{\"phone\": \"phone\", \"userName\": \"string\"}', 'phone', 'string', '{\"accid\": \"\", \"imToken\": \"\", \"csAccountId\": \"\"}', '{999}', 1, '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08') RETURNING user_base_id;",
)
Expect(err).NotTo(HaveOccurred())
_, err = pG.DB.QueryOne(
pg.Scan(&Id),
"INSERT INTO \"users\".\"user\"(\"user_id\", \"company_id\", \"user_base_id\", \"user_type\", \"user_code\", \"organization_id\", \"department_id\", \"user_org\", \"user_role\", \"favorite_menus\", \"cooperation_info\", \"enable_status\", \"ext\", \"created_at\", \"updated_at\") VALUES (999, 5, 999, 1025, 'ADMIN01', 5, 5, '[{\"orgId\": 5, \"orgName\": \"string1\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"deletedAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[{\"ext\": {\"orgName\": \"string1\"}, \"roleId\": 5, \"roleName\": \"企业管理员\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[]', '{\"cooperationCompany\": \"\", \"cooperationDeadline\": \"0001-01-01T00:00:00Z\"}', 1, '{\"phone\": \"18860183031\", \"depName\": \"string1\", \"orgName\": \"string1\"}', '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08');\n",
)
Expect(err).NotTo(HaveOccurred())
})
... ... @@ -25,9 +30,9 @@ var _ = Describe("修改密码", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userId": 999,
"oldPassword": "string",
"newPassword": "string",
"newPassword": "string999",
}
httpExpect.POST("/auth/change-password").
WithJSON(body).
... ... @@ -42,7 +47,9 @@ var _ = Describe("修改密码", func() {
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM s WHERE true")
_, err := pG.DB.Exec("DELETE FROM users.user_base WHERE user_base_id = 999")
Expect(err).NotTo(HaveOccurred())
_, err = pG.DB.Exec(`DELETE FROM users."user" WHERE user_id = 999`)
Expect(err).NotTo(HaveOccurred())
})
})
... ...