Commit c4efb0db by fz

1.setnx添加业务前缀

2.分享钥匙列表返回page对象
1 parent 2623c831
...@@ -64,5 +64,5 @@ public interface SmartVehicleBlueShareKeyMapper { ...@@ -64,5 +64,5 @@ public interface SmartVehicleBlueShareKeyMapper {
*/ */
int updateByPrimaryKey(SmartVehicleBlueShareKey record); int updateByPrimaryKey(SmartVehicleBlueShareKey record);
int updateByIds(List<Long> ids); int updateShareStatusByIds(List<Long> ids);
} }
\ No newline at end of file \ No newline at end of file
...@@ -36,6 +36,6 @@ public interface SmartVehicleBlueShareKeyService { ...@@ -36,6 +36,6 @@ public interface SmartVehicleBlueShareKeyService {
SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByIDDelete(Long id); SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByIDDelete(Long id);
int updateByIds(List<Long> ids); int updateShareStatusByIds(List<Long> ids);
} }
...@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.common.utils.StringUtils;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import com.glsx.smart.dao.entity.*; import com.glsx.smart.dao.entity.*;
import com.glsx.smart.exception.BusinessException; import com.glsx.smart.exception.BusinessException;
...@@ -670,27 +671,23 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService { ...@@ -670,27 +671,23 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
} }
List<Long> expireList = new ArrayList<>(); List<Long> expireList = new ArrayList<>();
List<SmartVehicleBlueShareKey> resList = new ArrayList<>();
//过期数据分类 //过期数据分类
Date finalNowDate = nowDate; Date finalNowDate = nowDate;
shareKeyList.stream().forEach(key->{ shareKeyList.stream().forEach(key->{
Date expireDate = key.getExpireTime(); Date expireDate = key.getExpireTime();
if(finalNowDate.after(expireDate)) if(finalNowDate.after(expireDate)){
expireList.add(key.getId()); expireList.add(key.getId());
else //过期关闭
resList.add(key); key.setShareStatus(1);
}); }
if(CollectionUtils.isEmpty(resList))
return R.ok().data(null);
});
//如果当前时间已经超过过期时间,更新数据 //如果当前时间已经超过过期时间,更新数据
if (CollectionUtils.isNotEmpty(expireList)){ if (CollectionUtils.isNotEmpty(expireList)){
smartVehicleBlueShareKeyService.updateByIds(expireList); smartVehicleBlueShareKeyService.updateShareStatusByIds(expireList);
} }
return R.ok().data(resList); return R.ok().data(PageInfo.of(shareKeyList));
} }
} }
...@@ -116,7 +116,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService { ...@@ -116,7 +116,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
if (nowDate.after(expireDate)) if (nowDate.after(expireDate))
return R.error("当前时间已超过分享过期时间"); return R.error("当前时间已超过分享过期时间");
boolean res = redisService.setnx(shareKeyId,userId); boolean res = redisService.setnx("receive_share_key:"+shareKeyId,userId);
if(!res) if(!res)
return R.error("钥匙已经被领用"); return R.error("钥匙已经被领用");
......
...@@ -113,8 +113,8 @@ public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShar ...@@ -113,8 +113,8 @@ public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShar
} }
@Override @Override
public int updateByIds(List<Long> ids) { public int updateShareStatusByIds(List<Long> ids) {
return smartVehicleBlueShareKeyMapper.updateByIds(ids); return smartVehicleBlueShareKeyMapper.updateShareStatusByIds(ids);
} }
private Date getFormatNowDate() { private Date getFormatNowDate() {
......
...@@ -342,7 +342,7 @@ ...@@ -342,7 +342,7 @@
</update> </update>
<update id="updateByIds"> <update id="updateShareStatusByIds">
update smart_vehicle_blue_share_key set share_status = 1 where id in update smart_vehicle_blue_share_key set share_status = 1 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}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!