Search in sources :

Example 1 with SubscriptionFollower

use of com.topcom.cms.yuqing.domain.SubscriptionFollower in project topcom-cloud by 545314690.

the class SubscriptionFollowerController method scanFollower.

/**
 * 扫描用户列表,检测最后一个用户是否为添加的用户,如果不是继续检测,超时时间为60s
 * @param
 * @return
 */
@ApiOperation("添加关注")
@RequestMapping(value = "/scanFollower", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public SubscriptionFollower scanFollower(HttpServletRequest request, HttpServletResponse response, @ApiParam("wechatName") @RequestParam(required = true) String wechatName) {
    List<SubscriptionFollower> sFcontent = subscriptionFollowerManager.findByNickname(DEFAL_PAGEABLE, wechatName).getContent();
    if (sFcontent != null && sFcontent.size() > 0) {
        return sFcontent.get(0);
    }
    List<String> userList = wechatUtil.getUserList();
    String openId = userList.get(userList.size() - 1);
    SubscriptionFollower lastFollower = wechatUtil.getUserInfo(openId);
    if (lastFollower.getNickname().equals(wechatName)) {
        subscriptionFollowerManager.save(lastFollower);
        return lastFollower;
    }
    for (int i = 0; i < 5; i++) {
        try {
            Thread.sleep(20000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        userList = wechatUtil.getUserList(openId);
        if (userList != null && userList.size() > 0) {
            for (String s : userList) {
                SubscriptionFollower follower = wechatUtil.getUserInfo(s);
                if (follower.getNickname().equals(wechatName)) {
                    subscriptionFollowerManager.save(follower);
                    return follower;
                }
            }
        } else
            continue;
    }
    SubscriptionFollower timeOut = new SubscriptionFollower();
    timeOut.setRemark("time out");
    return timeOut;
}
Also used : SubscriptionFollower(com.topcom.cms.yuqing.domain.SubscriptionFollower) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with SubscriptionFollower

use of com.topcom.cms.yuqing.domain.SubscriptionFollower in project topcom-cloud by 545314690.

the class ScanWechatJob method updateFollowerinfo.

private boolean updateFollowerinfo(List<String> userList) {
    if (userList == null || userList.size() == 0) {
        return false;
    }
    Map<String, Long> openidAndId = new HashMap<>();
    for (int i = 0; i < allFollower.size(); i++) {
        openidAndId.put(allFollower.get(i).getOpenid(), allFollower.get(i).getId());
    }
    for (int i = 0; i < userList.size(); i++) {
        String openid = userList.get(i);
        SubscriptionFollower userInfo = wechatUtil.getUserInfo(openid);
        if (userInfo == null) {
            continue;
        }
        if (openidAndId.keySet().contains(openid)) {
            userInfo.setId(openidAndId.get(openid));
            subscriptionFollowerManager.delete(userInfo.getId());
        }
        subscriptionFollowerManager.save(userInfo);
    }
    return true;
}
Also used : SubscriptionFollower(com.topcom.cms.yuqing.domain.SubscriptionFollower)

Example 3 with SubscriptionFollower

use of com.topcom.cms.yuqing.domain.SubscriptionFollower in project topcom-cloud by 545314690.

the class WechatUtil method main.

public static void main(String[] args) {
    JSONObject result1 = new JSONObject();
    result1.put("value", "北京发生13级地震目前无人生还");
    result1.put("color", "#173177");
    JSONObject result2 = new JSONObject();
    result2.put("value", "上海发生19级地震目前无人生还");
    result2.put("color", "#666666");
    JSONObject result3 = new JSONObject();
    result1.put("value", "西安发生27级地震目前无人生还");
    result1.put("color", "#888888");
    JSONObject name = new JSONObject();
    name.put("value", "boos");
    name.put("color", "#888888");
    JSONObject num = new JSONObject();
    num.put("value", "11231");
    num.put("color", "#111111");
    JSONObject data = new JSONObject();
    data.put("result1", result1);
    data.put("result2", result2);
    data.put("result", result3);
    data.put("name", name);
    data.put("num", num);
    JSONObject param = new JSONObject();
    param.put("data", data);
    param.put("touser", "ozC850c9D3CCDlkd017cEP62xYWw");
    param.put("template_id", "N_sOGso5v-NU7esOVO2iU9lGsvWooiz7MbJ4IQmHE5w");
    param.put("url", "http://tcbds.xicp.io:8090/yuqing/module/login.html");
    WechatUtil wechatUtil = new WechatUtil();
    wechatUtil.sendTemplate(param);
    List<String> userList = wechatUtil.getUserList();
    SubscriptionFollower subscriptionFollower = wechatUtil.getUserInfo(userList.get(0));
    System.out.println(subscriptionFollower);
}
Also used : SubscriptionFollower(com.topcom.cms.yuqing.domain.SubscriptionFollower) JSONObject(net.sf.json.JSONObject)

Example 4 with SubscriptionFollower

use of com.topcom.cms.yuqing.domain.SubscriptionFollower in project topcom-cloud by 545314690.

the class SubscriptionFollowerController method findByNickname.

@ApiOperation("findByNickname")
@RequestMapping(value = "/findByNickname", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public Page<SubscriptionFollower> findByNickname(HttpServletRequest request, HttpServletResponse response, @ApiParam("Nickname") @RequestParam(required = true) String Nickname) {
    Pageable pageable = new PageRequest(0, 10);
    Page<SubscriptionFollower> page = subscriptionFollowerManager.findByNickname(pageable, Nickname);
    return page;
}
Also used : SubscriptionFollower(com.topcom.cms.yuqing.domain.SubscriptionFollower) PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with SubscriptionFollower

use of com.topcom.cms.yuqing.domain.SubscriptionFollower in project topcom-cloud by 545314690.

the class SubscriptionFollowerManagerImpl method save.

@Override
public List<SubscriptionFollower> save(Iterable<SubscriptionFollower> entities) {
    for (SubscriptionFollower entity : entities) {
        List<SubscriptionFollower> byOpenid = this.findByOpenid(entity.getOpenid());
        this.deleteInBatch(byOpenid);
    }
    return super.save(entities);
}
Also used : SubscriptionFollower(com.topcom.cms.yuqing.domain.SubscriptionFollower)

Aggregations

SubscriptionFollower (com.topcom.cms.yuqing.domain.SubscriptionFollower)6 ApiOperation (io.swagger.annotations.ApiOperation)2 JSONObject (net.sf.json.JSONObject)2 HashMap (java.util.HashMap)1 PageRequest (org.springframework.data.domain.PageRequest)1 Pageable (org.springframework.data.domain.Pageable)1