天鸟技术中台-建设过程-日常经验4:接口抽象和标准约定

public interface Service {

    //----------------query-------------------//

    RpcResult<Page<Vo>> listPage(Query query);

    RpcResult<List<Vo>> list(Query query);

    RpcResult<Vo> findById(JtnQuery query);

     

    RpcResult<List<Vo>> findByIdList(List<Integer> idList);

    //----------------update-------------------//

    RpcResult<Integer> save(Update update);

        

    RpcResult<Integer> add(Create create);

    RpcResult<Boolean> updateById(Update update);

    RpcResult<Boolean> removeById(Integer id);

     

    RpcResult<Boolean> removeById(JtnRemove remove);

     

     

}

1、list, 多个。list不分页,list分页。

2、find,精确查找。一般是根据 id 或 idList。

3、save,保存,add和updateById 适配

4、add添加,updatById,更新

5、removeById,根据id删除

特别需要说明,根据id查找和 根据id删除。

这2个功能,本身 只需要 id一个参数,但是为了 满足所有情况,做了抽象封装。

@Data

public class JtnQuery {

    //主键id

    private Integer id;

    //应用id

    private Integer appId;

    //是否查询关联字段

    private Integer relationFieldYn;

    //批量查询

    private List<Integer> idList;

}

@Data

public class JtnRemove {

    // 主键id

    private Integer id;

    // 应用id

    private Integer appId;

    //批量删除

    private List<Integer> idList;

     

    // 是否删除关联字段,删除PostCategory时,级联逻辑删除Post(暂不实现)

    private Integer relationFieldYn;

}

天鸟技术/FansUnion/雷哥

2019年11月16日

北京

发布了1318 篇原创文章 · 获赞 2522 · 访问量 340万+

猜你喜欢

转载自blog.csdn.net/FansUnion/article/details/103101401