|
|
|
@ -13,6 +13,7 @@ import (
|
|
|
|
|
"git.oa00.com/go/mysql"
|
|
|
|
|
"github.com/golangkit/formatime"
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
"gorm.io/gorm/clause"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type logic struct {
|
|
|
|
@ -30,12 +31,13 @@ func (o logic) List(args ApplyList) (res []upgrade.ApplyEntry, total int64, err
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
query.Count(&total)
|
|
|
|
|
query.Limit(args.GetLimit()).Offset(args.GetStart()).Find(&res)
|
|
|
|
|
query.Preload(clause.Associations).Limit(args.GetLimit()).Offset(args.GetStart()).Find(&res)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ApplySure struct {
|
|
|
|
|
ID uint `json:"id" validate:"required"`
|
|
|
|
|
ID uint `json:"id" validate:"required"`
|
|
|
|
|
UserID uint `json:"-"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o logic) Sure(args ApplySure) error {
|
|
|
|
@ -99,6 +101,14 @@ func (o logic) Sure(args ApplySure) error {
|
|
|
|
|
err = fmt.Errorf("创建用户错误103:" + err.Error())
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := tx.Table((&upgrade.ApplyEntry{}).TableName()).Where("id = ?", args.ID).Updates(upgrade.ApplyEntry{
|
|
|
|
|
State: 1,
|
|
|
|
|
ProcessTime: formatime.NewSecondNow(),
|
|
|
|
|
ProcessUserID: args.UserID,
|
|
|
|
|
}).Error; err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}); err != nil {
|
|
|
|
|
return err
|
|
|
|
@ -106,7 +116,11 @@ func (o logic) Sure(args ApplySure) error {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if err := mysql.Db.Transaction(func(tx *gorm.DB) error {
|
|
|
|
|
if err := tx.Table((&upgrade.ApplyEntry{}).TableName()).Where("id = ?", args.ID).Updates(upgrade.ApplyEntry{State: 1}).Error; err != nil {
|
|
|
|
|
if err := tx.Table((&upgrade.ApplyEntry{}).TableName()).Where("id = ?", args.ID).Updates(upgrade.ApplyEntry{
|
|
|
|
|
State: 1,
|
|
|
|
|
ProcessTime: formatime.NewSecondNow(),
|
|
|
|
|
ProcessUserID: args.UserID,
|
|
|
|
|
}).Error; err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if err := tx.Model(&mu).Updates(user.RecookUserInfoModel{
|
|
|
|
@ -125,11 +139,17 @@ func (o logic) Sure(args ApplySure) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ApplyReject struct {
|
|
|
|
|
ID uint `json:"id" validate:"required"`
|
|
|
|
|
ApplySure
|
|
|
|
|
Reason string `json:"reason" validate:"required,maxLen=20"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o logic) Reject(args ApplyReject) error {
|
|
|
|
|
mysql.Db.Table((&upgrade.ApplyEntry{}).TableName()).Where("id = ?", args.ID).Updates(upgrade.ApplyEntry{State: 2, Reason: args.Reason})
|
|
|
|
|
mysql.Db.Table((&upgrade.ApplyEntry{}).TableName()).Where("id = ?", args.ID).Updates(
|
|
|
|
|
upgrade.ApplyEntry{
|
|
|
|
|
State: 2,
|
|
|
|
|
Reason: args.Reason,
|
|
|
|
|
ProcessTime: formatime.NewSecondNow(),
|
|
|
|
|
ProcessUserID: args.UserID,
|
|
|
|
|
})
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|