作者 tangxvhui

Merge branch 'dev-tangxvhui' into test

... ... @@ -459,6 +459,12 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
if len(taskList) == 0 {
continue
}
if taskList[0].UseEndTime == 1 {
if staffAssess.BeginTime.Unix() > taskList[0].EndTime {
continue
}
}
//获取里程碑数据
_, taskStageList, err := taskStageRepo.Find(map[string]interface{}{
"taskId": taskList[0].Id,
... ... @@ -493,8 +499,10 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
}
}
}
if newTaskRecord.TaskStageCheck.Id > 0 {
taskRecordList = append(taskRecordList, &newTaskRecord)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -8,8 +8,11 @@ type TaskInfoAdapter struct {
Leader UserData `json:"leader"` // 任务负责人
Status int `json:"status"` // 任务的状态
StatusDescription string `json:"statusDescription"` //
Level int `json:"level"` // 优先级,值越小优先级越高
LevelName string `json:"levelName"` // 优先级名称
// Level int `json:"level"` // 优先级,值越小优先级越高
LevelName string `json:"levelName"` // 任务类别名称
SortBy int `json:"sortBy"` // 优先级排序;值越小优先级越高
EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
UseEndtime int `json:"useEndTime"` // 是否应用任务截止的时间;默认值0:不应用,1:应用
RelatedUserId []string `json:"relatedUserId"` // 相关的员工id
RelatedUser []UserData `json:"relatedUser"` // 相关的员工id
StageList []TaskStage `json:"stageList"`
... ...
package command
type CancelIgnoreCommand struct {
TaskId int `json:"taskId,string"`
UserId int `json:"-"`
CompanyId int `json:"-"`
}
... ...
... ... @@ -8,6 +8,6 @@ type SearchTaskCommand struct {
OnlyMy bool `json:"onlyMy"` //只查看我负责的任务
SearchWord string `json:"searchWord"`
// TaskName string `json:"taskName"` //任务名称
// LevelName string `json:"levelName"` //优先级
LevelName string `json:"levelName"` //任务类型
// LeaderName string `json:"leaderId"` //任务负责人id
}
... ...
... ... @@ -73,7 +73,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error())
}
if cnt > 0 {
//TODO
//任务已存在
return nil
}
... ... @@ -172,11 +172,11 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if len(param.StageList) < 3 {
return map[string]interface{}{
"id": param.Id,
}, application.ThrowError(application.INTERNAL_SERVER_ERROR, "里程碑数量至少3个")
}
// if len(param.StageList) < 3 {
// return map[string]interface{}{
// "id": param.Id,
// }, application.ThrowError(application.INTERNAL_SERVER_ERROR, "里程碑数量至少3个")
// }
if len(param.StageList) > 5 {
return map[string]interface{}{
"id": param.Id,
... ... @@ -213,30 +213,14 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
if len(relatedUserIds) > 0 {
_, relatedUser, err = userRepo.Find(map[string]interface{}{
"ids": relatedUserIds,
"companyId": param.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error())
}
}
_, leaderList, err := userRepo.Find(map[string]interface{}{
"id": taskData.Leader.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询人员失败:"+err.Error())
}
if len(leaderList) == 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有查询到人员")
}
leaderData := leaderList[0]
//更新相关人员
taskData.RelatedUser = []int{int(leaderData.Id)}
if leaderData.ParentId != 0 {
taskData.RelatedUser = append(taskData.RelatedUser, int(leaderData.ParentId))
}
taskData.RelatedUser = []int{}
for _, val := range relatedUser {
if val.Id == leaderData.Id || val.Id == leaderData.ParentId {
continue
}
taskData.RelatedUser = append(taskData.RelatedUser, int(val.Id))
}
//更新任务名称
... ... @@ -314,7 +298,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
}
taskData.SetCurrentStage(stageList)
taskData.SetSortBy(param.SortBy)
taskData.EndTime = param.EndTime
//处理endTime
taskData.EndTime = dayEndTime(time.Unix(param.EndTime, 10)).Unix()
taskData.UseEndTime = param.UseEndtime
err = taskRepo.Save(taskData)
if err != nil {
... ... @@ -323,7 +308,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//更具markStage 记录的里程碑数据生成通知
//根据markStage 记录的里程碑数据生成通知
for _, val := range markStage {
for _, val2 := range taskData.RelatedUser {
t1 := time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02")
... ... @@ -486,8 +471,11 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
},
Status: int(taskData.Status),
StatusDescription: taskData.StatusDescription(),
Level: taskData.Level,
// Level: taskData.Level,
LevelName: taskData.LevelName,
SortBy: int(taskData.SortBy),
EndTime: taskData.EndTime,
UseEndtime: taskData.UseEndTime,
RelatedUserId: []string{},
RelatedUser: []adapter.UserData{},
StageList: []adapter.TaskStage{},
... ... @@ -910,6 +898,22 @@ func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.T
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error())
}
taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, taskIgnoreList, err := taskIgnoreRepo.Find(map[string]interface{}{
"taskId": param.TaskId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error())
}
for _, v := range taskIgnoreList {
err = taskIgnoreRepo.Remove(v.Id)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -1026,6 +1030,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
CompanyId: param.CompanyId,
OnlyMy: param.OnlyMy,
SearchWord: param.SearchWord,
LevelName: param.LevelName,
}
taskDao := dao.NewTaskDao(map[string]interface{}{
... ... @@ -1041,7 +1046,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
}
//里程碑异常s
//里程碑异常
taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计异常的任务里程碑总数"+err.Error())
... ... @@ -1172,6 +1177,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
CompanyId: param.CompanyId,
OnlyMy: param.OnlyMy,
SearchWord: param.SearchWord,
LevelName: param.LevelName,
}
taskDao := dao.NewTaskDao(map[string]interface{}{
... ... @@ -1321,3 +1327,174 @@ func (srv TaskService) ListTaskLevel(companyId int) (map[string]interface{}, err
}
return result, nil
}
// 取消关注的任务列表
func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result map[string]interface{}, err error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
var limit = 20
var offset = 0
if param.PageSize > 0 {
limit = param.PageSize
if param.PageNumber > 0 {
offset = (param.PageNumber - 1) * param.PageSize
}
}
param.SearchWord = strings.TrimSpace(param.SearchWord)
if len(param.SearchWord) > 0 {
param.SearchWord = "%" + param.SearchWord + "%"
}
condition := dao.ListTaskCondition{
Limit: limit,
Offset: offset,
UserId: param.UserId,
CompanyId: param.CompanyId,
OnlyMy: param.OnlyMy,
SearchWord: param.SearchWord,
LevelName: param.LevelName,
}
taskDao := dao.NewTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
})
//任务列表数据
taskListData, err := taskDao.ListTaskIgnore(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
}
//查到的任务数据总数
taskCount, err := taskDao.CountTaskIgnore(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
}
taskResult := []*adapter.TaskItem{}
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
nowTime := time.Now().Unix()
for _, val := range taskListData {
tk := adapter.TaskItem{
Id: val.TaskId,
Name: "",
Alias: val.Alias,
Leader: val.LeaderName,
Status: val.Status,
Level: val.Level,
LevelName: val.LevelName,
UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
Anomaly: val.Anomaly,
WarnFlag: 0,
LastStage: adapter.TaskStage{
Id: val.LastStage.Id,
Name: val.LastStage.Name,
StatusDescription: val.LastStage.StatusDescription(),
SortBy: val.LastStage.SortBy,
PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
IsRef: false,
},
CurrentStage: adapter.TaskStage{
Id: val.CurrentStage.Id,
Name: val.CurrentStage.Name,
StatusDescription: val.CurrentStage.StatusDescription(),
SortBy: val.CurrentStage.SortBy,
PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
IsRef: false,
},
}
if val.LastStage.RealCompletedAt > 0 {
tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
}
if val.CurrentStage.RealCompletedAt > 0 {
tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02")
}
if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt {
tk.WarnFlag = int(domain.TaskWarn)
}
if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime {
tk.WarnFlag = int(domain.TaskWarn)
}
_, stageList, err := taskStageRepo.Find(map[string]interface{}{
"taskId": val.TaskId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
}
for _, val2 := range stageList {
stage := adapter.TaskStage{
Id: val2.Id,
Name: val2.Name,
SortBy: val2.SortBy,
PlanCompletedAt: time.Unix(int64(val2.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
}
if val2.RealCompletedAt > 0 {
stage.RealCompletedAt = time.Unix(int64(val2.RealCompletedAt), 0).Local().Format("2006-01-02")
}
switch val2.SortBy {
case 1:
tk.StageA = stage
case 2:
tk.StageB = stage
case 3:
tk.StageC = stage
case 4:
tk.StageD = stage
case 5:
tk.StageE = stage
}
}
taskResult = append(taskResult, &tk)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result = tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
return
}
// 从取消关注的列表中移除数据
func (srv *TaskService) CancleTaskIgnore(param *command.CancelIgnoreCommand) (result map[string]interface{}, err error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, taskIgnoreList, err := taskIgnoreRepo.Find(map[string]interface{}{
"userId": param.UserId,
"taskId": param.TaskId,
})
if len(taskIgnoreList) == 0 {
return
}
err = taskIgnoreRepo.Remove(taskIgnoreList[0].Id)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
... ...
... ... @@ -68,6 +68,7 @@ type ListTaskCondition struct {
CompanyId int //公司id
UserId int //谁要查看任务数据
OnlyMy bool //只查看我负责的任务
LevelName string //任务类型名称
SearchWord string
}
... ... @@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
... ... @@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
... ... @@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
... ... @@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
... ... @@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error)
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
... ... @@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) {
}
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?) `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
... ... @@ -453,6 +477,8 @@ type ListTask struct {
CreatedAt time.Time `pg:"created_at"`
CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
SortBy int `pg:"sort_by"`
EndTime int `pg:"end_time"`
}
// (新)获取任务,用于页面展示; 无过滤查看权限
... ... @@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
task.updated_at,
task.current_stage,
task.last_stage,
task.sort_by,
task.end_time,
task.created_at
from task
left join t_task_ignore on t_task_ignore.task_id=task.id
... ... @@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
t_task.updated_at ,
t_task.current_stage,
t_task.last_stage,
t_task.sort_by,
t_task.end_time,
t_task.created_at
from t_task
where 1=1
)select *
from t_task_1
order by t_task_1.sort_by_1,
order by t_task_1.status, t_task_1.sort_by_1,
t_task_1.sort_by_2,t_task_1.anomaly desc,
t_task_1."level",t_task_1."created_at"
t_task_1.sort_by,t_task_1."created_at"
limit ? offset ?
`
condition := []interface{}{param.UserId, param.CompanyId}
... ... @@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
strSql2 := fmt.Sprintf(sqlStr, whereSql)
condition = append(condition, param.Limit, param.Offset)
result := []ListTask{}
... ... @@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
task.last_stage,
task.status ,
task.updated_at,
task.sort_by,
task.end_time,
task.created_at
from task
join t_task_1 on t_task_1.id=task.id
... ... @@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
t_task.last_stage,
t_task.status ,
t_task.updated_at ,
t_task.sort_by,
t_task.end_time,
t_task.created_at
from t_task
where 1=1
)select *
from tt_task_1
order by tt_task_1.sort_by_1,
order by tt_task_1.status,tt_task_1.sort_by_1,
tt_task_1.sort_by_2,tt_task_1.anomaly desc,
tt_task_1."level",tt_task_1."created_at"
tt_task_1.sort_by,tt_task_1."created_at"
limit ? offset ?
`
condition := []interface{}{param.CompanyId}
... ... @@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
strSql2 := fmt.Sprintf(strSql, whereSql)
condition = append(condition, param.Limit, param.Offset)
result := []ListTask{}
... ... @@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
_, err := tx.Query(&result, strSql2, condition...)
return result, err
}
// 获取已取消关注的任务列表
func (d *TaskDao) ListTaskIgnore(param ListTaskCondition) ([]ListTask, error) {
sqlStr := `with
t_task_ignore as(
select task_ignore.task_id
from task_ignore
where user_id =3252522494124032
)select
task.id as task_id ,
task.alias ,
task.leader ->>'name' as leader_name,
task."level" ,
task.level_name ,
task.anomaly ,
task.status ,
task.updated_at ,
task.created_at ,
task.current_stage ,
task.last_stage ,
task.sort_by ,
task.end_time
from task
join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 and task.company_id=? and task.deleted_at isnull `
condition := []interface{}{param.CompanyId}
whereSql := ``
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
}
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
condition = append(condition, param.Limit, param.Offset)
sqlStr = sqlStr + whereSql + ` limit ? offset ? `
result := []ListTask{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) {
sqlStr := `with
t_task_ignore as(
select task_ignore.task_id
from task_ignore
where user_id =3252522494124032
)select
count(*) as cnt
from task
join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 and task.company_id=? and task.deleted_at isnull `
condition := []interface{}{param.CompanyId}
whereSql := ``
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
}
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name = ? `
}
condition = append(condition, param.Limit, param.Offset)
sqlStr = sqlStr + whereSql + ` limit ? offset ? `
result := 0
tx := d.transactionContext.PgTx
_, err := tx.Query(pg.Scan(&result), sqlStr, condition...)
return result, err
}
... ...
... ... @@ -27,7 +27,7 @@ type Task struct {
Anomaly int `pg:"anomaly,use_zero"` // 异常反馈的数量
WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常标记
CurrentStage domain.TaskStage `pg:"current_stage,type:jsonb"` // 添加type:jsonb 防止orm(可能是特性)生成sql时字段丢失
SortBy int `pg:"sort_by"` // 优先级排序;值越小优先级越高
EndTime int64 `pg:"end_time"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
UseEndTime int `pg:"use_end_time"` // 是否应用任务截止的时间;默认值0:不应用,1:应用
SortBy int `pg:"sort_by,use_zero"` // 优先级排序;值越小优先级越高
EndTime int64 `pg:"end_time,use_zero"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
UseEndTime int `pg:"use_end_time,use_zero"` // 是否应用任务截止的时间;默认值0:不应用,1:应用
}
... ...
... ... @@ -88,6 +88,12 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int
tx := repo.transactionContext.PgTx
var m []*models.TaskIgnore
query := tx.Model(&m)
if v, ok := queryOptions["userId"]; ok {
query.Where(" user_id=? ", v)
}
if v, ok := queryOptions["taskId"]; ok {
query.Where(" task_id=? ", v)
}
query.Order("id desc")
count, err := query.SelectAndCount()
if err != nil {
... ...
... ... @@ -215,3 +215,36 @@ func (c *TaskController) SaveTaskLevel() {
err = srv.SaveTaskLevel(paramReq)
c.Response(nil, err)
}
// 取消关注的任务列表
func (c *TaskController) ListTaskIgnore() {
srv := service.NewTaskService()
paramReq := &command.SearchTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
result, err := srv.ListTaskIgnore(paramReq)
c.Response(result, err)
}
// 从取消关注的任务列表中移除
func (c *TaskController) CancelIgnore() {
srv := service.NewTaskService()
paramReq := &command.CancelIgnoreCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
_, err = srv.CancleTaskIgnore(paramReq)
c.Response(nil, err)
}
... ...
... ... @@ -29,6 +29,8 @@ func init() {
web.NSCtrlPost("/list/select", (*controllers.TaskController).SelectCondition),
web.NSCtrlPost("/task_record/list", (*controllers.TaskController).ListTaskRecord),
web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo),
web.NSCtrlPost("/ignore/list", (*controllers.TaskController).ListTaskIgnore),
web.NSCtrlPost("/ignore/cancle", (*controllers.TaskController).CancelIgnore),
)
web.AddNamespace(taskFontNS)
t := web.NewNamespace("/test/task",
... ...
-- 修改task表结构
ALTER TABLE public.task
ADD sort_by int8 NOT NULL DEFAULT 0;
ALTER TABLE public.task
ADD end_time int8 NOT NULL DEFAULT 0;
ALTER TABLE public.task
ADD use_end_time int8 NOT NULL DEFAULT 0;
... ...