use of com.duan.blogos.restful.ResultBean in project BlogSystem by DuanJiaNing.
the class BloggerAccountController method delete.
/**
* 注销账号
*/
@RequestMapping(value = "/{bloggerId}", method = RequestMethod.DELETE)
public ResultBean delete(HttpServletRequest request, @PathVariable Integer bloggerId) {
handleBloggerSignInCheck(request, bloggerId);
boolean result = accountService.deleteAccount(bloggerId);
if (!result)
handlerOperateFail(request);
// session 失效
HttpSession session = request.getSession();
session.invalidate();
return new ResultBean<>("");
}
use of com.duan.blogos.restful.ResultBean in project BlogSystem by DuanJiaNing.
the class BloggerAccountController method checkUsernameUsed.
/**
* 检查用户名是否存在
*/
@RequestMapping(value = "/check=username", method = RequestMethod.GET)
public ResultBean checkUsernameUsed(HttpServletRequest request, @RequestParam("username") String username) {
handleNameCheck(request, username);
BloggerAccount account = accountService.getAccount(username);
if (account != null) {
return new ResultBean(exceptionManager.getDuplicationDataException(new RequestContext(request)));
} else {
return new ResultBean<>("");
}
}
use of com.duan.blogos.restful.ResultBean in project BlogSystem by DuanJiaNing.
the class BloggerBlogCategoryController method get.
/**
* 查看指定类别
*/
@RequestMapping(value = "/{categoryId}", method = RequestMethod.GET)
public ResultBean<BloggerCategoryDTO> get(HttpServletRequest request, @PathVariable Integer bloggerId, @PathVariable Integer categoryId) {
handleAccountCheck(request, bloggerId);
handleCategoryExistCheck(request, bloggerId, categoryId);
BloggerCategoryDTO dto = bloggerCategoryService.getCategory(bloggerId, categoryId);
if (dto == null)
handlerOperateFail(request);
return new ResultBean<>(dto);
}
use of com.duan.blogos.restful.ResultBean in project BlogSystem by DuanJiaNing.
the class BloggerCollectBlogController method update.
/**
* 修改博文收藏
*/
@RequestMapping(value = "/{blogId}", method = RequestMethod.PUT)
public ResultBean update(HttpServletRequest request, @PathVariable("blogId") Integer blogId, @PathVariable("bloggerId") Integer bloggerId, @RequestParam(value = "reason", required = false) String newReason) {
handleBloggerSignInCheck(request, bloggerId);
if (StringUtils.isEmpty(newReason)) {
throw exceptionManager.getParameterIllegalException(new RequestContext(request));
}
boolean result = bloggerCollectBlogService.updateCollect(bloggerId, blogId, newReason, -1);
if (!result)
handlerOperateFail(request);
return new ResultBean<>("");
}
use of com.duan.blogos.restful.ResultBean in project BlogSystem by DuanJiaNing.
the class BloggerGalleryController method update.
/**
* 更新图片信息
*/
@RequestMapping(value = "/{pictureId}", method = RequestMethod.PUT)
public ResultBean update(HttpServletRequest request, @PathVariable("bloggerId") Integer bloggerId, @PathVariable("pictureId") Integer pictureId, @RequestParam(value = "category", required = false) Integer newCategory, @RequestParam(value = "bewrite", required = false) String newBeWrite, @RequestParam(value = "title", required = false) String newTitle) {
handleBloggerSignInCheck(request, bloggerId);
RequestContext context = new RequestContext(request);
// 检查博主是否有指定图片
BloggerPicture picture = bloggerPictureService.getPicture(pictureId);
if (picture == null || !bloggerId.equals(picture.getBloggerId())) {
throw exceptionManager.getParameterIllegalException(context);
}
if (newCategory == null && newBeWrite == null && newTitle == null) {
throw exceptionManager.getParameterIllegalException(context);
}
// 更新图片类别只适用于图片管理员,普通博主没有修改类别的必要
if (newCategory != null) {
// 检查类别是否存在
if (BloggerPictureCategoryEnum.valueOf(newCategory) == null) {
throw exceptionManager.getParameterIllegalException(context);
}
// 检查权限
if (!validateManager.checkBloggerPictureLegal(bloggerId, newCategory))
throw exceptionManager.getUnauthorizedException(context);
}
boolean result = bloggerPictureService.updatePicture(pictureId, newCategory == null ? null : BloggerPictureCategoryEnum.valueOf(newCategory), newBeWrite, newTitle);
if (!result)
handlerOperateFail(request);
return new ResultBean<>("");
}
Aggregations