天鳥技術中臺-建設過程-日常經驗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日

北京

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章