Exemple #1
0
func SoftDeleteByIdAndVersion(DB db.IDb, table *db.Table, id int64, version int64) error {
	deletion := table.GetDeletionColumn()
	if deletion == nil {
		return dbx.NewPersistenceFail("DAOUtils.SoftDeleteByIdAndVersion", "Table "+table.GetName()+" does not have a deletion type column to do a soft delete.")
	}

	keyColumn := table.GetKeyColumns().Enumerator().Next().(*db.Column)
	versionColumn := table.GetVersionColumn()

	result, err := DB.Update(table).
		Set(deletion, tk.Milliseconds()).
		Set(versionColumn, version+1).
		Where(
			keyColumn.Matches(id),
			versionColumn.Matches(version),
		).
		Execute()

	if err != nil {
		return err
	}

	if result == 0 {
		return dbx.NewOptimisticLockFail("DAOUtils.removeByIdVersion: Unable to soft delete by id and version for the table " + table.GetName())
	}

	return nil
}
	"github.com/quintans/taskboard/go/service"
	T "github.com/quintans/taskboard/go/tables"
	. "github.com/quintans/toolkit/ext"
	"github.com/quintans/toolkit/web/app"

	"crypto/tls"
	"fmt"
	"net"
	"net/smtp"
	"time"
)

const FAULT_BIZ = "BIZ"

var (
	AbsentBoardFault     = dbx.NewPersistenceFail(FAULT_BIZ, "The Board no longer exists")
	AbsentLaneFault      = dbx.NewPersistenceFail(FAULT_BIZ, "The Lane no longer exists")
	OptimistickLockFault = dbx.NewOptimisticLockFail("Unable to apply changes due to a concurrent access. Try again.")
)

var _ service.ITaskBoardService = &TaskBoardServiceImpl{}

type TaskBoardServiceImpl struct {
}

func (this *TaskBoardServiceImpl) WhoAmI(c maze.IContext) (dto.IdentityDTO, error) {
	ctx := c.(*AppCtx)
	p := ctx.Principal
	identity := dto.IdentityDTO{}
	identity.Id = &p.UserId
	var name string