package com.ruoyi.clock.domain.vo;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.ruoyi.clock.service.IAgentService;
import com.ruoyi.clock.service.IShopService;
import com.ruoyi.common.annotation.ExcelDictFormat;
import com.ruoyi.common.convert.ExcelDictConvert;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.utils.spring.SpringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Date;


/**
 * 店员信息视图对象 tb_employee
 *
 * @author pengc
 * @date 2026-03-04
 */
@Data
@ApiModel("店员信息视图对象")
@ExcelIgnoreUnannotated
public class EmployeeVo {

    private static final long serialVersionUID = 1L;

    /**
     * 员工id
     */
    @ApiModelProperty("员工id")
    private Long employeeId;

    /**
     * 员工姓名
     */
    @ExcelProperty(value = "员工姓名")
    @ApiModelProperty("员工姓名")
    private String employeeName;

    /**
     * 代理商id
     */
    @ApiModelProperty("代理商id")
    private Long agentId;

    /**
     * 代理商名称
     */
    @ExcelProperty(value = "代理商名称")
    @ApiModelProperty("代理商名称")
    private String agentName;

    /**
     * 店铺id
     */
    @ApiModelProperty("店铺id")
    private Long shopId;

    @ExcelProperty(value = "店铺名称")
    @ApiModelProperty("店铺名称")
    private String shopName;

    /**
     * 用户头像
     */
    @ApiModelProperty(value = "用户头像")
    private String avatar;

    /**
     * 手机号码
     */
    @ExcelProperty(value = "手机号码")
    @ApiModelProperty("手机号码")
    private String phonenumber;

    /**
     * 帐号状态（0正常 1停用）
     */
    @ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "0=正常,1=停用")
    @ApiModelProperty("帐号状态（0正常 1停用）")
    private String status;

    /**
     * 密码
     */
    @ExcelProperty(value = "密码")
    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("删除标志（0代表存在 2代表删除）")
    private String delFlag;

    @ApiModelProperty("代理商信息")
    private AgentVo agent;

    public AgentVo loadAgentVo(){
        if (ObjectUtil.isNotNull(this.agentId)){
            IAgentService agentService = SpringUtils.getBean("agentServiceImpl", IAgentService.class);
            this.agent = agentService.queryById(this.agentId);
            if (ObjectUtil.isNotNull(this.agent)){
                this.agentName = agent.getAgentName();
            }
        }
        return this.agent;
    }

    @ApiModelProperty("门店信息")
    private ShopVo shop;

    public ShopVo loadShopVo(){
        if (ObjectUtil.isNotNull(this.shopId)){
            IShopService shopService = SpringUtils.getBean("shopServiceImpl", IShopService.class);
            this.shop = shopService.queryById(this.shopId);
            if (ObjectUtil.isNotNull(this.shop)){
                this.shopName = shop.getShopName();
            }
        }
        return this.shop;
    }
}
