Search in sources :

Example 6 with ResultBean

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<>("");
}
Also used : HttpSession(javax.servlet.http.HttpSession) ResultBean(com.duan.blogos.restful.ResultBean)

Example 7 with 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<>("");
    }
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) RequestContext(org.springframework.web.servlet.support.RequestContext) ResultBean(com.duan.blogos.restful.ResultBean)

Example 8 with 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);
}
Also used : BloggerCategoryDTO(com.duan.blogos.dto.blogger.BloggerCategoryDTO) ResultBean(com.duan.blogos.restful.ResultBean)

Example 9 with ResultBean

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<>("");
}
Also used : RequestContext(org.springframework.web.servlet.support.RequestContext) ResultBean(com.duan.blogos.restful.ResultBean)

Example 10 with 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<>("");
}
Also used : BloggerPicture(com.duan.blogos.entity.blogger.BloggerPicture) RequestContext(org.springframework.web.servlet.support.RequestContext) ResultBean(com.duan.blogos.restful.ResultBean)

Aggregations

ResultBean (com.duan.blogos.restful.ResultBean)28 RequestContext (org.springframework.web.servlet.support.RequestContext)12 Blog (com.duan.blogos.entity.blog.Blog)5 BloggerAccount (com.duan.blogos.entity.blogger.BloggerAccount)5 BloggerPicture (com.duan.blogos.entity.blogger.BloggerPicture)5 HttpSession (javax.servlet.http.HttpSession)5 BlogCategory (com.duan.blogos.entity.blog.BlogCategory)4 ArrayList (java.util.ArrayList)4 BlogListItemDTO (com.duan.blogos.dto.blog.BlogListItemDTO)3 BloggerDTO (com.duan.blogos.dto.blogger.BloggerDTO)3 BloggerProfile (com.duan.blogos.entity.blogger.BloggerProfile)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 BloggerCategoryDTO (com.duan.blogos.dto.blogger.BloggerCategoryDTO)2 FavouriteBlogListItemDTO (com.duan.blogos.dto.blogger.FavouriteBlogListItemDTO)2 BlogLabel (com.duan.blogos.entity.blog.BlogLabel)2 BlogStatistics (com.duan.blogos.entity.blog.BlogStatistics)2 BlogListItemComparatorFactory (com.duan.blogos.manager.comparator.BlogListItemComparatorFactory)2 HashMap (java.util.HashMap)2 JSONObject (com.alibaba.fastjson.JSONObject)1 BlogMainContentDTO (com.duan.blogos.dto.blog.BlogMainContentDTO)1