use of com.alibaba.fastjson.JSONObject in project benchmark by seelunzi.
the class ExOrderServiceImpl method getNewListMarket.
/* */
/* */
/* */
/* */
/* */
public String getNewListMarket(String header, String timeorder) /* */
{
/* 187 */
String[] headarry = header.split("_");
/* 188 */
int keepDecimalForCoin = 8;
/* 189 */
int keepDecimalForCurrency = 8;
/* */
/* 191 */
String str = this.redisService.get("cn:coinInfoList");
/* 192 */
if (!StringUtils.isEmpty(str)) {
/* 193 */
JSONArray pa = JSON.parseArray(str);
/* 194 */
if (pa != null) {
/* 195 */
for (int i = 0; i < pa.size(); i++) {
/* 196 */
JSONObject obj = pa.getJSONObject(i);
/* 197 */
if (header.equals(obj.getString("coinCode") + "_" + obj.getString("fixPriceCoinCode"))) {
/* 198 */
keepDecimalForCoin = obj.getIntValue("keepDecimalForCoin");
/* 199 */
keepDecimalForCurrency = obj.getIntValue("keepDecimalForCurrency");
/* 200 */
break;
/* */
}
/* */
}
/* */
}
/* */
}
/* */
/* 206 */
Map<String, Object> seramap = new HashMap();
/* 207 */
seramap.put("coinCode", headarry[0]);
/* 208 */
seramap.put("fixPriceCoinCode", headarry[1]);
/* 209 */
seramap.put("count", ExchangeDataCacheRedis.LastOrderRecordsLmit);
/* 210 */
List<ExOrderInfo> list = null;
/* 211 */
if (timeorder.equals("asc")) {
/* 212 */
String v = header + ":" + "LastOrderRecords";
/* 213 */
if (!StringUtil.isEmpty(v)) {
/* 214 */
list = this.exOrderInfoDao.findNewList(seramap);
/* 215 */
this.redisService.save(header + ":" + "LastOrderRecords", JSON.toJSONString(list));
/* */
} else {
/* 217 */
list = JSON.parseArray(v, ExOrderInfo.class);
/* */
}
/* */
} else /* */
{
/* 221 */
String v = this.redisService.get(header + ":" + "LastOrderRecords");
/* 222 */
if (StringUtil.isEmpty(v)) {
/* 223 */
list = this.exOrderInfoDao.findNewListDesc(seramap);
/* 224 */
Collections.reverse(list);
/* 225 */
this.redisService.save(header + ":" + "LastOrderRecords", JSON.toJSONString(list));
/* */
} else {
/* 227 */
list = JSON.parseArray(v, ExOrderInfo.class);
/* 228 */
Collections.reverse(list);
/* */
}
/* */
}
/* */
/* 232 */
List<MarketTradesSub> listsub = new ArrayList();
/* 233 */
for (ExOrderInfo l : list) {
/* 234 */
MarketTradesSub sub = new MarketTradesSub();
/* 235 */
sub.setAmount(l.getTransactionCount().setScale(keepDecimalForCoin, 4));
/* 236 */
sub.setPrice(l.getTransactionPrice().setScale(keepDecimalForCurrency, 4));
/* 237 */
sub.setTid(l.getOrderNum());
/* 238 */
sub.setType(l.getInOrOutTransaction());
/* 239 */
sub.setTime(l.getTransactionTime().getTime() / 1000L);
/* 240 */
listsub.add(sub);
/* */
}
/* 242 */
SortList<MarketTradesSub> sort = new SortList();
/* 243 */
sort.Sort(listsub, "getTime", "desc");
/* 244 */
MarketTrades marketTrades = new MarketTrades();
/* 245 */
marketTrades.setTrades(listsub);
/* 246 */
return JSON.toJSONString(marketTrades).toString();
/* */
}
use of com.alibaba.fastjson.JSONObject in project WeexErosFramework by bmfe.
the class EventFetch method fetch.
public void fetch(String params, final Context context, final JSCallback jscallback) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
JSONObject object = parseManager.parseObject(params);
final String mUrl = object.getString("url");
Boolean noRepeat = object.getBoolean("noRepeat");
if (noRepeat != null && noRepeat) {
axiosManager.cancel(mUrl);
}
switch(object.getString("method")) {
case OkHttpUtils.METHOD.GET:
AxiosGet axiosGet = parseManager.parseObject(params, AxiosGet.class);
get(context, axiosManager, axiosGet, jscallback);
break;
case OkHttpUtils.METHOD.POST:
AxiosPost axiosPost = parseManager.parseObject(params, AxiosPost.class);
post(context, axiosManager, axiosPost, jscallback);
break;
case OkHttpUtils.METHOD.HEAD:
AxiosGet axiosHead = parseManager.parseObject(params, AxiosGet.class);
head(context, axiosManager, axiosHead, jscallback);
break;
case OkHttpUtils.METHOD.DELETE:
AxiosPost axiosDelete = parseManager.parseObject(params, AxiosPost.class);
delete(context, axiosManager, axiosDelete, jscallback);
break;
case OkHttpUtils.METHOD.PUT:
AxiosPost axiosPut = parseManager.parseObject(params, AxiosPost.class);
put(context, axiosManager, axiosPut, jscallback);
break;
case OkHttpUtils.METHOD.PATCH:
AxiosPost axiosPatch = parseManager.parseObject(params, AxiosPost.class);
patch(context, axiosManager, axiosPatch, jscallback);
break;
}
}
use of com.alibaba.fastjson.JSONObject in project ranch by heisedebaise.
the class EditorServiceImpl method queryUser.
@Override
public JSONObject queryUser() {
PageList<RoleModel> roles = roleService.query(userHelper.id());
JSONArray list = new JSONArray();
roles.getList().forEach(role -> list.add(find(role.getEditor())));
JSONObject object = roles.toJson(false);
object.put("list", list);
return object;
}
use of com.alibaba.fastjson.JSONObject in project ranch by heisedebaise.
the class ElementServiceImpl method sort.
@Override
public JSONArray sort(String editor, String parent, String[] ids, String[] modifies) {
JSONArray array = new JSONArray();
if (ids.length > modifies.length)
return array;
if (validator.isEmpty(parent))
parent = editor;
for (int i = 0; i < ids.length; i++) {
ElementModel element = findById(ids[i]);
if (element == null || !element.getEditor().equals(editor) || !element.getParent().equals(parent) || element.getSort() == i + 1 || element.getModify() != numeric.toLong(modifies[i]))
continue;
save(element, i + 1);
JSONObject object = new JSONObject();
object.put("id", element.getId());
object.put("modify", element.getModify());
array.add(object);
}
return array;
}
use of com.alibaba.fastjson.JSONObject in project ranch by heisedebaise.
the class ElementServiceImpl method batch.
@Override
public JSONArray batch(String parameters) {
JSONArray array = new JSONArray();
JSONArray params = json.toArray(parameters);
if (params == null) {
logger.warn(null, "批量操作参数集[{}]解析失败!", parameters);
return array;
}
String editor = null;
int size = params.size();
for (int i = 0; i < size; i++) {
JSONObject object = params.getJSONObject(i);
if (!object.containsKey("editor"))
return array;
if (i == 0) {
editor = object.getString("editor");
if (editorService.findById(editor) == null || !roleService.hasType(null, editor, RoleService.Type.Editor))
return array;
} else if (!object.getString("editor").equals(editor))
return array;
switch(object.getString("operation")) {
case "save":
if (parentNotExists(object.getString("parent")) || modifyDisable(object.getString("id"), false, editor, object.getLongValue("modify")))
return array;
continue;
case "sort":
if (parentNotExists(object.getString("parent")))
return array;
continue;
case "delete":
if (modifyDisable(object.getString("id"), true, editor, object.getLongValue("modify")))
return array;
continue;
default:
return array;
}
}
for (int i = 0; i < size; i++) {
JSONObject object = params.getJSONObject(i);
switch(object.getString("operation")) {
case "save":
Map<String, String> map = new HashMap<>();
object.keySet().stream().filter(key -> !key.equals("operation")).forEach(key -> map.put(key, object.getString(key)));
array.add(save(modelHelper.fromMap(map, ElementModel.class)));
continue;
case "sort":
array.add(sort(editor, object.getString("parent"), converter.toArray(object.getString("ids"), ","), converter.toArray(object.getString("modifies"), ",")));
continue;
case "delete":
delete(object.getString("id"));
array.add("");
}
}
return array;
}
Aggregations