|
|
|
@ -8,10 +8,10 @@ import com.bsd.say.entities.Record;
|
|
|
|
|
import com.bsd.say.entities.Users;
|
|
|
|
|
import com.bsd.say.mapper.RecordMapper;
|
|
|
|
|
import com.bsd.say.mapper.UsersMapper;
|
|
|
|
|
import com.bsd.say.service.RedisService;
|
|
|
|
|
import com.bsd.say.service.UsersService;
|
|
|
|
|
import com.bsd.say.util.HttpRequestUtils;
|
|
|
|
|
import com.bsd.say.util.MD5Utils;
|
|
|
|
|
import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
@ -28,6 +28,8 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
|
@Service("usersService")
|
|
|
|
|
@Transactional
|
|
|
|
|
public class UsersServiceImpl extends BaseServiceImpl<UsersMapper, Users> implements UsersService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
@Value("${bsd.tokenkey}")
|
|
|
|
@ -44,6 +46,10 @@ public class UsersServiceImpl extends BaseServiceImpl<UsersMapper,Users> impleme
|
|
|
|
|
private WeixinService weixinService;
|
|
|
|
|
@Resource
|
|
|
|
|
private RecordMapper recordMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private RedisService redisService;
|
|
|
|
|
static final String RECORD_PREFIX = "BSD_RECORD_";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public UsersMapper getBaseMapper() {
|
|
|
|
@ -52,6 +58,7 @@ public class UsersServiceImpl extends BaseServiceImpl<UsersMapper,Users> impleme
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 发送验证码
|
|
|
|
|
*
|
|
|
|
|
* @param ajaxRequest
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -127,11 +134,13 @@ public class UsersServiceImpl extends BaseServiceImpl<UsersMapper,Users> impleme
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过openId获取record中的name 和 phone
|
|
|
|
|
*
|
|
|
|
|
* @param ajaxRequest
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult getUserInfoByOpenId(AjaxRequest ajaxRequest) {
|
|
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
|
if (data == null) {
|
|
|
|
@ -140,6 +149,13 @@ public class UsersServiceImpl extends BaseServiceImpl<UsersMapper,Users> impleme
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
} else {
|
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
|
if (redisService.exists(RECORD_PREFIX + openId)) {
|
|
|
|
|
|
|
|
|
|
String userInfoStr = redisService.get(RECORD_PREFIX + openId).toString();
|
|
|
|
|
ajaxResult.setData(JSONObject.parseObject(userInfoStr));
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(openId)) {
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("openId missing");
|
|
|
|
@ -152,10 +168,12 @@ public class UsersServiceImpl extends BaseServiceImpl<UsersMapper,Users> impleme
|
|
|
|
|
userInfo.put("name", record.getName());
|
|
|
|
|
userInfo.put("phone", record.getPhone());
|
|
|
|
|
}
|
|
|
|
|
redisService.set(RECORD_PREFIX + openId, userInfo.toJSONString());
|
|
|
|
|
ajaxResult.setData(userInfo);
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|