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;
	}

}