4 Star 95 Fork 21

wujiawei/wu-framework-parent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.idea
doc-puml
doc/lazy-vuepress-starter
docker
images
wu-bionic-parent
wu-database-parent
wu-database-lazy-datasource-starter
wu-database-lazy-jpa
src
README.md
pom.xml
wu-database-lazy-lambda
wu-database-lazy-orm-core
wu-database-lazy-sql
wu-elasticsearch-starter
wu-hbase-starter
Lazy ORM Log 1.png
Lazy ORM Log 2 .png
Lazy ORM log.png
README.md
Version.md
lazy-orm.puml
pom.xml
wu-easy-parent
wu-framework-authorization
wu-framework-bean
wu-framework-core
wu-framework-integration-starter
wu-framework-plus
wu-framework-test
wu-framework-translation
wu-framework-web
wu-inner-integration
wu-smart-integration
wu-smart-platform
.gitignore
LICENSE
README.md
Version.md
docker-confluentinc-compose.yml
docker-ewomail-compose.yml
docker-rabbitmq-compose.yml
docker-redis-compose.yml
docker-skywalking-compose.yml
graalvm.md
k8s-clickhose.yaml
k8s-config-map.yaml
k8s-ewomail.yaml
k8s-ipsec-vpn-server.yaml
k8s-jenkins-ci.yaml
k8s-jenkins.yaml
k8s-kafka.yaml
k8s-mongo.yaml
k8s-mysql.yaml
k8s-nexus.yaml
k8s-rocketmq.yaml
k8s-skywalking.yaml
k8s-zentao.yaml
k8s.yaml
pom.xml
skywalking.yaml
tips.md
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

介绍Lazy Jpa 是lazy orm框架衍生出类似Spring JPA 框架

非Spring项目使用

安装
        <dependency>
            <groupId>top.wu2020</groupId>
            <artifactId>wu-database-lazy-jpa</artifactId>
            <version>1.2.8-JDK17-SNAPSHOT</version>
        </dependency>
声明接口

public interface TestLazyJpaRepository extends LazyJpaRepository<SysUser,Long> {
}

接口调用(基础CRUD)
    public static void main(String[] args) {
        LazyLambdaStream lazyLambdaStream = LazyLambdaStreamFactory.createLazyLambdaStream("jdbc:mysql://127.0.0.1:3306/wu_database_lazy_simple?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai",
                "root", "wujiawei");
        TestLazyJpaRepository lazyJpaRepository = LazyRepositoryFactorySupport.createLazyJpaRepository(lazyLambdaStream, TestLazyJpaRepository.class);
    
        // 统计数据库数量
        long count = lazyJpaRepository.count();
        // 获取所有数据
        Iterable<SysUser> all = lazyJpaRepository.findAll();
        for (SysUser sysUser : all) {
            System.out.println(sysUser);
        }
    }

Spring 项目使用

安装
        <dependency>
            <groupId>top.wu2020</groupId>
            <artifactId>wu-framework-lazy-orm-spring-starter</artifactId>
            <version>1.2.8-JDK17-SNAPSHOT</version>
        </dependency>
声明接口
@LazyRepository
public interface TestLazyJpaRepository extends LazyJpaRepository<SysUser,Long> {
}
接口配置
@LazyRepositoryScan(scanBasePackages = "com.wu.xxx.mapper")// 扫描你使用的repository接口
@SpringBootApplication
public class WuDatabaseLazyStarterSimpleApplication {

    public static void main(String[] args) {
        SpringApplication.run(WuDatabaseLazyStarterSimpleApplication.class, args);
    }
}

接口使用

@LazyRepository
public interface SysMenuLazyJpaRepository extends LazyJpaRepository<SysMenu, Integer> {
    
    // 自定义查询
    @LazySelect("select * from sys_menu where parent_id={parentId}")
    List<SysMenu> findListByParentId(Integer parentId);


    @LazySelect("select * from sys_menu where id ={id}")
    SysMenu findMenuById(@LazyParam("id") Integer menuId);


    @LazySelect("select * from sys_menu where id ={id}")
    List<Map<?, ?>> findListMapByParentId(@LazyParam("id") Integer menuId);

    @LazyInsert("INSERT Ignore INTO `sys_menu` ( `id`, `name`, `url`, `icon`, `parent_id`,`parent_name`,`sort`,`status`) VALUES ({id},{name},{url},{icon},{parentId},{parentName},{sort},{status});")
    void insert(Integer id,
                String name,
                String url,
                String icon,
                Integer parentId,
                String parentName,
                Integer sort,
                Integer status
    );

    @LazyUpdate("UPDATE `sys_menu` SET  `name` = {name} WHERE `id` = {id};")
    void updateNameById(Integer id, String name);


    @LazyDelete("DELETE FROM sys_menu  WHERE `id` = {id};")
    void removeById(int id);
    /**
     * 执行sql select * from sys_menu where id={id}
     * 根据ID获取数据
     * @param id 数据ID
     */
    SysMenu findById(int id);

    /**
     * 执行sql select id,name,url,icon from sys_menu where id={id}
     * 获取ID、名称、url、icon
     * @param id 主键ID
     * @return 查询信息
     */
    SysMenu findIdAndNameAndUrlAndIconById(int id);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/wujiawei1207537021/wu-framework-parent.git
git@gitee.com:wujiawei1207537021/wu-framework-parent.git
wujiawei1207537021
wu-framework-parent
wu-framework-parent
master

搜索帮助