Commit a678f530 by fz

Merge branch 'master' into dev

# Conflicts:
#	src/main/java/com/glsx/smart/constant/Constants.java
#	src/main/java/com/glsx/smart/controller/UserRelationController.java
#	src/main/java/com/glsx/smart/exception/ResultEnum.java
#	src/main/java/com/glsx/smart/service/impl/SmartSceneServiceImpl.java
#	src/main/java/com/glsx/smart/service/impl/SmartUserRelationServiceImpl.java
2 parents b80186de 636bace5
Showing 63 changed files with 2036 additions and 44 deletions
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
<properties> <properties>
<org.projectlombok.version>1.18.12</org.projectlombok.version> <org.projectlombok.version>1.18.12</org.projectlombok.version>
<druid.version>1.1.12</druid.version> <druid.version>1.1.12</druid.version>
<jwt.version>3.8.1</jwt.version>
<jjwt.version>0.9.1</jjwt.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -116,5 +118,17 @@ ...@@ -116,5 +118,17 @@
<version>2.5.0</version> <version>2.5.0</version>
</dependency> </dependency>
<!--jwt-->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -15,7 +15,7 @@ public class Constants { ...@@ -15,7 +15,7 @@ public class Constants {
public final static String SCENE_CONTENT_DEVICE = "scene_content_device"; public final static String SCENE_CONTENT_DEVICE = "scene_content_device";
public final static long REDIS_CACHE_TIME = 3; public final static long REDIS_CACHE_TIME = 3; //redis缓存时间
public final static Byte USER_CHANNEL_TUYA = 1; //用户渠道涂鸦 public final static Byte USER_CHANNEL_TUYA = 1; //用户渠道涂鸦
......
package com.glsx.smart.controller; package com.glsx.smart.controller;
import com.glsx.cloudframework.core.util.Assert;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import com.glsx.smart.pojo.request.*; import com.glsx.smart.pojo.request.*;
import com.glsx.smart.service.AiLockingKeyService; import com.glsx.smart.service.AiLockingKeyService;
import com.glsx.smart.service.AiLockingKeyShareService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
/**
* @Title: ConditionController.java
* @Description: 提供给gop-accounts(车钥匙app)使用的接口
* @author fengzhi
* @version V1.0
*/
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/lockingKey") @RequestMapping("/lockingKey")
...@@ -14,12 +21,50 @@ public class AiLockingkeyController { ...@@ -14,12 +21,50 @@ public class AiLockingkeyController {
@Autowired @Autowired
private AiLockingKeyService aiLockingKeyService; private AiLockingKeyService aiLockingKeyService;
@Autowired
private AiLockingKeyShareService aiLockingKeyShareService;
/************************分享车钥匙相关接口************************/
//主车钥匙修改分享状态
@PostMapping(value = "/setPrimaryShareStatus")
public R setPrimaryLockingKeyShareStatus(@RequestBody SmartKeyPrimaryShareEditReq request) {
return aiLockingKeyService.setPrimaryLockingKeyShareStatus(request);
}
//车钥匙分享令牌获取
@GetMapping(value = "/getShareToken")
public R getShareToken(SmartCarKeyTokenRequest request) {
return aiLockingKeyService.getShareToken(request);
}
//智能车钥匙共享列表获取
@GetMapping(value = "/getShareKeyList")
public R getShareKeyList(SmartShareCarKeyPageRequest request) {
return aiLockingKeyService.getShareKeyList(request);
}
//分享车钥匙设置修改分享状态
@PostMapping(value = "/setShareStatus")
public R setShareLockingKeyShareStatus(@RequestBody SmartShareKeyEditReq request) {
return aiLockingKeyShareService.removeShareKey(request);
}
/************************车钥匙相关接口************************/
//sn查询/新增车钥匙 //sn查询/新增车钥匙
@GetMapping(value = "/get") @GetMapping(value = "/get")
public R getLockingKey(SmartCarKeyRequest request) { public R getLockingKey(SmartCarKeyRequest request) {
return aiLockingKeyService.getLockingKey(request); return aiLockingKeyService.getLockingKey(request);
} }
//sn查询车钥匙蓝牙地址
@GetMapping(value = "/bluemac/get")
public R getMobileBlueMac(SmartCarKeyRequest request) {
return aiLockingKeyService.getMobileBlueMac(request);
}
//userId查询车钥匙 //userId查询车钥匙
@GetMapping(value = "/user/getAll") @GetMapping(value = "/user/getAll")
public R getAllKeyByUser(SmartCarKeyUserRequest request) { public R getAllKeyByUser(SmartCarKeyUserRequest request) {
...@@ -28,7 +73,7 @@ public class AiLockingkeyController { ...@@ -28,7 +73,7 @@ public class AiLockingkeyController {
//智能车钥匙解绑 //智能车钥匙解绑
@PostMapping(value = "/remove") @PostMapping(value = "/remove")
public R removeLockingKey(@RequestBody SmartCarKeyRmRequest request) { public R removeLockingKey(@RequestBody SmartCarKeyRequest request) {
return aiLockingKeyService.removeLockingKey(request); return aiLockingKeyService.removeLockingKey(request);
} }
...@@ -38,12 +83,24 @@ public class AiLockingkeyController { ...@@ -38,12 +83,24 @@ public class AiLockingkeyController {
return aiLockingKeyService.saveLockingKeyRegisterInfo(request); return aiLockingKeyService.saveLockingKeyRegisterInfo(request);
} }
//根据userid注销钥匙
@PostMapping(value = "/removeKeysByUser")
public R removeKeysByUser(@RequestBody SmartCarKeyUserRequest request) {
return aiLockingKeyService.removeKeysByUser(request);
}
//车钥匙操作指令上报 //车钥匙操作指令上报
@PostMapping(value = "/logCommand") @PostMapping(value = "/logCommand")
public R LogLockingKeyCommand(@RequestBody SmartCarKeyCommandRequest request) { public R LogLockingKeyCommand(@RequestBody SmartCarKeyCommandRequest request) {
return aiLockingKeyService.LogLockingKeyCommand(request); return aiLockingKeyService.LogLockingKeyCommand(request);
} }
//车钥匙操作指令批量上报
@PostMapping(value = "/batchLogCommand")
public R batchLogCommand(@RequestBody SmartCarKeyActionLogBatchRequest request) {
return aiLockingKeyService.batchLogCommand(request);
}
//车钥匙修改昵称 //车钥匙修改昵称
@PostMapping(value = "/setName") @PostMapping(value = "/setName")
public R setLockingKeyName(@RequestBody SmartCarKeyNameRequest request) { public R setLockingKeyName(@RequestBody SmartCarKeyNameRequest request) {
......
package com.glsx.smart.controller;
import com.glsx.plat.core.web.R;
import com.glsx.smart.pojo.request.*;
import com.glsx.smart.service.AiLockingKeyShareService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/share/lockingKey")
public class AiLockingkeyShareController {
@Autowired
private AiLockingKeyShareService aiLockingKeyShareService;
//通过令牌获取领取信息
@GetMapping(value = "/getByToken")
public R getShareKeyByToken(@RequestParam(value="token") String token) {
return aiLockingKeyShareService.getShareKeyByToken(token);
}
//判断令牌是否有效
@GetMapping(value = "/isTokenValid")
public R isTokenValid(@RequestParam(value="token") String token) {
return aiLockingKeyShareService.isTokenValid(token);
}
//根据userId获取分享车钥匙列表
@GetMapping(value = "/getShareKeyListByUser")
public R getShareKeyListByUser(@RequestParam(value="userId")Long userId) {
return aiLockingKeyShareService.getShareKeyListByUser(userId);
}
//领取钥匙接口
@PostMapping(value = "/receive")
public R receiveKey(@RequestBody SmartCarKeyReceiveRequest request) {
return aiLockingKeyShareService.receiveKey(request);
}
//分享钥匙的操作日志
@PostMapping(value = "/logCommand")
public R logShareLockingKeyCommand(@RequestBody SmartCarKeyShareLogRequest request) {
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) {
return aiLockingKeyShareService.getShareLockingKey(keyId);
}
//删除共享钥匙
@PostMapping(value = "/removeShareKey")
public R removeShareKey(@RequestBody SmartShareKeyEditReq request) {
return aiLockingKeyShareService.removeShareKey(request);
}
}
...@@ -57,6 +57,7 @@ public class UserKafkaController { ...@@ -57,6 +57,7 @@ public class UserKafkaController {
@RequestMapping(value = "/updateUserAddress", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/updateUserAddress", method = {RequestMethod.POST, RequestMethod.GET})
public boolean updateUserAddress(@RequestParam("userId") Long userId, @RequestParam("phone") String phone, public boolean updateUserAddress(@RequestParam("userId") Long userId, @RequestParam("phone") String phone,
@RequestParam("lngAndLat") String lngAndLat){ @RequestParam("lngAndLat") String lngAndLat){
log.info("更新用户家庭地址:{} {} {}", userId, phone, lngAndLat);
SmartUserRelation relation = getUserRelation(userId, phone); SmartUserRelation relation = getUserRelation(userId, phone);
if(relation == null){ if(relation == null){
return false; return false;
......
package com.glsx.smart.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 智能车钥匙手机蓝牙感应状态表
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "smart_key_blue_sense")
public class SmartKeyBlueSense {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 智能车钥匙设备号
*/
private String sn;
/**
* 自动感应状态 0:关,1:远,2:中,3:近
*/
private Integer autoSenseStatus;
/**
* 手机蓝牙的MAC地址
*/
private String mobileBlueMac;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
/**
* 逻辑删除 0:正常 1:删除
*/
private Integer isDelete;
/**
* 车钥匙的主键id
*/
private Long carKeyId;
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.entity; package com.glsx.smart.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
...@@ -15,6 +18,9 @@ import java.util.Date; ...@@ -15,6 +18,9 @@ import java.util.Date;
* 智能蓝牙车钥匙指令操作日志表 * 智能蓝牙车钥匙指令操作日志表
*/ */
@Data @Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "smart_key_command_log") @Table(name = "smart_key_command_log")
public class SmartKeyCommandLog implements Serializable { public class SmartKeyCommandLog implements Serializable {
@Id @Id
...@@ -39,7 +45,7 @@ public class SmartKeyCommandLog implements Serializable { ...@@ -39,7 +45,7 @@ public class SmartKeyCommandLog implements Serializable {
/** /**
* 创建时间 * 创建时间
*/ */
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat( @JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss", pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8" timezone = "GMT+8"
......
package com.glsx.smart.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 分享智能蓝牙车钥匙指令操作日志表
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "smart_key_blue_sense")
public class SmartKeyCommandShareLog {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 分享车钥匙ID
*/
private Long shareCarKeyId;
/**
* 指令代码(1、开锁;2、关锁;3、开尾门;4、寻车;5、自动感应近;6、自动感应中;7、自动感应远;8、自动感应关)
*/
private String keyCommand;
/**
* 下发时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
}
\ No newline at end of file \ No newline at end of file
...@@ -63,6 +63,16 @@ public class SmartScene implements Serializable { ...@@ -63,6 +63,16 @@ public class SmartScene implements Serializable {
private Long backPic; private Long backPic;
/** /**
* 列表页面图ID 关联smart_sys_file中id
*/
private Long pagePic;
/**
* 列表页面图
*/
private String pagePicUrl;
/**
* 场景背景图 * 场景背景图
*/ */
private String backPicUrl; private String backPicUrl;
......
...@@ -59,11 +59,26 @@ public class SmartSceneTemplate extends BaseDTO implements Serializable { ...@@ -59,11 +59,26 @@ public class SmartSceneTemplate extends BaseDTO implements Serializable {
private Long backPic; private Long backPic;
/** /**
* 列表页面图ID 关联smart_sys_file中id
*/
private Long pagePic;
/**
* 常驻首页 0否 1是
*/
private Byte isTop;
/**
* 场景背景图 * 场景背景图
*/ */
private String backPicUrl; private String backPicUrl;
/** /**
* 列表页面图
*/
private String pagePicUrl;
/**
* 查看次数 * 查看次数
*/ */
private Long viewTimes; private Long viewTimes;
......
package com.glsx.smart.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 分享智能蓝牙车钥匙信息
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SmartShareKeyBlueKey{
private Long id;
/**
* 令牌
*/
private String shareKeyToken;
/**
* 钥匙领取状态 0:未领取 1:已领取
*/
private Integer sharePickStatus;
/**
* 领取用户ID
*/
private Long pickUserId;
/**
* 分享状态 0:关闭 1:打开
*/
private Integer shareStatus;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
/**
* 领取时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date pickTime;
/**
* 分享钥匙过期时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd",
timezone = "GMT+8"
)
private Date expireTime;
/**
* 停用时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date stopTime;
/*****************主钥匙********************/
/**
* 车钥匙ID
*/
private Long carKeyId;
/**
* 用户ID
*/
private Long userId;
/**
* 智能车钥匙设备号
*/
private String sn;
/**
* 平台生成的唯一CREP信息(密文)
*/
private String crepCode;
/**
* 注册成功后生成的密钥(密文)
*/
private String secretKey;
/**
* 智能车钥匙MAC地址
*/
private String smartLockMac;
/**
* 车牌号
*/
private String carNumber;
/**
* 昵称
*/
private String keyName;
/**
* 逻辑删除 0:正常 1:删除
*/
private Integer isDelete;
/**
* 手机编号
*/
private String mobileCode;
/**
* ios专用
*/
private String peripheralUuid;
/**
* 主钥匙的分享状态 0:关闭 1:打开
* 默认打开
*/
private Integer mainShareStatus;
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.entity; package com.glsx.smart.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* 智能蓝牙车钥匙表 * 智能蓝牙车钥匙表
*/ */
@Data @Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "smart_vehicle_blue_key") @Table(name = "smart_vehicle_blue_key")
public class SmartVehicleBlueKey implements Serializable { public class SmartVehicleBlueKey {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
...@@ -42,11 +47,6 @@ public class SmartVehicleBlueKey implements Serializable { ...@@ -42,11 +47,6 @@ public class SmartVehicleBlueKey implements Serializable {
private String secretKey; private String secretKey;
/** /**
* 手机蓝牙的MAC地址
*/
private String mobileBlueMac;
/**
* 智能车钥匙MAC地址 * 智能车钥匙MAC地址
*/ */
private String smartLockMac; private String smartLockMac;
...@@ -62,11 +62,6 @@ public class SmartVehicleBlueKey implements Serializable { ...@@ -62,11 +62,6 @@ public class SmartVehicleBlueKey implements Serializable {
private String keyName; private String keyName;
/** /**
* 自动感应状态 0:关 1:开
*/
private Integer autoSenseStatus;
/**
* 逻辑删除 0:正常 1:删除 * 逻辑删除 0:正常 1:删除
*/ */
private Integer isDelete; private Integer isDelete;
...@@ -74,7 +69,7 @@ public class SmartVehicleBlueKey implements Serializable { ...@@ -74,7 +69,7 @@ public class SmartVehicleBlueKey implements Serializable {
/** /**
* 创建时间 * 创建时间
*/ */
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat( @JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss", pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8" timezone = "GMT+8"
...@@ -85,4 +80,19 @@ public class SmartVehicleBlueKey implements Serializable { ...@@ -85,4 +80,19 @@ public class SmartVehicleBlueKey implements Serializable {
* 手机编号 * 手机编号
*/ */
private String mobileCode; private String mobileCode;
/**
* ios专用
*/
private String peripheralUuid;
private Integer autoSenseStatus;
private String mobileBlueMac;
/**
* 分享状态 0:关闭 1:打开
* 默认打开
*/
private Integer shareStatus;
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* 分享智能蓝牙车钥匙表
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "smart_vehicle_blue_share_key")
public class SmartVehicleBlueShareKey implements Comparable<SmartVehicleBlueShareKey>{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 车钥匙ID
*/
private Long carKeyId;
/**
* 令牌
*/
private String shareKeyToken;
/**
* 钥匙领取状态 0:未领取 1:已领取
*/
private Integer sharePickStatus;
/**
* 领取用户ID
*/
private Long pickUserId;
/**
* 分享状态 1:打开 0:关闭
*/
private Integer shareStatus;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
/**
* 领取时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date pickTime;
/**
* 分享钥匙过期时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd",
timezone = "GMT+8"
)
private Date expireTime;
/**
* 停用时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date stopTime;
@Override
public int compareTo(com.glsx.smart.dao.entity.SmartVehicleBlueShareKey o) {
Integer data = this.getShareStatus();
Integer data2 = o.getShareStatus();
if (null == data)
return 1;
if (null == data2)
return -1;
return data2.compareTo(data);
}
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartKeyBlueSense;
import com.glsx.smart.dao.entity.SmartKeyBlueSenseExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SmartKeyBlueSenseMapper {
long countByExample(SmartKeyBlueSenseExample example);
int deleteByExample(SmartKeyBlueSenseExample example);
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Long id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(SmartKeyBlueSense record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(SmartKeyBlueSense record);
List<SmartKeyBlueSense> selectByExample(SmartKeyBlueSenseExample example);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
SmartKeyBlueSense selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SmartKeyBlueSense record, @Param("example") SmartKeyBlueSenseExample example);
int updateByExample(@Param("record") SmartKeyBlueSense record, @Param("example") SmartKeyBlueSenseExample example);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(SmartKeyBlueSense record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(SmartKeyBlueSense record);
/**
*
*/
List<SmartKeyBlueSense> getByCarKeyIds(List<Long> ids);
}
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,7 @@ package com.glsx.smart.dao.mapper; ...@@ -2,6 +2,7 @@ package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartKeyCommandLog; import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample; 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.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -30,4 +31,6 @@ public interface SmartKeyCommandLogMapper { ...@@ -30,4 +31,6 @@ public interface SmartKeyCommandLogMapper {
int updateByPrimaryKeySelective(SmartKeyCommandLog record); int updateByPrimaryKeySelective(SmartKeyCommandLog record);
int updateByPrimaryKey(SmartKeyCommandLog record); int updateByPrimaryKey(SmartKeyCommandLog record);
int insertBatch(@Param("lockingkeyActLogList")List<SmartCarKeyCommandRequest> lockingkeyActLogList);
} }
\ No newline at end of file \ No newline at end of file
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;
import java.util.List;
@Mapper
public interface SmartKeyCommandShareLogMapper {
long countByExample(SmartKeyCommandShareLogExample example);
int deleteByExample(SmartKeyCommandShareLogExample example);
/**
* delete by primary key
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Long id);
/**
* insert record to table
* @param record the record
* @return insert count
*/
int insert(SmartKeyCommandShareLog record);
/**
* insert record to table selective
* @param record the record
* @return insert count
*/
int insertSelective(SmartKeyCommandShareLog record);
List<SmartKeyCommandShareLog> selectByExample(SmartKeyCommandShareLogExample example);
/**
* select by primary key
* @param id primary key
* @return object by primary key
*/
SmartKeyCommandShareLog selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SmartKeyCommandShareLog record, @Param("example") SmartKeyCommandShareLogExample example);
int updateByExample(@Param("record") SmartKeyCommandShareLog record, @Param("example") SmartKeyCommandShareLogExample example);
/**
* update record selective
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(SmartKeyCommandShareLog record);
/**
* update record
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(SmartKeyCommandShareLog record);
int insertBatch(@Param("lockingkeyActLogList")List<SmartCarKeyShareLogRequest> lockingkeyActLogList);
}
\ No newline at end of file \ No newline at end of file
...@@ -13,21 +13,59 @@ public interface SmartVehicleBlueKeyMapper { ...@@ -13,21 +13,59 @@ public interface SmartVehicleBlueKeyMapper {
int deleteByExample(SmartVehicleBlueKeyExample example); int deleteByExample(SmartVehicleBlueKeyExample example);
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(SmartVehicleBlueKey record); int insert(SmartVehicleBlueKey record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(SmartVehicleBlueKey record); int insertSelective(SmartVehicleBlueKey record);
List<SmartVehicleBlueKey> selectByExample(SmartVehicleBlueKeyExample example); List<SmartVehicleBlueKey> selectByExample(SmartVehicleBlueKeyExample example);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
SmartVehicleBlueKey selectByPrimaryKey(Long id); SmartVehicleBlueKey selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SmartVehicleBlueKey record, @Param("example") SmartVehicleBlueKeyExample example); int updateByExampleSelective(@Param("record") SmartVehicleBlueKey record, @Param("example") SmartVehicleBlueKeyExample example);
int updateByExample(@Param("record") SmartVehicleBlueKey record, @Param("example") SmartVehicleBlueKeyExample example); int updateByExample(@Param("record") SmartVehicleBlueKey record, @Param("example") SmartVehicleBlueKeyExample example);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(SmartVehicleBlueKey record); int updateByPrimaryKeySelective(SmartVehicleBlueKey record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(SmartVehicleBlueKey record); int updateByPrimaryKey(SmartVehicleBlueKey record);
int removeKeyByIds(List<Long> keyIds);
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartShareKeyBlueKey;import com.glsx.smart.dao.entity.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SmartVehicleBlueShareKeyMapper {
long countByExample(SmartVehicleBlueShareKeyExample example);
int deleteByExample(SmartVehicleBlueShareKeyExample example);
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Long id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(SmartVehicleBlueShareKey record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(SmartVehicleBlueShareKey record);
List<SmartVehicleBlueShareKey> selectByExample(SmartVehicleBlueShareKeyExample example);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
SmartVehicleBlueShareKey selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SmartVehicleBlueShareKey record, @Param("example") SmartVehicleBlueShareKeyExample example);
int updateByExample(@Param("record") SmartVehicleBlueShareKey record, @Param("example") SmartVehicleBlueShareKeyExample example);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(SmartVehicleBlueShareKey record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(SmartVehicleBlueShareKey record);
int updateShareStatusByIds(List<Long> ids);
List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
int closeShareKeyByMainKeyIds(List<Long> keyIds);
List<SmartShareKeyBlueKey> getShareKeyListByKeyId(Long keyId);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.exception;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public class CarKeyException extends RuntimeException {
private Integer code;
private String message;
public CarKeyException() {}
public CarKeyException(ResultEnum resultEnum) {
this.code = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static CarKeyException create(int code, String message){
CarKeyException businessException = new CarKeyException();
businessException.code = code;
businessException.message = message;
return businessException;
}
public static CarKeyException create(ResultEnum resultEnum) {
return create(resultEnum.getCode(), resultEnum.getMessage());
}
}
...@@ -6,6 +6,7 @@ import org.springframework.validation.BindException; ...@@ -6,6 +6,7 @@ import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.ServletRequestBindingException; import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/** /**
* <p>Description: * <p>Description:
...@@ -16,7 +17,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler; ...@@ -16,7 +17,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
* @deprecated 抛出异常,让上游服务捕获信息 * @deprecated 抛出异常,让上游服务捕获信息
*/ */
@Slf4j @Slf4j
//@RestControllerAdvice @RestControllerAdvice
@Deprecated @Deprecated
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
@ExceptionHandler({BusinessException.class}) @ExceptionHandler({BusinessException.class})
...@@ -25,6 +26,12 @@ public class GlobalExceptionHandler { ...@@ -25,6 +26,12 @@ public class GlobalExceptionHandler {
return R.error(e.getMessage()); return R.error(e.getMessage());
} }
@ExceptionHandler({CarKeyException.class})
public R handleCarKeyException(CarKeyException e) {
log.error("车钥匙异常", e);
return R.error(e.getCode(),e.getMessage());
}
@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class, @ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
BindException.class}) BindException.class})
public R handleBindException(Exception e) { public R handleBindException(Exception e) {
......
...@@ -26,13 +26,28 @@ public enum ResultEnum { ...@@ -26,13 +26,28 @@ public enum ResultEnum {
USER_NOT_FOUND(5001, "用户信息不存在"), USER_NOT_FOUND(5001, "用户信息不存在"),
DEVICE_SUBSCRIBE_ERROR(5002, "用户设备订阅失败"), DEVICE_SUBSCRIBE_ERROR(5002, "用户设备订阅失败"),
ENCRYPT_EXCEP_1(1101, "crep加密异常,无法插入"), CAR_KEY_EXCEP_1(1101, "crep加密异常,无法新增"),
ENCRYPT_EXCEP_2(1102, "crep加密异常,无法返回钥匙信息"), CAR_KEY_EXCEP_2(1102, "智能车钥匙查询,crep/secret加密异常"),
ENCRYPT_EXCEP_3(1103, "crep加密异常,无法更新"), CAR_KEY_EXCEP_3(1103, "车钥匙注册成功数据保存,车钥匙不存在"),
ENCRYPT_EXCEP_4(1104, "车钥匙操作指令上报crep解密异常"), CAR_KEY_EXCEP_4(1104, "车钥匙操作指令上报crep解密异常"),
ENCRYPT_EXCEP_5(1105, "智能车钥匙注册成功后的数据保存crep/secret解密异常"), CAR_KEY_EXCEP_5(1105, "智能车钥匙注册成功数据保存,crep/secret解密异常"),
ENCRYPT_EXCEP_6(1106, "智能车钥匙secretKey_db解密异常"), CAR_KEY_EXCEP_6(1106, "智能车钥匙查询,secretKey解密异常"),
ENCRYPT_EXCEP_7(1107, "智能车钥匙secretKey加密异常"), CAR_KEY_EXCEP_7(1107, "智能车钥匙secretKey加密异常"),
CAR_KEY_EXCEP_8(1108, "智能车钥匙新增异常"),
CAR_KEY_EXCEP_9(1109, "智能车钥匙注册成功数据保存,自动感应新增异常"),
CAR_KEY_EXCEP_10(1110, "智能车钥匙无crep"),
CAR_KEY_EXCEP_11(1111, "自动感应新增异常"),
CAR_KEY_EXCEP_12(1112, "智能车钥匙用户查询,secretKey解密异常"),
CAR_KEY_EXCEP_13(1113, "智能车钥匙用户查询,crep/secret加密异常"),
CAR_KEY_EXCEP_14(1114, "钥匙已领取"),
CAR_KEY_EXCEP_15(1115, "时间格式不对:yyyy-MM-dd"),
CAR_KEY_EXCEP_16(1116, "钥匙已过期"),
CAR_KEY_EXCEP_17(1117, "token令牌解析异常"),
CAR_KEY_EXCEP_18(1118, "token令牌超时异常"),
CAR_KEY_EXCEP_19(1119, "分享钥匙不存在"),
CAR_KEY_EXCEP_20(1120, "钥匙已关闭分享"),
CAR_KEY_EXCEP_21(1121, "钥匙信息不完整"),
; ;
private final Integer code; private final Integer code;
......
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;
}
...@@ -7,10 +7,13 @@ import lombok.Data; ...@@ -7,10 +7,13 @@ import lombok.Data;
*/ */
@Data @Data
public class SmartCarKeyAutoSenseRequest{ public class SmartCarKeyAutoSenseRequest{
//智能车钥匙自动感应状态 //智能车钥匙自动感应状态 0:关,1:远,2:中,3:近'
private String autoSenseStatus; private String autoSenseStatus;
private String sn; private String sn;
private String userId; private String userId;
//手机蓝牙的MAC地址
private String mobileMac;
} }
package com.glsx.smart.pojo.request; package com.glsx.smart.pojo.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/** /**
* 智能车钥匙,指令上报 * 智能车钥匙,指令上报
...@@ -17,4 +21,12 @@ public class SmartCarKeyCommandRequest{ ...@@ -17,4 +21,12 @@ public class SmartCarKeyCommandRequest{
//用户id //用户id
private String userId; private String userId;
//上报时间 yyyy-MM-dd
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
} }
package com.glsx.smart.pojo.request;
import lombok.Data;
/**
* 智能车钥匙领取
*/
@Data
public class SmartCarKeyReceiveRequest {
private String token;
private String userId;
}
...@@ -23,4 +23,9 @@ public class SmartCarKeyRegisterRequest{ ...@@ -23,4 +23,9 @@ public class SmartCarKeyRegisterRequest{
private String mobileCode; private String mobileCode;
private String userId; private String userId;
/**
* ios专用
*/
private String peripheralUuid;
} }
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;
}
package com.glsx.smart.pojo.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class SmartCarKeyShareLogRequest {
//指令代码
//1、开锁;2、关锁;3、开尾门;4、寻车;5、自动感应近;
// 6、自动感应中;7、自动感应远;8、自动感应关
private String keyCommand;
//分享车钥匙id
private String shareKeyId;
//上报时间 yyyy-MM-dd
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
}
...@@ -3,11 +3,13 @@ package com.glsx.smart.pojo.request; ...@@ -3,11 +3,13 @@ package com.glsx.smart.pojo.request;
import lombok.Data; import lombok.Data;
/** /**
* 智能车钥匙,解绑车钥匙接口 * 智能车钥匙,查询车钥匙和生成crep接口
*/ */
@Data @Data
public class SmartCarKeyRmRequest { public class SmartCarKeyTokenRequest {
private String sn; private String sn;
private String userId; private String userId;
private String expireTime;
} }
package com.glsx.smart.pojo.request;
import lombok.Data;
/**
* 智能车钥匙,解绑车钥匙接口
*/
@Data
public class SmartKeyPrimaryShareEditReq {
private String sn;
private String userId;
/**
* 分享状态 0:关闭 1:打开
* 默认打开
*/
private Integer shareStatus;
}
package com.glsx.smart.pojo.request;
import lombok.Data;
/**
* 智能车钥匙,指令上报
*/
@Data
public class SmartShareCarKeyPageRequest{
//用户id
private String userId;
private String sn;
/**
* 第几页
*/
private int pageNum;
/**
* 每一页的记录数
*/
private int pageSize;
}
package com.glsx.smart.pojo.request;
import lombok.Data;
/**
* 智能车钥匙,解绑车钥匙接口
*/
@Data
public class SmartShareKeyEditReq {
private String keyId;
}
...@@ -3,11 +3,13 @@ package com.glsx.smart.pojo.response; ...@@ -3,11 +3,13 @@ package com.glsx.smart.pojo.response;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@Data @Data
public class SmartCarKeyResponse implements Serializable { public class SmartCarKeyResponse implements Serializable {
private Long id;
/** /**
* 用户ID * 用户ID
*/ */
...@@ -68,4 +70,15 @@ public class SmartCarKeyResponse implements Serializable { ...@@ -68,4 +70,15 @@ public class SmartCarKeyResponse implements Serializable {
* 手机蓝牙的MAC地址 * 手机蓝牙的MAC地址
*/ */
private String mobileBlueMac; private String mobileBlueMac;
/**
* ios专用
*/
private String peripheralUuid;
/**
* 分享状态 0:关闭 1:打开
* 默认打开
*/
private Integer shareStatus;
} }
...@@ -28,6 +28,11 @@ public class RedisService { ...@@ -28,6 +28,11 @@ public class RedisService {
valueOperations.set(key, value); valueOperations.set(key, value);
} }
public boolean setnx(String key, Object value) {
ValueOperations valueOperations = redisTemplate.opsForValue();
return valueOperations.setIfAbsent(key, value);
}
public void setOutTime(String key, Object value,long timeout, TimeUnit unit) { public void setOutTime(String key, Object value,long timeout, TimeUnit unit) {
ValueOperations valueOperations = redisTemplate.opsForValue(); ValueOperations valueOperations = redisTemplate.opsForValue();
valueOperations.set(key, value,timeout,unit); valueOperations.set(key, value,timeout,unit);
......
...@@ -19,7 +19,7 @@ public interface AiLockingKeyService { ...@@ -19,7 +19,7 @@ public interface AiLockingKeyService {
/** /**
* 通过sn解绑车钥匙 * 通过sn解绑车钥匙
*/ */
R removeLockingKey(SmartCarKeyRmRequest request); R removeLockingKey(SmartCarKeyRequest request);
/** /**
* 车钥匙注册信息保存 * 车钥匙注册信息保存
...@@ -42,4 +42,17 @@ public interface AiLockingKeyService { ...@@ -42,4 +42,17 @@ public interface AiLockingKeyService {
R setLockingKeyAutoSense(SmartCarKeyAutoSenseRequest autoSenseStatus); R setLockingKeyAutoSense(SmartCarKeyAutoSenseRequest autoSenseStatus);
R getAllKeyByUser(SmartCarKeyUserRequest request); R getAllKeyByUser(SmartCarKeyUserRequest request);
R getMobileBlueMac(SmartCarKeyRequest request);
R removeKeysByUser(SmartCarKeyUserRequest request);
R setPrimaryLockingKeyShareStatus(SmartKeyPrimaryShareEditReq request);
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.*;
public interface AiLockingKeyShareService {
R getShareKeyByToken(String token);
R receiveKey(SmartCarKeyReceiveRequest request);
R logShareLockingKeyCommand(SmartCarKeyShareLogRequest request);
R removeShareKey(SmartShareKeyEditReq request);
R getShareLockingKey(String keyId);
R isTokenValid(String token);
R getShareKeyListByUser(Long userId);
R batchLogCommand(SmartCarKeyShareActionLogBatchRequest request);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartKeyBlueSense;
import com.glsx.smart.dao.entity.SmartKeyBlueSenseExample;
import java.util.List;
public interface SmartKeyBlueSenseService {
long countByExample(SmartKeyBlueSenseExample example);
int deleteByExample(SmartKeyBlueSenseExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartKeyBlueSense record);
int insertSelective(SmartKeyBlueSense record);
List<SmartKeyBlueSense> selectByExample(SmartKeyBlueSenseExample example);
SmartKeyBlueSense selectByPrimaryKey(Long id);
int updateByExampleSelective(SmartKeyBlueSense record, SmartKeyBlueSenseExample example);
int updateByExample(SmartKeyBlueSense record, SmartKeyBlueSenseExample example);
int updateByPrimaryKeySelective(SmartKeyBlueSense record);
int updateByPrimaryKey(SmartKeyBlueSense record);
List<SmartKeyBlueSense> getByCarKeyIds(List<Long> ids);
SmartKeyBlueSenseExample getBlueSenseExampleByCarKeyID(Long carKeyId);
SmartKeyBlueSense getRecentBlueSenseByCarKeyID(Long carKeyId);
}
...@@ -2,6 +2,7 @@ package com.glsx.smart.service; ...@@ -2,6 +2,7 @@ package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartKeyCommandLog; import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample; import com.glsx.smart.dao.entity.SmartKeyCommandLogExample;
import com.glsx.smart.pojo.request.SmartCarKeyCommandRequest;
import java.util.List; import java.util.List;
...@@ -30,6 +31,7 @@ public interface SmartKeyCommandLogService { ...@@ -30,6 +31,7 @@ public interface SmartKeyCommandLogService {
int updateByPrimaryKey(SmartKeyCommandLog record); int updateByPrimaryKey(SmartKeyCommandLog record);
int insertBatch(List<SmartCarKeyCommandRequest> lockingkeyActLogList);
} }
......
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{
long countByExample(SmartKeyCommandShareLogExample example);
int deleteByExample(SmartKeyCommandShareLogExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartKeyCommandShareLog record);
int insertSelective(SmartKeyCommandShareLog record);
List<SmartKeyCommandShareLog> selectByExample(SmartKeyCommandShareLogExample example);
SmartKeyCommandShareLog selectByPrimaryKey(Long id);
int updateByExampleSelective(SmartKeyCommandShareLog record,SmartKeyCommandShareLogExample example);
int updateByExample(SmartKeyCommandShareLog record,SmartKeyCommandShareLogExample example);
int updateByPrimaryKeySelective(SmartKeyCommandShareLog record);
int updateByPrimaryKey(SmartKeyCommandShareLog record);
int insertBatch(List<SmartCarKeyShareLogRequest> lockingkeyActLogList);
}
...@@ -30,7 +30,19 @@ public interface SmartVehicleBlueKeyService { ...@@ -30,7 +30,19 @@ public interface SmartVehicleBlueKeyService {
int updateByPrimaryKey(SmartVehicleBlueKey record); int updateByPrimaryKey(SmartVehicleBlueKey record);
SmartVehicleBlueKeyExample getBlueKeyExampleByUserAndSn(Long userId, String sn);
List<SmartVehicleBlueKey> selectByUserAndSn(Long userId, String sn);
List<SmartVehicleBlueKey> selectById(Long id);
int removeKeyByIds(List<Long> keyIds);
long countKeyByUser(long userId);
} }
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartShareKeyBlueKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample;
import java.util.List;
public interface SmartVehicleBlueShareKeyService {
long countByExample(SmartVehicleBlueShareKeyExample example);
int deleteByExample(SmartVehicleBlueShareKeyExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartVehicleBlueShareKey record);
int insertSelective(SmartVehicleBlueShareKey record);
List<SmartVehicleBlueShareKey> selectByExample(SmartVehicleBlueShareKeyExample example);
SmartVehicleBlueShareKey selectByPrimaryKey(Long id);
int updateByExampleSelective(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example);
int updateByExample(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example);
int updateByPrimaryKeySelective(SmartVehicleBlueShareKey record);
int updateByPrimaryKey(SmartVehicleBlueShareKey record);
SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByCarKeyID(Long carKeyId);
SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByID(Long id);
int updateShareStatusByIds(List<Long> ids);
List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
int closeShareKeyByCarKeyId(Long carKeyId);
int closeShareKeyByMainKeyIds(List<Long> keyIds);
List<SmartShareKeyBlueKey> getShareKeyListByKeyId(Long valueOf);
}
package com.glsx.smart.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.glsx.smart.dao.entity.SmartKeyBlueSense;
import com.glsx.smart.dao.entity.SmartKeyBlueSenseExample;
import com.glsx.smart.dao.mapper.SmartKeyBlueSenseMapper;
import com.glsx.smart.service.SmartKeyBlueSenseService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class SmartKeyBlueSenseServiceImpl implements SmartKeyBlueSenseService {
@Resource
private SmartKeyBlueSenseMapper smartKeyBlueSenseMapper;
@Override
public long countByExample(SmartKeyBlueSenseExample example) {
return smartKeyBlueSenseMapper.countByExample(example);
}
@Override
public int deleteByExample(SmartKeyBlueSenseExample example) {
return smartKeyBlueSenseMapper.deleteByExample(example);
}
@Override
public int deleteByPrimaryKey(Long id) {
return smartKeyBlueSenseMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(SmartKeyBlueSense record) {
return smartKeyBlueSenseMapper.insert(record);
}
@Override
public int insertSelective(SmartKeyBlueSense record) {
return smartKeyBlueSenseMapper.insertSelective(record);
}
@Override
public List<SmartKeyBlueSense> selectByExample(SmartKeyBlueSenseExample example) {
return smartKeyBlueSenseMapper.selectByExample(example);
}
@Override
public SmartKeyBlueSense selectByPrimaryKey(Long id) {
return smartKeyBlueSenseMapper.selectByPrimaryKey(id);
}
@Override
public int updateByExampleSelective(SmartKeyBlueSense record, SmartKeyBlueSenseExample example) {
return smartKeyBlueSenseMapper.updateByExampleSelective(record, example);
}
@Override
public int updateByExample(SmartKeyBlueSense record, SmartKeyBlueSenseExample example) {
return smartKeyBlueSenseMapper.updateByExample(record, example);
}
@Override
public int updateByPrimaryKeySelective(SmartKeyBlueSense record) {
return smartKeyBlueSenseMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(SmartKeyBlueSense record) {
return smartKeyBlueSenseMapper.updateByPrimaryKey(record);
}
@Override
public List<SmartKeyBlueSense> getByCarKeyIds(List<Long> ids) {
return smartKeyBlueSenseMapper.getByCarKeyIds(ids);
}
//查询车钥匙手机蓝牙,感应状态example,根据用户ID和sn查
@Override
public SmartKeyBlueSenseExample getBlueSenseExampleByCarKeyID(Long carKeyId) {
SmartKeyBlueSenseExample example = new SmartKeyBlueSenseExample();
example.createCriteria()
.andCarKeyIdEqualTo(carKeyId)
.andIsDeleteEqualTo(0);
return example;
}
//查询车钥匙最近的蓝牙感应信息
@Override
public SmartKeyBlueSense getRecentBlueSenseByCarKeyID(Long carKeyId) {
SmartKeyBlueSenseExample example = getBlueSenseExampleByCarKeyID(carKeyId);
List<SmartKeyBlueSense> smartKeyBlueSenseList = selectByExample(example);
return getRecentBlueMacAutoSense(smartKeyBlueSenseList);
}
//获取最新的手机蓝牙,自动感应记录
public SmartKeyBlueSense getRecentBlueMacAutoSense(List<SmartKeyBlueSense> smartKeyBlueSenseList) {
if (CollectionUtils.isEmpty(smartKeyBlueSenseList))
return null;
smartKeyBlueSenseList.sort((SmartKeyBlueSense o1, SmartKeyBlueSense o2) -> {
Date date1 = o1.getCreateTime();
Date date2 = o2.getCreateTime();
if (null == date1)
return 1;
if (null == date2)
return -1;
return o2.getCreateTime().compareTo(o1.getCreateTime());
}
);
return smartKeyBlueSenseList.get(0);
}
}
...@@ -3,6 +3,7 @@ package com.glsx.smart.service.impl; ...@@ -3,6 +3,7 @@ package com.glsx.smart.service.impl;
import com.glsx.smart.dao.entity.SmartKeyCommandLog; import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample; import com.glsx.smart.dao.entity.SmartKeyCommandLogExample;
import com.glsx.smart.dao.mapper.SmartKeyCommandLogMapper; import com.glsx.smart.dao.mapper.SmartKeyCommandLogMapper;
import com.glsx.smart.pojo.request.SmartCarKeyCommandRequest;
import com.glsx.smart.service.SmartKeyCommandLogService; import com.glsx.smart.service.SmartKeyCommandLogService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -70,6 +71,11 @@ public class SmartKeyCommandLogServiceImpl implements SmartKeyCommandLogService ...@@ -70,6 +71,11 @@ public class SmartKeyCommandLogServiceImpl implements SmartKeyCommandLogService
return smartKeyCommandLogMapper.updateByPrimaryKey(record); return smartKeyCommandLogMapper.updateByPrimaryKey(record);
} }
@Override
public int insertBatch(List<SmartCarKeyCommandRequest> lockingkeyActLogList) {
return smartKeyCommandLogMapper.insertBatch(lockingkeyActLogList);
}
} }
......
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;
import javax.annotation.Resource;
import java.util.List;
@Service
public class SmartKeyCommandShareLogServiceImpl implements SmartKeyCommandShareLogService{
@Resource
private SmartKeyCommandShareLogMapper smartKeyCommandShareLogMapper;
@Override
public long countByExample(SmartKeyCommandShareLogExample example) {
return smartKeyCommandShareLogMapper.countByExample(example);
}
@Override
public int deleteByExample(SmartKeyCommandShareLogExample example) {
return smartKeyCommandShareLogMapper.deleteByExample(example);
}
@Override
public int deleteByPrimaryKey(Long id) {
return smartKeyCommandShareLogMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(SmartKeyCommandShareLog record) {
return smartKeyCommandShareLogMapper.insert(record);
}
@Override
public int insertSelective(SmartKeyCommandShareLog record) {
return smartKeyCommandShareLogMapper.insertSelective(record);
}
@Override
public List<SmartKeyCommandShareLog> selectByExample(SmartKeyCommandShareLogExample example) {
return smartKeyCommandShareLogMapper.selectByExample(example);
}
@Override
public SmartKeyCommandShareLog selectByPrimaryKey(Long id) {
return smartKeyCommandShareLogMapper.selectByPrimaryKey(id);
}
@Override
public int updateByExampleSelective(SmartKeyCommandShareLog record,SmartKeyCommandShareLogExample example) {
return smartKeyCommandShareLogMapper.updateByExampleSelective(record,example);
}
@Override
public int updateByExample(SmartKeyCommandShareLog record,SmartKeyCommandShareLogExample example) {
return smartKeyCommandShareLogMapper.updateByExample(record,example);
}
@Override
public int updateByPrimaryKeySelective(SmartKeyCommandShareLog record) {
return smartKeyCommandShareLogMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(SmartKeyCommandShareLog record) {
return smartKeyCommandShareLogMapper.updateByPrimaryKey(record);
}
@Override
public int insertBatch(List<SmartCarKeyShareLogRequest> lockingkeyActLogList) {
return smartKeyCommandShareLogMapper.insertBatch(lockingkeyActLogList);
}
}
...@@ -146,6 +146,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ ...@@ -146,6 +146,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
@Override @Override
public int updateByPrimaryKeySelective(SmartScene record) { public int updateByPrimaryKeySelective(SmartScene record) {
redisService.delete(record.getId()+"_scene_status");
return sceneMapper.updateByPrimaryKeySelective(record); return sceneMapper.updateByPrimaryKeySelective(record);
} }
...@@ -329,14 +330,14 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ ...@@ -329,14 +330,14 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
Map<String, Object> map = sceneMapper.getBySourceAndUserId(scene.getId()); Map<String, Object> map = sceneMapper.getBySourceAndUserId(scene.getId());
String user_id = map.get("user_id") + ""; String user_id = map.get("user_id") + "";
Map<String, String> paramMap = new HashMap<>(); Map<String, String> paramMap = new HashMap<>();
String source = map.get("source") + ""; Object source=map.get("source") ;
paramMap.put("alias", user_id); paramMap.put("alias", user_id);
paramMap.put("deviceType", map.get("source") + ""); paramMap.put("deviceType", map.get("source") + "");
paramMap.put("title", title); paramMap.put("title", title);
paramMap.put("body", msg); paramMap.put("body", msg);
paramMap.put("msgBody", msg); paramMap.put("msgBody", msg);
saveMegInfo(user_id, title, msg); saveMegInfo(user_id, title, msg);
if (StringUtils.isEmpty(source)) { if(source==null){
return; return;
} }
try { try {
...@@ -385,7 +386,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ ...@@ -385,7 +386,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
Map<String, Object> map = sceneMapper.getBySourceAndUserId(scene.getId()); Map<String, Object> map = sceneMapper.getBySourceAndUserId(scene.getId());
String user_id = map.get("user_id") + ""; String user_id = map.get("user_id") + "";
String scene_name = map.get("scene_name") + ""; String scene_name = map.get("scene_name") + "";
String source = map.get("source") + ""; Object source = map.get("source");
Map<String, String> paramMap = new HashMap<>(); Map<String, String> paramMap = new HashMap<>();
paramMap.put("alias", user_id); paramMap.put("alias", user_id);
paramMap.put("deviceType", map.get("source") + ""); paramMap.put("deviceType", map.get("source") + "");
...@@ -405,7 +406,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ ...@@ -405,7 +406,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
String context = buildBody(collect, scene_name); String context = buildBody(collect, scene_name);
paramMap.put("msgBody", context); paramMap.put("msgBody", context);
saveMegInfo(user_id, title, context); saveMegInfo(user_id, title, context);
if (StringUtils.isEmpty(source)) { if(source==null){
return; return;
} }
try { try {
......
...@@ -69,9 +69,18 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService { ...@@ -69,9 +69,18 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
} }
@Override @Override
public Long insertSelective(SmartUserRelation record) { public synchronized Long insertSelective(SmartUserRelation record) {
int i = relationMapper.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
......
...@@ -5,7 +5,6 @@ import com.glsx.smart.dao.entity.SmartVehicleBlueKeyExample; ...@@ -5,7 +5,6 @@ import com.glsx.smart.dao.entity.SmartVehicleBlueKeyExample;
import com.glsx.smart.dao.mapper.SmartVehicleBlueKeyMapper; import com.glsx.smart.dao.mapper.SmartVehicleBlueKeyMapper;
import com.glsx.smart.service.SmartVehicleBlueKeyService; import com.glsx.smart.service.SmartVehicleBlueKeyService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
...@@ -70,7 +69,48 @@ public class SmartVehicleBlueKeyServiceImpl implements SmartVehicleBlueKeyServic ...@@ -70,7 +69,48 @@ public class SmartVehicleBlueKeyServiceImpl implements SmartVehicleBlueKeyServic
return smartVehicleBlueKeyMapper.updateByPrimaryKey(record); return smartVehicleBlueKeyMapper.updateByPrimaryKey(record);
} }
//查询车钥匙example,根据用户ID和sn查
@Override
public SmartVehicleBlueKeyExample getBlueKeyExampleByUserAndSn(Long userId, String sn) {
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria()
.andUserIdEqualTo(userId)
.andSnEqualTo(sn)
.andIsDeleteEqualTo(0);
return example;
}
@Override
public List<SmartVehicleBlueKey> selectByUserAndSn(Long userId, String sn) {
SmartVehicleBlueKeyExample example = getBlueKeyExampleByUserAndSn(userId,sn);
return smartVehicleBlueKeyMapper.selectByExample(example);
}
@Override
public List<SmartVehicleBlueKey> selectById(Long id) {
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria()
.andIdEqualTo(id)
.andIsDeleteEqualTo(0);
return smartVehicleBlueKeyMapper.selectByExample(example);
}
@Override
public int removeKeyByIds(List<Long> keyIds) {
return smartVehicleBlueKeyMapper.removeKeyByIds(keyIds);
}
@Override
public long countKeyByUser(long userId) {
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria()
.andUserIdEqualTo(userId);
return smartVehicleBlueKeyMapper.countByExample(example);
}
} }
package com.glsx.smart.service.impl;
import com.glsx.smart.dao.entity.SmartShareKeyBlueKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample;
import com.glsx.smart.dao.mapper.SmartVehicleBlueShareKeyMapper;
import com.glsx.smart.service.SmartVehicleBlueShareKeyService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShareKeyService {
@Resource
private SmartVehicleBlueShareKeyMapper smartVehicleBlueShareKeyMapper;
@Override
public long countByExample(SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.countByExample(example);
}
@Override
public int deleteByExample(SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.deleteByExample(example);
}
@Override
public int deleteByPrimaryKey(Long id) {
return smartVehicleBlueShareKeyMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.insert(record);
}
@Override
public int insertSelective(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.insertSelective(record);
}
@Override
public List<SmartVehicleBlueShareKey> selectByExample(SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.selectByExample(example);
}
@Override
public SmartVehicleBlueShareKey selectByPrimaryKey(Long id) {
return smartVehicleBlueShareKeyMapper.selectByPrimaryKey(id);
}
@Override
public int updateByExampleSelective(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.updateByExampleSelective(record, example);
}
@Override
public int updateByExample(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.updateByExample(record, example);
}
@Override
public int updateByPrimaryKeySelective(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.updateByPrimaryKey(record);
}
//查询分享车钥匙列表example,根据主钥匙ID查
@Override
public SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByCarKeyID(Long carKeyId) {
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample();
example.setOrderByClause("`share_status` desc");
example.createCriteria()
.andCarKeyIdEqualTo(carKeyId)
//已领取
.andSharePickStatusEqualTo(1);
return example;
}
//查询分享车钥匙example,根据分享钥匙ID查
@Override
public SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByID(Long id) {
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample();
example.createCriteria()
.andIdEqualTo(id)
//已领取
.andSharePickStatusEqualTo(1)
//分享状态打开
.andShareStatusEqualTo(1);
return example;
}
@Override
public int updateShareStatusByIds(List<Long> ids) {
return smartVehicleBlueShareKeyMapper.updateShareStatusByIds(ids);
}
@Override
public List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId) {
return smartVehicleBlueShareKeyMapper.getShareKeyListByUserId(userId);
}
@Override
public int closeShareKeyByCarKeyId(Long carKeyId) {
SmartVehicleBlueShareKey shareKey = new SmartVehicleBlueShareKey();
//关闭分享状态,更新过期时间
shareKey.setShareStatus(0);
shareKey.setStopTime(new Date());
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample();
example.createCriteria()
.andCarKeyIdEqualTo(carKeyId)
.andShareStatusEqualTo(1);
return smartVehicleBlueShareKeyMapper.updateByExampleSelective(shareKey, example);
}
@Override
public int closeShareKeyByMainKeyIds(List<Long> keyIds) {
//关闭分享状态,更新过期时间
return smartVehicleBlueShareKeyMapper.closeShareKeyByMainKeyIds(keyIds);
}
@Override
public List<SmartShareKeyBlueKey> getShareKeyListByKeyId(Long keyId) {
return smartVehicleBlueShareKeyMapper.getShareKeyListByKeyId(keyId);
}
}
package com.glsx.smart.utils;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
/**
* @Description: Jwt工具类
* @author fengzhi
* @version V1.0
*/
@Slf4j
@Component
public class JwtUtil {
//令牌加密key
@Value("${jwt.secret}")
private String KEY = "123456";
//令牌默认超时时间
@Value("${jwt.expiration}")
private String EXPIRATION;
/**
* 根据负责生成JWT的token
*/
public String generateToken(Map<String, Object> claims) {
return Jwts.builder()
.setClaims(claims)
.signWith(SignatureAlgorithm.HS256,KEY)
.compact();
}
public String generateToken(Map<String, Object> claims,long expireTime) {
return Jwts.builder()
.setClaims(claims)
.setExpiration(generateExpirationDate(expireTime))
.signWith(SignatureAlgorithm.HS256,KEY)
.compact();
}
/**
* 从token中获取JWT中的负载
*/
public Claims getClaimsFromToken(String token) {
Claims claims = null;
claims = Jwts.parser()
.setSigningKey(KEY)
.parseClaimsJws(token)
.getBody();
return claims;
}
/**
* 生成token的过期时间
*/
public Date generateExpirationDate(long expireTime) {
return new Date(System.currentTimeMillis() + expireTime * 1000);
}
/**
* 判断token是否已经失效
*/
public boolean isTokenExpired(String token) {
Date expiredDate = getExpiredDateFromToken(token);
return expiredDate.before(new Date());
}
/**
* 从token中获取过期时间
*/
public Date getExpiredDateFromToken(String token) {
Claims claims = getClaimsFromToken(token);
return claims.getExpiration();
}
/**
* 判断token是否可以被刷新
*/
//public boolean canRefresh(String token) {
// return !isTokenExpired(token);
//}
/**
* 刷新token
*/
//public String refreshToken(String token) {
// Claims claims = getClaimsFromToken(token);
// claims.put("created", new Date());
// return generateToken(claims);
//}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.smart.dao.mapper.SmartKeyCommandShareLogMapper">
<resultMap id="BaseResultMap" type="com.glsx.smart.dao.entity.SmartKeyCommandShareLog">
<!--@mbg.generated-->
<!--@Table smart_key_command_share_log-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="share_car_key_id" jdbcType="BIGINT" property="shareCarKeyId" />
<result column="key_command" jdbcType="VARCHAR" property="keyCommand" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Example_Where_Clause">
<!--@mbg.generated-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<!-- <when test="criterion.listValue">-->
<!-- and ${criterion.condition}-->
<!-- <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">-->
<!-- #{listItem}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--@mbg.generated-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<!-- <when test="criterion.listValue">-->
<!-- and ${criterion.condition}-->
<!-- <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">-->
<!-- #{listItem}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, share_car_key_id, key_command, create_time
</sql>
<select id="selectByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyCommandShareLogExample" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from smart_key_command_share_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from smart_key_command_share_log
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
delete from smart_key_command_share_log
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyCommandShareLogExample">
<!--@mbg.generated-->
delete from smart_key_command_share_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.glsx.smart.dao.entity.SmartKeyCommandShareLog" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into smart_key_command_share_log (share_car_key_id, key_command, create_time
)
values (#{shareCarKeyId,jdbcType=BIGINT}, #{keyCommand,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.glsx.smart.dao.entity.SmartKeyCommandShareLog" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into smart_key_command_share_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="shareCarKeyId != null">
share_car_key_id,
</if>
<if test="keyCommand != null">
key_command,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="shareCarKeyId != null">
#{shareCarKeyId,jdbcType=BIGINT},
</if>
<if test="keyCommand != null">
#{keyCommand,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyCommandShareLogExample" resultType="java.lang.Long">
<!--@mbg.generated-->
select count(*) from smart_key_command_share_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--@mbg.generated-->
update smart_key_command_share_log
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.shareCarKeyId != null">
share_car_key_id = #{record.shareCarKeyId,jdbcType=BIGINT},
</if>
<if test="record.keyCommand != null">
key_command = #{record.keyCommand,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--@mbg.generated-->
update smart_key_command_share_log
set id = #{record.id,jdbcType=BIGINT},
share_car_key_id = #{record.shareCarKeyId,jdbcType=BIGINT},
key_command = #{record.keyCommand,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.smart.dao.entity.SmartKeyCommandShareLog">
<!--@mbg.generated-->
update smart_key_command_share_log
<set>
<if test="shareCarKeyId != null">
share_car_key_id = #{shareCarKeyId,jdbcType=BIGINT},
</if>
<if test="keyCommand != null">
key_command = #{keyCommand,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.smart.dao.entity.SmartKeyCommandShareLog">
<!--@mbg.generated-->
update smart_key_command_share_log
set share_car_key_id = #{shareCarKeyId,jdbcType=BIGINT},
key_command = #{keyCommand,jdbcType=VARCHAR},
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 \ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<result column="type_key" jdbcType="VARCHAR" property="typeKey"/> <result column="type_key" jdbcType="VARCHAR" property="typeKey"/>
<result column="icon" jdbcType="BIGINT" property="icon"/> <result column="icon" jdbcType="BIGINT" property="icon"/>
<result column="back_pic" jdbcType="BIGINT" property="backPic"/> <result column="back_pic" jdbcType="BIGINT" property="backPic"/>
<result column="page_pic" jdbcType="BIGINT" property="pagePic"/>
<result column="view_times" jdbcType="BIGINT" property="viewTimes"/> <result column="view_times" jdbcType="BIGINT" property="viewTimes"/>
<result column="description" jdbcType="VARCHAR" property="description"/> <result column="description" jdbcType="VARCHAR" property="description"/>
<result column="condition_rule" jdbcType="TINYINT" property="conditionRule"/> <result column="condition_rule" jdbcType="TINYINT" property="conditionRule"/>
...@@ -28,10 +29,14 @@ ...@@ -28,10 +29,14 @@
fetchType="eager" fetchType="eager"
select="com.glsx.smart.dao.mapper.SmartSysFileMapper.selectUrlById"> select="com.glsx.smart.dao.mapper.SmartSysFileMapper.selectUrlById">
</collection> </collection>
<collection property="pagePicUrl" column="page_pic" ofType="com.glsx.smart.dao.entity.SmartScene"
fetchType="eager"
select="com.glsx.smart.dao.mapper.SmartSysFileMapper.selectUrlById">
</collection>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, user_id, scene_name, type_key, icon, back_pic, view_times, description, condition_rule, id, user_id, scene_name, type_key, icon, back_pic, page_pic, view_times, description, condition_rule,
execute_cycle, `status`, remark, create_time, update_time execute_cycle, `status`, remark, create_time, update_time
</sql> </sql>
<update id="updateBatch" parameterType="java.util.List"> <update id="updateBatch" parameterType="java.util.List">
...@@ -220,14 +225,14 @@ ...@@ -220,14 +225,14 @@
useGeneratedKeys="true"> useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into smart_scene insert into smart_scene
(user_id, scene_name, type_key, icon, back_pic, view_times, description, condition_rule, (user_id, scene_name, type_key, icon, back_pic, page_pic, view_times, description, condition_rule,
execute_cycle, `status`, remark, create_time, update_time) execute_cycle, `status`, remark, create_time, update_time)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.userId,jdbcType=BIGINT}, #{item.sceneName,jdbcType=VARCHAR}, (#{item.userId,jdbcType=BIGINT}, #{item.sceneName,jdbcType=VARCHAR},
#{item.typeKey,jdbcType=VARCHAR}, #{item.typeKey,jdbcType=VARCHAR},
#{item.icon,jdbcType=BIGINT}, #{item.backPic,jdbcType=BIGINT}, #{item.icon,jdbcType=BIGINT}, #{item.backPic,jdbcType=BIGINT},
#{item.viewTimes,jdbcType=BIGINT}, #{item.pagePic,jdbcType=BIGINT}, #{item.viewTimes,jdbcType=BIGINT},
#{item.description,jdbcType=VARCHAR}, #{item.conditionRule,jdbcType=TINYINT}, #{item.description,jdbcType=VARCHAR}, #{item.conditionRule,jdbcType=TINYINT},
#{item.executeCycle,jdbcType=TINYINT}, #{item.executeCycle,jdbcType=TINYINT},
#{item.status,jdbcType=TINYINT}, #{item.remark,jdbcType=VARCHAR}, #{item.status,jdbcType=TINYINT}, #{item.remark,jdbcType=VARCHAR},
...@@ -319,6 +324,9 @@ ...@@ -319,6 +324,9 @@
<if test="backPic != null"> <if test="backPic != null">
back_pic, back_pic,
</if> </if>
<if test="pagePic != null">
page_pic,
</if>
<if test="viewTimes != null"> <if test="viewTimes != null">
view_times, view_times,
</if> </if>
...@@ -364,6 +372,9 @@ ...@@ -364,6 +372,9 @@
<if test="backPic != null"> <if test="backPic != null">
#{backPic,jdbcType=BIGINT}, #{backPic,jdbcType=BIGINT},
</if> </if>
<if test="pagePic != null">
#{pagePic,jdbcType=BIGINT},
</if>
<if test="viewTimes != null"> <if test="viewTimes != null">
#{viewTimes,jdbcType=BIGINT}, #{viewTimes,jdbcType=BIGINT},
</if> </if>
...@@ -409,6 +420,9 @@ ...@@ -409,6 +420,9 @@
<if test="backPic != null"> <if test="backPic != null">
back_pic = #{backPic,jdbcType=BIGINT}, back_pic = #{backPic,jdbcType=BIGINT},
</if> </if>
<if test="pagePic != null">
page_pic = #{pagePic,jdbcType=BIGINT},
</if>
<if test="viewTimes != null"> <if test="viewTimes != null">
view_times = #{viewTimes,jdbcType=BIGINT}, view_times = #{viewTimes,jdbcType=BIGINT},
</if> </if>
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
<result column="type_key" jdbcType="VARCHAR" property="typeKey"/> <result column="type_key" jdbcType="VARCHAR" property="typeKey"/>
<result column="icon" jdbcType="BIGINT" property="icon"/> <result column="icon" jdbcType="BIGINT" property="icon"/>
<result column="back_pic" jdbcType="BIGINT" property="backPic"/> <result column="back_pic" jdbcType="BIGINT" property="backPic"/>
<result column="page_pic" jdbcType="BIGINT" property="pagePic"/>
<result column="is_top" jdbcType="TINYINT" property="isTop"/>
<result column="view_times" jdbcType="BIGINT" property="viewTimes"/> <result column="view_times" jdbcType="BIGINT" property="viewTimes"/>
<result column="description" jdbcType="VARCHAR" property="description"/> <result column="description" jdbcType="VARCHAR" property="description"/>
<result column="condition_rule" jdbcType="TINYINT" property="conditionRule"/> <result column="condition_rule" jdbcType="TINYINT" property="conditionRule"/>
...@@ -28,10 +30,13 @@ ...@@ -28,10 +30,13 @@
<collection property="backPicUrl" column="back_pic" ofType="com.glsx.smart.dao.entity.SmartSceneTemplate" fetchType="eager" <collection property="backPicUrl" column="back_pic" ofType="com.glsx.smart.dao.entity.SmartSceneTemplate" fetchType="eager"
select="com.glsx.smart.dao.mapper.SmartSysFileMapper.selectUrlById"> select="com.glsx.smart.dao.mapper.SmartSysFileMapper.selectUrlById">
</collection> </collection>
<collection property="pagePicUrl" column="page_pic" ofType="com.glsx.smart.dao.entity.SmartSceneTemplate" fetchType="eager"
select="com.glsx.smart.dao.mapper.SmartSysFileMapper.selectUrlById">
</collection>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, scene_name, type_key, icon, back_pic, view_times, description, condition_rule, id, scene_name, type_key, icon, back_pic, page_pic, is_top, view_times, description, condition_rule,
execute_cycle, `status`, remark, create_time, create_by, update_time, update_by execute_cycle, `status`, remark, create_time, create_by, update_time, update_by
</sql> </sql>
<update id="updateBatch" parameterType="java.util.List"> <update id="updateBatch" parameterType="java.util.List">
...@@ -232,15 +237,15 @@ ...@@ -232,15 +237,15 @@
useGeneratedKeys="true"> useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into smart_scene_template insert into smart_scene_template
(scene_name, type_key, icon, back_pic, view_times, description, condition_rule, (scene_name, type_key, icon, back_pic, page_pic, view_times, description, condition_rule,
execute_cycle, `status`, remark, create_time, create_by, update_time, update_by execute_cycle, `status`, remark, create_time, create_by, update_time, update_by
) )
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.sceneName,jdbcType=VARCHAR}, #{item.typeKey,jdbcType=VARCHAR}, (#{item.sceneName,jdbcType=VARCHAR}, #{item.typeKey,jdbcType=VARCHAR},
#{item.icon,jdbcType=BIGINT}, #{item.icon,jdbcType=BIGINT},
#{item.backPic,jdbcType=BIGINT}, #{item.viewTimes,jdbcType=BIGINT}, #{item.backPic,jdbcType=BIGINT}, #{item.pagePic,jdbcType=BIGINT},
#{item.description,jdbcType=VARCHAR}, #{item.viewTimes,jdbcType=BIGINT}, #{item.description,jdbcType=VARCHAR},
#{item.conditionRule,jdbcType=TINYINT}, #{item.executeCycle,jdbcType=TINYINT}, #{item.conditionRule,jdbcType=TINYINT}, #{item.executeCycle,jdbcType=TINYINT},
#{item.status,jdbcType=TINYINT}, #{item.remark,jdbcType=VARCHAR}, #{item.status,jdbcType=TINYINT}, #{item.remark,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP}, #{item.createTime,jdbcType=TIMESTAMP},
...@@ -333,6 +338,9 @@ ...@@ -333,6 +338,9 @@
<if test="backPic != null"> <if test="backPic != null">
back_pic, back_pic,
</if> </if>
<if test="pagePic != null">
page_pic,
</if>
<if test="viewTimes != null"> <if test="viewTimes != null">
view_times, view_times,
</if> </if>
...@@ -381,6 +389,9 @@ ...@@ -381,6 +389,9 @@
<if test="backPic != null"> <if test="backPic != null">
#{backPic,jdbcType=BIGINT}, #{backPic,jdbcType=BIGINT},
</if> </if>
<if test="pagePic != null">
#{pagePic,jdbcType=BIGINT},
</if>
<if test="viewTimes != null"> <if test="viewTimes != null">
#{viewTimes,jdbcType=BIGINT}, #{viewTimes,jdbcType=BIGINT},
</if> </if>
...@@ -429,6 +440,9 @@ ...@@ -429,6 +440,9 @@
<if test="backPic != null"> <if test="backPic != null">
back_pic = #{backPic,jdbcType=BIGINT}, back_pic = #{backPic,jdbcType=BIGINT},
</if> </if>
<if test="pagePic != null">
page_pic = #{pagePic,jdbcType=BIGINT},
</if>
<if test="viewTimes != null"> <if test="viewTimes != null">
view_times = #{viewTimes,jdbcType=BIGINT}, view_times = #{viewTimes,jdbcType=BIGINT},
</if> </if>
...@@ -472,6 +486,9 @@ ...@@ -472,6 +486,9 @@
<if test="status != null"> <if test="status != null">
and t.status = #{status,jdbcType=TINYINT} and t.status = #{status,jdbcType=TINYINT}
</if> </if>
<if test="isTop != null">
and t.is_top = #{isTop,jdbcType=TINYINT}
</if>
<if test="sceneName != null and sceneName != ''"> <if test="sceneName != null and sceneName != ''">
and t.scene_name = #{sceneName,jdbcType=VARCHAR} and t.scene_name = #{sceneName,jdbcType=VARCHAR}
</if> </if>
......
package com.glsx.smart.service;
import com.glsx.smart.service.impl.UserKafkaServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author wangxw
* @version 1.0.0
* @ClassName TestDubboService.java
* @description: ${description}
* @createTime 2021年05月05日 15:58:00
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestDubboService {
@Autowired
private UserKafkaServiceImpl userKafkaService;
@Test
public void testGetUserAddress() {
Long userId = 91712473L;
userKafkaService.getPointUser(userId);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!