inleft
2024-05-18 2ddbd99aa5b2e396f96c6daba60fe1ac2573d9fb
snowy-main/src/main/java/vip/xiaonuo/modular/blogfriendshiplink/controller/BlogLinkOutsideController.java
@@ -26,18 +26,19 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Dict;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.consts.CommonConstant;
import vip.xiaonuo.core.consts.MyConstant;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.exception.BlogException;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.blogfriendshiplink.entity.BlogFriendshipLink;
import vip.xiaonuo.modular.blogfriendshiplink.param.BlogFriendshipLinkVo;
import vip.xiaonuo.modular.blogfriendshiplink.entity.BlogLinkVo;
import vip.xiaonuo.modular.blogfriendshiplink.param.BlogFriendshipLinkParam;
import vip.xiaonuo.modular.blogfriendshiplink.param.BlogFriendshipLinkVo;
import vip.xiaonuo.modular.blogfriendshiplink.service.BlogFriendshipLinkService;
import vip.xiaonuo.sys.modular.dict.param.SysDictTypeParam;
import vip.xiaonuo.sys.modular.dict.service.SysDictTypeService;
@@ -67,6 +68,7 @@
    @Resource
    private SysDictTypeService sysDictTypeService;
    /**
     * 查询blog友情链接
     *
@@ -78,7 +80,7 @@
    public ResponseData queryBlogLinkGroup() {
        List<BlogFriendshipLink> linkList = blogFriendshipLinkService.lambdaQuery()
                .eq(BlogFriendshipLink::getIsEnable,MyConstant.Yes)
                .eq(BlogFriendshipLink::getIsEnable, MyConstant.Yes)
                .orderByAsc(BlogFriendshipLink::getTopValue)
                .orderByAsc(BlogFriendshipLink::getName)
                .list();
@@ -109,4 +111,50 @@
        return new SuccessResponseData(res);
    }
    /**
     * 添加友情链接
     *
     * @author inleft
     * @date 2022-02-17 15:05:44
     */
    @PostMapping("/blogLink/add")
    @BusinessLog(title = "外部blog系统_blog友情链接_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(BlogFriendshipLinkParam.add.class) BlogFriendshipLinkParam blogFriendshipLinkParam) {
        if (blogFriendshipLinkService.lambdaQuery()
                .eq(BlogFriendshipLink::getUrl, blogFriendshipLinkParam.getUrl())
                .count() > 0) {
            throw new BlogException("已经有该链接的记录啦,不要重复提交哦..");
        }
        blogFriendshipLinkParam.setIsEnable(MyConstant.Yes);
        blogFriendshipLinkService.add(blogFriendshipLinkParam);
        return new SuccessResponseData();
    }
    @GetMapping("/blogLink/getLinkType")
    @BusinessLog(title = "外部blog系统_blog友情链接_获取链接类型", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData getLinkType() {
        SysDictTypeParam param = new SysDictTypeParam();
        param.setCode("blog_link_type");
        param.setStatus(MyConstant.No);
        List<Dict> dictList = sysDictTypeService.dropDown(param);
        List<BlogLinkVo> res = new ArrayList<>(dictList.size());
        BlogLinkVo vo;
        for (Dict dict : dictList) {
            vo = new BlogLinkVo();
            vo.setGroupName(dict.get(CommonConstant.VALUE).toString());
            vo.setLinkTypeId(dict.getLong(CommonConstant.CODE));
            res.add(vo);
        }
        return new SuccessResponseData(res);
    }
}