package com.cyksj.model.excel;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cyksj.model.entity.WorkOrder;
import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/*
 *项目名: netflix
 *文件名: ExcelWorkOrderData
 *创建者: JavaZou
 *创建时间:2023/6/26 15:19
 */
@Getter
@Setter
@SearchBean(tables = "work_order wo left join user u on u.id = wo.user_id" +
		" left join goods_don g on g.id = wo.goods_id" +
		" left join goods_don_sku sku on sku.id = wo.sku_id")
public class ExcelWorkOrderData {
	@DbField("wo.id")
	@ExcelIgnore
	private Long id;

	@DbField("wo.account")
	@ExcelProperty("账号")
	private String account;

	@DbField("g.title")
	@ExcelProperty("平台")
	private String title;

	@DbField("sku.spec_val")
	@ExcelProperty("规格")
	private String specVal;

	@DbField("wo.user_id")
	@ExcelProperty("用户ID")
	private Long userId;

	@DbField("select nickname from user where id = wo.user_id limit 1")
	@ExcelProperty("用户名")
	private String nickname;

	@DbField("wo.type")
	@ExcelIgnore
	private WorkOrder.Type type;

	@DbField("wo.assign_customer_service_id")
	@ExcelIgnore
	private Long assignCustomerServiceId;

	@DbField("wo.status")
	@ExcelIgnore
	private WorkOrder.Status status;

	@DbIgnore
	@ExcelProperty("问题类型")
	private String questionType;

	@DbIgnore
	@ExcelProperty("问题状态")
	private String questionStatus;

	@DbField("wo.created_time")
	@ExcelProperty("提交时间")
	private Date createdTime;

	public String getQuestionType() {
		if (type == null) return StrUtil.EMPTY;
		return type.getDesc();
	}

	public String getQuestionStatus() {
		if (status == null) return StrUtil.EMPTY;
		return status.getDesc();
	}
}
