package com.iformall.domain.po;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Table(name = "wx_msg")
public class WxMsg extends BaseMsg {
    private static final long serialVersionUID = 1L;

    @Id
    protected Long id;

    @Transient
    protected List<String> ids;
    @Transient
    protected String sortColumns;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSortColumns() {
        return sortColumns;
    }

    public List<String> getIds() {
        return ids;
    }

    public void setIds(List<String> ids) {
        this.ids = ids;
    }

    /*租户ID**/
    @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId")
    private String tenantId;
    /*模板id**/
    @io.swagger.annotations.ApiModelProperty(value = "模板id", name = "modelId")
    private Long modelId;
    /*内容**/
    @io.swagger.annotations.ApiModelProperty(value = "内容", name = "msg")
    private String msg;
    /*发送时间**/
    @io.swagger.annotations.ApiModelProperty(value = "发送时间", name = "sendtime")
    private String sendtime;
    /*发送时间**/
    @io.swagger.annotations.ApiModelProperty(value = "发送时间", name = "createtime")
    private Date createtime;
    /*预计发送数量**/
    @io.swagger.annotations.ApiModelProperty(value = "预计发送数量", name = "expectSendNumber")
    private Integer expectSendNumber;
    /*成功数量**/
    @io.swagger.annotations.ApiModelProperty(value = "成功数量", name = "successNumber")
    private Integer successNumber;
    /*错误数量**/
    @io.swagger.annotations.ApiModelProperty(value = "错误数量", name = "errorNumber")
    private Integer errorNumber;
    /***/
    @io.swagger.annotations.ApiModelProperty(value = "", name = "returnResult")
    private String returnResult;
    /***/
    @io.swagger.annotations.ApiModelProperty(value = "", name = "phones")
    private String phones;
    /***/
    @io.swagger.annotations.ApiModelProperty(value = "", name = "signature")
    private String signature;
    /***/
    @io.swagger.annotations.ApiModelProperty(value = "", name = "isright")
    private Integer isright;
    /***/
    @io.swagger.annotations.ApiModelProperty(value = "", name = "name")
    private String name;
    /*发送状态0未发送 1已发送 2草稿箱**/
    @io.swagger.annotations.ApiModelProperty(value = "发送状态0失败1成功", name = "sendstatus")
    private Integer sendstatus;

    @io.swagger.annotations.ApiModelProperty(value = "excelpath", name = "excelpath")
    private String excelpath;

    @io.swagger.annotations.ApiModelProperty(value = "标签人群", name = "label")
    private String label;

    @io.swagger.annotations.ApiModelProperty(value = "状态0未发送 1已发送 2草稿箱", name = "status")
    private Integer status;

    @io.swagger.annotations.ApiModelProperty(value = "1标签短信2精准投放", name = "way")
    private Integer way;

    @io.swagger.annotations.ApiModelProperty(value = "couponInjectId", name = "couponInjectId")
    private Long couponInjectId;

    @Transient
    List<WxTags> tagsList;

    //用于mq发送消息
    private WxMsgConfig wxMsgConfig;
    private WxCouponInject couponInject;


    public WxMsgConfig getWxMsgConfig() {
        return wxMsgConfig;
    }

    public void setWxMsgConfig(WxMsgConfig wxMsgConfig) {
        this.wxMsgConfig = wxMsgConfig;
    }

    public WxCouponInject getCouponInject() {
        return couponInject;
    }

    public void setCouponInject(WxCouponInject couponInject) {
        this.couponInject = couponInject;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String _tenantId) {
        tenantId = _tenantId;
    }

    public Long getModelId() {
        return modelId;
    }

    public void setModelId(Long _modelId) {
        modelId = _modelId;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String _msg) {
        msg = _msg;
    }

    public String getSendtime() {
        return sendtime;
    }

    public void setSendtime(String _sendtime) {
        sendtime = _sendtime;
    }

    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date _createtime) {
        createtime = _createtime;
    }

    public Integer getExpectSendNumber() {
        return expectSendNumber;
    }

    public void setExpectSendNumber(Integer _expectSendNumber) {
        expectSendNumber = _expectSendNumber;
    }

    public Integer getSuccessNumber() {
        return successNumber;
    }

    public void setSuccessNumber(Integer _successNumber) {
        successNumber = _successNumber;
    }

    public Integer getErrorNumber() {
        return errorNumber;
    }

    public void setErrorNumber(Integer _errorNumber) {
        errorNumber = _errorNumber;
    }

    public String getReturnResult() {
        return returnResult;
    }

    public void setReturnResult(String _returnResult) {
        returnResult = _returnResult;
    }

    public String getPhones() {
        return phones;
    }

    public void setPhones(String _phones) {
        phones = _phones;
    }

    public String getSignature() {
        return signature;
    }

    public void setSignature(String _signature) {
        signature = _signature;
    }

    public Integer getIsright() {
        return isright;
    }

    public void setIsright(Integer _isright) {
        isright = _isright;
    }

    public String getName() {
        return name;
    }

    public void setName(String _name) {
        name = _name;
    }

    public Integer getSendstatus() {
        return sendstatus;
    }

    public void setSendstatus(Integer _sendstatus) {
        sendstatus = _sendstatus;
    }

    public String getExcelpath() {
        return excelpath;
    }

    public void setExcelpath(String excelpath) {
        this.excelpath = excelpath;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getWay() {
        return way;
    }

    public void setWay(Integer way) {
        this.way = way;
    }

    public List<WxTags> getTagsList() {
        return tagsList;
    }

    public void setTagsList(List<WxTags> tagsList) {
        this.tagsList = tagsList;
    }

    public Long getCouponInjectId() {
        return couponInjectId;
    }

    public void setCouponInjectId(Long couponInjectId) {
        this.couponInjectId = couponInjectId;
    }

    public static enum Field {
        Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"), ModelId_ASC("`model_id` ASC"), ModelId_DESC("`model_id` DESC"), Msg_ASC("`msg` ASC"), Msg_DESC("`msg` DESC"), Sendtime_ASC("`sendtime` ASC"), Sendtime_DESC("`sendtime` DESC"), Createtime_ASC("`createtime` ASC"), Createtime_DESC("`createtime` DESC"), ExpectSendNumber_ASC("`expect_send_number` ASC"), ExpectSendNumber_DESC("`expect_send_number` DESC"), SuccessNumber_ASC("`success_number` ASC"), SuccessNumber_DESC("`success_number` DESC"), ErrorNumber_ASC("`error_number` ASC"), ErrorNumber_DESC("`error_number` DESC"), ReturnResult_ASC("`return_result` ASC"), ReturnResult_DESC("`return_result` DESC"), Phones_ASC("`phones` ASC"), Phones_DESC("`phones` DESC"), Signature_ASC("`signature` ASC"), Signature_DESC("`signature` DESC"), Isright_ASC("`isright` ASC"), Isright_DESC("`isright` DESC"), Name_ASC("`name` ASC"), Name_DESC("`name` DESC"), Sendstatus_ASC("`sendstatus` ASC"), Sendstatus_DESC("`sendstatus` DESC");
        private String value;

        Field(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public void setCol(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return this.getValue();
        }
    }

    public void setSortColumns(WxMsg.Field... fields) {
        if (fields == null || fields.length == 0) {
            return;
        }
        for (int k = 0; k < fields.length; k++) {
            if (fields[k] == null) {
                return;
            }
        }
        StringBuilder sb = new StringBuilder(fields[0].toString());
        for (int k = 1; k < fields.length; k++) {
            sb.append(",");
            sb.append(fields[k].toString());
        }

        this.sortColumns = sb.toString();

    }

    public void setSortColumns(String sortColumns) {
        if (sortColumns == null || "".equals(sortColumns.trim())) {
            return;
        }
        if (sortColumns.contains(",")) {
            String[] cols = sortColumns.split(",");
            java.util.List<Field> fList = new java.util.ArrayList();
            for (int k = 0; k < cols.length; k++) {
                fList.add(Field.valueOf(cols[k]));
            }
            this.setSortColumns(fList.toArray(new Field[fList.size()]));
        } else {
            this.setSortColumns(Field.valueOf(sortColumns));
        }
    }
}
