Search in sources :

Example 1 with GameAgentVo

use of com.code.server.login.vo.GameAgentVo 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 2 with GameAgentVo

use of com.code.server.login.vo.GameAgentVo 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)

Example 3 with GameAgentVo

use of com.code.server.login.vo.GameAgentVo in project summer by foxsugar.

the class DemoAction method fetchPartner.

@DemoChecker
@RequestMapping("/fetchPartner")
public AgentResponse fetchPartner(long userId) {
    if (userId == 0) {
        return fetchPartners(1);
    }
    // GameAgent gameAgent = gameAgentDao.findOne(userId);
    GameAgent gameAgent = homeService.findOnePartner(userId);
    logger.info("==================================================");
    logger.info("userId is{}, game agent is{}", userId, gameAgent);
    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();
        BeanUtils.copyProperties(gameAgent, gameAgentVo);
        AgentUser agentUser = agentUserDao.findAgentUserByInvite_code(gameAgent.getId() + "");
        if (agentUser != null) {
            gameAgentVo.setPassword(agentUser.getPassword());
        }
        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 : GameAgentVo(com.code.server.login.vo.GameAgentVo) DemoChecker(com.code.server.login.anotation.DemoChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with GameAgentVo

use of com.code.server.login.vo.GameAgentVo in project summer by foxsugar.

the class DemoAction method fetchPartners.

@DemoChecker
@RequestMapping("/fetchPartners")
public AgentResponse fetchPartners(int curPage) {
    if (curPage > 0) {
        curPage--;
    }
    int pageSize = 20;
    Page<GameAgent> page = homeService.findPartner(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());
        AgentUser agentUser = agentUserDao.findAgentUserByUsername(gameAgent.getId() + "");
        System.out.println("agent user is " + agentUser);
        if (agentUser != null) {
            gameAgentVo.setPassword(agentUser.getPassword());
        }
        // gameAgentVo.setPassword(agentUser.getPassword());
        // gameAgentVo.setInvite_code(agentUser.getInvite_code());
        voList.add(gameAgentVo);
    }
    long count = homeService.partnerCount();
    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)4 GameAgentVo (com.code.server.login.vo.GameAgentVo)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 PageRequest (org.springframework.data.domain.PageRequest)2 AgentBean (com.code.server.constant.game.AgentBean)1