提交修改
This commit is contained in:
parent
e7a6ce70fa
commit
a31991fb0c
@ -51,4 +51,8 @@ public interface VvBuyerDao extends BaseMapper<VvBuyerEntity> {
|
|||||||
|
|
||||||
@LIMIT
|
@LIMIT
|
||||||
VvBuyerEntity selectVvBuyerIsTestById(Long id, Integer isTest);
|
VvBuyerEntity selectVvBuyerIsTestById(Long id, Integer isTest);
|
||||||
|
|
||||||
|
|
||||||
|
@LIMIT
|
||||||
|
VvBuyerEntity selectVvBuyerInfo(String buyerName, String buyerWeixin, String buyerPhone);
|
||||||
}
|
}
|
||||||
@ -5,7 +5,6 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class BuyerDTO {
|
public class BuyerDTO {
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 买家id
|
* 买家id
|
||||||
*/
|
*/
|
||||||
@ -16,4 +15,16 @@ public class BuyerDTO {
|
|||||||
* 买家名称
|
* 买家名称
|
||||||
*/
|
*/
|
||||||
private String buyerName;
|
private String buyerName;
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 是否是测试用户
|
||||||
|
*/
|
||||||
|
private Integer flag;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* token
|
||||||
|
*/
|
||||||
|
private String token ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.heyu.api.data.utils;
|
||||||
|
|
||||||
|
public class TokenUtils {
|
||||||
|
|
||||||
|
|
||||||
|
public static String generateToken(Long id) {
|
||||||
|
return MD5Utils.encode(System.currentTimeMillis() + "" + id );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(generateToken(1L));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.heyu.api.alibaba.request.mm;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class VvAppLoginRequest {
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 买家id,当前登录的买家id
|
||||||
|
*/
|
||||||
|
private Long buyerId ;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 目标买家信息 ,如 buyer_name, buyer_weixin, buyer_phone
|
||||||
|
*/
|
||||||
|
private String targetBuyer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.heyu.api.controller.vv;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.heyu.api.alibaba.request.mm.VvAppLoginRequest;
|
||||||
|
import com.heyu.api.data.dao.vv.VvBuyerDao;
|
||||||
|
import com.heyu.api.data.dto.BuyerDTO;
|
||||||
|
import com.heyu.api.data.entity.vv.VvBuyerEntity;
|
||||||
|
import com.heyu.api.data.utils.R;
|
||||||
|
import com.heyu.api.data.utils.RedisUtils;
|
||||||
|
import com.heyu.api.data.utils.TokenUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/target")
|
||||||
|
public class AppLoginController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VvBuyerDao vvBuyerDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisUtils redisUtils;
|
||||||
|
|
||||||
|
// http://localhost:8888/app/target/login
|
||||||
|
@RequestMapping("/login")
|
||||||
|
public R login(@RequestBody VvAppLoginRequest request) {
|
||||||
|
VvBuyerEntity vvBuyerEntity = vvBuyerDao.selectVvBuyerIsTestById(request.getBuyerId(), 1);
|
||||||
|
if (vvBuyerEntity == null) {
|
||||||
|
return R.error("你不是内部用户");
|
||||||
|
}
|
||||||
|
VvBuyerEntity target = vvBuyerDao.selectVvBuyerInfo(request.getTargetBuyer(),
|
||||||
|
request.getTargetBuyer(),
|
||||||
|
request.getTargetBuyer());
|
||||||
|
|
||||||
|
BuyerDTO buyerDTO = new BuyerDTO();
|
||||||
|
buyerDTO.setBuyerId(target.getId());
|
||||||
|
buyerDTO.setBuyerName(target.getBuyerName());
|
||||||
|
buyerDTO.setFlag(target.getIsTest());
|
||||||
|
String token = TokenUtils.generateToken(target.getId());
|
||||||
|
buyerDTO.setToken(token);
|
||||||
|
// 默认24 小时
|
||||||
|
redisUtils.set(token, JSON.toJSON(buyerDTO), RedisUtils.DEFAULT_EXPIRE);
|
||||||
|
return R.ok().put("buyer", buyerDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user