当前位置: 首页>>代码示例>>Java>>正文


Java EntityWrapper类代码示例

本文整理汇总了Java中com.baomidou.mybatisplus.mapper.EntityWrapper的典型用法代码示例。如果您正苦于以下问题:Java EntityWrapper类的具体用法?Java EntityWrapper怎么用?Java EntityWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityWrapper类属于com.baomidou.mybatisplus.mapper包,在下文中一共展示了EntityWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateInfo

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
/**
 * 获取更新文章信息
 *
 * @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";
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:32,代码来源:AdminArticleController.java

示例2: deleteType

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@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;
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:26,代码来源:TypeServiceImpl.java

示例3: queryList

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
public List<SysMenu> queryList(Map<String, Object> params) {
	List<SysMenu> pageInfo = super.queryList(params);
	Map<String, String> menuTypeMap = sysDicService.queryDicByType("MENUTYPE");
	EntityWrapper<SysMenu> wrapper = new EntityWrapper<SysMenu>();
	for (SysMenu sysMenu : pageInfo) {
		if (sysMenu.getMenuType() != null) {
			sysMenu.setTypeName(menuTypeMap.get(sysMenu.getMenuType().toString()));
		}
		SysMenu menu = new SysMenu();
		menu.setParentId(sysMenu.getId());
		wrapper.setEntity(menu);
		int count = mapper.selectCount(wrapper);
		if (count > 0) {
			sysMenu.setLeaf(0);
		}
	}
	return pageInfo;
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:19,代码来源:SysMenuService.java

示例4: updateByEntityWrapperOptLock

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
protected void updateByEntityWrapperOptLock() {
    Long id = 1992L;
    H2User user = new H2User();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2User userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());

    H2User updUser = new H2User();
    updUser.setName("999");

    userService.update(updUser, new EntityWrapper<>(userDB));

    userDB = userService.selectById(id);
    Assert.assertEquals(2, userDB.getVersion().intValue());
    Assert.assertEquals("999", userDB.getName());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:25,代码来源:AbstractH2UserTest.java

示例5: updateByEntityWrapperOptLockWithoutVersionVal

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
protected void updateByEntityWrapperOptLockWithoutVersionVal() {
    Long id = 993L;
    H2User user = new H2User();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2User userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());

    H2User updUser = new H2User();
    updUser.setName("999");
    userDB.setVersion(null);
    userService.update(updUser, new EntityWrapper<>(userDB));

    userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    Assert.assertEquals("999", userDB.getName());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:25,代码来源:AbstractH2UserTest.java

示例6: updateByEntityWrapperNoEntity

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
protected void updateByEntityWrapperNoEntity() {
    Long id = 998L;
    H2User user = new H2User();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2User userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    H2User updateUser = new H2User();
    updateUser.setName("998");
    boolean result = userService.update(updateUser, new EntityWrapper<H2User>());
    Assert.assertTrue(result);
    userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    EntityWrapper<H2User> param = new EntityWrapper<>();
    param.eq("name", "998");
    List<H2User> userList = userService.selectList(param);
    Assert.assertTrue(userList.size() > 1);
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:26,代码来源:AbstractH2UserTest.java

示例7: updateInLoopCase

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
protected void updateInLoopCase(){
    List<H2User> list = userService.selectList(new EntityWrapper<H2User>());
    Map<Long, Integer> versionBefore = new HashMap<>();
    Map<Long, String> nameExpect = new HashMap<>();
    for (H2User h2User : list) {
        Long id = h2User.getId();
        Integer versionVal = h2User.getVersion();
        versionBefore.put(id, versionVal);
        String randomName = h2User.getName() + "_" + new Random().nextInt(10);
        nameExpect.put(id, randomName);
        h2User.setName(randomName);
        userService.updateById(h2User);
    }

    list = userService.selectList(new EntityWrapper<H2User>());
    for (H2User u : list) {
        Assert.assertEquals(u.getName(), nameExpect.get(u.getId()));
        if (u.getVersion() != null)
            Assert.assertEquals(versionBefore.get(u.getId()) + 1, u.getVersion().intValue());
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:22,代码来源:AbstractH2UserTest.java

示例8: updateAllColumnInLoop

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
protected void updateAllColumnInLoop(){
    List<H2User> list = userService.selectList(new EntityWrapper<H2User>());
    Map<Long, Integer> versionBefore = new HashMap<>();
    Map<Long, String> nameExpect = new HashMap<>();
    for (H2User h2User : list) {
        Long id = h2User.getId();
        Integer versionVal = h2User.getVersion();
        versionBefore.put(id, versionVal);
        String randomName = h2User.getName() + "_" + new Random().nextInt(10);
        nameExpect.put(id, randomName);
        h2User.setName(randomName);
        userService.updateAllColumnById(h2User);
    }

    list = userService.selectList(new EntityWrapper<H2User>());
    for (H2User u : list) {
        Assert.assertEquals(u.getName(), nameExpect.get(u.getId()));
        Assert.assertEquals(versionBefore.get(u.getId()) + 1, u.getVersion().intValue());
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:21,代码来源:AbstractH2UserTest.java

示例9: testUpdateByEntityWrapper

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@Test
public void testUpdateByEntityWrapper() {
    Long id = 992L;
    H2UserNoVersion user = new H2UserNoVersion();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2UserNoVersion userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());

    H2UserNoVersion updUser = new H2UserNoVersion();
    updUser.setName("999");

    userService.update(updUser, new EntityWrapper<>(userDB));

    userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    Assert.assertEquals("999", userDB.getName());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:26,代码来源:H2UserNoVersionTest.java

示例10: testUpdateByEntityWrapper2

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@Test
public void testUpdateByEntityWrapper2() {
    Long id = 993L;
    H2UserNoVersion user = new H2UserNoVersion();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2UserNoVersion userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());

    H2UserNoVersion updUser = new H2UserNoVersion();
    updUser.setName("999");
    userDB.setVersion(null);
    userService.update(updUser, new EntityWrapper<>(userDB));

    userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    Assert.assertEquals("999", userDB.getName());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:26,代码来源:H2UserNoVersionTest.java

示例11: testUpdateByEntityWrapperNoDateVersion

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@Test
public void testUpdateByEntityWrapperNoDateVersion() {
    Long id = 992L;
    H2UserVersionAndLogicDeleteEntity user = new H2UserVersionAndLogicDeleteEntity();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userMapper.insertAllColumn(user);

    H2UserVersionAndLogicDeleteEntity userDB = userMapper.selectById(id);
    Assert.assertEquals("testType will only be updated by insertFill() when testType is null ", 1, userDB.getTestType().intValue());

    H2UserVersionAndLogicDeleteEntity updUser = new H2UserVersionAndLogicDeleteEntity();
    updUser.setName("999");

    userMapper.update(updUser, new EntityWrapper<>(userDB));

    userDB = userMapper.selectById(id);
    Assert.assertEquals("999", userDB.getName());
    assertUpdateFill(userDB.getLastUpdatedDt());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:26,代码来源:H2MetaObjAndVersionAndOptLockTest.java

示例12: testUpdateByEntityWrapperNoDateVersion

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@Test
public void testUpdateByEntityWrapperNoDateVersion() {
    Long id = 992L;
    H2UserDateVersion user = new H2UserDateVersion();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userMapper.insertAllColumn(user);

    H2UserDateVersion userDB = userMapper.selectById(id);

    H2UserDateVersion updUser = new H2UserDateVersion();
    updUser.setName("999");

    userMapper.update(updUser, new EntityWrapper<>(userDB));

    userDB = userMapper.selectById(id);
    Assert.assertEquals("999", userDB.getName());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:24,代码来源:H2UserDateVersionTest.java

示例13: testUpdateByEntityWrapperOptLock

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@Test
public void testUpdateByEntityWrapperOptLock() {
    Long id = 992L;
    H2UserIntVersionExtendTO user = new H2UserIntVersionExtendTO();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2UserIntVersionExtendTO userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());

    H2UserIntVersionExtendTO updUser = new H2UserIntVersionExtendTO();
    updUser.setName("999");

    userService.update(updUser, new EntityWrapper<>(userDB));

    userDB = userService.selectById(id);
    Assert.assertEquals(2, userDB.getVersion().intValue());
    Assert.assertEquals("999", userDB.getName());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:26,代码来源:H2UserExtendsTest.java

示例14: testUpdateByEntityWrapperOptLockWithoutVersionVal

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@Test
public void testUpdateByEntityWrapperOptLockWithoutVersionVal() {
    Long id = 993L;
    H2UserIntVersionExtendTO user = new H2UserIntVersionExtendTO();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2UserIntVersionExtendTO userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());

    H2UserIntVersionExtendTO updUser = new H2UserIntVersionExtendTO();
    updUser.setName("999");
    userDB.setVersion(null);
    userService.update(updUser, new EntityWrapper<>(userDB));

    userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    Assert.assertEquals("999", userDB.getName());
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:26,代码来源:H2UserExtendsTest.java

示例15: testUpdateByEntityWrapperNoEntity

import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入依赖的package包/类
@Test
public void testUpdateByEntityWrapperNoEntity() {
    Long id = 998L;
    H2UserIntVersionExtendTO user = new H2UserIntVersionExtendTO();
    user.setId(id);
    user.setName("992");
    user.setAge(92);
    user.setPrice(BigDecimal.TEN);
    user.setDesc("asdf");
    user.setTestType(1);
    user.setVersion(1);
    userService.insertAllColumn(user);

    H2UserIntVersionExtendTO userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    H2UserIntVersionExtendTO updateUser = new H2UserIntVersionExtendTO();
    updateUser.setName("998");
    boolean result = userService.update(updateUser, new EntityWrapper<H2UserIntVersionExtendTO>());
    Assert.assertTrue(result);
    userDB = userService.selectById(id);
    Assert.assertEquals(1, userDB.getVersion().intValue());
    EntityWrapper<H2UserIntVersionExtendTO> param = new EntityWrapper<>();
    param.eq("name", "998");
    List<H2UserIntVersionExtendTO> userList = userService.selectList(param);
    Assert.assertTrue(userList.size() > 1);
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:27,代码来源:H2UserExtendsTest.java


注:本文中的com.baomidou.mybatisplus.mapper.EntityWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。