Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormServiceTest.java
zhouhao 7 years ago
parent
commit
291865ea53
20 changed files with 718 additions and 34 deletions
  1. 34 15
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/AuthenticationContainer.java
  2. 139 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/MemeoryAuthenticationContainer.java
  3. 80 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/SimpleUserToken.java
  4. 24 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/UserToken.java
  5. 20 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/event/UserSignInEvent.java
  6. 9 0
      hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/PagerResult.java
  7. 22 2
      hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryService.java
  8. 10 7
      hsweb-message/hsweb-message-websocket/src/main/java/org/hswebframework/web/socket/handler/WebSocketUtils.java
  9. 7 5
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationController.java
  10. 11 1
      hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-service/hsweb-system-dynamic-form-service-api/src/main/java/org/hswebframework/web/service/form/DynamicFormOperationService.java
  11. 147 0
      hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-service/hsweb-system-dynamic-form-service-simple/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormOperationService.java
  12. 7 0
      hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-service/hsweb-system-dynamic-form-service-simple/src/main/java/org/hswebframework/web/service/form/simple/validator/GroovyVlidator.java
  13. 14 4
      hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormServiceTest.java
  14. 15 0
      hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-api/pom.xml
  15. 27 0
      hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-api/src/main/java/org/hswebframework/web/service/file/FileInfo.java
  16. 19 0
      hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-api/src/main/java/org/hswebframework/web/service/file/FileService.java
  17. 31 0
      hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/pom.xml
  18. 78 0
      hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/src/main/java/org/hswebframework/web/service/file/LocalFileService.java
  19. 20 0
      hsweb-system/hsweb-system-file/hsweb-system-file-service/pom.xml
  20. 4 0
      hsweb-system/hsweb-system-file/pom.xml

+ 34 - 15
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/AuthenticationContainer.java

@@ -18,9 +18,6 @@
 
 package org.hswebframework.web.authorization.container;
 
-import org.hswebframework.web.authorization.Authentication;
-
-import javax.servlet.http.HttpSession;
 import java.util.List;
 
 /**
@@ -32,40 +29,62 @@ import java.util.List;
 public interface AuthenticationContainer {
 
     /**
-     * 根据sessionId获取权限信息
+     * 根据token获取权限信息
      *
-     * @param sessionId
+     * @param token
      * @return 权限信息, 未授权时返回null
      */
-    Authentication getAuthenticationBySessionId(String sessionId);
+    UserToken getByToken(String token);
+
+    /**
+     * 根据用户id,获取全部授权信息,如果设置了不能跨地点登陆,返回值只可能是{@code null}或者size为1的list
+     * @param userId 用户id
+     * @return 授权信息
+     */
+    List<UserToken> getByUserId(String userId);
 
     /**
      * @param userId 用户ID
      * @return 用户是否已经授权
      */
-    boolean userIsAuthorized(String userId);
+    boolean userIsLoggedIn(String userId);
+
+    boolean tokenIsLoggedIn(String token);
 
     /**
-     * @return 已经授权的总人数
+     * @return 总用户数量,一个用户多个地方登陆数量算1
      */
-    int totalAuthorizedUser();
+    int totalUser();
 
+    /**
+     *
+     * @return 总token数量
+     */
+    int totalToken();
     /**
      * @return 所有被授权的用户
      */
-    List<Authentication> allAuthorizedUser();
+    List<UserToken> allLoggedUser();
 
     /**
      * 删除用户授权信息
      *
      * @param userId 用户ID
-     * @return 被删除的权限信息
      */
-    Authentication removeAuthentication(String userId);
+    void logoutByUserId(String userId);
+
+    /**
+     * 根据token删除
+     * @param token
+     */
+    void logoutByToken(String token);
 
     /**
-     * @param authentication
-     * @return 添加后被覆盖的权限信息 ,如果没有则返回null
+     * @param token
+     * @param userId
      */
-    Authentication addAuthentication(Authentication authentication, String sessionId);
+    UserToken signIn(String token, String userId);
+
+
+    void touch(String token);
 }

+ 139 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/MemeoryAuthenticationContainer.java

@@ -0,0 +1,139 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+
+package org.hswebframework.web.authorization.container;
+
+import org.hswebframework.web.authorization.AuthenticationManager;
+import org.hswebframework.web.authorization.container.event.UserSignInEvent;
+import org.hswebframework.web.authorization.listener.AuthorizationListenerDispatcher;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.stream.Collectors;
+
+/**
+ * 授权容器,用来操作所有已经授权的用户
+ *
+ * @author zhouhao
+ * @since 3.0
+ */
+public class MemeoryAuthenticationContainer implements AuthenticationContainer {
+
+    private ConcurrentMap<String, SimpleUserToken> tokenUserStorage = new ConcurrentHashMap<>(256);
+
+    private AuthenticationManager authenticationManager;
+
+    // timeout seconds
+    private long timeout = 3600;
+
+    private AuthorizationListenerDispatcher authorizationListenerDispatcher;
+
+    public void setAuthenticationManager(AuthenticationManager authenticationManager) {
+        this.authenticationManager = authenticationManager;
+    }
+
+    public void setAuthorizationListenerDispatcher(AuthorizationListenerDispatcher authorizationListenerDispatcher) {
+        this.authorizationListenerDispatcher = authorizationListenerDispatcher;
+    }
+
+    public void setTimeout(long timeout) {
+        this.timeout = timeout;
+    }
+
+    public long getTimeout() {
+        return timeout;
+    }
+
+    private UserToken checkTimeout(UserToken detail) {
+        if (null == detail) return null;
+        if (System.currentTimeMillis() - detail.getLastRequestTime() > timeout * 1000) {
+            logoutByToken(detail.getToken());
+            return null;
+        }
+        return detail;
+    }
+
+    @Override
+    public UserToken getByToken(String token) {
+        return checkTimeout(tokenUserStorage.get(token));
+    }
+
+    @Override
+    public List<UserToken> getByUserId(String userId) {
+        return tokenUserStorage.values().stream()
+                .filter(detail -> detail.getUserId().equals(userId) && checkTimeout(detail) != null)
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public boolean userIsLoggedIn(String userId) {
+        return getByUserId(userId).size() > 0;
+    }
+
+    @Override
+    public boolean tokenIsLoggedIn(String token) {
+        return getByToken(token) != null;
+    }
+
+    @Override
+    public int totalUser() {
+        return tokenUserStorage.values().stream().map(UserToken::getUserId).distinct().mapToInt(userId->1).sum();
+    }
+
+    @Override
+    public int totalToken() {
+        return tokenUserStorage.size();
+    }
+
+    @Override
+    public List<UserToken> allLoggedUser() {
+        return tokenUserStorage.values().stream()
+                .map(this::checkTimeout)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public void logoutByUserId(String userId) {
+        getByUserId(userId).forEach(detail -> logoutByToken(detail.getToken()));
+    }
+
+    @Override
+    public void logoutByToken(String token) {
+        tokenUserStorage.remove(token);
+    }
+
+    @Override
+    public UserToken signIn(String token, String userId) {
+        SimpleUserToken detail = new SimpleUserToken(userId, token);
+        if (null != authorizationListenerDispatcher)
+            authorizationListenerDispatcher.doEvent(new UserSignInEvent(detail));
+        tokenUserStorage.put(token, detail);
+        return detail;
+    }
+
+    @Override
+    public void touch(String token) {
+        SimpleUserToken detail = tokenUserStorage.get(token);
+        if (null != detail)
+            detail.touch();
+    }
+}

+ 80 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/SimpleUserToken.java

@@ -0,0 +1,80 @@
+package org.hswebframework.web.authorization.container;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Created by zhouhao on 2017/7/7.
+ */
+public class SimpleUserToken implements UserToken {
+
+    private String userId;
+
+    private String token;
+
+    private AtomicLong requestTimesCounter=new AtomicLong(0);
+
+    private volatile long lastRequestTime=System.currentTimeMillis();
+
+    private volatile long firstRequestTime=System.currentTimeMillis();
+
+    private long requestTimes;
+
+    public SimpleUserToken(String userId, String token) {
+        this.userId = userId;
+        this.token = token;
+    }
+
+    public SimpleUserToken() {
+    }
+
+    @Override
+    public String getUserId() {
+        return userId;
+    }
+
+    @Override
+    public long getRequestTimes() {
+        return requestTimesCounter.get();
+    }
+
+    @Override
+    public long getLastRequestTime() {
+        return lastRequestTime;
+    }
+
+    @Override
+    public long getSignInTime() {
+        return firstRequestTime;
+    }
+
+    @Override
+    public String getToken() {
+        return token;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public void setFirstRequestTime(long firstRequestTime) {
+        this.firstRequestTime = firstRequestTime;
+    }
+
+    public void setLastRequestTime(long lastRequestTime) {
+        this.lastRequestTime = lastRequestTime;
+    }
+
+    public void setRequestTimes(long requestTimes) {
+        this.requestTimes = requestTimes;
+        requestTimesCounter.set(requestTimes);
+    }
+
+    public  synchronized void touch(){
+        requestTimesCounter.addAndGet(1);
+        lastRequestTime=System.currentTimeMillis();
+    }
+}

+ 24 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/UserToken.java

@@ -0,0 +1,24 @@
+package org.hswebframework.web.authorization.container;
+
+
+import java.io.Serializable;
+
+/**
+ * Created by zhouhao on 2017/7/7.
+ */
+public interface UserToken extends Serializable, Comparable<UserToken> {
+    String getUserId();
+
+    String getToken();
+
+    long getRequestTimes();
+
+    long getLastRequestTime();
+
+    long getSignInTime();
+
+    @Override
+    default int compareTo(UserToken o) {
+        return Long.valueOf(getSignInTime()).compareTo(o.getSignInTime());
+    }
+}

+ 20 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/container/event/UserSignInEvent.java

@@ -0,0 +1,20 @@
+package org.hswebframework.web.authorization.container.event;
+
+import org.hswebframework.web.authorization.container.UserToken;
+import org.hswebframework.web.authorization.listener.event.AuthorizationEvent;
+
+/**
+ * Created by zhouhao on 2017/7/7.
+ */
+public class UserSignInEvent implements AuthorizationEvent {
+    private UserToken detail;
+
+
+    public UserSignInEvent(UserToken detail) {
+        this.detail = detail;
+    }
+
+    public UserToken getDetail() {
+        return detail;
+    }
+}

+ 9 - 0
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/PagerResult.java

@@ -22,11 +22,20 @@ package org.hswebframework.web.commons.entity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.Collections;
 import java.util.List;
 
 @ApiModel(description = "分页结果")
 public class PagerResult<E> implements Entity {
     private static final long serialVersionUID = -6171751136953308027L;
+
+    public static <E> PagerResult<E> empty(){
+        return new PagerResult<>(0, Collections.emptyList());
+    }
+
+    public static <E> PagerResult<E> of(int total,List<E> list){
+        return new PagerResult<>(total,list);
+    }
     private int total;
 
     private List<E> data;

+ 22 - 2
hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryService.java

@@ -20,16 +20,36 @@ package org.hswebframework.web.service;
 import java.util.List;
 
 /**
- * TODO 完成注释
- *
+ * 查询服务接口,提供基本的查询功能
  * @author zhouhao
+ * @since 3.0
+ * @see QueryByEntityService
  */
 public interface QueryService<E, PK> {
+
+    /**
+     * 根据主键查询
+     * @param id 主键
+     * @return 查询结果,无结果时返回{@code null}
+     */
     E selectByPk(PK id);
 
+    /**
+     * 根据多个主键查询
+     * @param id 主键集合
+     * @return 查询结果,如果无结果返回空集合,而不是返回{@code null}
+     */
     List<E> selectByPk(List<PK> id);
 
+    /**
+     * 查询所有结果
+     * @return 所有结果,如果无结果则返回空集合,而不是返回{@code null}
+     */
     List<E> select();
 
+    /**
+     * 查询结果总数
+     * @return 结果总数
+     */
     int count();
 }

+ 10 - 7
hsweb-message/hsweb-message-websocket/src/main/java/org/hswebframework/web/socket/handler/WebSocketUtils.java

@@ -36,13 +36,16 @@ public class WebSocketUtils {
                         .add(tmp[1].trim());
         }
 
-        Function<Set<String>, Optional<Authentication>> userGetter = set ->
-                set == null ? Optional.empty() : set.stream()
-                        .map(container::getAuthenticationBySessionId)
-                        .filter(Objects::nonNull).findFirst();
-
-        return userGetter.apply(sessionId.get("SESSION"))
-                .orElseGet(() -> userGetter.apply(sessionId.get("JSESSIONID")).orElse(null));
+        // TODO: 2017/7/12  修改权限获取方式
+        throw new UnsupportedOperationException();
+//        Function<Set<String>, Optional<Authentication>> userGetter = set ->
+//                set == null ? Optional.empty() : set.stream()
+//                        .map(container::getByToken)
+//                        .filter(Objects::nonNull)
+//                        .findFirst();
+//
+//        return userGetter.apply(sessionId.get("SESSION"))
+//                .orElseGet(() -> userGetter.apply(sessionId.get("JSESSIONID")).orElse(null));
 
     }
 }

+ 7 - 5
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationController.java

@@ -23,7 +23,8 @@ import io.swagger.annotations.ApiParam;
 import org.hswebframework.web.BusinessException;
 import org.hswebframework.web.NotFoundException;
 import org.hswebframework.web.authorization.Authentication;
-import org.hswebframework.web.authorization.AuthenticationInitializeService;
+//import org.hswebframework.web.authorization.AuthenticationInitializeService;
+import org.hswebframework.web.authorization.AuthenticationManager;
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.authorization.listener.AuthorizationListenerDispatcher;
 import org.hswebframework.web.authorization.listener.event.*;
@@ -56,10 +57,11 @@ public class AuthorizationController {
     @Autowired
     private UserService userService;
 
-    @Autowired
-    private AuthenticationInitializeService authenticationInitializeService;
-
+//    @Autowired
+//    private AuthenticationInitializeService authenticationInitializeService;
 
+    @Autowired
+    private AuthenticationManager authenticationManager;
     @Autowired
     private AuthorizationListenerDispatcher authorizationListenerDispatcher;
 
@@ -109,7 +111,7 @@ public class AuthorizationController {
                 throw new BusinessException("{password_error}", 400);
             }
             // 验证通过
-            Authentication authentication = authenticationInitializeService.initUserAuthorization(entity.getId());
+            Authentication authentication = authenticationManager.getByUserId(entity.getId());
             AuthorizationSuccessEvent event = new AuthorizationSuccessEvent(authentication, parameterGetter);
             int size = authorizationListenerDispatcher.doEvent(event);
             if (size == 0) {

+ 11 - 1
hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-service/hsweb-system-dynamic-form-service-api/src/main/java/org/hswebframework/web/service/form/DynamicFormOperationService.java

@@ -1,24 +1,34 @@
 package org.hswebframework.web.service.form;
 
+import org.hsweb.ezorm.core.dsl.Query;
 import org.hswebframework.web.commons.entity.PagerResult;
 import org.hswebframework.web.commons.entity.param.DeleteParamEntity;
 import org.hswebframework.web.commons.entity.param.QueryParamEntity;
 import org.hswebframework.web.commons.entity.param.UpdateParamEntity;
 
+import java.util.List;
+
 /**
- * TODO 完成注释
+ * 动态表单操作接口,用于对动态表单进行增删改查操作
  *
+ * @since 3.0
  * @author zhouhao
+ *
  */
 public interface DynamicFormOperationService {
     <T> PagerResult<T> selectPager(String formId, QueryParamEntity paramEntity);
 
     <T> T selectSingle(String formId, QueryParamEntity paramEntity);
 
+    <T> List<T> select(String formId, QueryParamEntity paramEntity);
+
     int count(String formId, QueryParamEntity paramEntity);
 
     <T> int update(String formId, UpdateParamEntity<T> paramEntity);
 
+    <T> void insert(String formId, T entity);
+
     int delete(String formId, DeleteParamEntity paramEntity);
 
+
 }

+ 147 - 0
hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-service/hsweb-system-dynamic-form-service-simple/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormOperationService.java

@@ -0,0 +1,147 @@
+package org.hswebframework.web.service.form.simple;
+
+import org.hsweb.ezorm.core.Delete;
+import org.hsweb.ezorm.core.Insert;
+import org.hsweb.ezorm.core.Update;
+import org.hsweb.ezorm.rdb.RDBDatabase;
+import org.hsweb.ezorm.rdb.RDBQuery;
+import org.hsweb.ezorm.rdb.RDBTable;
+import org.hswebframework.web.NotFoundException;
+import org.hswebframework.web.commons.entity.PagerResult;
+import org.hswebframework.web.commons.entity.param.DeleteParamEntity;
+import org.hswebframework.web.commons.entity.param.QueryParamEntity;
+import org.hswebframework.web.commons.entity.param.UpdateParamEntity;
+import org.hswebframework.web.entity.form.DynamicFormEntity;
+import org.hswebframework.web.service.form.DatabaseRepository;
+import org.hswebframework.web.service.form.DynamicFormOperationService;
+import org.hswebframework.web.service.form.DynamicFormService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.sql.SQLException;
+import java.util.List;
+
+@Service("dynamicFormOperationService")
+@Transactional
+public class SimpleDynamicFormOperationService implements DynamicFormOperationService {
+
+    private DynamicFormService dynamicFormService;
+
+    private DatabaseRepository databaseRepository;
+
+    @Autowired
+    public void setDynamicFormService(DynamicFormService dynamicFormService) {
+        this.dynamicFormService = dynamicFormService;
+    }
+
+    @Autowired
+    public void setDatabaseRepository(DatabaseRepository databaseRepository) {
+        this.databaseRepository = databaseRepository;
+    }
+
+    protected <T> RDBTable<T> getTable(String formId){
+        DynamicFormEntity entity= dynamicFormService.selectByPk(formId);
+        if(null==entity)throw new NotFoundException("表单不存在");
+
+        RDBDatabase database=entity.getDataSourceId()!=null?
+                databaseRepository.getDatabase(entity.getDataSourceId()):
+                databaseRepository.getDefaultDatabase();
+        return database.getTable(entity.getDatabaseTableName());
+    };
+    @Override
+    public <T> PagerResult<T> selectPager(String formId, QueryParamEntity paramEntity) {
+        RDBTable<T> table=getTable(formId);
+        try {
+            RDBQuery<T> query=table.createQuery();
+
+            int total= query.setParam(paramEntity).total();
+            if(total==0){
+                return PagerResult.empty();
+            }
+            paramEntity.rePaging(total);
+            List<T> list =query.setParam(paramEntity).list();
+            return PagerResult.of(total,list);
+        } catch (SQLException e) {
+            //todo custom exception
+            throw new RuntimeException(e);
+        }
+
+    }
+
+    @Override
+    public <T> List<T> select(String formId, QueryParamEntity paramEntity) {
+        RDBTable<T> table=getTable(formId);
+        try {
+            RDBQuery<T> query=table.createQuery();
+            return query.setParam(paramEntity).list();
+        } catch (SQLException e) {
+            //todo custom exception
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public <T> T selectSingle(String formId, QueryParamEntity paramEntity) {
+        RDBTable<T> table=getTable(formId);
+        try {
+            RDBQuery<T> query=table.createQuery();
+
+            return query.setParam(paramEntity).single();
+        } catch (SQLException e) {
+            //todo custom exception
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public int count(String formId, QueryParamEntity paramEntity) {
+        RDBTable table=getTable(formId);
+        try {
+            RDBQuery query=table.createQuery();
+
+            return query.setParam(paramEntity).total();
+        } catch (SQLException e) {
+            //todo custom exception
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public <T> int update(String formId, UpdateParamEntity<T> paramEntity) {
+        RDBTable table=getTable(formId);
+        try {
+            Update<T> update=table.createUpdate();
+
+            return update.setParam(paramEntity).exec();
+        } catch (SQLException e) {
+            //todo custom exception
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public <T> void insert(String formId, T entity) {
+        RDBTable table=getTable(formId);
+        try {
+           Insert<T> insert=table.createInsert();
+            insert.value(entity).exec();
+        } catch (SQLException e) {
+            //todo custom exception
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public int delete(String formId, DeleteParamEntity paramEntity) {
+        RDBTable table=getTable(formId);
+        try {
+            Delete delete=table.createDelete();
+
+            return delete.setParam(paramEntity).exec();
+        } catch (SQLException e) {
+            //todo custom exception
+            throw new RuntimeException(e);
+        }
+    }
+}

+ 7 - 0
hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-service/hsweb-system-dynamic-form-service-simple/src/main/java/org/hswebframework/web/service/form/simple/validator/GroovyVlidator.java

@@ -0,0 +1,7 @@
+package org.hswebframework.web.service.form.simple.validator;
+
+/**
+ * Created by zhouhao on 2017/7/12.
+ */
+public class GroovyVlidator {
+}

+ 14 - 4
hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormServiceTest.java

@@ -9,11 +9,8 @@ import org.hswebframework.web.tests.SimpleWebApplicationTests;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.sql.Array;
 import java.sql.JDBCType;
 import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.stream.Stream;
 
 /**
  * TODO 完成注释
@@ -28,6 +25,8 @@ public class SimpleDynamicFormServiceTest extends SimpleWebApplicationTests {
     @Autowired
     private DynamicFormColumnService dynamicFormColumnService;
 
+    @Autowired
+    private DynamicFormOperationService dynamicFormOperationService;
     @Autowired
     private SqlExecutor sqlExecutor;
 
@@ -61,9 +60,20 @@ public class SimpleDynamicFormServiceTest extends SimpleWebApplicationTests {
         column_age.setPrecision(4);
         column_age.setScale(0);
 
-        Stream.of(column_id, column_name, column_age).forEach(dynamicFormColumnService::insert);
+        Stream.of(column_id,column_name,column_age).forEach(dynamicFormColumnService::insert);
         dynamicFormService.deploy(id);
 
+        dynamicFormOperationService.insert(form.getId(),new HashMap<String,Object>(){
+            {
+                put("id","test");
+                put("name","张三");
+                put("age",10);
+            }
+        });
+       List<Object> objects= dynamicFormOperationService.select(form.getId(),new QueryParamEntity());
+
+        Assert.assertTrue(objects.size()==1);
+        System.out.println(objects);
         sqlExecutor.list("select * from f_test");
     }
 }

+ 15 - 0
hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-api/pom.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-file-service</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-file-service-api</artifactId>
+
+
+</project>

+ 27 - 0
hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-api/src/main/java/org/hswebframework/web/service/file/FileInfo.java

@@ -0,0 +1,27 @@
+package org.hswebframework.web.service.file;
+
+import java.io.Serializable;
+
+/**
+ * Created by zhouhao on 2017/7/8.
+ */
+public interface FileInfo  extends Serializable{
+
+    String getId();
+
+    void setId(String id);
+
+    String getName();
+
+    long getLength();
+
+    long getCreateTime();
+
+    String getCreatorId();
+
+    String getMd5();
+
+    String getLocation();
+
+
+}

+ 19 - 0
hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-api/src/main/java/org/hswebframework/web/service/file/FileService.java

@@ -0,0 +1,19 @@
+package org.hswebframework.web.service.file;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ */
+public interface FileService {
+
+    InputStream readFile(String fileId);
+
+    FileInfo saveFile(InputStream fileStream,String fileName,String creatorId) throws IOException;
+
+    void writeFile(String fileId, OutputStream out);
+
+    String md5(String fileId);
+
+}

+ 31 - 0
hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/pom.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-file-service</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-file-service-simple</artifactId>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-file-service-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hswebframework</groupId>
+            <artifactId>hsweb-utils</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 78 - 0
hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/src/main/java/org/hswebframework/web/service/file/LocalFileService.java

@@ -0,0 +1,78 @@
+package org.hswebframework.web.service.file;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.hswebframework.utils.time.DateFormatter;
+
+import java.io.*;
+import java.util.Date;
+
+/**
+ * Created by zhouhao on 2017/7/8.
+ */
+public class LocalFileService implements FileService {
+
+    private String fileBasePath=".";
+
+
+    public String getFileBasePath() {
+        return fileBasePath;
+    }
+
+    @Override
+    public InputStream readFile(String fileId) {
+
+        return null;
+    }
+
+    @Override
+    public FileInfo saveFile(InputStream fileStream, String fileName,String creatorId) throws IOException {
+        //配置中的文件上传根路径
+        String fileBasePath = getFileBasePath();
+        //文件存储的相对路径,以日期分隔,每天创建一个新的目录
+        String filePath = "/file/".concat(DateFormatter.toString(new Date(),"yyyy-MM-dd"));
+        //文件存储绝对路径
+        String absPath = fileBasePath.concat(filePath);
+        File path = new File(absPath);
+        if (!path.exists()) path.mkdirs(); //创建目录
+        String newName = String.valueOf(System.nanoTime()); //临时文件名 ,纳秒的md5值
+        String fileAbsName = absPath.concat("/").concat(newName);
+        //try with resource
+        long fileLength = 0;
+        try (BufferedInputStream in = new BufferedInputStream(fileStream);
+             BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(fileAbsName))) {
+            byte[] buffer = new byte[2048 * 10];
+            int len;
+            while ((len = in.read(buffer)) != -1) {
+                fileLength+=len;
+                os.write(buffer, 0, len);
+            }
+            os.flush();
+        }
+        File newFile = new File(fileAbsName);
+        //获取文件的md5值
+        String md5;
+        try (FileInputStream inputStream = new FileInputStream(newFile)) {
+            md5 = DigestUtils.md5Hex(inputStream);
+        }
+        //判断文件是否已经存在
+      //  Resources resources = resourcesService.selectByMd5(md5);
+       // if (resources != null) {
+         //   newFile.delete();//文件已存在则删除临时文件不做处理
+           // return resources;
+        //} else {
+          //  newName = md5;
+            //newFile.renameTo(new File(absPath.concat("/").concat(newName)));
+        //}
+        return null;
+    }
+
+    @Override
+    public void writeFile(String fileId, OutputStream out) {
+
+    }
+
+    @Override
+    public String md5(String fileId) {
+        return null;
+    }
+}

+ 20 - 0
hsweb-system/hsweb-system-file/hsweb-system-file-service/pom.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-file</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-file-service</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>hsweb-system-file-service-api</module>
+        <module>hsweb-system-file-service-simple</module>
+    </modules>
+
+
+</project>

+ 4 - 0
hsweb-system/hsweb-system-file/pom.xml

@@ -10,6 +10,10 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>hsweb-system-file</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>hsweb-system-file-service</module>
+    </modules>
 
 
 </project>