3行代碼寫出8個接口,開掛了?
閱讀本文大概需要 6?分鐘。
來自:https://my.oschina.net/tommylemon/blog/1574430
@RequestMapping("test/{request}")
public?String?test(@PathVariable?String?request)?{
????return?request?+?":?Hello?World";
}
base_url/get/userbase_url/get/user/listbase_url/get/commentbase_url/get/comment/list增?base_url/post
刪(包括批量)?base_url/delete
改(包括批量)?base_url/put
查(包括列表)?base_url/get
統(tǒng)計?base_url/head
base_url/get/base_url/get/base_url/getbase_url/get
//注冊表并添加權(quán)限,用默認(rèn)配置
@MethodAccess
public?class?User?{
//內(nèi)容一般僅供表字段說明及 Android App 開發(fā)使用,服務(wù)端不用的可不寫。
}
//Verifier?內(nèi)添加權(quán)限
accessMap.put(User.class.getSimpleName(),?getAccessMap(User.class.getAnnotation(MethodAccess.class)));
@MethodAccess(
??POST?=?{UNKNOWN,?ADMIN}?//只允許未登錄角色和管理員角色新增?User,默認(rèn)配置是?{LOGIN,?ADMIN}
)
public?class?User?{}
URL:http://apijson.cn:8080/get{
????"User":?{
????????"id":?82001
????}
}?
{
????"User":?{
????????"id":?82001,
????????"sex":?0,
????????"name":?"Test",
????????"tag":?"APIJSON?User",
????????"head":?"http://static.oschina.net/uploads/user/19/39085_50.jpg",
????????"contactIdList":?[
????????????82004,
????????????82021,
????????????70793
????????],
????????"pictureList":?[
????????????"http://common.cnblogs.com/images/icon_weibo_24.png"
????????],
????????"date":?"2017-02-01?19:21:50.0"
????},
????"code":?200,
????"msg":?"success"
}
URL:http://apijson.cn:8080/get{
????"[]":?{?//數(shù)組
????????"User":?{
????????????"sex":?1,?//性別為女
????????????"@column":?"id,name"?//只需要id,name這兩個字段
????????}
????}
}
{
????"[]":?[
????????{
????????????"User":?{
????????????????"id":?82002,
????????????????"name":?"Happy~"
????????????}
????????},
????????{
????????????"User":?{
????????????????"id":?82003,
????????????????"name":?"Wechat"
????????????}
????????},
????????{
????????????"User":?{
????????????????"id":?82005,
????????????????"name":?"Jan"
????????????}
????????}
????],
????"code":?200,
????"msg":?"success"
}
{
????"User[]":?{?//提取User
????????"User":?{
????????????"sex":?1,?//性別為女
????????????"@column":?"id,name"?//只需要id,name這兩個字段
????????}
????}
{
????"User[]":?[
????????{
????????????"id":?82002,
????????????"name":?"Happy~"
????????},
????????{
????????????"id":?82003,
????????????"name":?"Wechat"
????????},
????????{
????????????"id":?82005,
????????????"name":?"Jan"
????????}
????],
????"code":?200,
????"msg":?"success"
}
{
????"User-name[]":?{?//提取User.name
????????"User":?{
????????????"sex":?1,?//性別為女
????????????"@column":?"name"?//只需要name這個字段
????????}
????}
}
{
????"User-name[]":?[
????????"Happy~",
????????"Wechat",
????????"Jan",
????????"Meria",
????????"Tommy"
????],
????"code":?200,
????"msg":?"success"
}
{
????"[]":?{
????????"Comment":?{},?//評論
????????"User":?{??????//發(fā)布評論的用戶
????????????"id@":?"/Comment/userId"?//User.id?=?Comment.userId
????????}
????}
}
{
????"[]":?[
????????{
????????????"Comment":?{
????????????????"id":?3,
????????????????"toId":?0,
????????????????"userId":?82002,
????????????????"momentId":?15,
????????????????"date":?"2017-02-01?19:20:50.0",
????????????????"content":?"This?is?a?Content...-3"
????????????},
????????????"User":?{
????????????????"id":?82002,
????????????????"sex":?1,
????????????????"name":?"Happy~",
????????????????"tag":?"iOS",
????????????????"head":?"http://static.oschina.net/uploads/user/1174/2348263_50.png?t=1439773471000",
????????????????"contactIdList":?[
????????????????????82005,
????????????????????82001,
????????????????????38710
????????????????],
????????????????"pictureList":?[],
????????????????"date":?"2017-02-01?19:21:50.0"
????????????}
????????},
????????{
????????????"Comment":?{
????????????????"id":?4,
????????????????"toId":?0,
????????????????"userId":?38710,
????????????????"momentId":?470,
????????????????"date":?"2017-02-01?19:20:50.0",
????????????????"content":?"This?is?a?Content...-4"
????????????},
????????????"User":?{
????????????????"id":?38710,
????????????????"sex":?0,
????????????????"name":?"TommyLemon",
????????????????"tag":?"Android&Java",
????????????????"head":?"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000",
????????????????"contactIdList":?[
????????????????????82003,
????????????????????82005
????????????????],
????????????????"pictureList":?[
????????????????????"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000",
????????????????????"http://common.cnblogs.com/images/icon_weibo_24.png"
????????????????],
????????????????"date":?"2017-02-01?19:21:50.0"
????????????}
????????}
????],
????"code":?200,
????"msg":?"success"
}
{
????"Moment":?{},
????"User[]":?{
????????"User":?{
????????????"id{}@":?"Moment/praiseUserIdList"?//id在點(diǎn)贊列表praiseUserIdList內(nèi)
????????}
????}
}
{
????"User":?{},
????"Moment[]":?{?//朋友圈照片列表
????????"Moment":?{
????????????"@order":"date-",?//按發(fā)布時間date倒序排列
????????????"userId@":?"User/id"
????????}
????}
}
{
????"[]":?{
????????"count":?3,?//只要3個
????????"page":?2,??//要第2頁的
????????"Moment":?{},
????????"User":?{
????????????"id@":?"/Moment/userId"
????????},
????????"Comment[]":?{
????????????"Comment":?{
????????????????"momentId@":?"[]/Moment/id"
????????????}
????????}
????}
}?
"key[]":{}?????????????????????????????????????????//?查詢數(shù)組
"key{}":[1,2,3]????????????????????????????????????//?匹配選項范圍
"key{}":"<=10,length(key)>1..."????????????????????//?匹配條件范圍
"key()":"function(arg0,arg1...)"???????????????????//?遠(yuǎn)程調(diào)用函數(shù)
"key@":"key0/key1.../targetKey"????????????????????//?引用賦值
"key$":"%abc%"?????????????????????????????????????//?模糊搜索
"key?":"^[0-9]+$"??????????????????????????????????//?正則匹配
"key+":[1]?????????????????????????????????????????//?增加/擴(kuò)展
"key-":888.88?????????????????????????????????????//?減少/去除?
"name:alias"??????????????????????????????????????//?新建別名
"@column":"id,sex,name"???????????????????????????//?返回字段
"@group":"userId"?????????????????????????????????//?分組方式
"@having":"max(id)>=100"??????????????????????????//?聚合函數(shù)
"@order":"date-,name+"????????????????????????????//?排序方式

http://apijson.cn:8080/post{
????"Comment":?{
????????"userId":?82001,
????????"momentId":?15,
????????"content":?"測試新增評論"
????},
????"tag":?"Comment"
}
http://apijson.cn:8080/delete{
????"Comment":?{
????????"id":?1510394480987
????},
????"tag":?"Comment"
}
http://apijson.cn:8080/put{
????"Comment":?{
????????"id":?22,
????????"content":?"測試修改評論"
????},
????"tag":?"Comment"
}
http://apijson.cn:8080/delete{
????"Comment":?{
????????"id{}":?[1510394480987,?1510394804925]
????},
????"tag":?"Comment[]"
}
http://apijson.cn:8080/put{
????"Comment":?{
????????"id{}":?[22,?114],
????????"content":?"測試批量修改評論"
????},
????"tag":?"Comment[]"
}
http://apijson.cn:8080/head{
????"Comment":?{
????????"content$":?"%測試%"?//內(nèi)容包含?測試?兩個字
????}
}


推薦閱讀:
支付寶員工因績效3.25B被辭退,員工告上法院,結(jié)果來了!
內(nèi)容包含Java基礎(chǔ)、JavaWeb、MySQL性能優(yōu)化、JVM、鎖、百萬并發(fā)、消息隊列、高性能緩存、反射、Spring全家桶原理、微服務(wù)、Zookeeper、數(shù)據(jù)結(jié)構(gòu)、限流熔斷降級......等技術(shù)棧!
?戳閱讀原文領(lǐng)取!? ? ? ? ? ? ? ??? ??? ? ? ? ? ? ? ? ? ?朕已閱?

