1 Star 1 Fork 0

netkit / 通用工具箱

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

Toolkit

introduction

  • util:
    • bean copier util
    • json serializer util
  • common interface
    • cache key interface: CacheKeyAble
    • bean copier interface: Convertible
    • map interface: Mappable
    • response code interface: ResponseCode
  • common exception
    • response exception: ResponseException
    • business exception: ServiceException
    • validate exception: ValidateException
  • common response bean
    • api response: ApiResponse
    • pagination bean: PageList

usage

1.add maven dependency
<dependency>
    <groupId>top.netkit</groupId>
    <artifactId>toolkit</artifactId>
    <version>1.0.2</version>
</dependency>
2. use the package

(1)bean copier util

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 util

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);
    }
}

Contribution

  1. Fork the repository
  2. Create feature/featureName branch
  3. Commit your code
  4. Create Pull Request
Java
1
https://gitee.com/netkit/toolkit.git
git@gitee.com:netkit/toolkit.git
netkit
toolkit
通用工具箱
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891