欢迎使用CSDN-markdown编辑器

2 篇文章 0 订阅

动态的SQL改变界面显示数据的样式,如去掉时间后面的一个.0,在后面还有另一种方法,在实体BEEN里面来修改的。

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ccs.terminal.mapper.ActionListMapper" >
  <resultMap id="BaseResultMap" type="actionList" >

    <id column="action_id" property="actionId" jdbcType="BIGINT" />
    <result column="terminal_key" property="terminalKey" jdbcType="VARCHAR" />
    <result column="phone_number" property="phoneNumber" jdbcType="VARCHAR" />
    <result column="action_type" property="actionType" jdbcType="VARCHAR" />
    <result column="begin_Date" property="beginDate" jdbcType="TIMESTAMP" />
    <result column="end_date" property="endDate" jdbcType="TIMESTAMP" />
    <result column="version_number" property="versionNumber" jdbcType="BIGINT" />
    <result column="created_by" property="createdBy" jdbcType="BIGINT" />
    <result column="creation_date" property="creationDate" jdbcType="TIMESTAMP" />
    <result column="last_update_by" property="lastUpdateBy" jdbcType="BIGINT" />
    <result column="last_update_date" property="lastUpdateDate" jdbcType="TIMESTAMP" />
    <!-- 关联终端表的一个字段 -->
     <result column="terminal_name" property="terminalName" jdbcType="VARCHAR" />

        <result column="action_name" property="actionName" jdbcType="VARCHAR" />
  </resultMap>



    <!-- 终端信息映射 -->
  <resultMap id="ExportMap" type="com.ccs.terminal.model.ActionListExport" >
      <result column="phone_number" property="phoneNumber" jdbcType="VARCHAR" />
      <result column="action_type" property="actionType" jdbcType="VARCHAR" />
      <result column="begin_Date" property="beginDate" jdbcType="TIMESTAMP" />
      <result column="end_date" property="endDate" jdbcType="TIMESTAMP" />
       <result column="terminal_key" property="terminalKey" jdbcType="VARCHAR" />
  </resultMap>

  <!-- 终端信息所有字段 -->
  <sql id="Base_Column_List" >
     sal.action_id, 
     sal.terminal_key, 
     sal.phone_number, 
     (select option_item.item_name from shrg_os_option_item_tl option_item where sal.action_type= option_item.item_key) as action_name, 
     sal.terminal_name, 
    date_format(
        sal.begin_Date,
        '%Y-%m-%d %T'
    ) AS begin_Date, 
        date_format(
        sal.end_Date,
        '%Y-%m-%d %T'
    ) AS end_Date,
     sal.version_number,
     sal.created_by, 
     sal.creation_date, 
     sal.last_update_by, 
     sal.last_update_date
  </sql>


    <sql id="Base_Column_List_export" >
     phone_number, 
     (select option_item.item_name from shrg_os_option_item_tl option_item where action_type= option_item.item_key) as action_type, 
    date_format(
        begin_Date,
        '%Y-%m-%d %T'
    ) AS begin_Date, 
        date_format(
        end_Date,
        '%Y-%m-%d %T'
    ) AS end_Date
   </sql>
  <!-- 查询条件 -->
  <sql id="selectWhere" >
       <where>
          1=1
                  <if test="beginDate !=  null">
                         and       sal.begin_Date=#{beginDate} 
                  </if>
                       <if test="endDate !=  null">
                         and      sal.end_Date=#{endDate} 
                  </if>
       </where>
  </sql>

  <!--查询通话的所有记录  -->
  <select  id="selectActionListList"   parameterType="java.util.Map" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from shrg_action_terminal_v sal
        <include refid="selectWhere" />
        limit #{start},#{rows}
  </select>

    <!--查询通话的所有记录条数  -->
  <select id="countActionListList" parameterType="java.util.Map" resultType="java.lang.Integer" >
        select count(*)
        from shrg_action_terminal_v  sal
        <include refid="selectWhere" />
  </select>

    <!-- 查询所有终端数据 -->
  <select id="exportCallRecord"  resultMap="ExportMap"  parameterType="java.util.Map" >
       select   <include refid="Base_Column_List_export" /> from shrg_action_list_t
    </select>





  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from shrg_action_list_t
    where action_id = #{actionId,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 08 11:37:54 CST 2016.
    -->
    delete from shrg_action_list_t
    where action_id = #{actionId,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.ccs.terminal.model.ActionList" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 08 11:37:54 CST 2016.
    -->
    insert into shrg_action_list_t (action_id, terminal_key, phone_number, 
      action_type, begin_Date, end_date, 
      version_number, created_by, creation_date, 
      last_update_by, last_update_date)
    values (#{actionId,jdbcType=BIGINT}, #{terminalKey,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=VARCHAR}, 
      #{actionType,jdbcType=VARCHAR}, #{beginDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, 
      #{versionNumber,jdbcType=BIGINT}, #{createdBy,jdbcType=BIGINT}, #{creationDate,jdbcType=TIMESTAMP}, 
      #{lastUpdateBy,jdbcType=BIGINT}, #{lastUpdateDate,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.ccs.terminal.model.ActionList" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 08 11:37:54 CST 2016.
    -->
    insert into shrg_action_list_t
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="actionId != null" >
        action_id,
      </if>
      <if test="terminalKey != null" >
        terminal_key,
      </if>
      <if test="phoneNumber != null" >
        phone_number,
      </if>
      <if test="actionType != null" >
        action_type,
      </if>
      <if test="beginDate != null" >
        begin_Date,
      </if>
      <if test="endDate != null" >
        end_date,
      </if>
      <if test="versionNumber != null" >
        version_number,
      </if>
      <if test="createdBy != null" >
        created_by,
      </if>
      <if test="creationDate != null" >
        creation_date,
      </if>
      <if test="lastUpdateBy != null" >
        last_update_by,
      </if>
      <if test="lastUpdateDate != null" >
        last_update_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="actionId != null" >
        #{actionId,jdbcType=BIGINT},
      </if>
      <if test="terminalKey != null" >
        #{terminalKey,jdbcType=VARCHAR},
      </if>
      <if test="phoneNumber != null" >
        #{phoneNumber,jdbcType=VARCHAR},
      </if>
      <if test="actionType != null" >
        #{actionType,jdbcType=VARCHAR},
      </if>
      <if test="beginDate != null" >
        #{beginDate,jdbcType=TIMESTAMP},
      </if>
      <if test="endDate != null" >
        #{endDate,jdbcType=TIMESTAMP},
      </if>
      <if test="versionNumber != null" >
        #{versionNumber,jdbcType=BIGINT},
      </if>
      <if test="createdBy != null" >
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="creationDate != null" >
        #{creationDate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastUpdateBy != null" >
        #{lastUpdateBy,jdbcType=BIGINT},
      </if>
      <if test="lastUpdateDate != null" >
        #{lastUpdateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.ccs.terminal.model.ActionList" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 08 11:37:54 CST 2016.
    -->
    update shrg_action_list_t
    <set >
      <if test="terminalKey != null" >
        terminal_key = #{terminalKey,jdbcType=VARCHAR},
      </if>
      <if test="phoneNumber != null" >
        phone_number = #{phoneNumber,jdbcType=VARCHAR},
      </if>
      <if test="actionType != null" >
        action_type = #{actionType,jdbcType=VARCHAR},
      </if>
      <if test="beginDate != null" >
        begin_Date = #{beginDate,jdbcType=TIMESTAMP},
      </if>
      <if test="endDate != null" >
        end_date = #{endDate,jdbcType=TIMESTAMP},
      </if>
      <if test="versionNumber != null" >
        version_number = #{versionNumber,jdbcType=BIGINT},
      </if>
      <if test="createdBy != null" >
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="creationDate != null" >
        creation_date = #{creationDate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastUpdateBy != null" >
        last_update_by = #{lastUpdateBy,jdbcType=BIGINT},
      </if>
      <if test="lastUpdateDate != null" >
        last_update_date = #{lastUpdateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where action_id = #{actionId,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ccs.terminal.model.ActionList" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 08 11:37:54 CST 2016.
    -->
    update shrg_action_list_t
    set terminal_key = #{terminalKey,jdbcType=VARCHAR},
      phone_number = #{phoneNumber,jdbcType=VARCHAR},
      action_type = #{actionType,jdbcType=VARCHAR},
      begin_Date = #{beginDate,jdbcType=TIMESTAMP},
      end_date = #{endDate,jdbcType=TIMESTAMP},
      version_number = #{versionNumber,jdbcType=BIGINT},
      created_by = #{createdBy,jdbcType=BIGINT},
      creation_date = #{creationDate,jdbcType=TIMESTAMP},
      last_update_by = #{lastUpdateBy,jdbcType=BIGINT},
      last_update_date = #{lastUpdateDate,jdbcType=TIMESTAMP}
    where action_id = #{actionId,jdbcType=BIGINT}
  </update>
</mapper>

在实体BEEN里面来去掉时间后面的.0。

package com.subOs.model;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

/**-----------------------------------------------------------------------------------------------
 *---  create by 张意虎  on 2016-05-31  version  V2016_1.0    子系统用户的实体been  ---
 *-----------------------------------------------------------------------------------------------*/
public class SubUser {
    private Long id;// 表ID

    private String loginName;// 登陆名

    private String password;// 密码

    private String userName;// 姓名(用户名)

    private int sex;// 性别

    private String  sexStr;//由于数据库里面存储的是int类型,easyui读取数据到界面时,也只是Int.所以添加一个这样的字段。


    public void setSex(int sex) {
        this.sex = sex;
        if(sex==1){
            setSexStr("男");
        }else{
            setSexStr("女");
        }
    }
    public int getSex() {
        return sex;
    }
    public String getSexStr() {
        System.out.println("sexStr"+sexStr);
        return sexStr;
    }

    public void setSexStr(String sexStr) {
        this.sexStr = sexStr;
    }

    private String email;// 邮箱

    private String phone;// 电话

    private String mobile;// 手机

    private Long deptmentId;// 部门ID

    private String remark;// 备注

    private String approveFlag;// 审批状态

    private String type;// 用户类型(区分本系统和子系统0.1.2.3)

    private String enable;// 是否启用

    private Long createBy;// 创建人

    private Timestamp creationDate;// 创建日期

    private String creationDateStr;//页面显示的日期(新增的,数据库没有,页面显示的)

    private Long lastUpdateBy;// 最后修改人

    private Timestamp lastUpdateDate;// 最后修改的日期

    private String lastUpdateDateStr;//页面显示的修改时间(新增的,数据库没有,页面显示的)

    private Long versionNumber;// 版本号,默认为0

    private String userLevel;//用户级别

    private String userType;//用户类型

    private Long customerId;//客户ID
    private  String customerName;//客户名字
    private String lastUpdateByStr;//上次修改人(新增的,数据库没有,页面显示的)
    private String createByStr;//创建人名字。

    private  String [] systemSelect ;//用来存储我们的子系统
    private  String [] rolesSelect ;//用来存储添加子系统用户时,角色的保存。
    private  String userCode;


    public String getUserLevel() {
        return userLevel;
    }
    public void setUserLevel(String userLevel) {
        this.userLevel = userLevel;
    }
    public String getUserType() {
        return userType;
    }
    public void setUserType(String userType) {
        this.userType = userType;
    }
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    public String[] getRolesSelect() {
        return rolesSelect;
    }
    public void setRolesSelect(String[] rolesSelect) {
        this.rolesSelect = rolesSelect;
    }
    public String[] getSystemSelect() {
        return systemSelect;
    }
    public void setSystemSelect(String[] systemSelect) {
        this.systemSelect = systemSelect;
    }
    public String getLastUpdateByStr() {
        return lastUpdateByStr;
    }
    public void setLastUpdateByStr(String lastUpdateByStr) {
        this.lastUpdateByStr = lastUpdateByStr;
    }
    public String getCreateByStr() {
        return createByStr;
    }
    public void setCreateByStr(String createByStr) {
        this.createByStr = createByStr;
    }
    public String getCustomerName() {
        return customerName;
    }
    public void setCustomerName(String customerName) {
        this.customerName = customerName == null ? null : customerName.trim();
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getCustomerId() {
        return customerId;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName == null ? null : loginName.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? null : userName.trim();
    }



    public String getEmail() {
        return email;
    }






    public void setEmail(String email) {
        this.email = email == null ? null : email.trim();
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile == null ? null : mobile.trim();
    }

    public Long getDeptmentId() {
        return deptmentId;
    }

    public void setDeptmentId(Long deptmentId) {
        this.deptmentId = deptmentId;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark == null ? null : remark.trim();
    }

    public String getApproveFlag() {
        return approveFlag;
    }

    public void setApproveFlag(String approveFlag) {
        this.approveFlag = approveFlag == null ? null : approveFlag.trim();
    }

    public String getType() {
        System.out.println("type"+type);
        return type;
    }

    public void setType(String type) {
        this.type = type == null ? null : type.trim();
    }

    public String getEnable() {
        return enable;
    }

    public void setEnable(String enable) {
        this.enable = enable == null ? null : enable.trim();
    }

    public Long getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Long createBy) {
        this.createBy = createBy;
    }



    public Long getLastUpdateBy() {
        return lastUpdateBy;
    }

    public void setLastUpdateBy(Long lastUpdateBy) {
        this.lastUpdateBy = lastUpdateBy;
    }



    public Timestamp getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Timestamp creationDate) {
          this.creationDate = creationDate;
            if (creationDate!=null){
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                setCreationDateStr(format.format(creationDate));
            }
            else{
                setCreationDateStr(null);
            }
    }

    public Timestamp getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(Timestamp lastUpdateDate) {
          this.lastUpdateDate = lastUpdateDate;
            if(lastUpdateDate!=null){
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                setLastUpdateDateStr(format.format(lastUpdateDate));
            }else{
                setLastUpdateDateStr(null);
            }      
    }

    public String getCreationDateStr() {
        return creationDateStr;
    }

    public void setCreationDateStr(String creationDateStr) {
        this.creationDateStr = creationDateStr;
    }

    public String getLastUpdateDateStr() {
        return lastUpdateDateStr;
    }

    public void setLastUpdateDateStr(String lastUpdateDateStr) {
        this.lastUpdateDateStr = lastUpdateDateStr;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public Long getVersionNumber() {
        return versionNumber;
    }

    public void setVersionNumber(Long versionNumber) {
        this.versionNumber = versionNumber;
    }
}

去掉.0还有一个方法

第一步在JSP头部加上

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

第二步在要去掉.0的位置。加上,但是得有EL表达式才行

<td><fmt:formatDate type="time" value="${ringManager.lastUpdateDate }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值