|
@@ -9,10 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.fuzamei.constant.OperationType;
|
|
|
import com.fuzamei.entity.Token;
|
|
|
import com.fuzamei.entity.User;
|
|
|
import com.fuzamei.entity.UserDetail;
|
|
|
import com.fuzamei.mapperInterface.LoginMapper;
|
|
|
+import com.fuzamei.mapperInterface.UserMapper;
|
|
|
import com.fuzamei.service.LoginService;
|
|
|
import com.fuzamei.util.JSONUtil;
|
|
|
import com.fuzamei.util.blockchain.BlockChainUtil;
|
|
@@ -25,6 +28,8 @@ public class LoginServiceImpl implements LoginService{
|
|
|
private LoginMapper loginMapper;
|
|
|
@Autowired
|
|
|
private BlockChainUtil blockChainUtil;
|
|
|
+ @Autowired
|
|
|
+ private UserMapper userMapper;
|
|
|
@Override
|
|
|
public User queryUser(String username, String password) {
|
|
|
return loginMapper.queryUser(username,password);
|
|
@@ -62,6 +67,17 @@ public class LoginServiceImpl implements LoginService{
|
|
|
long uId = user.getUserId();
|
|
|
String publicKey = KeyUtils.getPublicKey(KeyUtils.getPrivateKey(password, random));
|
|
|
ProtobufBean protobufBean = ProtobufUtils.requestUserCreate(uId,publicKey);
|
|
|
+ //下面往【操作记录】表插入数据
|
|
|
+ Long currentTime = System.currentTimeMillis();//得到当前系统时间
|
|
|
+ String hash = String.valueOf(protobufBean.getInstructionId());
|
|
|
+ User pp=new User();
|
|
|
+ pp.setUserId(user.getUserId());//操作人(管理员)
|
|
|
+ pp.setOperationTypeId(OperationType.CREATE);//操作类型 (创建管理员)
|
|
|
+ pp.setUserIdb(user.getUserId());//这里是被操作人账号 (还是管理员)
|
|
|
+ pp.setOperationTime(currentTime);//操作时间
|
|
|
+ pp.setHash(hash);//操作hash
|
|
|
+ userMapper.insertOperationHistory(pp);//插入到操作记录表去
|
|
|
+ //丢区块链
|
|
|
String result = BlockChainUtil.sendPostParam(protobufBean);
|
|
|
boolean flag = BlockChainUtil.vilaResult(result);
|
|
|
if(!flag) throw new RuntimeException("区块链操作失败");
|