1 Star 1 Fork 0

netkit / 通用工具箱

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
shixinke 提交于 2022-05-16 20:45 . util optimize

web常用工具箱

English

介绍

web常用工具箱

  • 工具类:
    • bean拷贝工具类
    • json序列化工具类
  • 常用接口
    • 缓存键定义接口: CacheKeyAble
    • 可拷贝的bean接口: Convertible
    • 可转换为map的接口: Mappable
    • 响应码接口: ResponseCode
  • 常用异常
    • 通用响应异常类: ResponseException
    • 业务异常类: ServiceException
    • 验证异常类: ValidateException
  • 常用响应相关类
    • 接口响应类: ApiResponse
    • 分页响应类: PageList

使用说明

1.添加maven依赖
<dependency>
    <groupId>top.netkit</groupId>
    <artifactId>toolkit</artifactId>
    <version>1.0.2</version>
</dependency>
2. 基本使用

(1)bean拷贝

import top.netkit.toolkit.base.Convertible;
public class Item implements Convertible {
    private Long id;
    private String name;

    public Long getId() {
        return id;
    }
    
    public String getName() {
        return name;
    }
}

public class ItemVO {
    private Long id;
    private String name;

    public Long getId() {
        return id;
    }
    
    public String getName() {
        return name;
    }
}

public class Demo {

    public static void main(String[] args){
        Item item = new Item();
        //其他操作查询出item信息      
        ItemVO itemVO = item.convert(ItemVO.class);
    }

}

(2)json工具类

public class Demo {
    public static void main(String[] args){
      String data = "{\"id\":1,\"name\":\"netkit\"}";
      Map<String, Object> dataMap = JsonUtil.parseObject(data, Map.class);
      String jsonString = JsonUtil.toJsonString(dataMap);
    }
}

参与贡献

  1. Fork 本仓库
  2. 新建 feature/feature分支
  3. 提交代码
  4. 新建 Pull Request
Java
1
https://gitee.com/netkit/toolkit.git
git@gitee.com:netkit/toolkit.git
netkit
toolkit
通用工具箱
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891