| | |
| | | import com.boying.entity.User; |
| | | import com.boying.service.ParkService; |
| | | import com.boying.service.UserService; |
| | | import com.boying.util.RedisJsonUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | private StringRedisTemplate redisTemplate; |
| | | private final ParkService parkService; |
| | | private final UserService userService; |
| | | private final RedisJsonUtil redisJsonUtil; |
| | | |
| | | @PostMapping("/findPage") |
| | | public Object findPage(Page page) { |
| | |
| | | redisTemplate.opsForValue().set("car_park_" + park.getId(),"0",30, TimeUnit.DAYS); |
| | | redisTemplate.opsForValue().set("park_up_" + park.getId(),"true",30, TimeUnit.DAYS); |
| | | } |
| | | try { |
| | | redisJsonUtil.set("park-"+park.getId(), park); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("保存成功"); |
| | | } |
| | | |
| | | @PostMapping("/delete") |
| | | public Object delete(Long id) { |
| | | parkService.removeById(id); |
| | | redisJsonUtil.del("park-"+id); |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | |
| | | for (Long id : ids) { |
| | | Park byId1 = parkService.getById(id); |
| | | String num = redisTemplate.opsForValue().get("car_park_" + byId1.getId()); |
| | | if(StringUtils.isNotBlank(num)){ |
| | | num = "0"; |
| | | try { |
| | | if(StringUtils.isBlank(num)){ |
| | | num = "0"; |
| | | } |
| | | byId1.setCarNum(Integer.parseInt(num)); |
| | | }catch (Exception e){ |
| | | byId1.setCarNum(0); |
| | | e.printStackTrace(); |
| | | } |
| | | byId1.setCarNum(Integer.parseInt(num)); |
| | | list.add(byId1); |
| | | } |
| | | return R.ok(list); |