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

网友投稿 802 2022-10-23

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

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

QUI-Framework个快速开发框架,里面有定制化ORM,MVC 。简单容易上手。

Action 层代码:

@Route(value = “/WebDemo”)@Controller(value = “webDemoAction”)public class WebDemoAction extends BaseController{

@Overrideprotected PageResultgetPageContent() {// TODO Auto-generated method stubIWebDemoService webDemoService=(IWebDemoService)BaseServiceFactory.getInstance(WebDemoServiceImpl.class);this.processQueryCondiction();return webDemoService.findByCriteria(queryCriteria);}

@Overrideprotected void processQueryCondiction() {// TODO Auto-generated method stubMapcondition =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”) StringsortField,@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) throwsException{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”) StringidString)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 层实现类:

@Overridepublic void doCreateEntity(WebDemoEntity webDemoEntity) {// TODO Auto-generated method stubIWebDemoDao webDemoDao= (IWebDemoDao) newBaseDaoFactory().getInstance(IWebDemoDao.class);if(!StringUtil.isNullOrEmpty(webDemoEntity.getId())){webDemoDao.doUpdateEntity(webDemoEntity);}else{webDemoDao.doCreateEntity(webDemoEntity);}

}

@Overridepublic void doRemoveEntitys(Listentities) {// TODO Auto-generated method stubIWebDemoDao webDemoDao= (IWebDemoDao) newBaseDaoFactory().getInstance(IWebDemoDao.class);for(WebDemoEntity webDemoEntity :entities){webDemoDao.doRemoveEntity(webDemoEntity);}

}

@Overridepublic WebDemoEntity findById(Integer id) {// TODO Auto-generated method stubIWebDemoDao webDemoDao= (IWebDemoDao) newBaseDaoFactory().getInstance(IWebDemoDao.class);return webDemoDao.findById(id);}

@Overridepublic ListfindByParams(Mapparams) {// TODO Auto-generated method stubIWebDemoDao webDemoDao= (IWebDemoDao) newBaseDaoFactory().getInstance(IWebDemoDao.class);

return webDemoDao.findByParams(params);}

@Overridepublic PageResultfindByCriteria(QueryCriteria criteria) {// TODO Auto-generated method stubIWebDemoDao webDemoDao= (IWebDemoDao) newBaseDaoFactory().getInstance(IWebDemoDao.class);

return webDemoDao.findByCriteria(criteria);}

@Overridepublic String convertEntityToString(WebDemoEntity webDemoEntity) {// TODO Auto-generated method stub

return webDemoEntity.toJSONObject().toJSONString().replaceAll(“null”, “”);}

@Overridepublic String convertListToString(Listentities) {// TODO Auto-generated method stubreturn JSONConvertUtils.convertBeanToJson(entities, new WebDemoEntity());}

@Overridepublic String convertPageResultToString(PageResultresult) {// TODO Auto-generated method stubSetfilters=new HashSet();filters.add(“id”);filters.add(“name”);return JSONConvertUtils.convertPageResultToJsonString(result, filters,WebDemoEntity.class);}

@Overridepublic void doCreateEntity(Listentities) {// TODO Auto-generated method stubIWebDemoDao webDemoDao= (IWebDemoDao) newBaseDaoFactory().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 {

@Insertpublic void doCreateEntity(WebDemoEntity webDemoEntity );

@Updatepublic void doUpdateEntity(WebDemoEntity webDemoEntity );

@Deletepublic 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;@Overridepublic Serializable generateId() {// TODO Auto-generated method stubif(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 stubJSONObject _json = new JSONObject();_json.put(“id”, id);_json.put(“name”, name);return _json;}}

而且新版本可后台代码自动生成。请查看地址的附件,代码没有用git。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:EasyReact- 美团客户端响应式框架
下一篇:Vue中图片上传组件封装-antd的a-upload二次封装-案例
相关文章

 发表评论

暂时没有评论,来抢沙发吧~