2020-11-24 17:36:42 +08:00
|
|
|
package users
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type DeleteAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *DeleteAction) RunPost(params struct {
|
|
|
|
|
UserId int64
|
|
|
|
|
}) {
|
|
|
|
|
defer this.CreateLogInfo("删除ACME用户 %d", params.UserId)
|
|
|
|
|
|
2020-11-25 21:19:07 +08:00
|
|
|
countResp, err := this.RPC().ACMETaskRPC().CountAllEnabledACMETasksWithACMEUserId(this.AdminContext(), &pb.CountAllEnabledACMETasksWithACMEUserIdRequest{AcmeUserId: params.UserId})
|
2020-11-24 17:36:42 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if countResp.Count > 0 {
|
2020-11-25 21:19:07 +08:00
|
|
|
this.Fail("有任务正在和这个用户关联,所以不能删除")
|
2020-11-24 17:36:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = this.RPC().ACMEUserRPC().DeleteACMEUser(this.AdminContext(), &pb.DeleteACMEUserRequest{AcmeUserId: params.UserId})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|