Commit 9e9f18b4 by wnb0128

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

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