model层部分表删除部分字段
Former-commit-id: 269c3fa7e6b90f6df8ecdbcea312bfac4394eb04
This commit is contained in:
parent
91078c2684
commit
68cde61a44
|
@ -468,7 +468,7 @@ type SaveHashcatReq {
|
|||
}
|
||||
|
||||
type getHashcatHandlerReq {
|
||||
CrackTaskId int64 `json:"crackTaskId"` // 任务id
|
||||
CrackTaskId string `path:"crackTaskId"` // 任务id
|
||||
}
|
||||
|
||||
type getHashcatHandlerResp {
|
||||
|
|
|
@ -4,14 +4,22 @@ import (
|
|||
"gitlink.org.cn/jcce-pcm/utils/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/core"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
)
|
||||
|
||||
func GetHashcatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetHashcatHandlerReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := core.NewGetHashcatLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetHashcat()
|
||||
resp, err := l.GetHashcat(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ func ScheduleTaskByYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ScheduleTaskByYamlReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.HttpResult(r, w, nil, err)
|
||||
return
|
||||
}
|
||||
// 解析yaml文件
|
||||
|
|
|
@ -25,10 +25,10 @@ func NewGetHashcatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetHas
|
|||
}
|
||||
}
|
||||
|
||||
func (l *GetHashcatLogic) GetHashcat() (resp *types.GetHashcatHandlerResp, err error) {
|
||||
|
||||
func (l *GetHashcatLogic) GetHashcat(req *types.GetHashcatHandlerReq) (resp *types.GetHashcatHandlerResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var hashcatList []*model.THashcat
|
||||
tx := l.svcCtx.DbEngin.Find(&hashcatList)
|
||||
tx := l.svcCtx.DbEngin.Where("crack_task_id = ?", req.CrackTaskId).Find(&hashcatList)
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
|
|
|
@ -32,17 +32,15 @@ func (l *ScheduleTaskByYamlLogic) ScheduleTaskByYaml(req *types.ScheduleTaskByYa
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// construct task info
|
||||
// 构建任务结构体
|
||||
taskModel := model.Task{
|
||||
Status: "Saved",
|
||||
Description: req.Description,
|
||||
Name: req.Name,
|
||||
YamlString: string(bytes),
|
||||
StartTime: time.Now(),
|
||||
CreatedTime: time.Now(),
|
||||
UpdatedTime: time.Now(),
|
||||
}
|
||||
// save the task in mysql and return id
|
||||
// 保存任务数据到数据库
|
||||
tx := l.svcCtx.DbEngin.Create(&taskModel)
|
||||
if tx.Error != nil {
|
||||
return tx.Error
|
||||
|
@ -51,6 +49,7 @@ func (l *ScheduleTaskByYamlLogic) ScheduleTaskByYaml(req *types.ScheduleTaskByYa
|
|||
// push message into topic
|
||||
for _, task := range req.Tasks {
|
||||
task.TaskId = taskModel.Id
|
||||
// 将任务数据转换成消息体
|
||||
reqMessage, err := json.Marshal(task)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
|
|
|
@ -44,8 +44,6 @@ func (l *ScheduleTaskLogic) ScheduleTask(req *types.ScheduleTaskReq) (err error)
|
|||
Name: req.Name,
|
||||
YamlString: string(bytes),
|
||||
StartTime: time.Now(),
|
||||
CreatedTime: time.Now(),
|
||||
UpdatedTime: time.Now(),
|
||||
}
|
||||
// save the task in mysql and return id
|
||||
tx := l.svcCtx.DbEngin.Create(&taskModel)
|
||||
|
|
|
@ -437,7 +437,7 @@ type SaveHashcatReq struct {
|
|||
}
|
||||
|
||||
type GetHashcatHandlerReq struct {
|
||||
CrackTaskId int64 `json:"crackTaskId"` // 任务id
|
||||
CrackTaskId string `path:"crackTaskId"` // 任务id
|
||||
}
|
||||
|
||||
type GetHashcatHandlerResp struct {
|
||||
|
|
|
@ -44,12 +44,7 @@ type (
|
|||
EndTime string `db:"end_time"` // 结束运行时间
|
||||
RunningTime int64 `db:"running_time"` // 已运行时间(单位秒)
|
||||
YamlString string `db:"yaml_string"`
|
||||
Result string `db:"result"` // 作业结果
|
||||
CreatedBy int64 `db:"created_by"` // 创建人
|
||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy int64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime time.Time `db:"updated_time"` // 更新时间
|
||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除(0-否,1-是)
|
||||
Result string `db:"result"` // 作业结果
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue