Authored by DengXinFei

rollback

Showing 100 changed files with 2 additions and 409 deletions

Too many changes to show.

To preserve performance only 100 of 100+ files are displayed.

package com.yoho.activity.common;
import com.yoho.service.model.activity.BaseBO;
public class ApiResponse extends BaseBO {
/**
*
*/
private static final long serialVersionUID = -5131027255966719148L;
private int code = 200;
private String message = "success";
private String md5;
private Object data;
public ApiResponse() {
}
public ApiResponse(Object data) {
this.data = data;
}
public ApiResponse(int code, String message) {
this.code = code;
this.message = message;
}
public ApiResponse(int code, String message, Object data) {
this.code = code;
this.message = message;
this.data = data;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMd5() {
return md5;
}
public void setMd5(String md5) {
this.md5 = md5;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
... ... @@ -10,18 +10,9 @@ package com.yoho.activity.common.constatns;
* 2016年3月8日
*/
public class Constant {
//调用接口,成功的返回码
public static final int CODE_SUCCESS = 200;
//是否执行定时任务
public static boolean EXECUTE_TASK = true;
// 新注册用户领取的人数
public final static String NEW_REGISTER_GET_TIME_MEM_KEY = "yh:users:new_register_get_time_";
// 已注册用户领取的人数
public final static String USED_REGISTER_GET_TIME_MEM_KEY = "yh:users:used_register_get_time_";
}
... ...
/**
*
*/
package com.yoho.activity.common.helper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Resource;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import com.yoho.activity.common.interceptor.SecurityInterceptor;
/**
* 描述:
*
* @author ping.huang
* 2016年4月1日
*/
@Component
public class ClientSecretHelper {
@Resource
SecurityInterceptor securityInterceptor;
/**
* 生产client_secret
* @param map
*/
public String createClientSecret(Map<String, String> map) {
if (MapUtils.isEmpty(map)) {
return null;
}
map.put("v", "7");
map.put("client_secret", securityInterceptor.getSign(map));
List<String> list = new ArrayList<String>();
for (Entry<String, String> entry : map.entrySet()) {
list.add(entry.getKey() + "=" + entry.getValue());
}
return StringUtils.join(list, "&");
}
}
... ... @@ -24,23 +24,6 @@ public final class DateUtils {
}
/**
* 按照格式,取得当前时间
* @param str
* @return
*/
public static String getToday(String str) {
return getDateFormatStr(new Date(), str);
}
/**
* 获取今天的日期时间(yyyy-MM-dd HH:mm:ss)
* @return
*/
public static String getcurrentDateTime() {
return getToday(DEFAULT_FOMARTPATTER);
}
/**
*
* @param time 获取数据库中的UNIX_Time(该时间是距离1970年的秒数,在转换过程中先要换算成毫秒)中的月份信息
* @return
... ...
package com.yoho.activity.common.utils;
import java.util.Random;
public class RandomUtil {
public static String autoGetPassword() {
StringBuilder sb = new StringBuilder();
Random random = new Random();
sb.append(random.nextInt(1000000));
sb.append("yh");
return sb.toString();
}
/**
* java生成随机数字和字母组合
* @param length[生成随机数的长度]
* @return
*/
public static String getCharAndNumr(int numLength,int charLength) {
String val = "";
Random random = new Random();
for (int i = 0; i < numLength; i++) {
// 输出字母还是数字
val += String.valueOf(random.nextInt(10));
}
for(int j=0;j<charLength;j++){
int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;
val += (char) (choice + random.nextInt(26));
}
return val.toLowerCase();
}
}
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yohobuy-activity</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf.yhactivity</groupId>
<artifactId>yohobuy-activity-controller</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhactivity</groupId>
<artifactId>yohobuy-activity-service</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.service.model</groupId>
<artifactId>activity-service-model</artifactId>
</dependency>
</dependencies>
</project>
package com.yoho.activity.controller;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
/**
*
*/
package com.yoho.activity.controller;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.service.ICocacolaService;
import com.yoho.error.exception.ServiceException;
/**
* 描述:
*
* @author ping.huang
* 2016年4月1日
*/
@Controller
@RequestMapping("/cocacola/CocacolaController")
public class CocacolaController {
static Logger log = LoggerFactory.getLogger(CocacolaController.class);
@Resource
ICocacolaService cocacolaService;
@Value("${cocacola.wechat.share.url}")
private String wechatShareUrl;
/**
* 发送短信验证码
* @param area
* @param mobile
* @return
* @throws Exception
*/
@RequestMapping("/sendSms")
@ResponseBody
public ApiResponse sendSms(String area, String mobile) throws ServiceException {
log.info("sendSms with area={}, mobile={}", area, mobile);
ApiResponse response = cocacolaService.sendSms(area, mobile);
log.info("sendSms with area={}, mobile={}, response={}", area, mobile, response);
return response;
}
/**
* 验证验证码
* 该方法会执行后续一系列动作
* 1、验证验证码
* 2、查询该手机号是否已经领取过该优惠券。如果已经领取,直接提示已经领取过;
* 3、如果未领取,则判断该手机号码是否注册过有货账号,如果没有,则调用注册接口,注册。
* 4、调用接口发送优惠券
* 5、如果用户是新用户,则发送短信提醒用户。
* @param code
* @param area
* @param mobile
* @param client_id
* @return
* @throws ServiceException
*/
@RequestMapping("/validRegCodeAndSendCode")
@ResponseBody
public ApiResponse validRegCodeAndSendCode(String code, String area, String mobile, String client_id) throws ServiceException {
log.info("validRegCodeAndSendCode with code={},area={}, mobile={},", code, area, mobile);
ApiResponse response = cocacolaService.validCodeAndSendCode(code, area, mobile, client_id);
log.info("validRegCodeAndSendCode with code={}, area={}, mobile={}, response={}",code, area, mobile, response);
return response;
}
/**
* 获取微信分享的url
* @return
* @throws ServiceException
*/
@RequestMapping("/getWechatShareUrl")
@ResponseBody
public ApiResponse getWechatShareUrl() throws ServiceException {
log.info("enter getWechatShareUrl");
String url = wechatShareUrl;
log.info("getWechatShareUrl success");
JSONObject json = new JSONObject();
json.put("wechatShareUrl", url);
ApiResponse response = new ApiResponse(json);
return response;
}
}
package com.yoho.activity.controller.interceptor;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.support.spring.FastJsonJsonView;
/**
*
* 服务的全局异常处理 spring mvc server 通用的异常处理。 2种响应: 1.
* 返回200,并且用json作为消息体,并且设置消息头(方便resttemplate处理) 2. 返回500,设置消息头 Created by
* chunhua.zhang@yoho.cn on 2015/11/19.
*/
public class ExceptionInterceptor implements HandlerExceptionResolver {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object handler, Exception exception) {
if (exception == null) {
return new ModelAndView();
}
logger.error("");
ModelAndView mv = getErrorJsonView(500, exception.getMessage());
return mv;
}
/**
* 使用FastJson提供的FastJsonJsonView视图返回,不需要捕获异常
*/
public static ModelAndView getErrorJsonView(int code, String message) {
ModelAndView modelAndView = new ModelAndView();
FastJsonJsonView jsonView = new FastJsonJsonView();
Map<String, Object> errorInfoMap = new HashMap<>();
errorInfoMap.put("code", code);
errorInfoMap.put("message", message);
jsonView.setAttributesMap(errorInfoMap);
modelAndView.setView(jsonView);
return modelAndView;
}
}
package org.yohobuy.activity.controller;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
... ... @@ -4,7 +4,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.0.7-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
... ... @@ -45,16 +45,11 @@
<artifactId>yohobuy-activity-other</artifactId>
<version>${project-version}</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhactivity</groupId>
<artifactId>yohobuy-activity-controller</artifactId>
<version>${project-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- CORE核心代码�??-->
<!-- CORE核心代码�?-->
<dependency>
<groupId>com.yoho.common</groupId>
<artifactId>error-code</artifactId>
... ... @@ -167,7 +162,6 @@
<module>queue</module>
<module>service</module>
<module>other</module>
<module>controller</module>
</modules>
</project>
\ No newline at end of file
... ...