Commit 266e8f0c authored by 李健华's avatar 李健华

添加微信绑定相关查询接口

parent 0b584202
......@@ -6,6 +6,7 @@ import cn.quantgroup.xyqb.entity.Merchant;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.model.AuthBean;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.LoginProperties;
import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;
import cn.quantgroup.xyqb.service.merchant.IMerchantService;
......@@ -25,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
......@@ -447,4 +449,23 @@ public class WeChatController implements IBaseController {
}
@RequestMapping("/userIdToUnionId")
public JsonResult userIdToUnionId(@RequestParam Long userId) {
List<WechatUserInfo> wechatUserInfoList = null;
if (userId != null && userId > 0) {
wechatUserInfoList = wechatService.queryListByUserId(userId);
}
return JsonResult.buildSuccessResult("通过用户ID查询的绑定微信相关信息", wechatUserInfoList);
}
@RequestMapping("/unionIdToUserId")
public JsonResult unionIdToUserId(@RequestParam String unionId) {
List<WechatUserInfo> wechatUserInfoList = null;
if (unionId != null && !"".equals(unionId)) {
wechatUserInfoList = wechatService.queryListByUnionId(unionId);
}
return JsonResult.buildSuccessResult("通过unionId查询的绑定微信相关信息", wechatUserInfoList);
}
}
......@@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import static org.springframework.transaction.annotation.Propagation.MANDATORY;
/**
......@@ -88,4 +90,14 @@ public interface IWeChatUserRepository extends JpaRepository<WechatUserInfo, Lon
@Transactional
void deleteByUserId(Long userId);
/**
* 通过userId查询相关绑定微信记录
*/
List<WechatUserInfo> findByUserId(Long userId);
/**
* 通过unionId查询相关绑定微信记录
*/
List<WechatUserInfo> findByUnionId(String unionId);
}
......@@ -3,6 +3,8 @@ package cn.quantgroup.xyqb.service.wechat;
import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;
import java.util.List;
/**
* Created by Miraculous on 2017/1/19.
*/
......@@ -47,4 +49,8 @@ public interface IWechatService {
* @return 禁用结果
*/
int forbiddenXyqbAndWuxiUserByUserId(Long userId);
List<WechatUserInfo> queryListByUserId(Long userId);
List<WechatUserInfo> queryListByUnionId(String unionId);
}
......@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
......@@ -251,4 +252,14 @@ public class WechatServiceImpl implements IWechatService {
public int forbiddenXyqbAndWuxiUserByUserId(Long userId) {
return weChatUserRepository.forbiddenXyqbAndWuxiUserByUserId(userId);
}
@Override
public List<WechatUserInfo> queryListByUserId(Long userId) {
return weChatUserRepository.findByUserId(userId);
}
@Override
public List<WechatUserInfo> queryListByUnionId(String unionId) {
return weChatUserRepository.findByUnionId(unionId);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment