Commit f50d3488 by fz

1.小程序根据userid查询分享车钥匙,添加主车钥匙信息返回

1 parent 0ea992c2
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;
/**
* 分享钥匙领取时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd",
timezone = "GMT+8"
)
private Date pickTime;
/**
* 分享状态 0:关闭 1:打开
*/
private Integer shareStatus;
/**
* 分享钥匙过期时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd",
timezone = "GMT+8"
)
private Date expireTime;
/*****************主钥匙********************/
/**
* 车钥匙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;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
/**
* 手机编号
*/
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.mapper; 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.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample; import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample;
import java.util.List; import java.util.List;
...@@ -65,4 +66,6 @@ public interface SmartVehicleBlueShareKeyMapper { ...@@ -65,4 +66,6 @@ public interface SmartVehicleBlueShareKeyMapper {
int updateByPrimaryKey(SmartVehicleBlueShareKey record); int updateByPrimaryKey(SmartVehicleBlueShareKey record);
int updateShareStatusByIds(List<Long> ids); int updateShareStatusByIds(List<Long> ids);
List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.service; 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.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample; import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample;
...@@ -36,6 +37,6 @@ public interface SmartVehicleBlueShareKeyService { ...@@ -36,6 +37,6 @@ public interface SmartVehicleBlueShareKeyService {
int updateShareStatusByIds(List<Long> ids); int updateShareStatusByIds(List<Long> ids);
List<SmartVehicleBlueShareKey> getShareKeyListByUserId(Long userId); List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
} }
...@@ -163,7 +163,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService { ...@@ -163,7 +163,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
return R.ok().data(null); return R.ok().data(null);
//校验过期时间 //校验过期时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); /* SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowTime = sdf.format(new Date()); String nowTime = sdf.format(new Date());
Date expireDate = keyList.get(0).getExpireTime(); Date expireDate = keyList.get(0).getExpireTime();
...@@ -185,7 +185,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService { ...@@ -185,7 +185,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
SmartVehicleBlueShareKeyExample exampleDelete = shareKeyService.getBlueKeyShareExampleByID(Long.valueOf(keyid)); SmartVehicleBlueShareKeyExample exampleDelete = shareKeyService.getBlueKeyShareExampleByID(Long.valueOf(keyid));
shareKeyService.updateByExampleSelective(blueKey, exampleDelete); shareKeyService.updateByExampleSelective(blueKey, exampleDelete);
return R.ok().data(null); return R.ok().data(null);
} }*/
return R.ok().data(keyList.get(0)); return R.ok().data(keyList.get(0));
} }
...@@ -202,11 +202,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService { ...@@ -202,11 +202,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
public R getShareKeyListByUser(Long userId) { public R getShareKeyListByUser(Long userId) {
Assert.notNull(userId,"用户id不能为空"); Assert.notNull(userId,"用户id不能为空");
List<SmartVehicleBlueShareKey> keys = shareKeyService.getShareKeyListByUserId(userId); List<SmartShareKeyBlueKey> keys = shareKeyService.getShareKeyListByUserId(userId);
if (CollectionUtils.isEmpty(keys)){
return R.ok().data(keys);
}
//校验过期时间 //校验过期时间
/* SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); /* SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
......
package com.glsx.smart.service.impl; 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.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample; import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample;
import com.glsx.smart.dao.mapper.SmartVehicleBlueShareKeyMapper; import com.glsx.smart.dao.mapper.SmartVehicleBlueShareKeyMapper;
...@@ -101,13 +102,8 @@ public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShar ...@@ -101,13 +102,8 @@ public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShar
} }
@Override @Override
public List<SmartVehicleBlueShareKey> getShareKeyListByUserId(Long userId) { public List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId) {
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample(); return smartVehicleBlueShareKeyMapper.getShareKeyListByUserId(userId);
example.createCriteria()
.andPickUserIdEqualTo(userId)
.andSharePickStatusEqualTo(1)
.andShareStatusEqualTo(1);
return smartVehicleBlueShareKeyMapper.selectByExample(example);
} }
} }
...@@ -13,6 +13,33 @@ ...@@ -13,6 +13,33 @@
<result column="share_status" jdbcType="TINYINT" property="shareStatus"/> <result column="share_status" jdbcType="TINYINT" property="shareStatus"/>
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/> <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
</resultMap> </resultMap>
<resultMap id="BaseMultiResultMap" type="com.glsx.smart.dao.entity.SmartShareKeyBlueKey">
<!--@mbg.generated-->
<!--@Table smart_vehicle_blue_share_key-->
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="car_key_id" jdbcType="BIGINT" property="carKeyId"/>
<result column="share_key_token" jdbcType="VARCHAR" property="shareKeyToken"/>
<result column="share_pick_status" jdbcType="TINYINT" property="sharePickStatus"/>
<result column="pick_user_id" jdbcType="BIGINT" property="pickUserId"/>
<result column="pick_time" jdbcType="TIMESTAMP" property="pickTime"/>
<result column="share_status" jdbcType="TINYINT" property="shareStatus"/>
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
<!--主钥匙字段-->
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="crep_code" jdbcType="VARCHAR" property="crepCode"/>
<result column="secret_key" jdbcType="VARCHAR" property="secretKey"/>
<result column="smart_lock_Mac" jdbcType="VARCHAR" property="smartLockMac"/>
<result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
<result column="key_name" jdbcType="VARCHAR" property="keyName"/>
<result column="is_delete" jdbcType="TINYINT" property="isDelete"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="mobile_code" jdbcType="VARCHAR" property="mobileCode"/>
<result column="peripheral_uuid" jdbcType="VARCHAR" property="peripheralUuid"/>
<result column="main_share_status" jdbcType="TINYINT" property="mainShareStatus"/>
</resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!--@mbg.generated--> <!--@mbg.generated-->
<where> <where>
...@@ -84,28 +111,70 @@ ...@@ -84,28 +111,70 @@
select select
<if test="distinct"> <if test="distinct">
distinct distinct
</if> </if>
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from smart_vehicle_blue_share_key from smart_vehicle_blue_share_key
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause"/> <include refid="Example_Where_Clause"/>
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null">
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
...@@ -113,13 +182,31 @@ ...@@ -113,13 +182,31 @@
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from smart_vehicle_blue_share_key from smart_vehicle_blue_share_key
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated--> <!--@mbg.generated-->
...@@ -127,12 +214,24 @@ ...@@ -127,12 +214,24 @@
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</delete> </delete>
<delete id="deleteByExample" parameterType="com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample"> <delete id="deleteByExample" parameterType="com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample">
<!--@mbg.generated--> <!--@mbg.generated-->
delete from smart_vehicle_blue_share_key delete from smart_vehicle_blue_share_key
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause"/> <include refid="Example_Where_Clause"/>
</if> </if>
...@@ -148,6 +247,12 @@ ...@@ -148,6 +247,12 @@
#{expireTime,jdbcType=TIMESTAMP}) #{expireTime,jdbcType=TIMESTAMP})
</insert> </insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" <insert id="insertSelective" keyColumn="id" keyProperty="id"
parameterType="com.glsx.smart.dao.entity.SmartVehicleBlueShareKey" useGeneratedKeys="true"> parameterType="com.glsx.smart.dao.entity.SmartVehicleBlueShareKey" useGeneratedKeys="true">
...@@ -155,50 +260,128 @@ ...@@ -155,50 +260,128 @@
insert into smart_vehicle_blue_share_key insert into smart_vehicle_blue_share_key
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="carKeyId != null"> <if test="carKeyId != null">
car_key_id, car_key_id,
</if> </if>
<if test="shareKeyToken != null"> <if test="shareKeyToken != null">
share_key_token, share_key_token,
</if> </if>
<if test="sharePickStatus != null"> <if test="sharePickStatus != null">
share_pick_status, share_pick_status,
</if> </if>
<if test="pickUserId != null"> <if test="pickUserId != null">
pick_user_id, pick_user_id,
</if> </if>
<if test="pickTime != null"> <if test="pickTime != null">
pick_time, pick_time,
</if> </if>
<if test="shareStatus != null"> <if test="shareStatus != null">
share_status, share_status,
</if> </if>
<if test="expireTime != null"> <if test="expireTime != null">
expire_time, expire_time,
</if> </if>
</trim> </trim>
...@@ -207,45 +390,117 @@ ...@@ -207,45 +390,117 @@
#{carKeyId,jdbcType=BIGINT}, #{carKeyId,jdbcType=BIGINT},
</if> </if>
<if test="shareKeyToken != null"> <if test="shareKeyToken != null">
#{shareKeyToken,jdbcType=VARCHAR}, #{shareKeyToken,jdbcType=VARCHAR},
</if> </if>
<if test="sharePickStatus != null"> <if test="sharePickStatus != null">
#{sharePickStatus,jdbcType=TINYINT}, #{sharePickStatus,jdbcType=TINYINT},
</if> </if>
<if test="pickUserId != null"> <if test="pickUserId != null">
#{pickUserId,jdbcType=BIGINT}, #{pickUserId,jdbcType=BIGINT},
</if> </if>
<if test="pickTime != null"> <if test="pickTime != null">
#{pickTime,jdbcType=TIMESTAMP}, #{pickTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="shareStatus != null"> <if test="shareStatus != null">
#{shareStatus,jdbcType=TINYINT}, #{shareStatus,jdbcType=TINYINT},
</if> </if>
<if test="expireTime != null"> <if test="expireTime != null">
#{expireTime,jdbcType=TIMESTAMP}, #{expireTime,jdbcType=TIMESTAMP},
</if> </if>
</trim> </trim>
...@@ -256,6 +511,12 @@ ...@@ -256,6 +511,12 @@
select count(*) from smart_vehicle_blue_share_key select count(*) from smart_vehicle_blue_share_key
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause"/> <include refid="Example_Where_Clause"/>
</if> </if>
...@@ -265,57 +526,147 @@ ...@@ -265,57 +526,147 @@
update smart_vehicle_blue_share_key update smart_vehicle_blue_share_key
<set> <set>
<if test="record.id != null"> <if test="record.id != null">
id = #{record.id,jdbcType=BIGINT}, id = #{record.id,jdbcType=BIGINT},
</if> </if>
<if test="record.carKeyId != null"> <if test="record.carKeyId != null">
car_key_id = #{record.carKeyId,jdbcType=BIGINT}, car_key_id = #{record.carKeyId,jdbcType=BIGINT},
</if> </if>
<if test="record.shareKeyToken != null"> <if test="record.shareKeyToken != null">
share_key_token = #{record.shareKeyToken,jdbcType=VARCHAR}, share_key_token = #{record.shareKeyToken,jdbcType=VARCHAR},
</if> </if>
<if test="record.sharePickStatus != null"> <if test="record.sharePickStatus != null">
share_pick_status = #{record.sharePickStatus,jdbcType=TINYINT}, share_pick_status = #{record.sharePickStatus,jdbcType=TINYINT},
</if> </if>
<if test="record.pickUserId != null"> <if test="record.pickUserId != null">
pick_user_id = #{record.pickUserId,jdbcType=BIGINT}, pick_user_id = #{record.pickUserId,jdbcType=BIGINT},
</if> </if>
<if test="record.pickTime != null"> <if test="record.pickTime != null">
pick_time = #{record.pickTime,jdbcType=TIMESTAMP}, pick_time = #{record.pickTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.shareStatus != null"> <if test="record.shareStatus != null">
share_status = #{record.shareStatus,jdbcType=TINYINT}, share_status = #{record.shareStatus,jdbcType=TINYINT},
</if> </if>
<if test="record.expireTime != null"> <if test="record.expireTime != null">
expire_time = #{record.expireTime,jdbcType=TIMESTAMP}, expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
</if> </if>
</set> </set>
...@@ -336,6 +687,12 @@ ...@@ -336,6 +687,12 @@
expire_time = #{record.expireTime,jdbcType=TIMESTAMP} expire_time = #{record.expireTime,jdbcType=TIMESTAMP}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/> <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
...@@ -345,58 +702,148 @@ ...@@ -345,58 +702,148 @@
update smart_vehicle_blue_share_key update smart_vehicle_blue_share_key
<set> <set>
<if test="carKeyId != null"> <if test="carKeyId != null">
car_key_id = #{carKeyId,jdbcType=BIGINT}, car_key_id = #{carKeyId,jdbcType=BIGINT},
</if> </if>
<if test="shareKeyToken != null"> <if test="shareKeyToken != null">
share_key_token = #{shareKeyToken,jdbcType=VARCHAR}, share_key_token = #{shareKeyToken,jdbcType=VARCHAR},
</if> </if>
<if test="sharePickStatus != null"> <if test="sharePickStatus != null">
share_pick_status = #{sharePickStatus,jdbcType=TINYINT}, share_pick_status = #{sharePickStatus,jdbcType=TINYINT},
</if> </if>
<if test="pickUserId != null"> <if test="pickUserId != null">
pick_user_id = #{pickUserId,jdbcType=BIGINT}, pick_user_id = #{pickUserId,jdbcType=BIGINT},
</if> </if>
<if test="pickTime != null"> <if test="pickTime != null">
pick_time = #{pickTime,jdbcType=TIMESTAMP}, pick_time = #{pickTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="shareStatus != null"> <if test="shareStatus != null">
share_status = #{shareStatus,jdbcType=TINYINT}, share_status = #{shareStatus,jdbcType=TINYINT},
</if> </if>
<if test="expireTime != null"> <if test="expireTime != null">
expire_time = #{expireTime,jdbcType=TIMESTAMP}, expire_time = #{expireTime,jdbcType=TIMESTAMP},
</if> </if>
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.glsx.smart.dao.entity.SmartVehicleBlueShareKey"> <update id="updateByPrimaryKey" parameterType="com.glsx.smart.dao.entity.SmartVehicleBlueShareKey">
<!--@mbg.generated--> <!--@mbg.generated-->
...@@ -411,21 +858,71 @@ ...@@ -411,21 +858,71 @@
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<update id="updateShareStatusByIds"> <update id="updateShareStatusByIds">
update smart_vehicle_blue_share_key update smart_vehicle_blue_share_key
<set> <set>
sex= now(), sex= now(),
share_status = 1 share_status = 1
</set> </set>
where id in where id in
<foreach collection="list" item="keyId" open="(" separator="," close=")" index="index"> <foreach collection="list" item="keyId" open="(" separator="," close=")" index="index">
#{keyId} #{keyId}
</foreach> </foreach>
</update> </update>
<select id="getShareKeyListByUserId" resultMap="BaseMultiResultMap">
SELECT
bsk.id as id,
bsk.share_key_token,
bsk.car_key_id,
bsk.share_pick_status,
bsk.pick_user_id,
bsk.pick_time,
bsk.share_status,
bsk.expire_time,
bk.user_id,
bk.sn,
bk.crep_code,
bk.secret_key,
bk.smart_lock_Mac,
bk.car_number,
bk.key_name,
bk.is_delete,
bk.create_time,
bk.mobile_code,
bk.peripheral_uuid,
bk.share_status as main_share_status
FROM
smart_vehicle_blue_share_key bsk
INNER JOIN smart_vehicle_blue_key bk ON bsk.car_key_id = bk.id
WHERE
bsk.pick_user_id = #{userId,jdbcType=BIGINT}
AND bsk.share_pick_status = 1
AND bsk.share_status = 1
</select>
</mapper> </mapper>
\ No newline at end of file \ 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!