package role

import (
	"mini_server/internal/dao"
	"mini_server/internal/server/httpreply"
	"net/http"

	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
)

// 角色列表查询接口，查询全部
func QueryAllRole(c *gin.Context) {
	reply := httpreply.NewDefaultReplyData()
	defer httpreply.Reply(c, reply)

	list, err := dao.Character_QueryAllCharacter()
	if err != nil {
		logrus.Errorf("角色列表查询失败,err:%v", err)
		reply.Status = http.StatusInternalServerError
		reply.Message = "角色列表查询失败"
		return
	}

	roleList := make([]*RoleInfo, len(list))
	for i, data := range list {
		var detail RoleInfo
		Copy_mysql_data(data, &detail)
		roleList[i] = &detail
	}
	reply.Data = roleList
}
