renren-security使用demo

首先配置renren-admin

1.打开相应sql文件,在数据库中创建系统所需初始表

2.修改数据源

配置renren-generator

1.修改数据源(不需要初始表)


打开renren-generator

只要数据库中存在表,界面就会显示

选择生成代码


代码生成为压缩包,解压后根据目录结构放入renren-admin

启动renren-admin


刚才生成的页面已经自动加载进来了,在菜单管理中配置

编写与数据库交互的代码

mybatis plus方式(单表简单逻辑使用方便):

@RunWith(SpringRunner.class)
@SpringBootTest
public class TestNewForm {
    @Autowired
    TestService testService;
    @Test
    public void insert(){
        TestEntity testEntity=new TestEntity();
        //testEntity.setId(10);
        testEntity.setAddress("cd");
        testEntity.setName("xwj");
        testEntity.setDate(new Date());
        testEntity.setIsdel(0);
        testService.insert(testEntity);
    }
    @Test
    public void updateById(){
        TestEntity testEntity=new TestEntity();
        testEntity.setId(1011521023183151105L);
        testEntity.setAddress("成都");
        testEntity.setName("xwj");
        testEntity.setDate(new Date());
        testService.updateById(testEntity);
    }
    @Test
    public void deleteByLogic(){
        TestEntity testEntity=new TestEntity();
        testEntity.setId(1011521023183151105L);
        testService.deleteById(testEntity);
    }
    @Test
    public void selectById(){
        TestEntity testEntity=testService.selectById(1011521023183151105L);
        System.err.print(testEntity.getName());
    }
    @Test
    public void selectByCondition(){
        List<TestEntity> testEntities=testService.selectList(
                new EntityWrapper<TestEntity>().eq("isdel","0").eq("address","成都")
        );
        for (TestEntity testEntity : testEntities) {
            System.err.println(testEntity.getName());
        }
    }
   
其中在insert的时候如果想用数据库的自增,需要修改id-type为0,此处使用的是自带的全局数字id,为long型
普通的delete不需要修改entity代码,如果想要使用逻辑删除,加上注解

逻辑删除以前和逻辑删除以后的标志显示修改


mybatis方式,自定义xml写法

dao层添加


service层添加


serviceimp层添加(mybatis plus官方是直接用mapper,这里做了封装需要这样用,这里的basemapper拥有dao层的方法)


xml文件按照传统配置


使用:


猜你喜欢

转载自blog.csdn.net/qq_35615462/article/details/80817742
今日推荐