Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

24.2. MongoDB

24.2.1. 枚舉定義

			
package api.pojo;

public class Enum {

	public enum Authority {
		USER, EXPERTS, ORGANIZATION, ADMIN
	}

	public enum Status {
		Enabled, Disabled, Yes, No, Y, N
	}

	public enum Examine {
		New, Pending, Rejected, Approved
	}

	public enum Task {
		New, Processing, Canceled, Completed
	}

	public enum Sex {
		True, False, T, F, Male, Female, Boy, Girl
	}

	public Enum() {
		// TODO Auto-generated constructor stub
	}
}
			
			
			

24.2.2. 日誌表

			
package api.domain;

import java.util.Date;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document
public class Logging {

	public enum Priority {
		info, warning, error, critical, exception, debug
	}

	public enum Facility {
		app, sms, ios, android, api, db
	}

	@Id
	private String id;
	private String tag;
	private Date time;
	private Facility facility;
	private Priority priority;
	private String message;

	public Logging() {
		// TODO Auto-generated constructor stub
	}

	public String getId() {
		return id;
	}

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

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public Facility getFacility() {
		return facility;
	}

	public void setFacility(Facility facility) {
		this.facility = facility;
	}

	public Priority getPriority() {
		return priority;
	}

	public void setPriority(Priority priority) {
		this.priority = priority;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	@Override
	public String toString() {
		return "Logging [id=" + id + ", tag=" + tag + ", time=" + time + ", facility=" + facility + ", priority=" + priority + ", message=" + message + "]";
	}

}

			
			

24.2.3. 地址與定位

			
package cn.netkiller.api.domain;

import org.springframework.data.geo.Point;
import org.springframework.data.redis.core.index.GeoIndexed;
import org.springframework.data.redis.core.index.Indexed;

public class Address {

	private @Indexed String city;
	private String country;
	private @GeoIndexed Point location;

	public Address(String city, String country, Point location) {
		this.city = city;
		this.country = country;
		this.location = location;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public Point getLocation() {
		return location;
	}

	public void setLocation(Point location) {
		this.location = location;
	}

}