作者 tangxvhui

日常保存

... ... @@ -485,6 +485,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
AnomalyState: domain.AnomalyStateInit,
TaskStages: []domain.TaskStage{},
TaskStageCheck: domain.TaskStage{},
TaskCreatedBy: taskList[0].CreatedBy,
}
sort.Slice(taskStageList, func(i, j int) bool {
return taskStageList[i].SortBy < taskStageList[j].SortBy
... ...
... ... @@ -11,6 +11,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
//TODO 检查任务里程碑反馈, 记录异常情况
// 检查昨日提交的任务里程碑反馈
func CheckYesterdayTaskRecord() {
nowTime := time.Now()
... ... @@ -90,10 +92,8 @@ func getYesterdayTaskRecord(nowDay string) ([]*domain.TaskRecord, error) {
_ = transactionContext.RollbackTransaction()
}()
// nowDay := time.Now().Format("2006-01-02")
nowDayTime, _ := time.ParseInLocation("2006-01-02", nowDay, time.Local)
yesterday := nowDayTime.Add(-23 * time.Hour).Format("2006-01-02")
taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ...
package service
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
func checkTaskRecordV2(param *domain.TaskRecord) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return err
}
if err := transactionContext.StartTransaction(); err != nil {
return err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, taskDataList, err := taskRepo.Find(map[string]interface{}{"id": param.TaskId})
if err != nil {
return fmt.Errorf("获取任务数据失败:%s", err)
}
if len(taskDataList) == 0 {
return nil
}
taskData := taskDataList[0]
anomalyDataTmp := domain.TaskAnomaly{
Id: taskData.Id,
CreatedAt: taskData.CreatedAt,
UpdatedAt: taskData.UpdatedAt,
CompanyId: taskData.CompanyId,
TaskId: taskData.Id,
Category: 0,
CurrentStage: taskData.CurrentStage,
LastStage: taskData.LastStage,
AssessFlag: 0,
WarnFlag: 0,
AssistFlag: 0,
IsLast: 1,
TaskLevel: taskData.LevelName,
TaskName: taskData.Name,
TaskAlias: taskData.Alias,
TaskSortBy: taskData.SortBy,
TaskEndTime: taskData.EndTime,
RecordBegin: 0,
NoticeWho: []int64{},
Marks: map[string]string{
"a": "", "b": "", "c": "", "d": "",
},
}
var anomalyList []domain.TaskAnomaly
// 检查反馈异常
if param.IsRemarkAnomaly() {
taskData.Anomaly += 1
anomalyDataTmp.Category = 2
anomalyList = append(anomalyList, anomalyDataTmp)
} else {
taskData.Anomaly = 0
}
// 检查里程碑异常
if param.IsTaskStageAnomaly() {
taskData.WarnFlag = domain.TaskWarn
} else {
taskData.WarnFlag = domain.TaskWarnNull
}
// 检查辅导异常
if param.IsAssistAnomaly() {
taskData.AssistFlag += 1
} else {
taskData.AssistFlag = 0
}
err = taskRepo.Save(taskData)
if err != nil {
return fmt.Errorf("保存任务数据:%s", err)
}
if err := transactionContext.CommitTransaction(); err != nil {
return err
}
return nil
}
... ...
... ... @@ -29,41 +29,20 @@ func dayEndTime(t time.Time) time.Time {
return t2
}
// func dayZeroTime(t time.Time) time.Time {
// y, m, d := t.Local().Date()
// t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
// return t2
// }
// func (srv TaskService) CreateTaskTest(param *command.CreateTaskCommand) error {
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// defer func() {
// _ = transactionContext.RollbackTransaction()
// }()
// err = srv.CreateTask(transactionContext, param)
// if err != nil {
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// return nil
// }
func dayZeroTime(t time.Time) time.Time {
y, m, d := t.Local().Date()
t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
return t2
}
// CreateTask 重评估模板中创建
func (srv TaskService) CreateTaskByProject(transactionContext application.TransactionContext, param *command.CreateTaskByProjectCommand) error {
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
cnt, _, err := taskRepo.Find(map[string]interface{}{
"name": param.Name,
"leaderId": strconv.Itoa(param.LeaderId),
... ... @@ -123,36 +102,11 @@ func (srv TaskService) CreateTaskByProject(transactionContext application.Transa
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
}
newTaskStage := []*domain.TaskStage{
// {
// Id: 0,
// TaskId: newTask.Id,
// Name: "里程碑1",
// SortBy: 1,
// PlanCompletedAt: nowEndTime.Add(30 * 24 * time.Hour).Unix(),
// RealCompletedAt: 0,
// },
// {
// Id: 0,
// TaskId: newTask.Id,
// Name: "里程碑2",
// SortBy: 2,
// PlanCompletedAt: nowEndTime.Add(60 * 24 * time.Hour).Unix(),
// RealCompletedAt: 0,
// },
// {
// Id: 0,
// TaskId: newTask.Id,
// Name: "里程碑3",
// SortBy: 3,
// PlanCompletedAt: nowEndTime.Add(90 * 24 * time.Hour).Unix(),
// RealCompletedAt: 0,
// },
}
err = taskStageRepo.Save(newTaskStage)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
}
newTaskStage := []*domain.TaskStage{}
// err = taskStageRepo.Save(newTaskStage)
// if err != nil {
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
// }
//记录待执行的里程碑
newTask.SetCurrentStage(newTaskStage)
err = taskRepo.Save(&newTask)
... ...
package service
// 异常中心查看
... ...
package domain
import "time"
// 任务的异常记录
type TaskAnomaly struct {
Id int
TaskId int
Types int
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CompanyId int `json:"companyId,string"`
TaskId int `jsom:"taskId,string"` // 任务id
Category int `json:"category"` // 异常记录的分类 1 里程碑异常;2反馈异常 ;3 辅导异常
CurrentStage TaskStage `json:"currentStage"` // 当前执行的里程碑
LastStage TaskStage `json:"lastStage"` // 上一个完成的里程碑
AssessFlag int `json:"anomaly"` // 异常反馈的次数
WarnFlag int `json:"warnFlag"` // 里程碑异常次数
AssistFlag int `json:"assistFlag"` // 辅导异常次数
IsLast int `json:"isLast"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录
TaskLevel string `json:"taskLevel"` // 任务类型
TaskName string `json:"taskName"` // 任务名称
TaskAlias string `json:"taskAlias"` // 任务别名
TaskSortBy TaskSortBy `json:"taskSortBy"` // 优先级排序;值越小优先级越高
TaskEndTime int64 `json:"taskEndTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
RecordBegin int `json:"recordBegin"` // 异常记录的开始时间
NoticeWho []int64 `json:"noticeWho"` // 异常记录消息通知的人
Marks map[string]string `json:"marks"` // 已经操作的标记
}
// 已点击“去更新”
func (t *TaskAnomaly) MarkA() {
t.Marks["a"] = "已更新"
}
// 已点击 "去反馈"
func (t *TaskAnomaly) MarkB() {
t.Marks["b"] = "已反馈"
}
// 已点击 "找上级"
func (t *TaskAnomaly) MarkC() {
t.Marks["c"] = "已求助"
}
// 已点击 "去辅导"
func (t *TaskAnomaly) MarkD() {
t.Marks["d"] = "已辅导"
}
// 存储
type TaskAnomalyRepository interface {
Save(param *TaskAnomaly) error
FindOne(queryOptions map[string]interface{}) (*TaskAnomaly, error)
Find(queryOptions map[string]interface{}) (int, []*TaskAnomaly, error)
}
... ...
package domain
import (
"strings"
"time"
)
... ... @@ -46,14 +47,42 @@ type TaskRecordRepository interface {
Find(queryOptions map[string]interface{}) (int, []*TaskRecord, error)
}
// 是否取消任务的里程碑反馈异常记录
// func (record *TaskRecord) CanTaskAnomaly() bool {
// trimSpace := strings.TrimLeft(record.AssistContent, "\n") // 去掉前换行符
// trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
// trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
// // 上级填写内容有值,选项是已辅导,变为正常
// if !(len(trimSpace) == 0 || trimSpace == "无") && record.AssistLevel != AssistLevel1 {
// return true
// }
// return false
// }
// 是否是辅导异常
func (r *TaskRecord) IsAssistAnomaly() bool {
r.AssistContent = strings.TrimSpace(r.AssistContent)
if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" {
return true
}
return false
}
// 是否是里程碑异常
func (r *TaskRecord) IsTaskStageAnomaly() bool {
if r.TaskStageCheck.Id == 0 {
return false
}
realCompletedAt := r.TaskStageCheck.RealCompletedAt
if realCompletedAt == 0 {
//假设现在完成
realCompletedAt = time.Now().Unix()
}
if r.TaskStageCheck.PlanCompletedAt < realCompletedAt {
//逾期完成,或者预期未完成
return true
}
return false
}
// 是否是反馈异常
func (r *TaskRecord) IsRemarkAnomaly() bool {
all := ""
for _, val := range r.RemarkContent {
txt := strings.TrimSpace(val.RemarkText)
all += txt
}
if len(all) == 0 || all == "无" {
return true
}
return false
}
... ...
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 任务的异常记录
type TaskAnomaly struct {
tableName struct{} `comment:"任务的异常记录" pg:"task_anomaly"`
Id int `pg:"id"`
CreatedAt time.Time `pg:"created_at"`
UpdatedAt time.Time `pg:"updated_at"`
CompanyId int `pg:"company_id"`
TaskId int `pg:"task_id"` // 任务id
Category int `pg:"category"` // 异常任务的分类
CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
AssessFlag int `pg:"assess_flag,use_zero"` // 异常反馈的次数
WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常次数
AssistFlag int `pg:"assist_flag,use_zero"` // 辅导异常次数
IsLast int `pg:"is_last"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录
TaskLevel string `pg:"task_level"` // 任务类型
TaskName string `pg:"task_name"` // 任务名称
TaskAlias string `pg:"task_alias"` // 任务别名
TaskSortBy int `pg:"task_sort_by"` // 优先级排序;值越小优先级越高
TaskEndTime int64 `pg:"task_end_time,use_zero"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
RecordBegin int `pg:"record_begin"` // 异常记录的开始时间
NoticeWho []int64 `pg:"notice_who"` // 异常记录消息通知的人
Marks map[string]string `pg:"marks"` // 已经操作的标记
}
... ...
package repository
import (
"errors"
"fmt"
"strconv"
"time"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
)
//任务
type TaskRepository struct {
transactionContext *pgTransaction.TransactionContext
}
var _ domain.TaskRepository = (*TaskRepository)(nil)
func NewTaskRepository(transactionContext *pgTransaction.TransactionContext) *TaskRepository {
return &TaskRepository{transactionContext: transactionContext}
}
func (repo *TaskRepository) TransformToDomain(d *models.Task) *domain.Task {
return &domain.Task{
Id: d.Id,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
CompanyId: d.CompanyId,
Name: d.Name,
Alias: d.Alias,
Leader: d.Leader,
Status: domain.TaskState(d.Status),
Level: d.Level,
LevelName: d.LevelName,
SortBy: domain.TaskSortBy(d.SortBy),
EndTime: d.EndTime,
UseEndTime: d.UseEndTime,
RelatedUser: d.RelatedUser,
RunAt: d.RunAt,
StopAt: d.StopAt,
Anomaly: d.Anomaly,
WarnFlag: domain.TaskWarnFlag(d.WarnFlag),
AssistFlag: d.AssistFlag,
AssistFlagMax: d.AssistFlagMax,
CurrentStage: d.CurrentStage,
LastStage: d.LastStage,
CreatedBy: d.CreatedBy,
}
}
func (repo *TaskRepository) Save(param *domain.Task) error {
param.UpdatedAt = time.Now()
if param.Id == 0 {
param.CreatedAt = time.Now()
}
m := models.Task{
Id: param.Id,
CreatedAt: param.CreatedAt,
UpdatedAt: param.UpdatedAt,
DeletedAt: param.DeletedAt,
Name: param.Name,
Alias: param.Alias,
CompanyId: param.CompanyId,
Leader: param.Leader,
Status: int(param.Status),
Level: param.Level,
LevelName: param.LevelName,
RelatedUser: param.RelatedUser,
LastStage: param.LastStage,
RunAt: param.RunAt,
StopAt: param.StopAt,
Anomaly: param.Anomaly,
WarnFlag: int(param.WarnFlag),
CurrentStage: param.CurrentStage,
SortBy: int(param.SortBy),
EndTime: param.EndTime,
UseEndTime: param.UseEndTime,
AssistFlag: param.AssistFlag,
AssistFlagMax: param.AssistFlagMax,
CreatedBy: param.CreatedBy,
}
db := repo.transactionContext.PgTx
if m.Id == 0 {
_, err := db.Model(&m).Insert()
if err != nil {
return err
}
} else {
_, err := db.Model(&m).WherePK().Update()
if err != nil {
return err
}
}
param.Id = m.Id
return nil
}
func (repo *TaskRepository) Remove(id int) error {
tx := repo.transactionContext.PgTx
nowTime := time.Now()
_, err := tx.Model(&models.Task{}).
Where("id=?", id).
Set("deleted_at=?", nowTime).
Update()
return err
}
func (repo *TaskRepository) FindOne(queryOptions map[string]interface{}) (*domain.Task, error) {
tx := repo.transactionContext.PgTx
m := new(models.Task)
query := tx.Model(m)
query.Where("deleted_at isnull")
if id, ok := queryOptions["id"]; ok {
query.Where("id=?", id)
}
if err := query.First(); err != nil {
if errors.Is(err, pg.ErrNoRows) {
return nil, fmt.Errorf("没有找到task数据")
} else {
return nil, err
}
}
u := repo.TransformToDomain(m)
return u, nil
}
func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Task, error) {
tx := repo.transactionContext.PgTx
var m []*models.Task
query := tx.Model(&m).
Where("deleted_at isnull").
Limit(20)
if val, ok := queryOptions["name"]; ok {
query.Where("task.name like ?", val)
}
if val, ok := queryOptions["companyId"]; ok {
query.Where("task.company_id = ?", val)
}
if val, ok := queryOptions["id"]; ok {
query.Where("task.id=?", val)
}
if val, ok := queryOptions["leaderId"]; ok {
query.Where("task.leader->>'id'=?", val)
}
if val, ok := queryOptions["aliasOrLeader"]; ok {
query.Where(`task.alias like ? or task.leader->>'name' like ?`, val, val)
}
if val, ok := queryOptions["status"]; ok {
query.Where("task.status=?", val)
}
if val, ok := queryOptions["createdBy"]; ok {
query.Where("created_by = ?", val)
}
if val, ok := queryOptions["limit"]; ok {
if limit, err := strconv.Atoi(fmt.Sprintf("%v", val)); err == nil {
query.Limit(limit)
}
}
if val, ok := queryOptions["offset"]; ok {
if offset, err := strconv.Atoi(fmt.Sprintf("%v", val)); err == nil {
query.Offset(offset)
}
}
query.Order("id desc")
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
}
var datas []*domain.Task
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
}
return count, datas, nil
}
... ...
... ... @@ -14,75 +14,67 @@ import (
//任务
type TaskRepository struct {
type TaskAnomalyRepository struct {
transactionContext *pgTransaction.TransactionContext
}
var _ domain.TaskRepository = (*TaskRepository)(nil)
var _ domain.TaskAnomalyRepository = (*TaskAnomalyRepository)(nil)
func NewTaskRepository(transactionContext *pgTransaction.TransactionContext) *TaskRepository {
return &TaskRepository{transactionContext: transactionContext}
func NewTaskAnomalyRepository(transactionContext *pgTransaction.TransactionContext) *TaskAnomalyRepository {
return &TaskAnomalyRepository{transactionContext: transactionContext}
}
func (repo *TaskRepository) TransformToDomain(d *models.Task) *domain.Task {
return &domain.Task{
func (repo *TaskAnomalyRepository) TransformToDomain(d *models.TaskAnomaly) *domain.TaskAnomaly {
return &domain.TaskAnomaly{
Id: d.Id,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
CompanyId: d.CompanyId,
Name: d.Name,
Alias: d.Alias,
Leader: d.Leader,
Status: domain.TaskState(d.Status),
Level: d.Level,
LevelName: d.LevelName,
SortBy: domain.TaskSortBy(d.SortBy),
EndTime: d.EndTime,
UseEndTime: d.UseEndTime,
RelatedUser: d.RelatedUser,
RunAt: d.RunAt,
StopAt: d.StopAt,
Anomaly: d.Anomaly,
WarnFlag: domain.TaskWarnFlag(d.WarnFlag),
AssistFlag: d.AssistFlag,
AssistFlagMax: d.AssistFlagMax,
TaskId: d.TaskId,
Category: d.Category,
CurrentStage: d.CurrentStage,
LastStage: d.LastStage,
CreatedBy: d.CreatedBy,
AssessFlag: d.AssessFlag,
WarnFlag: d.WarnFlag,
AssistFlag: d.AssistFlag,
IsLast: d.IsLast,
TaskLevel: d.TaskLevel,
TaskName: d.TaskName,
TaskAlias: d.TaskAlias,
TaskSortBy: domain.TaskSortBy(d.TaskSortBy),
TaskEndTime: d.TaskEndTime,
RecordBegin: d.RecordBegin,
NoticeWho: d.NoticeWho,
Marks: d.Marks,
}
}
func (repo *TaskRepository) Save(param *domain.Task) error {
func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error {
param.UpdatedAt = time.Now()
if param.Id == 0 {
param.CreatedAt = time.Now()
}
m := models.Task{
m := models.TaskAnomaly{
Id: param.Id,
CreatedAt: param.CreatedAt,
UpdatedAt: param.UpdatedAt,
DeletedAt: param.DeletedAt,
Name: param.Name,
Alias: param.Alias,
CompanyId: param.CompanyId,
Leader: param.Leader,
Status: int(param.Status),
Level: param.Level,
LevelName: param.LevelName,
RelatedUser: param.RelatedUser,
LastStage: param.LastStage,
RunAt: param.RunAt,
StopAt: param.StopAt,
Anomaly: param.Anomaly,
WarnFlag: int(param.WarnFlag),
TaskId: param.TaskId,
Category: param.Category,
CurrentStage: param.CurrentStage,
SortBy: int(param.SortBy),
EndTime: param.EndTime,
UseEndTime: param.UseEndTime,
LastStage: param.LastStage,
AssessFlag: param.AssessFlag,
WarnFlag: param.WarnFlag,
AssistFlag: param.AssistFlag,
AssistFlagMax: param.AssistFlagMax,
CreatedBy: param.CreatedBy,
IsLast: param.IsLast,
TaskLevel: param.TaskLevel,
TaskName: param.TaskName,
TaskAlias: param.TaskAlias,
TaskSortBy: int(param.TaskSortBy),
TaskEndTime: param.TaskEndTime,
RecordBegin: param.RecordBegin,
NoticeWho: param.NoticeWho,
Marks: param.Marks,
}
db := repo.transactionContext.PgTx
if m.Id == 0 {
... ... @@ -100,28 +92,16 @@ func (repo *TaskRepository) Save(param *domain.Task) error {
return nil
}
func (repo *TaskRepository) Remove(id int) error {
tx := repo.transactionContext.PgTx
nowTime := time.Now()
_, err := tx.Model(&models.Task{}).
Where("id=?", id).
Set("deleted_at=?", nowTime).
Update()
return err
}
func (repo *TaskRepository) FindOne(queryOptions map[string]interface{}) (*domain.Task, error) {
func (repo *TaskAnomalyRepository) FindOne(queryOptions map[string]interface{}) (*domain.TaskAnomaly, error) {
tx := repo.transactionContext.PgTx
m := new(models.Task)
m := new(models.TaskAnomaly)
query := tx.Model(m)
query.Where("deleted_at isnull")
if id, ok := queryOptions["id"]; ok {
query.Where("id=?", id)
}
if err := query.First(); err != nil {
if errors.Is(err, pg.ErrNoRows) {
return nil, fmt.Errorf("没有找到task数据")
return nil, fmt.Errorf("没有找到TaskAnomaly数据")
} else {
return nil, err
}
... ... @@ -130,33 +110,10 @@ func (repo *TaskRepository) FindOne(queryOptions map[string]interface{}) (*domai
return u, nil
}
func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Task, error) {
func (repo *TaskAnomalyRepository) Find(queryOptions map[string]interface{}) (int, []*domain.TaskAnomaly, error) {
tx := repo.transactionContext.PgTx
var m []*models.Task
query := tx.Model(&m).
Where("deleted_at isnull").
Limit(20)
if val, ok := queryOptions["name"]; ok {
query.Where("task.name like ?", val)
}
if val, ok := queryOptions["companyId"]; ok {
query.Where("task.company_id = ?", val)
}
if val, ok := queryOptions["id"]; ok {
query.Where("task.id=?", val)
}
if val, ok := queryOptions["leaderId"]; ok {
query.Where("task.leader->>'id'=?", val)
}
if val, ok := queryOptions["aliasOrLeader"]; ok {
query.Where(`task.alias like ? or task.leader->>'name' like ?`, val, val)
}
if val, ok := queryOptions["status"]; ok {
query.Where("task.status=?", val)
}
if val, ok := queryOptions["createdBy"]; ok {
query.Where("created_by = ?", val)
}
var m []*models.TaskAnomaly
query := tx.Model(&m)
if val, ok := queryOptions["limit"]; ok {
if limit, err := strconv.Atoi(fmt.Sprintf("%v", val)); err == nil {
query.Limit(limit)
... ... @@ -172,7 +129,7 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d
if err != nil {
return 0, nil, err
}
var datas []*domain.Task
var datas []*domain.TaskAnomaly
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
... ...