src/main/java/suwu/daopuerp/data/fileservice/FileServiceImpl.java
/**
     * find a entity
     *
     * @param info the key info to find
     * @return the entity
     */
find a entity
@param info the key info to find
@return the entity
find a entity @param info the key info to find @return the entity
@Override
    public T findOne(String info, Class<T> clazz) {
        String methodName = new Exception().getStackTrace()[2].getMethodName();
        String columnName = methodName.split("By")[1];
        columnName = columnName.replaceFirst(columnName.substring(0, 1), columnName.substring(0, 1).toLowerCase());
        try {
            columnName = ReflectionUtil.getAllField(clazz, columnName).getAnnotation(Column.class).name();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
        String tableName = AnnotationUtil.getTableName(clazz);
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
                new FileInputStream(savePath + tableName + fileType)))) {
            String json;
            while ((json = bufferedReader.readLine()) != null) {
                JSONObject jsonObject = JSONObject.fromObject(json);
                if (jsonObject.get(columnName).toString().equals(info)) {
                    return fromJsonToObject(jsonObject, clazz);
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
@ Override public T findOne ( String info , Class < T > clazz ) { String methodName = new Exception ( ) . getStackTrace ( ) [ 2 ] . getMethodName ( ) ; String columnName = methodName . split ( "By" ) [ 1 ] ; columnName = columnName . replaceFirst ( columnName . substring ( 0 , 1 ) , columnName . substring ( 0 , 1 ) . toLowerCase ( ) ) ; try { columnName = ReflectionUtil . getAllField ( clazz , columnName ) . getAnnotation ( Column . class ) . name ( ) ; } catch ( NoSuchFieldException e ) { e . printStackTrace ( ) ; } String tableName = AnnotationUtil . getTableName ( clazz ) ; try ( BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( savePath + tableName + fileType ) ) ) ) { String json ; while ( ( json = bufferedReader . readLine ( ) ) != null ) { JSONObject jsonObject = JSONObject . fromObject ( json ) ; if ( jsonObject . get ( columnName ) . toString ( ) . equals ( info ) ) { return fromJsonToObject ( jsonObject , clazz ) ; } } } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return null ; }
find a entity
 @param info the key info to find
 @return the entity
find a entity @param info the key info to find @return the entity