美文网首页
utils package

utils package

作者: 谢谢水果 | 来源:发表于2018-11-19 05:34 被阅读0次

    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);
        }
    }
    

    相关文章

      网友评论

          本文标题:utils package

          本文链接:https://www.haomeiwen.com/subject/hdanfqtx.html