Commit 7c1d0eeb by fz

1.添加主钥匙,分享钥匙批量上报指令日志接口

1 parent 0c1a6d49
package com.glsx.smart.controller;
import com.glsx.cloudframework.core.util.Assert;
import com.glsx.plat.core.web.R;
import com.glsx.smart.pojo.request.*;
import com.glsx.smart.service.AiLockingKeyService;
......@@ -94,6 +95,12 @@ public class AiLockingkeyController {
return aiLockingKeyService.LogLockingKeyCommand(request);
}
//车钥匙操作指令批量上报
@PostMapping(value = "/batchLogCommand")
public R batchLogCommand(@RequestBody SmartCarKeyActionLogBatchRequest request) {
return aiLockingKeyService.batchLogCommand(request);
}
//车钥匙修改昵称
@PostMapping(value = "/setName")
public R setLockingKeyName(@RequestBody SmartCarKeyNameRequest request) {
......
......@@ -44,6 +44,12 @@ public class AiLockingkeyShareController {
return aiLockingKeyShareService.logShareLockingKeyCommand(request);
}
//车钥匙操作指令批量上报
@PostMapping(value = "/batchLogCommand")
public R batchLogCommand(@RequestBody SmartCarKeyShareActionLogBatchRequest request) {
return aiLockingKeyShareService.batchLogCommand(request);
}
//获取分享的钥匙信息
@GetMapping(value = "/getKey")
public R getShareLockingKey(@RequestParam(value="keyId") String keyId) {
......
......@@ -2,6 +2,7 @@ package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample;
import com.glsx.smart.pojo.request.SmartCarKeyCommandRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -30,4 +31,6 @@ public interface SmartKeyCommandLogMapper {
int updateByPrimaryKeySelective(SmartKeyCommandLog record);
int updateByPrimaryKey(SmartKeyCommandLog record);
int insertBatch(@Param("lockingkeyActLogList")List<SmartCarKeyCommandRequest> lockingkeyActLogList);
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartKeyCommandShareLog;
import com.glsx.smart.dao.entity.SmartKeyCommandShareLogExample;
import com.glsx.smart.pojo.request.SmartCarKeyShareLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -60,4 +61,6 @@ public interface SmartKeyCommandShareLogMapper {
* @return update count
*/
int updateByPrimaryKey(SmartKeyCommandShareLog record);
int insertBatch(@Param("lockingkeyActLogList")List<SmartCarKeyShareLogRequest> lockingkeyActLogList);
}
\ No newline at end of file
package com.glsx.smart.pojo.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author fengzhi
* @version 1.0.0
* @ClassName LockingkeyShareIdRequest.java
* @description: 分享的数字钥匙操作
* @createTime 2021年05月02日 09:59:00
*/
@Data
public class SmartCarKeyActionLogBatchRequest {
/**
* 批量上报的日志
*/
@NotBlank
private String actLogList;
@NotBlank
private String userId;
}
package com.glsx.smart.pojo.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author fengzhi
* @version 1.0.0
* @ClassName LockingkeyShareIdRequest.java
* @description: 分享的数字钥匙操作
* @createTime 2021年05月02日 09:59:00
*/
@Data
public class SmartCarKeyShareActionLogBatchRequest {
/**
* 批量上报的日志
*/
@NotBlank
private String actLogList;
}
......@@ -53,4 +53,6 @@ public interface AiLockingKeyService {
R getShareToken(SmartCarKeyTokenRequest request);
R getShareKeyList(SmartShareCarKeyPageRequest request);
R batchLogCommand(SmartCarKeyActionLogBatchRequest request);
}
package com.glsx.smart.service;
import com.glsx.plat.core.web.R;
import com.glsx.smart.pojo.request.SmartCarKeyReceiveRequest;
import com.glsx.smart.pojo.request.SmartCarKeyShareLogRequest;
import com.glsx.smart.pojo.request.SmartShareKeyEditReq;
import com.glsx.smart.pojo.request.*;
public interface AiLockingKeyShareService {
......@@ -20,4 +18,6 @@ public interface AiLockingKeyShareService {
R isTokenValid(String token);
R getShareKeyListByUser(Long userId);
R batchLogCommand(SmartCarKeyShareActionLogBatchRequest request);
}
......@@ -2,6 +2,7 @@ package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample;
import com.glsx.smart.pojo.request.SmartCarKeyCommandRequest;
import java.util.List;
......@@ -30,6 +31,7 @@ public interface SmartKeyCommandLogService {
int updateByPrimaryKey(SmartKeyCommandLog record);
int insertBatch(List<SmartCarKeyCommandRequest> lockingkeyActLogList);
}
......
......@@ -2,6 +2,7 @@ package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartKeyCommandShareLog;
import com.glsx.smart.dao.entity.SmartKeyCommandShareLogExample;
import com.glsx.smart.pojo.request.SmartCarKeyShareLogRequest;
import java.util.List;
public interface SmartKeyCommandShareLogService{
......@@ -29,4 +30,5 @@ public interface SmartKeyCommandShareLogService{
int updateByPrimaryKey(SmartKeyCommandShareLog record);
int insertBatch(List<SmartCarKeyShareLogRequest> lockingkeyActLogList);
}
package com.glsx.smart.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import com.github.pagehelper.PageHelper;
......@@ -184,6 +185,25 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
return R.ok();
}
//车钥匙操作指令批量上报
@Override
public R batchLogCommand(SmartCarKeyActionLogBatchRequest request) {
String userId = request.getUserId();
String actLogList = request.getActLogList();
List<SmartCarKeyCommandRequest> lockingkeyActLogList = JSONArray.parseArray(actLogList, SmartCarKeyCommandRequest.class);
if (CollectionUtils.isEmpty(lockingkeyActLogList)) {
return R.ok();
}
lockingkeyActLogList.stream().forEach(key->key.setUserId(userId));
int count = smartKeyCommandLogService.insertBatch(lockingkeyActLogList);
return R.ok().data(count);
}
//车钥匙修改昵称
@Override
public R setLockingKeyName(SmartCarKeyNameRequest request) {
......@@ -707,4 +727,6 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
return R.ok().data(PageInfo.of(shareKeyList));
}
}
package com.glsx.smart.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.nacos.common.utils.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -8,9 +9,7 @@ import com.glsx.plat.core.web.R;
import com.glsx.smart.dao.entity.*;
import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.pojo.request.SmartCarKeyReceiveRequest;
import com.glsx.smart.pojo.request.SmartCarKeyShareLogRequest;
import com.glsx.smart.pojo.request.SmartShareKeyEditReq;
import com.glsx.smart.pojo.request.*;
import com.glsx.smart.redis.RedisService;
import com.glsx.smart.service.AiLockingKeyShareService;
import com.glsx.smart.service.SmartKeyCommandShareLogService;
......@@ -169,6 +168,21 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
return R.ok();
}
//分享钥匙操作日志批量上报
@Override
public R batchLogCommand(SmartCarKeyShareActionLogBatchRequest request) {
String actLogList = request.getActLogList();
List<SmartCarKeyShareLogRequest> lockingkeyActLogList = JSONArray.parseArray(actLogList, SmartCarKeyShareLogRequest.class);
if (CollectionUtils.isEmpty(lockingkeyActLogList)) {
return R.ok().data(0);
}
int count = shareLogService.insertBatch(lockingkeyActLogList);
return R.ok().data(count);
}
//删除共享钥匙
@Override
......
......@@ -3,6 +3,7 @@ package com.glsx.smart.service.impl;
import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample;
import com.glsx.smart.dao.mapper.SmartKeyCommandLogMapper;
import com.glsx.smart.pojo.request.SmartCarKeyCommandRequest;
import com.glsx.smart.service.SmartKeyCommandLogService;
import org.springframework.stereotype.Service;
......@@ -70,6 +71,11 @@ public class SmartKeyCommandLogServiceImpl implements SmartKeyCommandLogService
return smartKeyCommandLogMapper.updateByPrimaryKey(record);
}
@Override
public int insertBatch(List<SmartCarKeyCommandRequest> lockingkeyActLogList) {
return smartKeyCommandLogMapper.insertBatch(lockingkeyActLogList);
}
}
......
......@@ -3,6 +3,7 @@ package com.glsx.smart.service.impl;
import com.glsx.smart.dao.entity.SmartKeyCommandShareLog;
import com.glsx.smart.dao.entity.SmartKeyCommandShareLogExample;
import com.glsx.smart.dao.mapper.SmartKeyCommandShareLogMapper;
import com.glsx.smart.pojo.request.SmartCarKeyShareLogRequest;
import com.glsx.smart.service.SmartKeyCommandShareLogService;
import org.springframework.stereotype.Service;
......@@ -69,4 +70,9 @@ public class SmartKeyCommandShareLogServiceImpl implements SmartKeyCommandShareL
return smartKeyCommandShareLogMapper.updateByPrimaryKey(record);
}
@Override
public int insertBatch(List<SmartCarKeyShareLogRequest> lockingkeyActLogList) {
return smartKeyCommandShareLogMapper.insertBatch(lockingkeyActLogList);
}
}
......@@ -203,4 +203,12 @@
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<insert id="insertBatch" parameterType="com.glsx.smart.pojo.request.SmartCarKeyShareLogRequest">
INSERT INTO `smart_key_command_share_log` (`share_car_key_id`, `key_command`, `create_time`)
VALUES
<foreach collection="lockingkeyActLogList" item="keyActLog" separator=",">
(#{keyActLog.shareKeyId,jdbcType=BIGINT},#{keyActLog.keyCommand,jdbcType=VARCHAR},#{keyActLog.createTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!