Java Code Examples for com.baomidou.mybatisplus.mapper.EntityWrapper#setEntity()

The following examples show how to use com.baomidou.mybatisplus.mapper.EntityWrapper#setEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdminServiceImpl.java    From app-version with Apache License 2.0 6 votes vote down vote up
@Override
public ServiceResult unbindUserAndApp(String userId, int appId) {
    logger.info("解绑用户[{}]与App[{}]", userId, appId);
    UserAppRel userAppRel = new UserAppRel();
    userAppRel.setAppId(appId);
    userAppRel.setUserId(userId);
    EntityWrapper<UserAppRel> entityWrapper = new EntityWrapper<>();
    entityWrapper.setEntity(userAppRel);
    Integer delete = userAppRelMapper.delete(entityWrapper);
    if (delete > 0) {
        logger.info("解绑用户[{}]与App[{}]成功", userId, appId);
        return ServiceResult.ok(entityWrapper);
    } else {
        logger.error("解绑用户[{}]与App[{}]失败", userId, appId);
        return ServiceResultConstants.DB_ERROR;
    }
}
 
Example 2
Source File: AdminArticleController.java    From MI-S with MIT License 6 votes vote down vote up
/**
 * 获取更新文章信息
 *
 * @param articleId 用于获取文章信息
 * @param model
 * @return
 */
@RequestMapping("/updateInfo")
public String updateInfo(@RequestParam(value = "articleId") String articleId, Model model) {
    Article article = iArticleService.selectById(articleId);
    EntityWrapper<Tag> ewTag = new EntityWrapper<>();
    List<Tag> tagList = iTagService.selectList(ewTag);
    EntityWrapper<Type> ewType = new EntityWrapper<>();
    List<Type> typeList = iTypeService.selectList(ewType);

    ArticleType articleType = iArticleTypeService.selectById(articleId);
    EntityWrapper<ArticleTag> articleTagEntityWrapper = new EntityWrapper<>();
    ArticleTag at = new ArticleTag();
    at.setArticleId(articleId);
    articleTagEntityWrapper.setEntity(at);
    List<ArticleTag> articleTagList = iArticleTagService.selectList(articleTagEntityWrapper);

    model.addAttribute("article", article);
    model.addAttribute("articleType", articleType);
    model.addAttribute("articleTagList", articleTagList);

    model.addAttribute("typeList", typeList);
    model.addAttribute("tagList", tagList);

    return "admin/article/articleEditInfo";
}
 
Example 3
Source File: TypeServiceImpl.java    From MI-S with MIT License 6 votes vote down vote up
@Override
@Transactional
public boolean deleteType(String typeId) {
    EntityWrapper<ArticleType> ex = new EntityWrapper<>();

    ArticleType a = new ArticleType();
    a.setTypeId(typeId);
    ex.setEntity(a);
    List<ArticleType> list = articleTypeMapper.selectList(ex);

    articleTypeMapper.delete(ex); //删除关系表

    typeMapper.deleteById(typeId); //删除分类


    //全部删除完毕后迁移到默认分类下
    for (ArticleType at : list) {
        a = new ArticleType();
        a.setTypeId("default");
        a.setArticleId(at.getArticleId());
        articleTypeMapper.insert(a);
    }

    return true;
}
 
Example 4
Source File: ResourceServiceImpl.java    From xmanager with Apache License 2.0 5 votes vote down vote up
public List<Resource> selectByType(Integer type) {
    EntityWrapper<Resource> wrapper = new EntityWrapper<Resource>();
    Resource resource = new Resource();
    wrapper.setEntity(resource);
    wrapper.addFilter("resource_type = {0}", type);
    wrapper.orderBy("seq");
    return resourceMapper.selectList(wrapper);
}
 
Example 5
Source File: AdminTypeController.java    From MI-S with MIT License 5 votes vote down vote up
/**
 * 删除之前查询是否存在文章
 * @param typeId
 * @return
 */
@RequestMapping("/delCheckExist")
@ResponseBody
public BaseResult delCheckExist(String typeId){
    EntityWrapper<ArticleType> ew = new EntityWrapper<>();
    ArticleType articleType =new ArticleType();
    articleType.setTypeId(typeId);
    ew.setEntity(articleType);

    int count = iArticleTypeService.selectCount(ew);
    if (count > 0){
        return new BaseResult(null, ReturnCode.FAIL,"当前分类已存在文章");
    }
    return new BaseResult(null, ReturnCode.SUCCESS);
}
 
Example 6
Source File: AdminArticleController.java    From MI-S with MIT License 5 votes vote down vote up
/**
 * 更新文章可用状态
 *
 * @param id
 * @param status
 * @return
 */
@RequestMapping("/updateStatue")
@ResponseBody
public BaseResult updateStatue(String id, int status) {

    EntityWrapper<Article> ew = new EntityWrapper<>();
    Article article = new Article();
    article.setArticleId(id);
    article.setStatus(status);
    ew.setEntity(article);
    iArticleService.updateById(article);
    return new BaseResult(null, ReturnCode.SUCCESS);
}
 
Example 7
Source File: AdminTagController.java    From MI-S with MIT License 5 votes vote down vote up
/**
 * 删除之前查询是否存在文章
 * @param tagId
 * @return
 */
@RequestMapping("/delCheckExist")
@ResponseBody
public BaseResult delCheckExist(String tagId){
    EntityWrapper<ArticleTag> ew = new EntityWrapper<>();
    ArticleTag articleTag =new ArticleTag();
    articleTag.setTagId(tagId);
    ew.setEntity(articleTag);

    int count = iArticleTagService.selectCount(ew);
    if (count > 0){
        return new BaseResult(null, ReturnCode.FAIL,"当前分类已存在文章");
    }
    return new BaseResult(null, ReturnCode.SUCCESS);
}
 
Example 8
Source File: MenuController.java    From MI-S with MIT License 5 votes vote down vote up
/**
 * 主页
 **/
@RequestMapping("/")
public String home(Model model) {
    //后期参数定义 做成多博客系统
    UserInfo uInfo = iUserInfoService.selectByUserId("1");
    model.addAttribute("userInfo", uInfo);

    //友情链接
    List<Friendlink> fLinkList = iFriendlinkService.selectAllList();
    model.addAttribute("fLinkList", fLinkList);

    //类别
    List<TypeVo> typeList = iTypeService.initTypeList();
    model.addAttribute("typeList", typeList);

    //获取归档列表
    List<Map> archiveList = iArticleService.selectArticleArchiveList();
    model.addAttribute("archiveList", archiveList);

    //标签云
    List<Tag> tagList = iTagService.selectList(null);
    model.addAttribute("tagList", tagList);

    EntityWrapper<Article> exA = new EntityWrapper<>();
    Article article = new Article();
    article.setStatus(1);
    exA.setEntity(article);
    model.addAttribute("articleCount", iArticleService.selectCount(exA));
    model.addAttribute("tagCount", iTagService.selectCount(null));

    return "blog/index";
}
 
Example 9
Source File: IndexPageController.java    From MI-S with MIT License 4 votes vote down vote up
/**
 * 加载文章详细
 * 包括总标签数
 * 总文章数量
 * 分类及每个分类文章数量
 * 友链集合
 *
 * @return
 */
@RequestMapping("/article/details/{articleId}")
public String loadArticleD(@PathVariable String articleId, Model model) {
    //当前文章的所有信息
    //后期参数定义 做成多博客系统
    UserInfo uInfo = iUserInfoService.selectByUserId("1");
    model.addAttribute("userInfo", uInfo);


    //友情链接
    List<Friendlink> fLinkList = iFriendlinkService.selectList(null);
    model.addAttribute("fLinkList", fLinkList);


    //新增判断,当文章不存在或文章不展示的情况下,会跳转到404页面
    ArticleVo articleVo = iArticleService.getArticleCustomById(articleId);
    if (articleVo == null) {
        return "redirect:/404";
    }
    model.addAttribute("article", articleVo);

    EntityWrapper<Article> exA = new EntityWrapper<>();
    Article article = new Article();
    article.setStatus(1);
    exA.setEntity(article);
    model.addAttribute("articleCount", iArticleService.selectCount(exA));

    model.addAttribute("tagCount", iTagService.selectCount(null));

    //上一篇
    Article lastArticle = iArticleService.getLastArticle(articleId);
    model.addAttribute("lastArticle", lastArticle);

    //下一篇
    Article nextArticle = iArticleService.getNextArticle(articleId);
    model.addAttribute("nextArticle", nextArticle);

    //增加浏览量
    iArticleService.addArticleCount(articleId);

    return "blog/article";
}