use of ruangong.root.exception.BackException in project RG by ADrWondertainment.
the class PageUtil method getPageInfo.
/*
{
"pageNum":1,
"size":5
}
*/
public static HashMap<String, Integer> getPageInfo(JSONObject jsonObject, HttpServletRequest httpServletRequest, UserService userService) {
String email = (String) httpServletRequest.getSession().getAttribute("email");
if (email == null) {
throw new BackException(ErrorCode.USER_ILLEGAL_ACCESS, "用户未登录");
}
Result result = userService.GetUserByEmail(email);
User user = (User) result.getData();
Integer id = user.getId();
Integer pageNum = (Integer) jsonObject.get("pageNum");
Integer size = (Integer) jsonObject.get("size");
HashMap<String, Integer> map = new HashMap<>();
map.put("id", id);
map.put("pageIndex", pageNum);
map.put("sizePerPage", size);
return map;
}
use of ruangong.root.exception.BackException in project RG by ADrWondertainment.
the class AnswerServiceImpl method getAnswersByUserID.
@Override
public Result getAnswersByUserID(Integer id, Integer pageNum, Integer size) {
IPage<Answer> page = new Page(pageNum, size);
QueryWrapper<Answer> query = Wrappers.query();
query.eq("uid", id);
IPage<Answer> answerIPage = answerMapper.selectPage(page, query);
if (answerIPage == null) {
throw new BackException(ErrorCode.TEMPLATE_SELECT_FAILURE, "分页数据查询失败");
}
List<Answer> records = answerIPage.getRecords();
JSONArray jsonArray = JSONUtil.parseArray(records);
System.out.println(JSONUtil.toJsonPrettyStr(jsonArray));
ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
return result;
}
use of ruangong.root.exception.BackException in project RG by ADrWondertainment.
the class SheetServiceImpl method getSheetsInPages.
@Override
public Result getSheetsInPages(Integer id, Integer pageIndex, Integer sizePerPage) {
IPage<Sheet> page = new Page(pageIndex, sizePerPage);
QueryWrapper<Sheet> query = Wrappers.query();
query.eq("uid", id);
IPage<Sheet> sheetIPage = sheetMapper.selectPage(page, query);
if (sheetIPage == null) {
throw new BackException(ErrorCode.SHEET_SELECT_FAILURE, "分页数据查询失败");
}
JSONArray jsonArray = JSONUtil.parseArray(sheetIPage.getRecords());
ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
return result;
}
use of ruangong.root.exception.BackException in project RG by ADrWondertainment.
the class TemplateServiceImpl method getTemplatesInPages.
@Override
public Result getTemplatesInPages(Integer id, Integer pageNum, Integer size) {
IPage<Template> page = new Page(pageNum, size);
QueryWrapper<Template> query = Wrappers.query();
query.eq("uid", id);
IPage<Template> templateIPage = templateMapper.selectPage(page, query);
if (templateIPage == null) {
throw new BackException(ErrorCode.TEMPLATE_SELECT_FAILURE, "分页数据查询失败");
}
List<Template> records = templateIPage.getRecords();
List<TemplateTransfer> transfers = new ArrayList<>();
for (Template t : records) {
TemplateTransfer temp = new TemplateTransfer();
temp.setId(t.getId());
temp.setUid(t.getUid());
temp.setName(t.getName());
temp.setTime(t.getTime());
temp.setLength(t.getLength());
temp.setDescription(t.getDescription());
temp.setData(JSONUtil.parseObj(t.getData()));
transfers.add(temp);
}
JSONArray jsonArray = JSONUtil.parseArray(transfers);
ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
return result;
}
use of ruangong.root.exception.BackException in project RG by ADrWondertainment.
the class UserServiceImpl method GetUserByEmail.
@Override
public Result GetUserByEmail(String email) {
QueryWrapper<User> wrapper = new QueryWrapper<>();
wrapper.eq("email", email);
User user_result = userMapper.selectOne(wrapper);
if (user_result == null) {
throw new BackException(ErrorCode.USER_NAME_UNFINDED, "该用户不存在");
}
// if (user_result == null) {
// ResultUtil.quickSet(
// result,
// ErrorCode.USER_NAME_UNFINDED,
// "该用户不存在",
// null
// );
// return result;
// }
ResultUtil.quickSet(result, ErrorCode.SUCCESS, "查询成功", user_result);
return result;
}
Aggregations