发表于: 2017-12-19 21:47:57

1 538


一.今天完成的主要事情

1.编写查询提现订单列表接口

接口代码如下

@RequestMapping(value = "/a/u/withdrawal/list", method = RequestMethod.GET)

    public String getWithdrawalList(HttpServletRequest request, HttpServletResponse response, ModelMap model, Integer page,

                                    Integer size, Long schoolId, Long startTime, Long endTime, Integer status) throws Exception {

        log.info("Interface GET /a/u/withdrawal/list, Method getWithdrawalList() parameters, schoolId: " + schoolId +

                ", startTime: " + startTime + ", endTime: " + endTime + ", status: " + status);

        if (page == null) {

            page = 1;

        }

        if (size == null) {

            size = 10;

        }

        int start = (page - 1) * size;

        if (start < 0) {

            start = 0;

        }

        log.info("pageList is : page : " + page + ", size :" + start);

        //校验参数

        if (DataUtils.isNotNullOrEmpty(status) && (status < 0 || status > 2)) {

            log.info("Error value of parameter status, status is : " + status);

            model.addAttribute("code", -1001);

            return "/common/failure";

        }

        //业务逻辑实现

        try {

            Map<String, Object> queryWithdrawMap = DynamicUtil.getWithdrawListParams(startTime, endTime, schoolId, status, false);

            log.info("query withdraw map : " + queryWithdrawMap);

            List<Long> withdrawIdList = withdrawService.getIdsByDynamicCondition(Withdraw.class,

                    queryWithdrawMap, start, size);

            log.info("get withdraw Id list, list size is : " + withdrawIdList.size());

            List<Withdraw> withdrawList = null;

            Long total = 0L;

            if (CollectionUtils.isNotEmpty(withdrawIdList)) {

                withdrawList = withdrawService.getObjectsByIds(withdrawIdList);

                log.info("get withdraw list, list size is : " + withdrawList.size());

                Map<String, Object> countWithdrawMap = DynamicUtil.getWithdrawListParams(startTime,

                        endTime, schoolId, status, true);

                log.info("count withdraw map : " + countWithdrawMap);

                total = withdrawService.getIdsByDynamicCondition(Withdraw.class, countWithdrawMap,

                        0, Integer.MAX_VALUE).get(0);

                log.info("get withdraw list total is : " + total);

            }

            model.addAttribute("code", 0);

            model.addAttribute("size", size);

            model.addAttribute("total", total);

            model.addAttribute("withdrawList", withdrawList);

            return "/yi-nucleus-service/withdraw/json/withdrawListJson";

        } catch (Throwable t) {

            log.error(t.getMessage());

            log.error("Method getWithdrawalList() failed, page is : " + page + " size is : " + size);

            model.addAttribute("code", -1);

            return "/common/failure";

        }

    }


2.编写查询结算列表接口

@RequestMapping(value = "/a/u/settlement/list", method = RequestMethod.GET)

    public String getSettlementList(HttpServletRequest request, HttpServletResponse response, ModelMap model, Integer page,

                                    Integer size, Long schoolId, Long startTime, Long endTime, Integer status, Integer type) throws Exception {

        //打印并设置page,size参数

        log.info("Interface GET /a/u/settlement/list, Method getSettlementList() parameters, schoolId: " + schoolId +

                 ", startTime: " + startTime + ", endTime: " + endTime + ", status: " + status + ", type: " + type);

        if (page == null){

            page = 1;

        }

        if (size == null){

            size = 10;

        }

        int start = (page - 1) * size;

        if (start < 0 ){

            start = 0;

        }

        log.info("pageList : page= " + start + " , size=" + size);

        //参数校验

        if (DataUtils.isNullOrEmpty(type)){

            log.info("Parameter type can not be null, type = " + type);

            model.addAttribute("code", -1000);

            return "/common/failure";

        }

        if (type < 0 || type > 2){

            log.info("Error value of parameter type, type is : " + type);

            model.addAttribute("code", -1001);

            return "/common/failure";

        }

        if (type == 0 && DataUtils.isNullOrEmpty(schoolId)){

            log.info("Paramenter schoolId can not be null when type=0, schoolId = " + schoolId);

            model.addAttribute("code", -1001);

            return "/common/failure";

        }

        if (DataUtils.isNotNullOrEmpty(status) && (status <0 || status>2)){

            log.info("Error value of parameter status, status is : " + status);

            model.addAttribute("code", -1001);

            return "/common/failure";

        }

        //业务逻辑

        try{

            Map<String, Object> querySettlementMap = DynamicUtil.getSettlementListParams(schoolId, startTime, endTime, status, type, false);

            log.info("map : " + querySettlementMap);

            List<Long> settlementIdList = settlementService.getIdsByDynamicCondition(Settlement.class, querySettlementMap, start, size);

            log.info("get settlement Id list, list size is : " + settlementIdList.size());

            List<Settlement> settlementList = null;

            Integer total = 0;

            if (CollectionUtils.isNotEmpty(settlementIdList)){

                settlementList = settlementService.getObjectsByIds(settlementIdList);

                log.info("get settlement list by ids, list size is : " + settlementList.size());

                Map<String, Object> countSettlementMap = DynamicUtil.getSettlementListParams(schoolId, startTime, endTime, status, type, true);

                total = settlementService.getIdsByDynamicCondition(Settlement.class, countSettlementMap, 0, Integer.MAX_VALUE).size();

                log.info("count settlement list total size is : " + total);

            }

            model.addAttribute("code", 0);

            model.addAttribute("settlementList", settlementList);

            model.addAttribute("total", total);

            model.addAttribute("size", size);

            return "/yi-nucleus-service/settlement/json/settlementListJson";

        } catch (Throwable t){

            log.error(t.getMessage());

            log.error("Method getSettlementList() failed, page is: " + page + ", size is: " + size);

            model.addAttribute("code", -1);

            return "/common/failure";

        }

    }


整体思路都是先打印入参,确定page和size参数,校验入参,最后实现业务逻辑

总结自己写的代码,还存在代码冗余的问题,目前是先实现功能,因为进度正常,后续再重构优化代码,尽量精简代码

3.和前端腾飞不断持续的集成

目前项目中这个页面已经可以进行端到端的测试

二.明天计划完成的主要事情

按部就班的完成自己负责的模块的部分,并且和前端持续集成


三.遇到的问题

暂无


四.收获

终于体验了一把前后端持续集成的感觉


五,项目进度情况

暂无延期风险


返回列表 返回列表
评论

    分享到