|
@@ -1,9 +1,12 @@
|
|
|
package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
+import cn.hutool.extra.servlet.ServletUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
|
+import com.fdkankan.manage.common.RedisKeyUtil;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.entity.Feedback;
|
|
|
import com.fdkankan.manage.entity.FeedbackOption;
|
|
@@ -12,13 +15,17 @@ import com.fdkankan.manage.mapper.IFeedbackMapper;
|
|
|
import com.fdkankan.manage.service.IFeedbackOptionService;
|
|
|
import com.fdkankan.manage.service.IFeedbackService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.manage.util.ProvinceUtils;
|
|
|
import com.fdkankan.manage.vo.request.FeedbackParam;
|
|
|
import com.fdkankan.manage.vo.response.GroupByAvg;
|
|
|
import com.fdkankan.manage.vo.response.GroupByCount;
|
|
|
+import com.fdkankan.manage.vo.response.IpAddressVo;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.HashMap;
|
|
@@ -127,4 +134,23 @@ public class FeedbackServiceImpl extends ServiceImpl<IFeedbackMapper, Feedback>
|
|
|
feedbackOption.setScore(bigDecimal.toString());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getDefaultAddress(HttpServletRequest request) {
|
|
|
+ //获取ip地址
|
|
|
+ String clientIP = ServletUtil.getClientIP(request);
|
|
|
+ if(StringUtils.isBlank(clientIP)){
|
|
|
+ return new IpAddressVo();
|
|
|
+ }
|
|
|
+ String redisKey = String.format(RedisKeyUtil.ipAddress,clientIP);
|
|
|
+ if(redisUtil.hasKey(redisKey)){
|
|
|
+ return JSONObject.parseObject(redisUtil.get(redisKey));
|
|
|
+ }
|
|
|
+ IpAddressVo addressByIp = ProvinceUtils.getAddressByIp(clientIP);
|
|
|
+ redisUtil.set(redisKey,JSONObject.toJSONString(addressByIp));
|
|
|
+ return addressByIp;
|
|
|
+ }
|
|
|
}
|