// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.17.8
package sys

import (
	"context"
	"hotgo/api/admin/users"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	Users = cUsers{}
)

type cUsers struct{}

// List 查看前台用户表列表
func (c *cUsers) List(ctx context.Context, req *users.ListReq) (res *users.ListRes, err error) {
	list, totalCount, err := service.SysUsers().List(ctx, &req.UsersListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.UsersListModel{}
	}

	res = new(users.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出前台用户表列表
func (c *cUsers) Export(ctx context.Context, req *users.ExportReq) (res *users.ExportRes, err error) {
	err = service.SysUsers().Export(ctx, &req.UsersListInp)
	return
}

// Edit 更新前台用户表
func (c *cUsers) Edit(ctx context.Context, req *users.EditReq) (res *users.EditRes, err error) {
	err = service.SysUsers().Edit(ctx, &req.UsersEditInp)
	return
}

// View 获取指定前台用户表信息
func (c *cUsers) View(ctx context.Context, req *users.ViewReq) (res *users.ViewRes, err error) {
	data, err := service.SysUsers().View(ctx, &req.UsersViewInp)
	if err != nil {
		return
	}

	res = new(users.ViewRes)
	res.UsersViewModel = data
	return
}

// Delete 删除前台用户表
func (c *cUsers) Delete(ctx context.Context, req *users.DeleteReq) (res *users.DeleteRes, err error) {
	err = service.SysUsers().Delete(ctx, &req.UsersDeleteInp)
	return
}

// Status 更新前台用户表状态
func (c *cUsers) Status(ctx context.Context, req *users.StatusReq) (res *users.StatusRes, err error) {
	err = service.SysUsers().Status(ctx, &req.UsersStatusInp)
	return
}