6 changed files with 71 additions and 3 deletions
After Width: | Height: | Size: 158 KiB |
@ -0,0 +1,54 @@ |
|||||||
|
package com.fr.conf.db.demo.fun.http; |
||||||
|
|
||||||
|
import com.fr.conf.db.demo.SystemConfigAccessBridge; |
||||||
|
import com.fr.conf.db.demo.fun.SystemConfigDAO; |
||||||
|
import com.fr.conf.db.demo.fun.entity.SystemConfigEntity; |
||||||
|
import com.fr.data.NetworkHelper; |
||||||
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||||
|
import com.fr.stable.db.action.DBAction; |
||||||
|
import com.fr.stable.db.dao.DAOContext; |
||||||
|
import com.fr.stable.query.condition.impl.QueryConditionImpl; |
||||||
|
import com.fr.stable.query.restriction.RestrictionFactory; |
||||||
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.io.PrintWriter; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class OutputHttpHandler extends BaseHttpHandler { |
||||||
|
@Override |
||||||
|
public RequestMethod getMethod() { |
||||||
|
return RequestMethod.GET; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getPath() { |
||||||
|
return "/db/output"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isPublic() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||||
|
List<SystemConfigEntity> entities = SystemConfigAccessBridge.getDbAccessor().runQueryAction(new DBAction<List<SystemConfigEntity>>() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<SystemConfigEntity> run(DAOContext daoContext) throws Exception { |
||||||
|
// 查询收入大于10000的人
|
||||||
|
return daoContext.getDAO(SystemConfigDAO.class).find(new QueryConditionImpl().addRestriction(RestrictionFactory.gte("salary", 10000.0))); |
||||||
|
} |
||||||
|
}); |
||||||
|
PrintWriter writer = NetworkHelper.createPrintWriter(httpServletResponse); |
||||||
|
writer.println("The people who's salary is more than 10000:<br/>"); |
||||||
|
for (SystemConfigEntity entity : entities) { |
||||||
|
writer.println(entity.toString()); |
||||||
|
writer.println("<br/>"); |
||||||
|
} |
||||||
|
writer.flush(); |
||||||
|
writer.close(); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue