QUI-DEVELOP - 快速WEB开发框架MVC+ORM


GPL
跨平台
Java

软件简介

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
Mapcondition =new HashMap();
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(Mapparams);

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(Mapparams) {
// 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(Mapparams);

@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,Mapparams);

@Insert(type=insertType.insertBycustom)
public void doCreateEntity(String sql,Mapparams);
}

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。