查看: 6906|回复: 3

搭建自定义工程及开发-获取不到用户信息

升级   0.04%

32

主题

54

回帖

4

积分

注册会员

Rank: 2

积分
4
发表于 2021-11-29 01:47:36 | 显示全部楼层 |阅读模式

背景:因为现有接口企业微信的考勤数据只有管理员账户可以调用,只好自己弄一个,获取当前用户的企业微信考勤。
参考:https://www.yuque.com/o2oa/course/tuef8c
版本:6.4.4
问题:当前用户信息一直是Anonymous
相关代码:
JaxrsServicePathFilter.java 中设置了需要登陆才能访问


@WebFilter(urlPatterns = { "/servlet/*", "/jaxrs/qywxAttendance/*", }, asyncSupported = true)
public class JaxrsServicePathFilter extends CipherManagerUserJaxrsFilter {
}



Action 类中 定义了        EffectivePerson effectivePerson = this.effectivePerson(request);


@Path("expand/qywxAttendance")
@JaxrsDescribe("企业微信考勤")
public class QywxAttendanceDetailAction extends StandardJaxrsAction {

    private static Logger logger = LoggerFactory.getLogger(QywxAttendanceDetailAction.class);

    @JaxrsMethodDescribe(value = "列示当前用户/指定用户的企业微信打卡记录,分页..", action = ActionListPaging.class)
    @POST
    @Path("list/paging/{page}/size/{size}")
    @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
    @Consumes(MediaType.APPLICATION_JSON)
    public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
            @JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
            @JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size, JsonElement jsonElement) {
        ActionResult<List<ActionListPaging.Wo>> result = new ActionResult<>();
        EffectivePerson effectivePerson = this.effectivePerson(request);
        System.out.println(this.effectivePerson(request).toString());
        try {
            result = new ActionListPaging().execute(effectivePerson, page, size, jsonElement);
        } catch (Exception e) {
            logger.error(e, effectivePerson, request, jsonElement);
            result.error(e);
        }
        asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
    }
}


通过System.out.println(this.effectivePerson(request).toString()); 输出后,结果如下


理论上来说,必须要登陆才能访问,用户信息肯定是有的,就是不知道没获取到


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

升级   0.02%

0

主题

38

回帖

2

积分

注册会员

Rank: 2

积分
2
发表于 2021-11-29 10:22:11 | 显示全部楼层
您web上访问这个服务的时候,可以f12先看一下,是否有x-token。
或者说,您从哪里触发的这个服务的打印?

从现在的截图上看,现在访问服务是没有用户登录的情况。
回复

使用道具 举报

升级   0.04%

32

主题

54

回帖

4

积分

注册会员

Rank: 2

积分
4
发表于 2021-11-29 14:55:23 | 显示全部楼层
找到问题了,JaxrsServicePathFilter.java 中的路径和action文件的路径不一致导致的
回复

使用道具 举报

升级   100%

139

主题

1万

回帖

4万

积分

超级版主

Rank: 8Rank: 8

积分
41458
发表于 2021-11-29 15:09:48 | 显示全部楼层
xuannan 发表于 2021-11-29 14:55
找到问题了,JaxrsServicePathFilter.java 中的路径和action文件的路径不一致导致的

回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

联系客服 关注微信 下载APP 返回顶部 返回列表
viewthread