天天看点

添加之前查询数据库是否已经添加过(去空格后存储到数据库)!

public Map<String,Object> TcarinfoInsert(TCarInfo tCarInfo){
    Map<String,Object> result=  new HashMap<>();
    //车牌号去空
    String plateNo=tCarInfo.getPlateNo().replaceAll(" ","");
    //根据车牌号查询车信息
    TCarInfo _tCarInfo=commondao.findOne(TCarInfo.class,"where tcarinfo.plateNo = ? ", plateNo);
    if(_tCarInfo==null){
        tCarInfo.setPlateNo(plateNo);
        try {
            commondao.insert(tCarInfo);
        } catch (Exception e) {
            e.printStackTrace();
            result.put("code",0001);
            result.put("msg","添加失败");
        }
        result.put("code",0000);
        result.put("msg","添加成功");
    }else{
        //生成验证码
        new Random();
        result.put("code",0002);
        result.put("msg","添加成功");
        // 调短信验证接口,目前手里没有接口
    }
    return result;
}      

继续阅读