Search in sources :

Example 91 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project summer by foxsugar.

the class DelegateRelataionAction method fetchPlayers.

@AuthChecker
@RequestMapping("/fetchPlayers")
public AgentResponse fetchPlayers() {
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    long agentId = AgentUtil.getAgentByRequest(request);
    List<OneLevelInfoVo> levelInfoVoList = delegateRelataionService.fetchSelfPlayerList(agentId);
    Map<String, Object> result = new HashMap<>();
    result.put("result", levelInfoVoList);
    AgentResponse agentResponse = new AgentResponse(200, result);
    return agentResponse;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) OneLevelInfoVo(com.code.server.login.vo.OneLevelInfoVo) HashMap(java.util.HashMap) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) AuthChecker(com.code.server.login.anotation.AuthChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 92 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project summer by foxsugar.

the class DelegateRelataionAction method fetchOneLevelDelegate.

@AuthChecker
@RequestMapping("/fetch2Delegate")
public AgentResponse fetchOneLevelDelegate() {
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    long agentId = AgentUtil.getAgentByRequest(request);
    List<TwoLevelInfoVo> list = delegateRelataionService.fetchTwoLevelDelegateList(agentId);
    Map<String, Object> result = new HashMap<>();
    result.put("result", list);
    AgentResponse agentResponse = new AgentResponse(200, result);
    return agentResponse;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HashMap(java.util.HashMap) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) TwoLevelInfoVo(com.code.server.login.vo.TwoLevelInfoVo) AuthChecker(com.code.server.login.anotation.AuthChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 93 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project summer by foxsugar.

the class RecommendDelegateAction method bindDelegate.

@AuthChecker
@RequestMapping("/bindDelegate")
public AgentResponse bindDelegate(long userId) {
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    long agentId = AgentUtil.getAgentByRequest(request);
    boolean ret = recommendDelegateService.bindDelegate(userId, agentId);
    Map<String, Object> result = new HashMap<>();
    AgentResponse agentResponse = null;
    if (ret) {
        result.put("msg", "绑定失败");
        agentResponse = new AgentResponse(500, result);
    } else {
        result.put("msg", "绑定成功");
        agentResponse = new AgentResponse(200, result);
    }
    return agentResponse;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HashMap(java.util.HashMap) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) AuthChecker(com.code.server.login.anotation.AuthChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 94 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project summer by foxsugar.

the class RecommendDelegateAction method findUser.

@AuthChecker
@RequestMapping("/findUser")
public AgentResponse findUser(long userId) {
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    long agentId = AgentUtil.getAgentByRequest(request);
    RecommandUserVo vo = recommendDelegateService.findRecommandUser(userId, agentId);
    Map<String, Object> result = new HashMap<>();
    result.put("result", vo);
    AgentResponse agentResponse = new AgentResponse(200, result);
    return agentResponse;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RecommandUserVo(com.code.server.login.vo.RecommandUserVo) HashMap(java.util.HashMap) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) AuthChecker(com.code.server.login.anotation.AuthChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 95 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project summer by foxsugar.

the class TodayChargeAction method waterRecord.

@AuthChecker
// 流水记录
@RequestMapping("/waterRecord")
public AgentResponse waterRecord() {
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    long agentId = AgentUtil.getAgentByRequest(request);
    List<WaterRecordVo> waterRecordVoList = todayChargeService.waterRecords(agentId);
    AgentResponse agentResponse = new AgentResponse(200, waterRecordVoList);
    return agentResponse;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) AuthChecker(com.code.server.login.anotation.AuthChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)204 HttpServletRequest (javax.servlet.http.HttpServletRequest)92 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)62 RequestAttributes (org.springframework.web.context.request.RequestAttributes)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)32 Test (org.junit.jupiter.api.Test)28 lombok.val (lombok.val)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)22 Test (org.junit.Test)18 AuthChecker (com.code.server.login.anotation.AuthChecker)17 HttpSession (javax.servlet.http.HttpSession)12 Before (org.junit.Before)12 HashMap (java.util.HashMap)11 Method (java.lang.reflect.Method)8 Date (java.util.Date)7 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)7 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)7 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)6 Map (java.util.Map)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6