isNull判断property字段是否是null,用isEmpty更方便,包含了null和空字符串
例子一:
isEqual相当于equals,数字用得多些,一般都是判断状态值
<isEqual property="state" compareValue="0">
< /isEqual>
或
<isEqual property="state" compareProperty="nextState">
< /isEqual>
例子一:
传入的map或者类的属性name等于"1"吗,是就附加and和vvvv = '哈哈'
<isEqual property="name" compareValue="1" prepend="and">
vvvv = '哈哈'
< /isEqual>
传入的map或者类的属性name是null吗,是就附加and和vvvv = null
< isNull property="name" prepend="and">
vvvv = null
< /isNull>
我的应用:
###说明
1. 功能描述
用户可自行设置部分非重要弹出公告的设置。
2. 功能需求
1) 允许用户自行屏蔽“返销公告”,“银行存款通知”,“在线存款通知”三种类型公告。
2) 可在以上三种公告弹出页面上使用复选框设置不再通知此类公告。
3. 界面需求
1) 弹出公告页:
在“返销公告”( 25 ),“银行存款通知”( 63 )及“在线存款通知”( 64 )三种类型公告页面上增加复选框“不再弹出此类公告”。
2) 公告提示设置:
可直接对以上三种公告进行屏蔽设置(开启 10| 关闭11)。
4. 业务流程
5. 逻辑需求
用户存储屏蔽状态存储于 t_bussiness_set 中的“返销公告屏蔽”( sale_back ),“银行存款通知”(remittance_bank ),“在线存款通知”( remittance_online )字段。
6. 性能需求
7. 相关模块
8. 数据库相关表
1) T_bussiness_set 商户设置表
2) T_notice 公告表
1.sqlMap
Xml代码- <select id="querySingleModelByOut" parameterClass="com.hanpeng.base.phone.model.TBussinessNotice"
- resultClass="com.hanpeng.base.phone.model.TBussinessNotice">
- select * from (select row_.*, rownum rownum_ from (
- SELECT
- i.NOTICE_NUM as noticeNum ,
- i.BUSSINESS_ID as bussinessId ,
- i.STATE as state ,
- i.READ_DATE as readDate ,
- n.NOTICE_TITLE as noticeTitle ,
- n.NOTICE_INFO as noticeInfo ,
- n.CREATE_DATE as createDate ,
- n.EMPLOYEE_ID as employeeId ,
- n.NOTICE_TYPE as noticeType ,
- n.NOTICE_SHOW_TYPE as noticeShowType ,
- n.FINISH_DATE as finishDate ,
- n.PUBLISH_DATE as publishDate
- FROM T_BUSSINESS_NOTICE i left join T_NOTICE n on n.NOTICE_NUM = i.NOTICE_NUM
- WHERE
- n.PUBLISH_DATE <= sysdate AND n.FINISH_DATE >= sysdate
- <isNotEmpty prepend=" AND " property="bussinessId">
- i.BUSSINESS_ID = #bussinessId# </isNotEmpty>
- <isNotEmpty prepend=" AND " property="state">
- i.STATE = #state# </isNotEmpty>
- <isNotEmpty prepend=" AND " property="noticeShowType">
- n.NOTICE_SHOW_TYPE = #noticeShowType# </isNotEmpty>
- <isEqual property="saleBack" compareValue="10" prepend=" AND ">
- n.NOTICE_TYPE!='25'</isEqual>
- <isEqual property="remittanceBank" compareValue="10" prepend=" AND ">
- n.NOTICE_TYPE!='63'</isEqual>
- <isEqual property="remittanceOnline" compareValue="10" prepend=" AND ">
- n.NOTICE_TYPE!='64'</isEqual>
- )row_ where rownum <=1 ) where rownum_>=0
- </select>
2.Action
Java代码- /**
- * 查询公告弹出
- * @return
- * @author wwy
- * @date 2011-10-13 下午13:35:11
- */
- public void queryByOut(){
- try {
- PrintWriter out = this.getResponse().getWriter();
- if(getUserId() != null){
- bussinessNotice = noticeService.selectSingleModelByOut("26",getUserId());
- if(bussinessNotice==null){
- out.print("");
- }
- else{
- out.print("{\"noticeNum\":\""+bussinessNotice.getNoticeNum()+"\"}");
- }
- }else{
- out.print("");
- }
- } catch (Exception e) {
- log.error("弹出式公告查询失败" + e.fillInStackTrace());
- }
- }
3.serviceImpl
Java代码- public TBussinessNotice selectSingleModelByOut(String state,
- String bussinessId) {
- TBussinessNotice tbn = new TBussinessNotice();
- tbn.setBussinessId(bussinessId);
- tbn.setState("17");
- tbn.setNoticeShowType(state);
- TBussinessSet bussinessSet = BussinessSetService.queryById(bussinessId);//设置状态,sqlMap根据状态isEqual判断
- tbn.setSaleBack(bussinessSet.getSaleBack());
- tbn.setRemittanceBank(bussinessSet.getRemittanceBank());
- tbn.setRemittanceOnline(bussinessSet.getRemittanceOnline());
- return bussinessNoticeDao.selectSingleModelByOut(tbn);
- }
4.frameTop.jsp
Js代码- <script type="text/javascript">
- //弹出公告查询
- var autoNotice = setInterval(getNotice,1000*60);
- function getNotice(){
- clearInterval(autoNotice);
- $.ajax({
- type:'post',
- url:'Notice_queryByOut',
- dataType:'json',
- success:function(data){
- if(data!=null){
- $.hpDialog.open('Notice_detailByNotice?initLoadMethod=c&id='+data.noticeNum);
- }else{
- autoNotice = setInterval(getNotice,1000*60);
- }
- }
- });
- }
- function noticeCallback(){
- getNotice();
- }
- </script>
5.noticeDetail.jsp
Html代码- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>公告明细</title>
- <meta http-equiv="X-UA-Compatible" content="IE=7" />
- <%@ include file="/cssBasePage.jsp"%>
- <script type="text/javascript" src="<%=path %>/jsp/phone/interaction/notice/noticeDetail.js"></script>
- </head>
- <body>
- <form id="form1">
- <div class="jf_tanchu">
- <div class="jf_tanchutit">${ bussinessNotice.noticeTitle}</div>
- <div class="jf_tanchubox">
- <div class="jf_tanchubox_right">
- 公告类型:<v:dcolor code="${ bussinessNotice.noticeType}"/>
- 发布时间:<fmt:formatDate value="${ bussinessNotice.createDate}" pattern="yyyy-MM-dd"/>
- </div>
- ${bussinessNotice.noticeInfo}
- </div>
- </div>
- <s:if test="bussinessNotice.noticeType=='25'||bussinessNotice.noticeType=='63'||bussinessNotice.noticeType=='64'">
- <div>
- <input type="hidden" name="noticeType" value="${bussinessNotice.noticeType}"/>
- <input type="checkbox" id="isSelect" name="isSelect" value="${bussinessNotice.noticeType}" onclick="javascript:noTips();"/>
- <label for="isSelect">不再通知此类公告</label>
- </div>
- </s:if>
- </form>
- <div class="jf_tanchubot">
- <s:if test="initLoadMethod == \"c\" ">
- <hp:HpButton TJsClick="var win = $.dialog.open.origin;win.noticeCallback();$.dialog.close();" TValue="confirmed" id=""></hp:HpButton>
- </s:if>
- <s:else>
- <hp:HpButton TJsClick="$.dialog.close();" TValue="close" id=""></hp:HpButton>
- </s:else>
- </div>
- </body>
- </html>
6.noticeDetail.js
Js代码- function noTips(){
- var formParam = $("#form1").serialize();
- $.ajax({
- type:'post',
- url:'Notice_noTipsNotice',
- data:formParam,
- cache:false,
- dataType:'json',
- success:function(data){
- }
- });
- }