2020年12月9日 星期三

RestAPI 基礎

POST -> Json -> function name
GET   -> Json -> variable name

HelloWorld.java
package com.nkg.newera;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "xHiHi", schema = "dbo")
@Cacheable
public class HelloWorld
{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PKcodeID")
    private Integer id; //variable name

    @Column(name = "MD5Code", length = 16)
    private String md5Code;

    public void HelloWorld() {}

    public Integer getId()  //function name
                            //get, set不會出現, Id 第一個字母會變小寫, Id -> id
                            //但第一字母要大寫...還不知道方法
    {
        return id;
    }

    public void setId(Integer id) //get, set不會出現, Id 第一個字母會變小寫, Id -> id
    {
        this.id = id;
    }

    public String getmd5Code()
    {
        return md5CodeCode;
    }

    public void setmd5Code(String code)
    {
        this.md5Code = code;
    }
}

沒有留言:

張貼留言