/*
 * *********************************************************************************************************************
 *
 *          !!
 *        .F88X
 *        X8888Y
 *      .}888888N;
 *        i888888N;        .:!              .I$WI:
 *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
 *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
 *            +888888N;  .8888888Y                                  "&&8Y.}8,
 *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
 *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
 *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
 *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
 *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
 *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
 *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
 *      .:R888888I
 *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
 *        ~8888'
 *        .!88~                                                                     All rights reserved.
 *
 * *********************************************************************************************************************
 */

package com.persagy.server.datacenter.models.entities.dict

import com.alibaba.fastjson.annotation.JSONField
import com.persagy.server.datacenter.models.entities.base.BaseInfo
import io.swagger.v3.oas.annotations.media.Schema
import javax.persistence.Column
import javax.persistence.Id
import javax.persistence.Table

/**
 * 数据中心储存方案
 *
 * @author 张维新
 */
@Schema(description = "字典说明")
@Table(name = "dict.datacenter_property_def_scheme")
class DataCenterPropertyDefScheme : BaseInfo(){

    /** 一级标签 */
    @Schema(description = "一级标签")
    @Column(name = "first_tag")
    @JSONField(name = "FirstTag")
    var firstTag: String? = null

    /** 一级名称 */
    @Schema(description = "一级名称")
    @Column(name = "first_name")
    @JSONField(name = "FirstName")
    var firstName: String? = null

    /** 二级标签 */
    @Schema(description = "二级标签")
    @Column(name = "second_tag")
    @JSONField(name = "SecondTag")
    var secondTag: String? = null

    /** 二级名称 */
    @Schema(description = "二级名称")
    @Column(name = "second_name")
    @JSONField(name = "SecondName")
    var secondName: String? = null

    /** 信息点名称 */
    @Schema(description = "信息点名称")
    @Column(name = "info_point_name")
    @JSONField(name = "InfoPointName")
    var infoPointName: String? = null

    /** 信息点编码 */
    @Schema(description = "信息点编码")
    @Id
    @Column(name = "info_point_code")
    @JSONField(name = "InfoPointCode")
    var infoPointCode: String? = null

    /** 类型 */
    @Schema(description = "类型")
    @Column(name = "datatype")
    @JSONField(name = "DataType")
    var dataType: String? = null

    /** 输入方式 */
    @Schema(description = "输入方式")
    @Column(name = "inputmode")
    @JSONField(name = "InputMode")
    var inputMode: String? = null

    /** 单位 */
    @Schema(description = "单位")
    @Column(name = "unit")
    @JSONField(name = "Unit")
    var unit: String? = null

    /** 类型 */
    @Schema(description = "类型")
    @Id
    @Column(name = "type")
    @JSONField(name = "Type")
    var type: String? = null

    /** 父指针 */
    @Schema(description = "父指针")
    @Column(name = "parent_id")
    @JSONField(name = "ParentId")
    var parentId: String? = null

    /** 标记 */
    @Schema(description = "标记")
    @Column(name = "flag")
    @JSONField(name = "Flag")
    var  flag: String? = null

    /** 字典选择 */
    @Schema(description = "字典选择")
    @Column(name = "datasource")
    @JSONField(name = "DataSource",serialize=false)
    var dataSource: String? = null

    /** 备注 */
    @Schema(description = "字典选择")
    @Column(name = "note")
    @JSONField(name = "Note")
    var note: String? = null

    /** 优先级 */
    @Schema(description = "优先级")
    @Column(name = "priority")
    @JSONField(name = "Priority")
    var priority: String? = null

    /** 是否显示 */
    @Schema(description = "是否显示")
    @Column(name = "visible")
    @JSONField(name = "Visible")
    var visible: Boolean? = null

    /** 是否编辑 */
    @Schema(description = "是否编辑")
    @Column(name = "editable")
    @JSONField(name = "Editable")
    var editable: Boolean? = null

    /** 排序 */
    @Schema(description = "排序")
    @Column(name = "sort")
    @JSONField(name = "Sort")
    var sort: Int? = null

    /** 禁止操作 */
    @Schema(description = "禁止操作")
    @Column(name = "un_disabled")
    @JSONField(name = "UnDisabled")
    var unDisabled: Boolean? = null

    /** 路径 */
    @Schema(description = "路径")
    @JSONField(name = "Path")
    var path: String? = null
        get() {
            return if (firstTag == "基本信息"|| firstTag.isNullOrEmpty()){
                infoPointCode
            }else{
                if (secondTag.isNullOrEmpty()){
                    "$firstTag.$infoPointCode"
                }else{
                    "$firstTag.$secondTag.$infoPointCode"
                }
            }
        }

    /** 禁止操作 */
    @Schema(description = "禁止操作")
    @Id
    @Column(name = "scheme_id")
    @JSONField(name = "SchemeId")
    var schemeId: String? = null

} // Class PropertyDefProjectInfo