QUI-Framework个快速开发框架,里面有定制化ORM,MVC 。简单容易上手。
Action 层代码:
@Route(value = "/WebDemo")
@Controller(value = "webDemoAction")
public class WebDemoAction extends BaseController{
@Override
protected PageResultgetPageContent() {
// TODO Auto-generated method stub
IWebDemoService webDemoService=(IWebDemoService) BaseServiceFactory.getInstance(WebDemoServiceImpl.class);
this.processQueryCondiction();
return webDemoService.findByCriteria(queryCriteria);
}
@Override
protected void processQueryCondiction() {
// TODO Auto-generated method stub
Map
if(!StringUtil.isNullOrEmpty(searchforms)&&!StringUtils.equals("null", searchforms)){
JSONObject o = JSONObject.parseObject(searchforms);
if(!StringUtil.isNullOrEmpty(o.get("id"))){
condition.put("id", o.getInteger("id"));
}
if(!StringUtil.isNullOrEmpty(o.get("name"))){
condition.put("name", "%"+o.getString("name")+"%");
}
}
queryCriteria.setQueryCondition(condition);
if(!StringUtil.isNullOrEmpty(sortField)){
if("id".equals(sortField)){
queryCriteria.setOrderField("WEB_DEMO_ID");
}
if("name".equals(sortField)){
queryCriteria.setOrderField("WEB_DEMO_NAME");
}
}
if(!StringUtil.isNullOrEmpty(sortOrder)){
queryCriteria.setOrderDirection(sortOrder);
}else{
queryCriteria.setOrderDirection("desc");
}
if(!StringUtil.isNullOrEmpty(pageIndex)){
queryCriteria.setStartIndex(pageIndex);
}
if(!StringUtil.isNullOrEmpty(pageSize)){
queryCriteria.setPageSize(pageSize);
}
}
@Route(value = "/searchWebDemos.htm")
@MethodType(type = mType.post)
public String searchWebDemoEntitys(@FormParam("pageIndex") int pageIndex ,@FormParam("pageSize") int pageSize ,@FormParam("sortField") String sortField,@FormParam("sortOrder") String sortOrder ,@FormParam("params") String params) throws Exception{
String result="";
this.pageIndex=pageIndex-1;
this.pageSize=pageSize;
this.sortField=sortField;
this.sortOrder=sortOrder;
this.searchforms=params;
IWebDemoService webDemoService=(IWebDemoService) BaseServiceFactory.getInstance(WebDemoServiceImpl.class);
result=webDemoService.convertPageResultToString(getPageContent());
return result;
}
@Route(value = "/saveWebDemos.htm")
@MethodType(type = mType.post)
public String saveWebDemoEntity(@FormParam("saveforms") String saveforms) throws Exception{
WebDemoEntity webDemoEntity=JSONObject.parseObject(saveforms, WebDemoEntity.class);
IWebDemoService webDemoService=(IWebDemoService) BaseServiceFactory.getInstance(WebDemoServiceImpl.class);
webDemoService.doCreateEntity(webDemoEntity);
return "save successful";
}
@Route(value = "/searchWebDemo.htm")
@MethodType(type = mType.post)
public String searchWebDemoEntity(@FormParam("id") Integer id) throws Exception{
IWebDemoService webDemoService=(IWebDemoService) BaseServiceFactory.getInstance(WebDemoServiceImpl.class);
WebDemoEntity webDemoEntity=webDemoService.findById(id);
String result=webDemoService.convertEntityToString(webDemoEntity);
return result;
}
@Route(value = "/removeWebDemos.htm")
@MethodType(type = mType.post)
public String removeWebDemoEntitys(@FormParam("idString") String idString)throws Exception{
if(!StringUtil.isNullOrEmpty(idString)){
String[] ids = idString.split(",");
IWebDemoService webDemoService=(IWebDemoService) BaseServiceFactory.getInstance(WebDemoServiceImpl.class);
Listentitys=new ArrayList();
for(String id:ids){
WebDemoEntity webDemoEntity=webDemoService.findById(Integer.parseInt(id));
entitys.add(webDemoEntity);
}
webDemoService.doRemoveEntitys(entitys);
}
return "Delete successful";
}
}
Service 层 接口代码:
public interface IWebDemoService{
public void doCreateEntity(WebDemoEntity webDemoEntity);
public void doCreateEntity(Listentities);
public void doRemoveEntitys(Listentities);
public WebDemoEntity findById(Integer integer);
public ListfindByParams(Map
public PageResultfindByCriteria(QueryCriteria criteria);
public String convertEntityToString(WebDemoEntity webDemoEntity);
public String convertListToString(Listentities);
public String convertPageResultToString(PageResultresult);
}
Service 层实现类:
@Override
public void doCreateEntity(WebDemoEntity webDemoEntity) {
// TODO Auto-generated method stub
IWebDemoDao webDemoDao= (IWebDemoDao) new BaseDaoFactory().getInstance(IWebDemoDao.class);
if(!StringUtil.isNullOrEmpty(webDemoEntity.getId())){
webDemoDao.doUpdateEntity(webDemoEntity);
}else{
webDemoDao.doCreateEntity(webDemoEntity);
}
}
@Override
public void doRemoveEntitys(Listentities) {
// TODO Auto-generated method stub
IWebDemoDao webDemoDao= (IWebDemoDao) new BaseDaoFactory().getInstance(IWebDemoDao.class);
for(WebDemoEntity webDemoEntity :entities){
webDemoDao.doRemoveEntity(webDemoEntity);
}
}
@Override
public WebDemoEntity findById(Integer id) {
// TODO Auto-generated method stub
IWebDemoDao webDemoDao= (IWebDemoDao) new BaseDaoFactory().getInstance(IWebDemoDao.class);
return webDemoDao.findById(id);
}
@Override
public ListfindByParams(Map
// TODO Auto-generated method stub
IWebDemoDao webDemoDao= (IWebDemoDao) new BaseDaoFactory().getInstance(IWebDemoDao.class);
return webDemoDao.findByParams(params);
}
@Override
public PageResultfindByCriteria(QueryCriteria criteria) {
// TODO Auto-generated method stub
IWebDemoDao webDemoDao= (IWebDemoDao) new BaseDaoFactory().getInstance(IWebDemoDao.class);
return webDemoDao.findByCriteria(criteria);
}
@Override
public String convertEntityToString(WebDemoEntity webDemoEntity) {
// TODO Auto-generated method stub
return webDemoEntity.toJSONObject().toJSONString().replaceAll("null", "");
}
@Override
public String convertListToString(Listentities) {
// TODO Auto-generated method stub
return JSONConvertUtils.convertBeanToJson(entities, new WebDemoEntity());
}
@Override
public String convertPageResultToString(PageResultresult) {
// TODO Auto-generated method stub
Setfilters=new HashSet();
filters.add("id");
filters.add("name");
return JSONConvertUtils.convertPageResultToJsonString(result, filters, WebDemoEntity.class);
}
@Override
public void doCreateEntity(Listentities) {
// TODO Auto-generated method stub
IWebDemoDao webDemoDao= (IWebDemoDao) new BaseDaoFactory().getInstance(IWebDemoDao.class);
for(WebDemoEntity webDemoEntity :entities){
if(StringUtil.isNullOrEmpty(webDemoEntity.getId())){
webDemoDao.doCreateEntity(webDemoEntity);
}else{
webDemoDao.doUpdateEntity(webDemoEntity);
}
}
}
}
Dao 层接口代码:(无Dao 实现类)
import java.util.List;
import java.util.Map;
import qui.orm.PageResult;
import qui.orm.QueryCriteria;
import qui.orm.annotation.Delete;
import qui.orm.annotation.Insert;
import qui.orm.annotation.Insert.insertType;
import qui.orm.annotation.Query;
import qui.orm.annotation.Query.queryType;
import qui.orm.annotation.Query.returnType;
import qui.orm.annotation.Update;
import com.weirong.web.entity.WebDemoEntity;
/**
* @author liubing
* @version 1.0
*/
public interface IWebDemoDao {
@Insert
public void doCreateEntity(WebDemoEntity webDemoEntity );
@Update
public void doUpdateEntity(WebDemoEntity webDemoEntity );
@Delete
public void doRemoveEntity(WebDemoEntity webDemoEntity);
@Query(type=queryType.findByKey)
public WebDemoEntity findById(Integer id);
@Query(type=queryType.findByParams,returnEntityClass=WebDemoEntity.class)
public ListfindByParams(Map
@Query(type=queryType.findByCriteria,returnEntityClass=WebDemoEntity.class)
public PageResultfindByCriteria(QueryCriteria criteria);
@Query(type=queryType.findBycustom,returnType=returnType.List,returnEntityClass=WebDemoEntity.class)
public ListfindByCustom(String sql,Map
@Insert(type=insertType.insertBycustom)
public void doCreateEntity(String sql,Map
}
Entity 层代码:
import java.io.Serializable;
import com.alibaba.fastjson.JSONObject;
import qui.orm.annotation.Column;
import qui.orm.annotation.Table;
import qui.orm.schema.data.BaseEntity;
@SuppressWarnings("serial")
@Table(name="WEB_DEMO")
public class WebDemoEntity extends BaseEntity{
private Integer id;
private String name;
@Override
public Serializable generateId() {
// TODO Auto-generated method stub
if(id==null){
id=super.sequenceIdProvider.create("WEB_DEMO").nextVal();
}
return (Integer) id;
}
@Column(isKey=true,name="WEB_DEMO_ID",isNull=true,typeLength=11,typeScale=0)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(isKey=false,name="WEB_DEMO_NAME",isNull=true,typeLength=300,typeScale=0)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public JSONObject toJSONObject() {
// TODO Auto-generated method stub
JSONObject _json = new JSONObject();
_json.put("id", id);
_json.put("name", name);
return _json;
}
}
而且新版本可后台代码自动生成。请查看地址的附件,代码没有用git。
uniquify释义 uniquify顾名思义,是为了保证mudule定义的唯一性,首先我们一起来回顾一下,DC针对的八个对象的定义。 DC将设计对象分为8类。 1、design:具有某种或多种逻辑功能的电路描述。即module定义。 2、cell:设计(design)的instance。 3、reference:cell或instance在库中定义的名字。design的instance
UUR/QUI: http://bbs.blueidea.com/thread-3036358-1-143.html qui的PPT: https://max.book118.com/html/2016/1207/69136287.shtm qui框架开发第一讲:框架概述与工程部署: https://download.csdn.net/download/qq30976851/9615
一.获取头部信息 @RequestHeader注解 可以获得请求头的信息 相当于 request.getHeader(name); value: 请求头的名称;required : 是否必须携带此请求头 1.controller代码 /** * @param @RequestHeader注解 可以获得请求头的信息 第一次使用eureka,引入了spring-cloud-
define 用来定义模块 require 用来加载模块 1 因为定义一个模块,可能会依赖其他模块,当然最简单的情况下是不依赖其他模块,这时就可以这样写: //Inside file my/shirt.js: define({ color: "black", size: "unisize" }); 官方解释:If the module does not have any dep
22. Web MVC框架
本文向大家介绍在windows下快速搭建web.py开发框架方法,包括了在windows下快速搭建web.py开发框架方法的使用技巧和注意事项,需要的朋友参考一下 用Python进行web开发的话有很多框架供选择,比如最出名的Django,tornado等,除了这些框架之外,有一个轻量级的框架使用起来也是非常方便和顺手,就是web.py。它由一名黑客所创建,但是不幸的是这位创建者于2013年自
Spring的模型-视图-控制器(MVC)框架是围绕一个DispatcherServlet来设计的,这个Servlet会把请求分发给各个处理器,并支持可配置的处理器映射、视图渲染、本地化、时区与主题渲染等,甚至还能支持文件上传。处理器是你的应用中注解了@Controller和@RequestMapping的类和方法,Spring为处理器方法提供了极其多样灵活的配置。Spring 3.0以后提供了@
本文向大家介绍Spring Web MVC框架学习之配置Spring Web MVC,包括了Spring Web MVC框架学习之配置Spring Web MVC的使用技巧和注意事项,需要的朋友参考一下 这一篇文章讲的是Spring Web MVC各部分的配置方法,包括Java代码配置和XML文件配置以及MVC命名空间的使用方法。 启用MVC Java配置和XML命名空间 默认配置 要启用MVC
22.1 Spring Web MVC框架介绍 Spring的Web模型-视图-控制器(MVC)框架是围绕将请求分发到不同处理程序的DispatcherServlet类设计的,辅以可配置的处理程序映射、视图解析、本地化、时区、主题解析(theme resolution)以及对文件上传的支持。默认的处理程序基于@Controller和@RequestMapping注解,提供了大量灵活的处理方法。自从
JFinal 是基于 Java 语言的极速 WEB + ORM + AOP + Template Engine 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。