Search in sources :

Example 1 with DemoChecker

use of com.code.server.login.anotation.DemoChecker in project summer by foxsugar.

the class DemoAction method findCharges.

@DemoChecker
@RequestMapping("/findCharges")
public AgentResponse findCharges(int curPage) {
    if (curPage > 0) {
        curPage--;
    }
    Page<Charge> page = homeService.findCharges(new PageRequest(curPage, 20));
    List<DChargeAdminVo> list = new ArrayList<>();
    page.getContent().stream().forEach(x -> {
        DChargeAdminVo dChargeAdminVo = new DChargeAdminVo();
        BeanUtils.copyProperties(x, dChargeAdminVo);
        list.add(dChargeAdminVo);
    });
    Long count = homeService.chargesCount();
    AgentResponse agentResponse = new AgentResponse();
    Map<String, Object> rs = new HashMap<>();
    rs.put("list", list);
    rs.put("total", count);
    agentResponse.setData(rs);
    return agentResponse;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) DChargeAdminVo(com.code.server.login.vo.DChargeAdminVo) DemoChecker(com.code.server.login.anotation.DemoChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DemoChecker

use of com.code.server.login.anotation.DemoChecker in project summer by foxsugar.

the class DemoAction method getChargeRecord.

@DemoChecker
@RequestMapping("/partnerRecord")
public AgentResponse getChargeRecord(String time, int curPage, int userId) {
    if (curPage > 0) {
        curPage--;
    }
    if (curPage > 0) {
        curPage--;
    }
    String[] sA = null;
    if (time.contains(",")) {
        sA = time.split(",", 1000);
    }
    String start = sA[0];
    String end = sA[1];
    int agentId = (int) AgentUtil.getUserIdByToken(AgentUtil.findTokenInHeader());
    start = DateUtil.becomeStandardSTime(start);
    end = DateUtil.becomeStandardSTime(end);
    List<String> listA = DateUtil.getDateListIn(end, start);
    Sort sort = new Sort(Sort.Direction.DESC, "date");
    Page<AgentRecords> page = null;
    List<AgentRecords> agentRecordsList = null;
    if (agentId == 1) {
        page = homeService.findAllAgentRecords(userId, listA, new PageRequest(curPage, 20, sort));
        agentRecordsList = page.getContent();
    } else {
        page = homeService.findAllAgentRecords(agentId, listA, new PageRequest(curPage, 20, sort));
        agentRecordsList = page.getContent();
    }
    Map<String, Object> rs = new HashMap<>();
    rs.put("list", agentRecordsList);
    rs.put("count", page.getTotalElements());
    AgentResponse agentResponse = new AgentResponse();
    agentResponse.setData(rs);
    return agentResponse;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Sort(org.springframework.data.domain.Sort) DemoChecker(com.code.server.login.anotation.DemoChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DemoChecker

use of com.code.server.login.anotation.DemoChecker in project summer by foxsugar.

the class DemoAction method getLogByDates.

@DemoChecker
@RequestMapping("/getLogByDates")
public AgentResponse getLogByDates(int num) {
    LocalDate today = LocalDate.now();
    List<String> days = new ArrayList<>();
    for (int i = 0; i < num; i++) {
        LocalDate temp = today.minusDays(i + 1);
        days.add(temp.toString());
    }
    return new AgentResponse(0, logRecordDao.findByIdIn(days));
}
Also used : LocalDate(java.time.LocalDate) DemoChecker(com.code.server.login.anotation.DemoChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with DemoChecker

use of com.code.server.login.anotation.DemoChecker in project summer by foxsugar.

the class DemoAction method fetchDelegate.

@DemoChecker
@RequestMapping("/fetchDelegate")
public AgentResponse fetchDelegate(long userId) {
    if (userId == 0) {
        return fetchDelegates(1);
    }
    // GameAgent gameAgent = gameAgentDao.findOne(userId);
    GameAgent gameAgent = homeService.findOneDelegate(userId);
    List<GameAgentVo> list = new ArrayList<>();
    AgentResponse agentResponse = new AgentResponse();
    if (gameAgent == null) {
        agentResponse.setData(list);
        agentResponse.setCode(com.code.server.login.action.ErrorCode.ERROR);
        Map<String, Object> result = new HashMap<>();
        agentResponse.setMsg(" 没有记录 ");
        result.put("total", 0);
        result.put("list", list);
        agentResponse.setData(result);
    } else {
        GameAgentVo gameAgentVo = new GameAgentVo();
        // 手动设置上级代理id
        AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(userId);
        gameAgent.setParentId(agentBean.getParentId());
        BeanUtils.copyProperties(gameAgent, gameAgentVo);
        gameAgentVo.setIsPartnerDes(gameAgent.getIsPartner() == 1 ? "合伙人" : "代理");
        list.add(gameAgentVo);
        Map<String, Object> result = new HashMap<>();
        result.put("total", 1);
        result.put("list", list);
        agentResponse.setData(result);
    }
    return agentResponse;
}
Also used : AgentBean(com.code.server.constant.game.AgentBean) GameAgentVo(com.code.server.login.vo.GameAgentVo) DemoChecker(com.code.server.login.anotation.DemoChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with DemoChecker

use of com.code.server.login.anotation.DemoChecker in project summer by foxsugar.

the class DemoAction method fetchDelegates.

@DemoChecker
@RequestMapping("/fetchDelegates")
public AgentResponse fetchDelegates(int curPage) {
    if (curPage > 0) {
        curPage--;
    }
    int pageSize = 20;
    // Page<GameAgent> page = gameAgentDao.findAll(new PageRequest(curPage, pageSize));
    Page<GameAgent> page = homeService.findDelegates(new PageRequest(curPage, pageSize));
    List<GameAgent> list = page.getContent();
    List<GameAgentVo> voList = new ArrayList<>();
    for (GameAgent gameAgent : list) {
        GameAgentVo gameAgentVo = new GameAgentVo();
        BeanUtils.copyProperties(gameAgent, gameAgentVo);
        User user = userDao.findOne(gameAgent.getId());
        gameAgentVo.setName(user.getUsername());
        voList.add(gameAgentVo);
    }
    long count = homeService.delegatesCount();
    Map<String, Object> rs = new HashMap<>();
    rs.put("total", count);
    rs.put("list", voList);
    AgentResponse agentResponse = new AgentResponse();
    agentResponse.setData(rs);
    return agentResponse;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) GameAgentVo(com.code.server.login.vo.GameAgentVo) DemoChecker(com.code.server.login.anotation.DemoChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DemoChecker (com.code.server.login.anotation.DemoChecker)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 PageRequest (org.springframework.data.domain.PageRequest)8 LocalDate (java.time.LocalDate)5 GameAgentVo (com.code.server.login.vo.GameAgentVo)4 AgentBean (com.code.server.constant.game.AgentBean)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Sort (org.springframework.data.domain.Sort)2 UserBean (com.code.server.constant.game.UserBean)1 KafkaMsgKey (com.code.server.constant.kafka.KafkaMsgKey)1 ResponseVo (com.code.server.constant.response.ResponseVo)1 ChargeService (com.code.server.db.Service.ChargeService)1 UserService (com.code.server.db.Service.UserService)1 MsgProducer (com.code.server.kafka.MsgProducer)1 GameUserService (com.code.server.login.service.GameUserService)1 ConstantFormVo (com.code.server.login.vo.ConstantFormVo)1 DChargeAdminVo (com.code.server.login.vo.DChargeAdminVo)1 Page (org.springframework.data.domain.Page)1