user_role.go 1.2 KB
package domain

import (
	"context"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)

type UserRole struct {
	Id        int64 // 唯一标识
	CompanyId int64 // 公司ID
	UserId    int64
	RoleId    int64
	CreatedAt int64
	UpdatedAt int64
	DeletedAt int64
	Version   int
}

type UserRoleRepository interface {
	Insert(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error)
	Update(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error)
	UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error)
	Delete(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error)
	DeleteByUser(ctx context.Context, conn transaction.Conn, userId int64) error
	DeleteRole(ctx context.Context, conn transaction.Conn, roleId int64) error
	DeleteByUserAndRole(ctx context.Context, conn transaction.Conn, userId int64, roleId int64) error
	FindOne(ctx context.Context, conn transaction.Conn, id int64) (*UserRole, error)
	Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*UserRole, error)
}

func (m *UserRole) Identify() interface{} {
	if m.Id == 0 {
		return nil
	}
	return m.Id
}