-
Notifications
You must be signed in to change notification settings - Fork 1
resource
muune edited this page Mar 6, 2019
·
24 revisions
- i18n : Ch.i18n.add()
- font : Ch.style.addFont()
- style : Ch.style.add()
- shape : Ch.drawable.shape()
- api : Ch.net.add()
- ruleset : Ch.ruleset.add()
- query : Ch.sql.addDb()
- db : Ch.sql.addQuery()
- Ch ์์ฑ์์์ ๋๋ฒ์งธ ์ธ์๋ก ๋ฐ์ path์์ ๊ฐ๊ฐ์ resource(i18n, font, style, shape, api, ruleset, query, db)๊ฐ ์ฒ๋ฆฌ๋๋ค.
- ์ฒ์์ ๋ก์ปฌํ์ผ์ ์๋ json์ ์ฝ์ด์ค๊ณ , ๊ฐ๊ฐ์ resource์ ๋ฐ๋ผ ๋ฆฌ์์ค๊ฐ Resํํ๋ก ์์ฑ๋์ DB์ id์ ๋ด์ฉ์ด ๋ค์ด๊ฐ๋ค.
- ์ธํฐ๋ท์ด ์ฌ์ฉ์ด ์ ๋๋ ํ๊ฒฝ์ด๋ฉด ์ด ๋ก์ปฌํ์ผ์ ๋ด์ฉ๋ค๋ก๋ง ์คํ์ด ๋๋ค.
- ํธ์คํธ ์ฝ๋์์ gateway๋ก ์ ์ธํ api๋ก ํต์ ํด์ json์ ๋ถ๋ฌ์ค๊ณ ์ด ๋ด์ฉ์ผ๋ก ๋ฆฌ์์ค๊ฐ Resํํ๋ก DB์ ์ญ์ , ๋ณ๊ฒฝ, ์ถ๊ฐ๋๋ค. * ์๋ Ch.res.load() ์ฐธ๊ณ
- ์ฐธ๊ณ Chela init
//App.kt
//Ch(application:Application, path:String = "")
Ch(this, "setting.json")
// setting.json
// "inited"๊ฐ db์ ์ ์ฅ๋ ๋์ key
{
"inited": {
"api": {
"gateway": {
"url": "http://www.bsidesoft.com:9980/seller2/api/gateway",
"method": "POST",
"requestTask": "akey|sheader|gateway|aes",
"responseTask": "pkey|aes|json|error|data",
"request": {
"id": {}
}
}
},
"i18n": {
"language": "en",
"footer": {
"ver": 1,
"isOne": "en",
"data": {
"en": {
"footer": "2019 ยฉZalagar Seoul All Rights Reserved."
}
}
}
},
"shape": {
"inputFocus": {
"corner": "5dp",
"strokeWidth": "1.5dp",
"strokeColor": "#18ba9b",
"solid": "#ffffff"
}
},
"font": {
"nn": "https://www.bsidesoft.com/hika/nanum.png"
},
"style": {
"actionbar": {
"background": "#18ba9b"
},
"alert": {
"background": "#fa635c",
"textColor": "#ffffff",
"textSize": "12dp"
}
},
"db": {
"seller": {
"isDefault": true,
"asset": "seller.mp4",
"keyProvider": "base"
}
}
}
}
Ch.res.load(res:JSONObject)
- Resource json์ ๋ถ๋ฌ์จ๋ค.
- ๊ฐ๊ฐ์ Resource(i18n, font, style, shape, api, ruleset, query, db)์ ๋ฐ๋ผ ๋ฆฌ์์ค๊ฐ Resํํ๋ก ์์ฑ๋์ DB์ ๋ด์ฉ์ด ๋ค์ด๊ฐ๊ฒ ๋๋ค.
- "remove"์ ์ญ์ ํ key๋ฅผ ์ ์ด์ฃผ๋ฉด ํด๋นํ๋ ๋ฐ์ดํฐ๋ ๋ค ์ง์์ค๋ค.
//http://www.bsidesoft.com:9980/seller2/api/gateway์ ๋ด์ฉ
// "gateway#1"๊ฐ db์ ์ ์ฅ๋ ๋์ key
{
"data": {
"remove": [
"old1",
"old2"
],
"gateway#1": {
"api": {
"base": "https://seller2.bsidesoft.com/",
"islogin": {
"url": "/api/?member/islogin",
"method": "POST",
"requestTask": "sheader",
"responseTask": "json|data",
"request": {
"authtoken": {}
}
},
"login": {
"url": "/api/?member/signin",
"method": "POST",
"requestTask": "sheader|jsonBody",
"responseTask": "json|authtoken|error|data[us.slab.seller.vo.User]",
"request": {
"userid": {
"name": "userid",
"rules": "se.userid"
},
"pass": {
"name": "userpw",
"rules": "se.pass"
}
}
}
},
"ruleset": {
"se": {
"userid": "string|firstlower|lowernum|minLength[4]|maxLength[30]",
"useridInput": "string|firstlower|lowernum|maxLength[30]",
"pass": "string|noblank|minLength[4]|maxLength[30]",
"passInput": "string|noblank|maxLength[30]",
"name": "string|minLength[1]|maxLength[255]",
"email": "string|email|minLength[4]|maxLength[255]",
"phone": "string|maxLength[255]",
"authtoken": "string|maxLength[255]"
}
},
"query": {
"se_add": [
"REPLACE into seller(userid,name,email,phone,authtoken)values(",
"@userid:se.userid@, @name:se.name@, @email:se.email@, @phone:se.phone@, @authtoken:se.authtoken@)"
],
"se_get": "select userid,name,email,phone,authtoken,regdate from seller limit 1"
}
}
}
}
if(Ch.net.isOn()){
App.isLoading(true)
Log.i("ch", "Ch.res.ids - ${Ch.res.ids}")
val result = Ch.net.api("gateway", "id" to Ch.res.ids){
Ch.res.load(it.result as JSONObject)
go()
}
if(result.isFail()){
Log.i("ch", result.msg )
go()
}
}