sys_user_department.go 1.6 KB
package domain

import (
	"context"
	"gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction"
)

type SysUserDepartment struct {
	Id           int64 `json:",omitempty"` // 唯一标识
	CompanyId    int64 `json:",omitempty"` // 公司ID
	UserId       int64 `json:",omitempty"` // 用户ID
	EmployeeId   int64 `json:",omitempty"` // 职工ID
	DepartmentId int64 `json:",omitempty"` // 部门ID
	CreatedAt    int64 `json:",omitempty"`
}

type SysUserDepartmentRepository interface {
	/*
		Delete(ctx context.Context, conn transaction.Conn, dm *SysUserDepartment) (*SysUserDepartment, error)
		FindOne(ctx context.Context, conn transaction.Conn, id int64) (*SysUserDepartment, error)
		Update(ctx context.Context, conn transaction.Conn, dm *SysUserDepartment) (*SysUserDepartment, error)
		UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *SysUserDepartment) (*SysUserDepartment, error)
	*/
	Insert(ctx context.Context, conn transaction.Conn, dm *SysUserDepartment) (*SysUserDepartment, error)
	Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*SysUserDepartment, error)

	FindByUser(ctx context.Context, conn transaction.Conn, companyId int64, userId []int64) (int64, []*SysUserDepartment, error)
	// ResetByUser 重置用户部门
	ResetByUser(ctx context.Context, conn transaction.Conn, companyId, userId, employeeId int64, departments []int64) error
	// DeleteByDepartment 删除部门用户
	DeleteByDepartment(ctx context.Context, conn transaction.Conn, companyId int64, departments []int64) error
}

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