一个学生含有多个奖项,一个奖项分配给多个学生(多对多)。一对一,奖项名称通过状态表获得。
people_status:
对学生的奖项进行增加修改删除。
增加某个学生的奖项,就是在people_status表中增加一条记录 。其他同理.
sql:
<select id="getAwardList" parameterClass="youth" resultClass="com.fjxhx.business.people.model.YouthModel"> $pageBegin$ select a.id,a.name,a.identityId,a.tel,a.email,a.nation, a.projectDiscribe,a.feature,a.applyDate,a.fundedDate,a.fundedMoney,a.applyTime,a.equipDate,a.trainRecord, a.helpYear,a.teacherId, getAwardName(a.id) as youthAward, getTeacherName(a.teacherId) as teacherNameTree, o.orgName AS projectPlace, (select b.value from b_status b where b.content=a.isDisable and b.code='yn') as isDisable, (select b.value from b_status b where b.content=a.isUndergrate and b.code='yn') as isUndergrate, (select b.value from b_status b where b.content=a.sex and b.code='sex') as sex, (select b.value from b_status b where b.content=a.projectCode and b.code='project_industry') as projectCode, (select b.value from b_status b where b.content=a.hkType and b.code='hkType') as hkType, (select b.value from b_status b where b.content=a.education and b.code='youth_education') as education from ybc_youth a,ybc_org o where a.projectPlace=o.orgCode <dynamic prepend="and"> <isNotEmpty prepend="and" property="projectPlace"> projectPlace = #projectPlace# </isNotEmpty> <isNotEmpty prepend="and " property="name"> name like concat('%', #name#, '%') </isNotEmpty> <isNotEmpty prepend="and" property="tel"> tel like concat('%', #tel#, '%') </isNotEmpty> <isNotEmpty prepend="and" property="apply_beginTime" > <![CDATA[ applyDate >= #apply_beginTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="apply_endTime" > <![CDATA[ applyDate <= #apply_endTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="funded_beginTime" > <![CDATA[ fundedDate >= #funded_beginTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="funded_endTime" > <![CDATA[ fundedDate <= #funded_endTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="statusContent"> a.id in(SELECT s.peopleId FROM ybc_people_status s WHERE s.statusCode='youth_award' AND s.statusContent=#statusContent#) </isNotEmpty> </dynamic> $pageEnd$ </select> <select id="getAwardAddList" parameterClass="youth" resultClass="com.fjxhx.business.people.model.YouthModel"> $pageBegin$ select a.id,a.name,a.identityId,a.tel,a.email,a.nation, a.projectDiscribe,a.feature,a.applyDate,a.fundedDate,a.fundedMoney,a.applyTime,a.equipDate,a.trainRecord, a.helpYear,a.teacherId, getAwardName(a.id) as youthAward, getTeacherName(a.teacherId) as teacherNameTree, o.orgName AS projectPlace, (select b.value from b_status b where b.content=a.isDisable and b.code='yn') as isDisable, (select b.value from b_status b where b.content=a.isUndergrate and b.code='yn') as isUndergrate, (select b.value from b_status b where b.content=a.sex and b.code='sex') as sex, (select b.value from b_status b where b.content=a.projectCode and b.code='project_industry') as projectCode, (select b.value from b_status b where b.content=a.hkType and b.code='hkType') as hkType, (select b.value from b_status b where b.content=a.education and b.code='youth_education') as education from ybc_youth a,ybc_org o where a.projectPlace=o.orgCode <dynamic prepend="and"> <isNotEmpty prepend="and" property="projectPlace"> projectPlace = #projectPlace# </isNotEmpty> <isNotEmpty prepend="and " property="name"> name like concat('%', #name#, '%') </isNotEmpty> <isNotEmpty prepend="and" property="tel"> tel like concat('%', #tel#, '%') </isNotEmpty> <isNotEmpty prepend="and" property="apply_beginTime" > <![CDATA[ applyDate >= #apply_beginTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="apply_endTime" > <![CDATA[ applyDate <= #apply_endTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="funded_beginTime" > <![CDATA[ fundedDate >= #funded_beginTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="funded_endTime" > <![CDATA[ fundedDate <= #funded_endTime# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="statusContent"> a.id not in(SELECT s.peopleId FROM ybc_people_status s WHERE s.statusCode='youth_award' AND s.statusContent=#statusContent#) </isNotEmpty> </dynamic> $pageEnd$ </select> <insert id="add_people_status" parameterClass="com.fjxhx.business.people.model.YouthModel" > insert into ybc_people_status (peopleId,statusCode,statusContent) values(#peopleId#,'youth_award',#statusContent#) </insert> <delete id="del_people_status" parameterClass="com.fjxhx.business.people.model.YouthModel"> delete from ybc_people_status where peopleId=#peopleId# and statusCode='youth_award' and statusContent=#statusContent# </delete>
java:
public void getAwardList() { model.setFisrtRow((model.getPage() - 1) * model.getRows()); model.setLastRow(model.getRows()); try { BaseDao dao = getDao(); List<YouthModel> peopleIds = dao.selectForList( "youth.getAwardList", model); HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("total", peopleIds.size()); hm.put("rows", peopleIds); hm.put("success", true); this.doResponseWithJson(hm); } catch (Exception e) { e.printStackTrace(); this.setData("操作失败"); this.setSuccess(false); this.send(); } } public void getAwardAddList() { model.setFisrtRow((model.getPage() - 1) * model.getRows()); model.setLastRow(model.getRows()); try { BaseDao dao = getDao(); List<YouthModel> peopleIds = dao.selectForList( "youth.getAwardAddList", model); HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("total", peopleIds.size()); hm.put("rows", peopleIds); hm.put("success", true); this.doResponseWithJson(hm); } catch (Exception e) { e.printStackTrace(); this.setData("操作失败"); this.setSuccess(false); this.send(); } } public void addAwardConfig() { try { BaseDao dao = getDao(); String peopleId[] = model.getPeopleId().split(","); for (int i = 0; i < peopleId.length; i++) { YouthModel temp = new YouthModel(); temp.setPeopleId(peopleId[i]); temp.setStatusContent(model.getStatusContent()); dao.insertSql("youth.add_people_status", temp); } } catch (Exception e) { e.printStackTrace(); this.setData("操作失败"); this.setSuccess(false); this.send(); } } public void removeAwardConfig() { try { BaseDao dao = getDao(); String peopleId[] = model.getPeopleId().split(","); for (int i = 0; i < peopleId.length; i++) { YouthModel temp = new YouthModel(); temp.setPeopleId(peopleId[i]); temp.setStatusContent(model.getStatusContent()); dao.insertSql("youth.del_people_status", temp); } } catch (Exception e) { e.printStackTrace(); this.setData("操作失败"); this.setSuccess(false); this.send(); } }
相关推荐
ibatis配置多表关联(一对一、一对多、多对多
Ibatis多表查询
Ibatis多表查询,一个小小的多表查询实例教你如何用ibatis进行多表查询
一份非常详细的讲解文档,从建表到Ibatis配置文件,再到dao代码全部都有
ibatis实战之一对多关联源代码 文章地址:http://blog.csdn.net/itmyhome1990/article/details/30050183
ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南
NULL 博文链接:https://self4j.iteye.com/blog/906319
包括了几部分: ...7.iBatis2学习笔记:多对多映射(双向) .doc 8.iBatis2学习笔记:总结与思考.doc 9.iBatis2实体状态图解.doc 10.iBatis insert操作陷阱.doc 每章都有小例子。 呵呵,希望有所帮助!
ibatis 的小例子,主要是通过ibatis来处理2个数据表,其中数据表直接是有关系的
ibatis 一对多关系映射 ibatis 一对多关系映射ibatis 一对多关系映射
Source Database : ibatis_db Target Server Type : MYSQL Target Server Version : 50022 File Encoding : 65001 Date: 2013-05-02 22:49:28 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- --...
使用ibatis配置的主子表关联查询的实例,一对多关系,在控制台打印,有log4j的使用,打印结果详细,(码云同步)
ibatis多表查询开发过程(java)
一、mybatis/ibatiS xml配置文件中 以 学生班级和班主任 为例 讲解多表映射 其中班级和学生为 一对多 班主任和班级为 一对一 二、extjs 前台写model 及 grid 简易编码 内有详细讲解
开发环境说明 ...本示例完整地结合Struts2+Spring2+iBatis2+MySQL5,演示了一个用户表的增、删、改、查。 想完整学习Struts2+Spring+iBatis的同仁,可以在这个例子中学习或模仿最基本也是最核心的技术要点。
ibatis学习 ibatis总结 ibatis ibatis ibatis
NULL 博文链接:https://keer2345.iteye.com/blog/673391
ibatis ORM框架 多对多,很好的例子
框架:spring ibatis jquery 数据库: mysql 2个关联关系的表 有分页查询