Commit 9e9f18b4 by wnb0128

车家智能数据服务 用户数据处理--think.wang

1 parent ec98dbdc
package com.glsx.smart.controller;
import cn.hutool.crypto.digest.MD5;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.MD5Utils;
import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.glsx.smart.constant.Constants;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.service.SmartUserRelationService;
import lombok.extern.slf4j.Slf4j;
......@@ -69,6 +68,8 @@ public class UserRelationController {
request.setChannel(userRelation.getChannel()); //涂鸦
SmartUserRelation user = userRelationService.getSingle(request);
request.setUserId(userRelation.getUserId());
String password = MD5Utils.md5Hex(request.getPhone(), "utf-8");
request.setPassword(password);
if(user != null){
String tuYaId = user.getThirdId();
if(StringUtils.isEmpty(tuYaId)){
......@@ -81,9 +82,8 @@ public class UserRelationController {
userRelationService.updateByPrimaryKeySelective(request);
return R.ok().data(tuYaId);
}
String password = MD5.create().digestHex(Constants.DEFAULT_PASSWORD);
// String password = MD5.create().digestHex(Constants.DEFAULT_PASSWORD);
request.setCreateTime(new Date());
request.setPassword(password);
if(request.getChannel() == 1){ //渠道为涂鸦
String tuYaId = this.syncUser(request.getPhone(), password);
request.setThirdId(tuYaId);
......
......@@ -7,6 +7,7 @@ import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.SmartUserRelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......@@ -22,22 +23,22 @@ import java.util.List;
@Service
public class SmartUserRelationServiceImpl implements SmartUserRelationService {
@Resource
private SmartUserRelationMapper smartUserRelationMapper;
private SmartUserRelationMapper relationMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return smartUserRelationMapper.deleteByPrimaryKey(id);
return relationMapper.deleteByPrimaryKey(id);
}
@Override
public int insertOrUpdate(SmartUserRelation userRelation) {
if (userRelation.getId() == null) {
return smartUserRelationMapper.insertSelective(userRelation);
return relationMapper.insertSelective(userRelation);
} else {
SmartUserRelation record = smartUserRelationMapper.selectByPrimaryKey(
SmartUserRelation record = relationMapper.selectByPrimaryKey(
userRelation.getId());
if (record != null) {
return smartUserRelationMapper.updateByPrimaryKeySelective(userRelation);
return relationMapper.updateByPrimaryKeySelective(userRelation);
} else {
throw new BusinessException(ResultEnum.ID_NOT_FOUND);
}
......@@ -45,34 +46,44 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
}
@Override
@Transactional
public Long insertSelective(SmartUserRelation record) {
int i = smartUserRelationMapper.insertSelective(record);
return i > 0 ? record.getId() : 0L;
SmartUserRelation request = new SmartUserRelation();
request.setPhone(record.getPhone());
request.setChannel(record.getChannel()); //涂鸦
SmartUserRelation user = relationMapper.getSingle(request);
if(user != null && user.getId() > 0L){
record.setId(user.getId());
relationMapper.updateByPrimaryKeySelective(record);
} else{
relationMapper.insertSelective(record);
}
return record.getId();
}
@Override
public SmartUserRelation getSingle(SmartUserRelation record) {
return smartUserRelationMapper.getSingle(record);
return relationMapper.getSingle(record);
}
@Override
public SmartUserRelation selectByPrimaryKey(Long id) {
return smartUserRelationMapper.selectByPrimaryKey(id);
return relationMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(SmartUserRelation record) {
return smartUserRelationMapper.updateByPrimaryKeySelective(record);
return relationMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateBatchSelective(List<SmartUserRelation> list) {
return smartUserRelationMapper.updateBatchSelective(list);
return relationMapper.updateBatchSelective(list);
}
@Override
public int batchInsert(List<SmartUserRelation> list) {
return smartUserRelationMapper.batchInsert(list);
return relationMapper.batchInsert(list);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!