作者 tangxvhui

更新

package command
type CancelAttentionCommand struct {
TaskId int `json:"taskId,string"`
UserId int `json:"-"`
CompanyId int `json:"-"`
}
... ...
... ... @@ -479,3 +479,23 @@ func (t TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.Ta
func (t TaskService) ListTask2() error {
return nil
}
// CancelAttention 用户取消关注某个任务
func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) 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()
}()
//0
//0
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil
}
... ...
... ... @@ -6,8 +6,9 @@ type TaskStageState int
const (
TaskStageUncompleted TaskStageState = 1 //里程碑未完成
TaskStageCompleted TaskStageState = 2 //里程碑完成
TaskStageCompletedOverdue TaskStageState = 3 //里程碑预期完成
TaskStageCompletedOverdue TaskStageState = 2 //里程碑逾期完成
TaskStageCompleted TaskStageState = 3 //里程碑完成
)
// 任务阶段
... ...
package repository
import (
"errors"
"fmt"
"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"
)
//任务
... ... @@ -13,18 +19,81 @@ type TaskIgnoreRepository struct {
var _ domain.TaskIgnoreRepository = (*TaskIgnoreRepository)(nil)
func (repo *TaskIgnoreRepository) TransformToDomain(d *models.TaskIgnore) *domain.TaskIgnore {
return &domain.TaskIgnore{
Id: d.Id,
TaskId: d.TaskId,
UserId: d.UserId,
CreatedAt: d.CreatedAt,
}
}
func (repo *TaskIgnoreRepository) Save(param *domain.TaskIgnore) error {
panic("not implemented") // TODO: Implement
if param.Id == 0 {
param.CreatedAt = time.Now()
return nil
}
m := models.TaskIgnore{
Id: param.Id,
TaskId: param.TaskId,
UserId: param.UserId,
CreatedAt: param.CreatedAt,
}
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 *TaskIgnoreRepository) Remove(id int) error {
panic("not implemented") // TODO: Implement
tx := repo.transactionContext.PgTx
_, err := tx.Model(&models.TaskIgnore{}).
Where("id=?", id).Delete()
return err
}
func (repo *TaskIgnoreRepository) FindOne(queryOptions map[string]interface{}) (*domain.TaskIgnore, error) {
panic("not implemented") // TODO: Implement
tx := repo.transactionContext.PgTx
m := new(models.TaskIgnore)
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_ignore 数据")
} else {
return nil, err
}
}
u := repo.TransformToDomain(m)
return u, nil
}
func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int, []*domain.TaskIgnore, error) {
panic("not implemented") // TODO: Implement
tx := repo.transactionContext.PgTx
var m []*models.TaskIgnore
query := tx.Model(&m)
query.Order("id desc")
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
}
var datas []*domain.TaskIgnore
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
}
return count, datas, nil
}
... ...