| | |
| | | package org.example.controller; |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | |
| | | import java.security.SecureRandom; |
| | | import java.sql.Date; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | currency.setCurrency(f.getCurrency()); |
| | | currency.setBuy(f.getBuy()); |
| | | currency.setSell(f.getSell()); |
| | | currencyMapper.insert(currency); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String formattedDateTime = now.format(formatter); |
| | | currency.setAddTime(formattedDateTime); |
| | | List<ConfigCurrency> configCurrencies = currencyMapper.selectList(new LambdaQueryWrapper<>(ConfigCurrency.class) |
| | | .eq(ConfigCurrency::getUserId,user.getId()) |
| | | .eq(ConfigCurrency::getCurrency, f.getCurrency()) |
| | | .eq(ConfigCurrency::getBuy, f.getBuy()) |
| | | .eq(ConfigCurrency::getSell, f.getSell()) |
| | | ); |
| | | if(CollectionUtil.isEmpty(configCurrencies)){ |
| | | currencyMapper.insert(currency); |
| | | } |
| | | }); |
| | | List<ConfigCurrency> configCurrencies = currencyMapper.selectList(new LambdaQueryWrapper<ConfigCurrency>().eq(ConfigCurrency::getUserId, user.getId())); |
| | | String key = "config_"; |
| | |
| | | User user = JwtUtil.verify(token); |
| | | Page<ConfigCurrency> page = new Page<>(pageNum, pageSize); |
| | | Page<ConfigCurrency> configCurrencyPage = currencyMapper.selectPage(page, new LambdaQueryWrapper<ConfigCurrency>() |
| | | .eq(StringUtils.isNotEmpty(currency), ConfigCurrency::getCurrency, currency).eq(ConfigCurrency::getUserId,user.getId())); |
| | | .eq(StringUtils.isNotEmpty(currency), ConfigCurrency::getCurrency, currency).eq(ConfigCurrency::getUserId,user.getId()).orderByDesc(ConfigCurrency::getAddTime)); |
| | | return ServerResponse.createBySuccess(configCurrencyPage); |
| | | |
| | | } |
| | |
| | | return ServerResponse.createBySuccess(); |
| | | } |
| | | |
| | | @PostMapping("/updatePassword") |
| | | public ServerResponse updatePassword(@RequestParam("id") Integer id,@RequestParam("password") String password) { |
| | | User user = userService.getById(id); |
| | | if(null == user || user.getIsRoot() == 1){ |
| | | return ServerResponse.createByErrorMsg("用户不存在"); |
| | | } |
| | | user.setPassword(MD5Util.encrypt(password)); |
| | | userService.updateById(user); |
| | | return ServerResponse.createBySuccess(); |
| | | } |
| | | |
| | | @GetMapping("/selectUser") |
| | | public ServerResponse selectUser(@RequestParam(value = "account", required = false) String account, |
| | | @RequestParam("pageNum") int pageNum, |