部分功能修改
Showing
5 changed files
with
94 additions
and
49 deletions
| ... | @@ -35,6 +35,8 @@ import java.util.Map; | ... | @@ -35,6 +35,8 @@ import java.util.Map; |
| 35 | @RestController | 35 | @RestController |
| 36 | public class ScoreLogInfoController { | 36 | public class ScoreLogInfoController { |
| 37 | 37 | ||
| 38 | final String keySecret = "33974941d83111e78cda7cd30abdaa16"; | ||
| 39 | |||
| 38 | private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 40 | private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 39 | 41 | ||
| 40 | @Autowired | 42 | @Autowired |
| ... | @@ -49,15 +51,30 @@ public class ScoreLogInfoController { | ... | @@ -49,15 +51,30 @@ public class ScoreLogInfoController { |
| 49 | @RequestMapping("/save") | 51 | @RequestMapping("/save") |
| 50 | public MessageEntity save(HttpServletRequest request, @ModelAttribute ScoreLogInfo scoreLogInfo, | 52 | public MessageEntity save(HttpServletRequest request, @ModelAttribute ScoreLogInfo scoreLogInfo, |
| 51 | String access_token, String state, String timestamp, String rands, String jsondata, String checksum, | 53 | String access_token, String state, String timestamp, String rands, String jsondata, String checksum, |
| 52 | String secret) throws ParseException, UnsupportedEncodingException { | 54 | String secret, String sign, String signTime) throws ParseException, UnsupportedEncodingException { |
| 53 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | 55 | MessageEntity.Builder builder = new MessageEntity.Builder(request); |
| 56 | if (scoreLogInfo.getScore() < 4000) { | ||
| 57 | return null; | ||
| 58 | } | ||
| 59 | if (scoreLogInfo.getScore() > 30000) { | ||
| 60 | return null; | ||
| 61 | } | ||
| 62 | System.out.println("sign ---------------->"+sign); | ||
| 63 | System.out.println("score ---------------->"+scoreLogInfo.getScore()); | ||
| 64 | System.out.println("signTime ---------------->"+signTime); | ||
| 65 | String forSign = MD5Utils.hash(keySecret + scoreLogInfo.getScore() + keySecret + signTime); | ||
| 66 | |||
| 67 | System.out.println("system sign ---------------->"+forSign); | ||
| 68 | if (!forSign.equals(sign)) { | ||
| 69 | return null; | ||
| 70 | } | ||
| 54 | boolean flag = false; | 71 | boolean flag = false; |
| 55 | String code = "9000"; | 72 | String code = "9000"; |
| 56 | // String openid = scoreLogInfo.getOpenid(); | 73 | // String openid = scoreLogInfo.getOpenid(); |
| 57 | Date lastDay = sdf.parse("2017-12-14 23:59:59"); | 74 | Date lastDay = sdf.parse("2017-12-14 23:59:59"); |
| 58 | if(lastDay.after(new Date())) { | 75 | if (lastDay.after(new Date())) { |
| 59 | if (StringUtils.isNotBlank(jsondata)) { | 76 | if (StringUtils.isNotBlank(jsondata)) { |
| 60 | jsondata = URLDecoder.decode(jsondata,"utf-8"); | 77 | jsondata = URLDecoder.decode(jsondata, "utf-8"); |
| 61 | ObjectMapper objectMapper = new ObjectMapper(); | 78 | ObjectMapper objectMapper = new ObjectMapper(); |
| 62 | Map map = null; | 79 | Map map = null; |
| 63 | try { | 80 | try { |
| ... | @@ -124,7 +141,6 @@ public class ScoreLogInfoController { | ... | @@ -124,7 +141,6 @@ public class ScoreLogInfoController { |
| 124 | return builder.success(true).code("2000").content(l).create(); | 141 | return builder.success(true).code("2000").content(l).create(); |
| 125 | } | 142 | } |
| 126 | 143 | ||
| 127 | |||
| 128 | @RequestMapping("/saveStat") | 144 | @RequestMapping("/saveStat") |
| 129 | public MessageEntity saveStat(HttpServletRequest request, @RequestParam String openid) { | 145 | public MessageEntity saveStat(HttpServletRequest request, @RequestParam String openid) { |
| 130 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | 146 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ... | ... |
| 1 | package com.example.controller; | 1 | package com.example.controller; |
| 2 | 2 | ||
| 3 | import com.example.models.ImgInfo; | 3 | import java.io.IOException; |
| 4 | import com.example.service.ImgInfoService; | 4 | import java.io.UnsupportedEncodingException; |
| 5 | import com.example.service.http.ClientConfigService; | 5 | import java.net.URLEncoder; |
| 6 | import com.example.service.http.ClientConfigServiceImpl; | 6 | import java.util.Map; |
| 7 | import com.example.service.http.HttpPostService; | 7 | |
| 8 | import com.example.support.model.MessageEntity; | 8 | import javax.servlet.http.HttpServletRequest; |
| 9 | import com.example.utils.file.DefaultFileUpload; | 9 | |
| 10 | import com.example.utils.file.FileUploadInfo; | ||
| 11 | import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 12 | import org.apache.wink.client.ClientResponse; | 10 | import org.apache.wink.client.ClientResponse; |
| 13 | import org.apache.wink.client.Resource; | 11 | import org.apache.wink.client.Resource; |
| 14 | import org.apache.wink.client.RestClient; | 12 | import org.apache.wink.client.RestClient; |
| 15 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Value; |
| 16 | import org.springframework.web.bind.annotation.*; | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
| 17 | import org.springframework.web.multipart.MultipartFile; | 15 | import org.springframework.web.bind.annotation.RequestParam; |
| 18 | import sun.misc.BASE64Decoder; | 16 | import org.springframework.web.bind.annotation.RestController; |
| 19 | import sun.misc.BASE64Encoder; | ||
| 20 | 17 | ||
| 21 | import javax.servlet.http.HttpServletRequest; | 18 | import com.example.service.http.ClientConfigService; |
| 22 | import java.io.IOException; | 19 | import com.example.service.http.ClientConfigServiceImpl; |
| 23 | import java.io.UnsupportedEncodingException; | 20 | import com.example.support.model.MessageEntity; |
| 24 | import java.util.Map; | 21 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 25 | 22 | ||
| 26 | /** | 23 | /** |
| 27 | * Created by JA on 17/7/3. | 24 | * Created by JA on 17/7/3. |
| ... | @@ -30,27 +27,32 @@ import java.util.Map; | ... | @@ -30,27 +27,32 @@ import java.util.Map; |
| 30 | @RestController | 27 | @RestController |
| 31 | public class WxController { | 28 | public class WxController { |
| 32 | 29 | ||
| 33 | // String jssdkurl = "http://gfwp.gac-toyota.com.cn/GTMCfamily/index.php/campaign/api2/getjssdk"; | 30 | @Value("${wx.sign.base.url}") |
| 34 | // | 31 | String wxSignBaseUrl; |
| 35 | // String getopenidurl = "http://gfwp.gac-toyota.com.cn/GTMCfamily/index.php/campaign/api2/getjssdk"; | ||
| 36 | // | ||
| 37 | // @Autowired | ||
| 38 | // private HttpPostService httpPostService; | ||
| 39 | // | ||
| 40 | // | ||
| 41 | // @RequestMapping("/getjssdk") | ||
| 42 | // public MessageEntity getjssdk(HttpServletRequest request, @RequestParam String url) { | ||
| 43 | // MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
| 44 | // String newUrl = jssdkurl + "?url="+ url; | ||
| 45 | // Map<String, Object> map = null; | ||
| 46 | // try { | ||
| 47 | // map = httpPostService.httpPost(newUrl, null); | ||
| 48 | // } catch (IOException e) { | ||
| 49 | // e.printStackTrace(); | ||
| 50 | // } | ||
| 51 | // return builder.success(true).code("2000").content(map).create(); | ||
| 52 | // } | ||
| 53 | 32 | ||
| 33 | // String jssdkurl = | ||
| 34 | // "http://gfwp.gac-toyota.com.cn/GTMCfamily/index.php/campaign/api2/getjssdk"; | ||
| 35 | // | ||
| 36 | // String getopenidurl = | ||
| 37 | // "http://gfwp.gac-toyota.com.cn/GTMCfamily/index.php/campaign/api2/getjssdk"; | ||
| 38 | // | ||
| 39 | // @Autowired | ||
| 40 | // private HttpPostService httpPostService; | ||
| 41 | // | ||
| 42 | // | ||
| 43 | // @RequestMapping("/getjssdk") | ||
| 44 | // public MessageEntity getjssdk(HttpServletRequest request, @RequestParam | ||
| 45 | // String url) { | ||
| 46 | // MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
| 47 | // String newUrl = jssdkurl + "?url="+ url; | ||
| 48 | // Map<String, Object> map = null; | ||
| 49 | // try { | ||
| 50 | // map = httpPostService.httpPost(newUrl, null); | ||
| 51 | // } catch (IOException e) { | ||
| 52 | // e.printStackTrace(); | ||
| 53 | // } | ||
| 54 | // return builder.success(true).code("2000").content(map).create(); | ||
| 55 | // } | ||
| 54 | 56 | ||
| 55 | @RequestMapping("/getUser") | 57 | @RequestMapping("/getUser") |
| 56 | public MessageEntity oauth(HttpServletRequest request, @RequestParam String access_token, String openid) { | 58 | public MessageEntity oauth(HttpServletRequest request, @RequestParam String access_token, String openid) { |
| ... | @@ -64,7 +66,7 @@ public class WxController { | ... | @@ -64,7 +66,7 @@ public class WxController { |
| 64 | ClientResponse response = resource.get(); | 66 | ClientResponse response = resource.get(); |
| 65 | String responseEntity = response.getEntity(String.class); | 67 | String responseEntity = response.getEntity(String.class); |
| 66 | Map readValue = null; | 68 | Map readValue = null; |
| 67 | // System.out.println("responseEntity:::"+responseEntity); | 69 | // System.out.println("responseEntity:::"+responseEntity); |
| 68 | ObjectMapper mapper = new ObjectMapper(); | 70 | ObjectMapper mapper = new ObjectMapper(); |
| 69 | try { | 71 | try { |
| 70 | readValue = mapper.readValue(responseEntity, Map.class); | 72 | readValue = mapper.readValue(responseEntity, Map.class); |
| ... | @@ -72,10 +74,34 @@ public class WxController { | ... | @@ -72,10 +74,34 @@ public class WxController { |
| 72 | return builder.success(false).code("999").content(readValue).create(); | 74 | return builder.success(false).code("999").content(readValue).create(); |
| 73 | } | 75 | } |
| 74 | } catch (IOException e) { | 76 | } catch (IOException e) { |
| 75 | e.printStackTrace();; | 77 | e.printStackTrace(); |
| 78 | ; | ||
| 76 | } | 79 | } |
| 77 | return builder.success(true).code("2000").content(readValue).create(); | 80 | return builder.success(true).code("2000").content(readValue).create(); |
| 78 | } | 81 | } |
| 79 | 82 | ||
| 83 | @RequestMapping("/wxSign") | ||
| 84 | public MessageEntity jsSign(HttpServletRequest request, @RequestParam String url) | ||
| 85 | throws UnsupportedEncodingException { | ||
| 86 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
| 87 | ClientConfigService configService = new ClientConfigServiceImpl(); | ||
| 88 | RestClient restClient = new RestClient(configService.getClientConfig()); | ||
| 89 | Resource resource = restClient.resource(wxSignBaseUrl + "?url=" + URLEncoder.encode(url, "utf-8")); | ||
| 90 | ClientResponse response = resource.get(); | ||
| 91 | String responseEntity = response.getEntity(String.class); | ||
| 92 | Map readValue = null; | ||
| 93 | // System.out.println("responseEntity:::"+responseEntity); | ||
| 94 | ObjectMapper mapper = new ObjectMapper(); | ||
| 95 | try { | ||
| 96 | readValue = mapper.readValue(responseEntity, Map.class); | ||
| 97 | if (null != readValue.get("errcode")) { | ||
| 98 | return builder.success(false).code("999").content(readValue).create(); | ||
| 99 | } | ||
| 100 | } catch (IOException e) { | ||
| 101 | e.printStackTrace(); | ||
| 102 | ; | ||
| 103 | } | ||
| 104 | return builder.success(true).code("2000").content(readValue).create(); | ||
| 105 | } | ||
| 80 | 106 | ||
| 81 | } | 107 | } | ... | ... |
| ... | @@ -14,7 +14,7 @@ public class ScoreLogInfo { | ... | @@ -14,7 +14,7 @@ public class ScoreLogInfo { |
| 14 | String gtmcUid; | 14 | String gtmcUid; |
| 15 | String gtmcName; | 15 | String gtmcName; |
| 16 | String gtmcDepartment; | 16 | String gtmcDepartment; |
| 17 | private Double score; | 17 | private Integer score; |
| 18 | private Date createAt; | 18 | private Date createAt; |
| 19 | private Integer status; | 19 | private Integer status; |
| 20 | 20 | ||
| ... | @@ -50,11 +50,11 @@ public class ScoreLogInfo { | ... | @@ -50,11 +50,11 @@ public class ScoreLogInfo { |
| 50 | this.headimgurl = headimgurl; | 50 | this.headimgurl = headimgurl; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | public Double getScore() { | 53 | public Integer getScore() { |
| 54 | return score; | 54 | return score; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | public void setScore(Double score) { | 57 | public void setScore(Integer score) { |
| 58 | this.score = score; | 58 | this.score = score; |
| 59 | } | 59 | } |
| 60 | 60 | ... | ... |
| ... | @@ -50,7 +50,7 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService { | ... | @@ -50,7 +50,7 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService { |
| 50 | if(count >= maxTime){ | 50 | if(count >= maxTime){ |
| 51 | code = "9902"; | 51 | code = "9902"; |
| 52 | }else{ | 52 | }else{ |
| 53 | Double score = scoreLogInfo.getScore(); | 53 | Integer score = scoreLogInfo.getScore(); |
| 54 | if(minScore > score){ | 54 | if(minScore > score){ |
| 55 | code = "9903"; | 55 | code = "9903"; |
| 56 | }else{ | 56 | }else{ | ... | ... |
| ... | @@ -21,3 +21,6 @@ mybatis.configLocation=classpath:/mybatis-config.xml | ... | @@ -21,3 +21,6 @@ mybatis.configLocation=classpath:/mybatis-config.xml |
| 21 | 21 | ||
| 22 | #port | 22 | #port |
| 23 | server.port=9092 | 23 | server.port=9092 |
| 24 | |||
| 25 | |||
| 26 | wx.sign.base.url=http://gfwp.gac-toyota.com.cn/GTMCfamily/index.php/campaign/api2/getjssdk | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment