package com.crm.rely.backend.core.entity.base;

import lombok.Data;

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

/**
 * Created by max on 2020/5/8.
 */
@Data
public class BaseApproveEntitys extends LongEntitys implements BaseInterfaceEntity {

    @NotNull(message = "invalid_request")
    @Min(value = 0, message = "invalid_request")
    private Integer status;

    @Size(max = 200, message = "content_oversize")
    private String approveDesc;

    private Long pushMessageId;

    private Long approveUser;

    private Date approveTime;

    private Date modifyTime;

    private Long modifyUser;

    private String modifyIp;

    @Override
    public void populateMetadata(String ip, Long userId, String location, Date dateTime) {
        modifyTime = dateTime;
        modifyUser = userId;
        modifyIp = ip;
        approveUser = userId;
        approveTime = dateTime;

        if (location != null && location.trim().length() > 0) {
            modifyIp += "-" + location;
        }
    }
}
