java springboot 处理函数 JsonResult JSONArray 以及JsonResult JSONArray复杂字符串形式 数据库形式的方法

后台java处理函数 JsonResult 形式
public JsonResult deleteReUser(String accountId) {
JsonResult result = new JsonResult<>();
。。。
try {

    } catch (Exception e) {
        e.printStackTrace();
        result.setMessage(e.getMessage());
        result.setSuccess(false);
    }
    return result;
}

后台java处理JSONArray形式
@GetMapping("/getStreetData")
public JSONArray getStreetData(String areaCode) {
JSONArray array = new JSONArray();
BaseStreetExample baseStreetExample = new BaseStreetExample();
BaseStreetExample.Criteria criteria = baseStreetExample.createCriteria();
criteria.andAreacodeEqualTo(areaCode);
Collection baseStreets = baseStreetMapper.selectByExample(baseStreetExample);
for(BaseStreet baseStreet : baseStreets) {
JSONObject object = new JSONObject();
object.put(“name”, baseStreet.getName());
object.put(“value”, baseStreet.getCode());
array.add(object);
}
return array;
}

后台Java返回JsonResult 复杂字符串形式 数据库复杂比较等功能
@PostMapping("/login")
public JsonResult login(@RequestBody Account account)
{
//JsonResult result = new JsonResult<>();
JsonResult result = new JsonResult<>();
result.setSuccess(false);
try{
JSONObject object = new JSONObject();
AccountExample accountExample = new AccountExample();
AccountExample.Criteria criteria = accountExample.createCriteria();
criteria.andMobileEqualTo(account.getMobile());
List accountList = accountMapper.selectByExample(accountExample);
object.put(“account”,accountList==null||accountList
.size()==0 ? null:accountList.get(0));
result.setData(object);
}catch (Exception e){
e.printStackTrace();
result.setMessage(“登录异常!”);
}
return result;
}

后台java处理函数 GridResult形式

public GridResult> getReUser(can1,can2) {
List> list = mybatisService.selectList(“SANLIAN_MAPPER.getQueryRecoveryUser”, new LinkedHashMap<>());
return new GridResult<>(list, list == null ? 0 : list.size());
}

你可能感兴趣的:(物联网云平台技术,JsonResult,JSONArray,Java,SpringBoot)