main--utils--ResultVOUtil.java
package com.tkft.sell.utils;
import com.tkft.sell.VO.ResultVO;
/**
* @Auther xinyuan
* @Date 11/17/18 8:33 PM
**/
public class ResultVOUtil {
public static ResultVO success(Object object){
ResultVO resultVO = new ResultVO();
resultVO.setData(object);
resultVO.setCode(0);
resultVO.setMsg("success");
return resultVO;
}
public static ResultVO success(){
return success(null);
}
public static ResultVO error(Integer code, String msg){
ResultVO resultVO = new ResultVO();
resultVO.setCode(code);
resultVO.setMsg(msg);
return resultVO;
}
}
生成随机数
main--utils--keyUtil.java
package com.tkft.sell.utils;
import java.util.Random;
/**
* @Auther xinyuan
* @Date 11/18/18 7:38 PM
**/
public class KeyUtil {
//生成唯一主键 时间+随机数
public static synchronized String genUniqueKey(){
Random random = new Random();
Integer number = random.nextInt(900000) + 100000;
return System.currentTimeMillis()+String.valueOf(number);
}
}
网友评论