package dto

import (
	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
	"strconv"
)

type OrgUserGetPageReq struct {
	dto.Pagination `search:"-"`
	NickName       string `form:"nickName"  search:"type:contains;column:nick_name;table:su" comment:"姓名"`     //姓名
	Username       string `form:"username"  search:"type:contains;column:username;table:su" comment:"账号（手机号）"` //账号（手机号）
	Status         string `form:"status"  search:"type:exact;column:status;table:su" comment:"状态"`             //状态 1 离职 2 在职
	RoleId         string `form:"roleId"  search:"type:exact;column:role_id;table:su" comment:"角色"`            //角色
}

type OrgUserGetPageReply struct {
	UserId   string `json:"userId"`
	RoleName string `json:"roleName"`
	NickName string `json:"nickName"`
	Username string `json:"username"`
	RoleId   string `json:"roleId"`
	Status   string `json:"status"`
}

func (m *OrgUserGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type OrgUserInsertReq struct {
	UserId     int    `json:"-" comment:""` //
	RoleId     string `json:"roleId" comment:"角色id"`
	NickName   string `json:"nickName" comment:"姓名"`
	NickNameEn string `json:"nickNameEn" comment:"姓名"`
	Username   string `json:"username" comment:"账号"`
	Status     string `json:"status" comment:"状态" default:"2"`
	UserType   string `json:"userType" comment:"类型" default:"2"`
	common.ControlBy
}

func (s *OrgUserInsertReq) Generate(model *models.SysUser) {
	model.UserId = s.UserId
	model.NickName = s.NickName
	model.NickNameEn = s.NickNameEn
	model.Username = s.Username
	model.RoleId, _ = strconv.Atoi(s.RoleId)
	model.Status = "2"
	model.Password = Pwd("123456")
	model.UserType = "2"
}

func (s *OrgUserInsertReq) GetId() interface{} {
	return s.UserId
}

type OrgUserUpdateReq struct {
	UserId     int    `uri:"userId" comment:""` //
	RoleId     string `json:"roleId" comment:"角色id"`
	NickName   string `json:"nickName" comment:"姓名"`
	NickNameEn string `json:"nickNameEn" comment:"姓名"`
	Username   string `json:"username" comment:"账号"`
	Password   string `json:"password" comment:"密码"`
	Status     string `json:"status" comment:"状态" default:"2"`
	common.ControlBy
}

type OrgUserUpdateStatusReq struct {
	UserId int    `json:"userId" comment:""`             //
	Status string `json:"status" comment:"状态 1 离职 2 在职"` //状态 1 离职 2 在职
	common.ControlBy
}

type ResetPwdReq struct {
	UserId int `json:"userId" comment:""` //
	common.ControlBy
}

func (s *OrgUserUpdateReq) Generate(model *models.SysUser) {
	model.UserId = s.UserId
	model.NickName = s.NickName
	model.NickNameEn = s.NickNameEn
	model.Username = s.Username
	model.Password = Pwd(s.Password)
	model.RoleId, _ = strconv.Atoi(s.RoleId)
	model.Status = s.Status
}

func (s *OrgUserUpdateReq) GetId() interface{} {
	return s.UserId
}

// OrgTeamUserGetReq 功能获取请求参数
type OrgUserGetReq struct {
	Id int `uri:"id"`
}

type OrgUserGetReply struct {
	UserId   string `json:"userId"`
	NickName string `json:"nickName"`
	RoleId   string `json:"roleId"`
	RoleName string `json:"roleName"`
	Username string `json:"username"`
}

func (s *OrgUserGetReq) GetId() interface{} {
	return s.Id
}

// OrgTeamUserDeleteReq 功能删除请求参数
type OrgUserDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *OrgUserDeleteReq) GetId() interface{} {
	return s.Ids
}
