Search in sources :

Example 6 with Link

use of com.moxi.mogublog.commons.entity.Link in project mogu_blog_v2 by moxi624.

the class LinkServiceImpl method editLink.

@Override
public String editLink(LinkVO linkVO) {
    Link link = linkService.getById(linkVO.getUid());
    Integer linkStatus = link.getLinkStatus();
    link.setTitle(linkVO.getTitle());
    link.setSummary(linkVO.getSummary());
    link.setLinkStatus(linkVO.getLinkStatus());
    link.setUrl(linkVO.getUrl());
    link.setSort(linkVO.getSort());
    link.setEmail(linkVO.getEmail());
    link.setFileUid(linkVO.getFileUid());
    link.setUpdateTime(new Date());
    link.updateById();
    // 友链从申请状态到发布状态,需要发送邮件到站长邮箱
    if (StringUtils.isNotEmpty(link.getEmail()) && CheckUtils.checkEmail(link.getEmail())) {
        if (ELinkStatus.APPLY.equals(linkStatus) && ELinkStatus.PUBLISH.equals(linkVO.getLinkStatus())) {
            log.info("发送友链申请通过的邮件通知");
            String linkApplyText = "<a href=\" " + link.getUrl() + "\">" + link.getTitle() + "</a> 站长,您申请的友链已经成功上架~";
            rabbitMqUtil.sendSimpleEmail(link.getEmail(), linkApplyText);
        }
    }
    // 删除Redis中的BLOG_LINK
    deleteRedisBlogLinkList();
    return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
Also used : Link(com.moxi.mogublog.commons.entity.Link)

Example 7 with Link

use of com.moxi.mogublog.commons.entity.Link in project mogu_blog_v2 by moxi624.

the class LinkServiceImpl method stickLink.

@Override
public String stickLink(LinkVO linkVO) {
    Link link = linkService.getById(linkVO.getUid());
    // 查找出最大的那一个
    QueryWrapper<Link> queryWrapper = new QueryWrapper<>();
    queryWrapper.orderByDesc(SQLConf.SORT);
    Page<Link> page = new Page<>();
    page.setCurrent(0);
    page.setSize(1);
    IPage<Link> pageList = linkService.page(page, queryWrapper);
    List<Link> list = pageList.getRecords();
    Link maxSort = list.get(0);
    if (StringUtils.isEmpty(maxSort.getUid())) {
        return ResultUtil.errorWithMessage(MessageConf.PARAM_INCORRECT);
    }
    if (maxSort.getUid().equals(link.getUid())) {
        return ResultUtil.errorWithMessage(MessageConf.OPERATION_FAIL);
    }
    Integer sortCount = maxSort.getSort() + 1;
    link.setSort(sortCount);
    link.setUpdateTime(new Date());
    link.updateById();
    // 删除Redis中的BLOG_LINK
    deleteRedisBlogLinkList();
    return ResultUtil.successWithMessage(MessageConf.OPERATION_SUCCESS);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Link(com.moxi.mogublog.commons.entity.Link)

Example 8 with Link

use of com.moxi.mogublog.commons.entity.Link in project mogu_blog_v2 by moxi624.

the class LinkServiceImpl method deleteLink.

@Override
public String deleteLink(LinkVO linkVO) {
    Link link = linkService.getById(linkVO.getUid());
    link.setStatus(EStatus.DISABLED);
    link.setUpdateTime(new Date());
    link.updateById();
    // 删除Redis中的BLOG_LINK
    deleteRedisBlogLinkList();
    return ResultUtil.successWithMessage(MessageConf.DELETE_SUCCESS);
}
Also used : Link(com.moxi.mogublog.commons.entity.Link)

Aggregations

Link (com.moxi.mogublog.commons.entity.Link)8 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)3 IPage (com.baomidou.mybatisplus.core.metadata.IPage)2 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)2 ApiOperation (io.swagger.annotations.ApiOperation)2 SystemConfig (com.moxi.mogublog.commons.entity.SystemConfig)1 User (com.moxi.mogublog.commons.entity.User)1 List (java.util.List)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1