标签:用户信息 exception 信息 The download repr ppi head ops
@GetMapping("download/result")
@ApiOperation("提供手机号绑定结果给浏览器下载") //Controller层代码
public Response<Boolean> downloadResultExcel(HttpServletRequest request) throws IOException {
String token = request.getHeader("Authorization");
return excelService.downloadResultExcel(token);
}
// @GetMapping("download/result") // @ApiOperation("提供手机号绑定结果给浏览器下载") public Response<Boolean> downloadResultExcel(String token)throws IOException { //Service层代码 String userIdStr = this.redisService.get(token); //调用redisService取得当前页面用户信息 User user = this.userMapper.selectById(userIdStr); if (user==null || user.getIsDelete()==1){ //判断该用户是否存在 return new Response<>("导出手机号绑定信息日志写入失败"); }else { if (operationLogService.addOperationLog(user.getId(),"导出手机号绑定信息成功",1).getCode().equals("500")){ return new Response<>("导出手机号绑定信息日志写入失败"); } } return new Response<>("",Response.SUCCESS_CODE,Boolean.TRUE); } }
附上redisService代码如下:
@Autowired private StringRedisTemplate stringRedisTemplate; public String get(String key) { return this.stringRedisTemplate.opsForValue().get(key); }
附上StringRedisTemplate代码如下:
package org.springframework.data.redis.core; import org.springframework.data.redis.connection.DefaultStringRedisConnection; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; public class StringRedisTemplate extends RedisTemplate<String, String> { public StringRedisTemplate() { RedisSerializer<String> stringSerializer = new StringRedisSerializer(); this.setKeySerializer(stringSerializer); this.setValueSerializer(stringSerializer); this.setHashKeySerializer(stringSerializer); this.setHashValueSerializer(stringSerializer); } public StringRedisTemplate(RedisConnectionFactory connectionFactory) { this(); this.setConnectionFactory(connectionFactory); this.afterPropertiesSet(); } protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) { return new DefaultStringRedisConnection(connection); } }
如果觉得上述内容还可以的话,可以扫描下方二维码进行赞赏哟~??????
同时也可关注微信公众号获得更多个人分享~??????
标签:用户信息 exception 信息 The download repr ppi head ops
原文地址:https://www.cnblogs.com/bobbycheng/p/11866241.html