|
@@ -3,6 +3,7 @@ package user
|
|
|
import (
|
|
import (
|
|
|
"git.sxidc.com/go-framework/baize/convenient/entity_crud"
|
|
"git.sxidc.com/go-framework/baize/convenient/entity_crud"
|
|
|
"git.sxidc.com/go-framework/baize/framework/binding"
|
|
"git.sxidc.com/go-framework/baize/framework/binding"
|
|
|
|
|
+ "git.sxidc.com/go-framework/baize/framework/core/api/response"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/domain"
|
|
"git.sxidc.com/go-framework/baize/framework/core/domain"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/domain/entity"
|
|
"git.sxidc.com/go-framework/baize/framework/core/domain/entity"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/infrastructure"
|
|
"git.sxidc.com/go-framework/baize/framework/core/infrastructure"
|
|
@@ -41,7 +42,7 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
|
|
|
|
|
encryptedPassword, err := encoding.AESEncrypt(userEntity.Password, simple.AESKey)
|
|
encryptedPassword, err := encoding.AESEncrypt(userEntity.Password, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return err
|
|
|
|
|
|
|
+ return errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
userEntity.Password = encryptedPassword
|
|
userEntity.Password = encryptedPassword
|
|
@@ -52,14 +53,14 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
|
|
|
|
|
encryptedPhone, err := encoding.AESEncrypt(userEntity.Phone, simple.AESKey)
|
|
encryptedPhone, err := encoding.AESEncrypt(userEntity.Phone, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return err
|
|
|
|
|
|
|
+ return errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
userEntity.Phone = encryptedPhone
|
|
userEntity.Phone = encryptedPhone
|
|
|
|
|
|
|
|
encryptedEmail, err := encoding.AESEncrypt(userEntity.Email, simple.AESKey)
|
|
encryptedEmail, err := encoding.AESEncrypt(userEntity.Email, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return err
|
|
|
|
|
|
|
+ return errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
userEntity.Email = encryptedEmail
|
|
userEntity.Email = encryptedEmail
|
|
@@ -98,7 +99,7 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
if strutils.IsStringNotEmpty(userEntity.Password) {
|
|
if strutils.IsStringNotEmpty(userEntity.Password) {
|
|
|
encryptedPassword, err := encoding.AESEncrypt(userEntity.Password, simple.AESKey)
|
|
encryptedPassword, err := encoding.AESEncrypt(userEntity.Password, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return err
|
|
|
|
|
|
|
+ return errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
userEntity.Password = encryptedPassword
|
|
userEntity.Password = encryptedPassword
|
|
@@ -111,7 +112,7 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
if strutils.IsStringNotEmpty(userEntity.Phone) {
|
|
if strutils.IsStringNotEmpty(userEntity.Phone) {
|
|
|
encryptedPhone, err := encoding.AESEncrypt(userEntity.Phone, simple.AESKey)
|
|
encryptedPhone, err := encoding.AESEncrypt(userEntity.Phone, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return err
|
|
|
|
|
|
|
+ return errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
userEntity.Phone = encryptedPhone
|
|
userEntity.Phone = encryptedPhone
|
|
@@ -120,7 +121,7 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
if strutils.IsStringNotEmpty(userEntity.Email) {
|
|
if strutils.IsStringNotEmpty(userEntity.Email) {
|
|
|
encryptedEmail, err := encoding.AESEncrypt(userEntity.Email, simple.AESKey)
|
|
encryptedEmail, err := encoding.AESEncrypt(userEntity.Email, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return err
|
|
|
|
|
|
|
+ return errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
userEntity.Email = encryptedEmail
|
|
userEntity.Email = encryptedEmail
|
|
@@ -195,7 +196,7 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
if strutils.IsStringNotEmpty(phone) {
|
|
if strutils.IsStringNotEmpty(phone) {
|
|
|
encryptedPassword, err := encoding.AESEncrypt(phone, simple.AESKey)
|
|
encryptedPassword, err := encoding.AESEncrypt(phone, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return false, err
|
|
|
|
|
|
|
+ return false, errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
conditions.Equal(ColumnPassword, encryptedPassword)
|
|
conditions.Equal(ColumnPassword, encryptedPassword)
|
|
@@ -211,7 +212,7 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
if strutils.IsStringNotEmpty(email) {
|
|
if strutils.IsStringNotEmpty(email) {
|
|
|
encryptedPassword, err := encoding.AESEncrypt(email, simple.AESKey)
|
|
encryptedPassword, err := encoding.AESEncrypt(email, simple.AESKey)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return false, err
|
|
|
|
|
|
|
+ return false, errors.New(err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
conditions.Equal(ColumnPassword, encryptedPassword)
|
|
conditions.Equal(ColumnPassword, encryptedPassword)
|
|
@@ -221,5 +222,64 @@ func (simple *Simple) Bind(binder *binding.Binder) {
|
|
|
default:
|
|
default:
|
|
|
return false, nil
|
|
return false, nil
|
|
|
}
|
|
}
|
|
|
|
|
+ }), entity_crud.WithQueryCallbacks(&entity_crud.QueryCallbacks[Info]{
|
|
|
|
|
+ OnSuccessReturn: func(e entity.Entity, i *infrastructure.Infrastructure, output response.InfosData[Info]) (response.InfosData[Info], error) {
|
|
|
|
|
+ errResponse := response.InfosData[Info]{
|
|
|
|
|
+ Infos: make([]Info, 0),
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ retInfos := make([]Info, len(output.Infos))
|
|
|
|
|
+ infos := output.Infos
|
|
|
|
|
+
|
|
|
|
|
+ for index, info := range infos {
|
|
|
|
|
+ if strutils.IsStringNotEmpty(info.Name) {
|
|
|
|
|
+ encryptedName, err := encoding.AESEncrypt(info.Name, simple.AESKey)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return errResponse, errors.New(err.Error())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ info.Name = encryptedName
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if strutils.IsStringNotEmpty(info.Email) {
|
|
|
|
|
+ encryptedEmail, err := encoding.AESEncrypt(info.Email, simple.AESKey)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return errResponse, errors.New(err.Error())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ info.Email = encryptedEmail
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ retInfos[index] = info
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return response.InfosData[Info]{
|
|
|
|
|
+ Infos: retInfos,
|
|
|
|
|
+ TotalCount: output.TotalCount,
|
|
|
|
|
+ PageNo: output.PageNo,
|
|
|
|
|
+ }, nil
|
|
|
|
|
+ },
|
|
|
|
|
+ }), entity_crud.WithGetByIDCallbacks(&entity_crud.GetByIDCallbacks[Info]{
|
|
|
|
|
+ OnSuccessReturn: func(e entity.Entity, i *infrastructure.Infrastructure, output Info) (Info, error) {
|
|
|
|
|
+ if strutils.IsStringNotEmpty(output.Name) {
|
|
|
|
|
+ encryptedName, err := encoding.AESEncrypt(output.Name, simple.AESKey)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return Info{}, errors.New(err.Error())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ output.Name = encryptedName
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if strutils.IsStringNotEmpty(output.Email) {
|
|
|
|
|
+ encryptedEmail, err := encoding.AESEncrypt(output.Email, simple.AESKey)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return Info{}, errors.New(err.Error())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ output.Email = encryptedEmail
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return output, nil
|
|
|
|
|
+ },
|
|
|
}))
|
|
}))
|
|
|
}
|
|
}
|