SSM+BJUI实现CRUD的报表功能
場景
常見的一種業務就是根據數據庫中的單表或者通過關聯多表的數據顯示在主頁面并實現分頁、按條件篩選、查看詳情
添加記錄、編輯記錄等。
實現效果
代碼實現
查詢操作
1.編寫action
@Controller @RequestMapping("/sys/cooperativePartnersManageAction") public class SysCooperativePartnerManageAction? extends BaseAction{private? SysPartnersService sysPartnersService;private SysCodeService codeService;@Autowiredpublic void setCodeService(SysCodeService codeService) {this.codeService = codeService;}@Autowiredpublic void setSysPartnersService(SysPartnersService sysPartnersService) {this.sysPartnersService = sysPartnersService;}注:
RequestMapping后面要在BJUI的頁面進行權限的配置時用到,具體參照:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/84232271#commentsedit
然后編寫控制跳轉后的主頁面的action中的方法toList
@RequestMapping(value = "/toList")public? ModelAndView toList(Integer pageSize, Integer pageCurrent, String orderField, String orderDirection,String partnerName,String companyName) {ModelAndView mv = null;try {PageResult<SysPartnersExt> pageResult = PageUtil.pageSet(this.getClass(), pageSize, pageCurrent, orderField, orderDirection);pageResult.getParam().put("status", "0");//插入模糊搜索數據if (partnerName != null && !"".equals(partnerName)) {pageResult.getParam().put("partnerName", partnerName);pageResult.getExt().put("partnerName", partnerName);}if (companyName != null && !"".equals(companyName)) {pageResult.getParam().put("companyName", companyName);pageResult.getExt().put("companyName", companyName);}pageResult.setOrderField("sp.RecordTime");pageResult.setOrderDirection("DESC");pageResult = this.sysPartnersService.getPartnerListPageResult(pageResult);mv = new ModelAndView();mv.addObject(ModelAndViewConstants.PAGE_RESULT, pageResult);mv.setViewName(ModelAndViewConstants.PARTNER_MAIN_VIEW);} catch (Exception e) {mv = new ModelAndView(ModelAndViewConstants.ERROR_VIEW);LogService.getInstance(this).debug(e);}return mv;}注:
①方法參數中的 String partnerName,String companyName是前端頁面在實現模糊查詢時傳過來的參數
②PageResult是一個封裝了頁面返回數據(頁面數據、分頁相關、查詢時排序參數等)
public class PageResult<T> implements Serializable {private Integer pageCurrent = 1;???????????//當前頁索引private Integer pageSize = 10;???????????//每頁記錄數private Map<String, Object> param = new HashMap<String, Object>();??//傳入的參數,param和where只用一個private String where;?????????????//where條件字符串,where和param只用一個private String orderField;????????????//排序字段private String orderDirection = "ASC";??????????//排序方向,升序or降序private Integer total;????????????//總記錄數private List<T> list = new ArrayList<T>();????????//頁面數據private Map<String, Object> ext = new HashMap<String, Object>();省略get、set方法。③status設置為0,表示數據是正常數據,未被修改過。
④然后將前端傳來的模糊查詢的參數賦值。
⑤pageResult.setOrderField("sp.RecordTime");
?? ?pageResult.setOrderDirection("DESC");
是設置查詢后的數據的排序字段以及排序方式,其中sp要與mapper文件中執行select語句時的別名一致。
⑥pageResult = this.sysPartnersService.getPartnerListPageResult(pageResult);
然后執行service層的查詢數據的方法,參數以及返回值類型都是pageResult 。
⑦最后將查詢到的數據傳遞到指定的頁面:
???mv.addObject(ModelAndViewConstants.PAGE_RESULT, pageResult);
???mv.setViewName(ModelAndViewConstants.PARTNER_MAIN_VIEW);
2.編寫service
?
public interface SysPartnersService extends BaseService<SysPartners, java.io.Serializable> {/*** 功能說明:通過PageResult獲取分頁數據* 修改說明:* @author?badao* @date 2018/11/13 周二: 9:20:55.03* @param pageResult 分頁查詢對象,包含查詢條件* @return 返回分頁查詢對象,包含頁面數據*/public PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult);3.編寫serviceImpl
@Service("sysPartnersService") public class SysPartnersServiceImpl extends BaseServiceImpl<SysPartners> implements SysPartnersService {private SysPartnersDao dao;@Autowiredpublic void setDao(SysPartnersDao dao) {super.setDao(dao);this.dao = dao;}@Overridepublic PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult) {// TODO Auto-generated method stubreturn this.dao.getPartnerListPageResult(pageResult);}4.編寫dao
?
public interface SysPartnersDao extends BaseDao<SysPartners, Serializable>{/*** 功能說明:通過PageResult獲取分頁數據* 修改說明:* @author?badao* @date 2018/11/13 周二: 9:55:54.57* @param pageResult 分頁查詢對象,包含查詢條件* @return 返回分頁查詢對象,包含頁面數據*/public PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult);5.編寫daoImpl
?
@Repository("sysPartnersDao") public class SysPartnersDaoImpl extends BaseDaoImpl<SysPartners, Serializable> implements SysPartnersDao {/*** 功能說明:獲取列表分頁數據* 修改說明:* @author?badao*?@date 2018/11/13 周二:10:55:37.38* @param params 查詢參數* @return 返回符合條件的記錄集合*/public List<SysPartnersExt> getPartnersListByParam(Map<String, Object> params) {String stmtId = this.getNameSpace() + MapperIdConstants._GETPARTNERSLISTBYPARAM;return this.getSqlSession().selectList(stmtId, params);}6.編寫mapper層
用代碼生成工具生成的mapper層:
<?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="**.sys.model.SysPartners"><!-- 結果集 -->????<resultMap id="BaseResultMap" type="**.sys.model.SysPartners"><id column="Id" property="id" jdbcType="INTEGER" /><result column="PartnerNum" property="partnerNum" jdbcType="VARCHAR" /><result column="SignKey" property="signKey" jdbcType="VARCHAR" /><result column="PartnerName" property="partnerName" jdbcType="VARCHAR" /><result column="CompanyName" property="companyName" jdbcType="VARCHAR" /><result column="ContactName" property="contactName" jdbcType="VARCHAR" /><result column="ContactMobile" property="contactMobile" jdbcType="VARCHAR" /><result column="ContactAddress" property="contactAddress" jdbcType="VARCHAR" /><result column="Extension" property="extension" jdbcType="VARCHAR" /><result column="ContactFixed" property="contactFixed" jdbcType="VARCHAR" /><result column="ContactCardNum" property="contactCardNum" jdbcType="VARCHAR" /><result column="Email" property="email" jdbcType="VARCHAR" /><result column="Province" property="province" jdbcType="VARCHAR" /><result column="City" property="city" jdbcType="VARCHAR" /><result column="District" property="district" jdbcType="VARCHAR" /><result column="ContractStatus" property="contractStatus" jdbcType="INTEGER" /><result column="ContractStatusName" property="contractStatusName" jdbcType="VARCHAR" /><result column="TestContractTime" property="testContractTime" jdbcType="TIMESTAMP" /><result column="FormalContractTime" property="formalContractTime" jdbcType="TIMESTAMP" /><result column="VipRestRoomPrice" property="vipRestRoomPrice" jdbcType="DECIMAL" /><result column="CipRestRoomPrice" property="cipRestRoomPrice" jdbcType="DECIMAL" /><result column="PassPrice" property="passPrice" jdbcType="DECIMAL" /><result column="CurrentAdvanceMoney" property="currentAdvanceMoney" jdbcType="DECIMAL" /><result column="QqNum" property="qqNum" jdbcType="VARCHAR" /><result column="MicroBlog" property="microBlog" jdbcType="VARCHAR" /><result column="ModifyUserId" property="modifyUserId" jdbcType="INTEGER" /><result column="ModifyUserName" property="modifyUserName" jdbcType="VARCHAR" /><result column="RecordTime" property="recordTime" jdbcType="TIMESTAMP" /><result column="Status" property="status" jdbcType="CHAR" /><result column="Remark" property="remark" jdbcType="VARCHAR" /></resultMap><sql id="Base_Column_List">Id, PartnerNum, SignKey, PartnerName, CompanyName, ContactName, ContactMobile, ContactAddress, Extension, ContactFixed, ContactCardNum, Email, Province, City, District, ContractStatus, ContractStatusName, TestContractTime, FormalContractTime, VipRestRoomPrice, CipRestRoomPrice, PassPrice, CurrentAdvanceMoney, QqNum, MicroBlog, ModifyUserId, ModifyUserName, RecordTime, Status, Remark</sql><!-- 按主鍵查詢 --><select id="getByPrimaryKey" parameterType="java.io.Serializable" resultMap="BaseResultMap">select<include refid="Base_Column_List" />from sys_partnerswhere Id = #{id}</select><select id="getByPrimaryKeys" parameterType="java.util.Map" resultMap="BaseResultMap">select<include refid="Base_Column_List" />from sys_partnerswhere Id = #{id, jdbcType=INTEGER}</select><!-- 參數查詢 --><select id="getByParam" parameterType="java.util.Map" resultMap="BaseResultMap">select<include refid="Base_Column_List" />from sys_partners<where><if test="id != null">Id= #{id}</if><if test="partnerNum != null"> and PartnerNum = #{partnerNum}</if><if test="signKey != null"> and SignKey = #{signKey}</if><if test="partnerName != null"> and PartnerName = #{partnerName}</if><if test="companyName != null"> and CompanyName = #{companyName}</if><if test="contactName != null"> and ContactName = #{contactName}</if><if test="contactMobile != null"> and ContactMobile = #{contactMobile}</if><if test="contactAddress != null"> and ContactAddress = #{contactAddress}</if><if test="extension != null"> and Extension = #{extension}</if><if test="contactFixed != null"> and ContactFixed = #{contactFixed}</if><if test="contactCardNum != null"> and ContactCardNum = #{contactCardNum}</if><if test="email != null"> and Email = #{email}</if><if test="province != null"> and Province = #{province}</if><if test="city != null">and City= #{city}</if><if test="district != null"> and District = #{district}</if><if test="contractStatus != null"> and ContractStatus = #{contractStatus}</if><if test="contractStatusName != null"> and ContractStatusName = #{contractStatusName}</if><if test="testContractTime != null"> and TestContractTime = #{testContractTime}</if><if test="formalContractTime != null"> and FormalContractTime = #{formalContractTime}</if><if test="vipRestRoomPrice != null"> and VipRestRoomPrice = #{vipRestRoomPrice}</if><if test="cipRestRoomPrice != null"> and CipRestRoomPrice = #{cipRestRoomPrice}</if><if test="passPrice != null"> and PassPrice = #{passPrice}</if><if test="currentAdvanceMoney != null"> and CurrentAdvanceMoney = #{currentAdvanceMoney}</if><if test="qqNum != null"> and QqNum = #{qqNum}</if><if test="microBlog != null"> and MicroBlog = #{microBlog}</if><if test="modifyUserId != null"> and ModifyUserId = #{modifyUserId}</if><if test="modifyUserName != null"> and ModifyUserName = #{modifyUserName}</if><if test="recordTime != null"> and RecordTime = #{recordTime}</if><if test="status != null"> and Status = #{status}</if><if test="remark != null"> and Remark = #{remark}</if></where><if test="orderColumn != null">order by ${orderColumn}<if test="orderTurn != null">${orderTurn}</if></if><if test="limit != null">limit<if test="offset != null">${offset},</if>${limit}</if></select><!-- 條件查詢 --><select id="getByWhere" parameterType="java.util.Map" resultMap="BaseResultMap">select<include refid="Base_Column_List" />from sys_partnerswhere 1 = 1 and ${where}<if test="orderColumn != null">order by ${orderColumn}<if test="orderTurn != null">${orderTurn}</if></if><if test="limit != null">limit<if test="offset != null">${offset},</if>${limit}</if></select><!-- 返回記錄數 --><select id="count" resultType="int">select count(1) from sys_partners t</select><!-- 返回符合條件的記錄數 --><select id="countByParam" parameterType="java.util.Map" resultType="int">select count(1) from sys_partners t<where><if test="id != null">Id= #{id}</if><if test="partnerNum != null"> and PartnerNum = #{partnerNum}</if><if test="signKey != null"> and SignKey = #{signKey}</if><if test="partnerName != null"> and PartnerName = #{partnerName}</if><if test="companyName != null"> and CompanyName = #{companyName}</if><if test="contactName != null"> and ContactName = #{contactName}</if><if test="contactMobile != null"> and ContactMobile = #{contactMobile}</if><if test="contactAddress != null"> and ContactAddress = #{contactAddress}</if><if test="extension != null"> and Extension = #{extension}</if><if test="contactFixed != null"> and ContactFixed = #{contactFixed}</if><if test="contactCardNum != null"> and ContactCardNum = #{contactCardNum}</if><if test="email != null"> and Email = #{email}</if><if test="province != null"> and Province = #{province}</if><if test="city != null">and City= #{city}</if><if test="district != null"> and District = #{district}</if><if test="contractStatus != null"> and ContractStatus = #{contractStatus}</if><if test="contractStatusName != null"> and ContractStatusName = #{contractStatusName}</if><if test="testContractTime != null"> and TestContractTime = #{testContractTime}</if><if test="formalContractTime != null"> and FormalContractTime = #{formalContractTime}</if><if test="vipRestRoomPrice != null"> and VipRestRoomPrice = #{vipRestRoomPrice}</if><if test="cipRestRoomPrice != null"> and CipRestRoomPrice = #{cipRestRoomPrice}</if><if test="passPrice != null"> and PassPrice = #{passPrice}</if><if test="currentAdvanceMoney != null"> and CurrentAdvanceMoney = #{currentAdvanceMoney}</if><if test="qqNum != null"> and QqNum = #{qqNum}</if><if test="microBlog != null"> and MicroBlog = #{microBlog}</if><if test="modifyUserId != null"> and ModifyUserId = #{modifyUserId}</if><if test="modifyUserName != null"> and ModifyUserName = #{modifyUserName}</if><if test="recordTime != null"> and RecordTime = #{recordTime}</if><if test="status != null"> and Status = #{status}</if><if test="remark != null"> and Remark = #{remark}</if></where></select><!-- 返回符合條件的記錄數 --><select id="countByWhere" parameterType="java.util.Map" resultType="int">select count(1) from sys_partners twhere 1=1 and ${where}</select><!-- 新增對象 -->?<insert id="insert" parameterType="com.wongoing.sys.model.SysPartners" useGeneratedKeys="true" keyProperty="id" >insert into sys_partners ( PartnerNum,? SignKey,? PartnerName,? CompanyName,? ContactName,? ContactMobile,? ContactAddress,? Extension,? ContactFixed,? ContactCardNum,? Email,? Province,? City,? District,? ContractStatus,? ContractStatusName,? TestContractTime,? FormalContractTime,? VipRestRoomPrice,? CipRestRoomPrice,? PassPrice,? CurrentAdvanceMoney,? QqNum,? MicroBlog,? ModifyUserId,? ModifyUserName,? RecordTime,? Status,? Remark)values (#{partnerNum,jdbcType=VARCHAR}, #{signKey,jdbcType=VARCHAR}, #{partnerName,jdbcType=VARCHAR}, #{companyName,jdbcType=VARCHAR}, #{contactName,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR}, #{contactAddress,jdbcType=VARCHAR}, #{extension,jdbcType=VARCHAR}, #{contactFixed,jdbcType=VARCHAR}, #{contactCardNum,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{district,jdbcType=VARCHAR}, #{contractStatus,jdbcType=INTEGER}, #{contractStatusName,jdbcType=VARCHAR}, #{testContractTime,jdbcType=TIMESTAMP}, #{formalContractTime,jdbcType=TIMESTAMP}, #{vipRestRoomPrice,jdbcType=DECIMAL}, #{cipRestRoomPrice,jdbcType=DECIMAL}, #{passPrice,jdbcType=DECIMAL}, #{currentAdvanceMoney,jdbcType=DECIMAL}, #{qqNum,jdbcType=VARCHAR}, #{microBlog,jdbcType=VARCHAR}, #{modifyUserId,jdbcType=INTEGER}, #{modifyUserName,jdbcType=VARCHAR}, #{recordTime,jdbcType=TIMESTAMP}, #{status,jdbcType=CHAR}, #{remark,jdbcType=VARCHAR})</insert><!-- 批量插入 --><insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"? keyColumn="id">insert into sys_partners ( PartnerNum,? SignKey,? PartnerName,? CompanyName,? ContactName,? ContactMobile,? ContactAddress,? Extension,? ContactFixed,? ContactCardNum,? Email,? Province,? City,? District,? ContractStatus,? ContractStatusName,? TestContractTime,? FormalContractTime,? VipRestRoomPrice,? CipRestRoomPrice,? PassPrice,? CurrentAdvanceMoney,? QqNum,? MicroBlog,? ModifyUserId,? ModifyUserName,? RecordTime,? Status,? Remark)<foreach collection="list" item="item" index="index" separator="union all">select #{item.partnerNum,jdbcType=VARCHAR}, #{item.signKey,jdbcType=VARCHAR}, #{item.partnerName,jdbcType=VARCHAR}, #{item.companyName,jdbcType=VARCHAR}, #{item.contactName,jdbcType=VARCHAR}, #{item.contactMobile,jdbcType=VARCHAR}, #{item.contactAddress,jdbcType=VARCHAR}, #{item.extension,jdbcType=VARCHAR}, #{item.contactFixed,jdbcType=VARCHAR}, #{item.contactCardNum,jdbcType=VARCHAR}, #{item.email,jdbcType=VARCHAR}, #{item.province,jdbcType=VARCHAR}, #{item.city,jdbcType=VARCHAR}, #{item.district,jdbcType=VARCHAR}, #{item.contractStatus,jdbcType=INTEGER}, #{item.contractStatusName,jdbcType=VARCHAR}, #{item.testContractTime,jdbcType=TIMESTAMP}, #{item.formalContractTime,jdbcType=TIMESTAMP}, #{item.vipRestRoomPrice,jdbcType=DECIMAL}, #{item.cipRestRoomPrice,jdbcType=DECIMAL}, #{item.passPrice,jdbcType=DECIMAL}, #{item.currentAdvanceMoney,jdbcType=DECIMAL}, #{item.qqNum,jdbcType=VARCHAR}, #{item.microBlog,jdbcType=VARCHAR}, #{item.modifyUserId,jdbcType=INTEGER}, #{item.modifyUserName,jdbcType=VARCHAR}, #{item.recordTime,jdbcType=TIMESTAMP}, #{item.status,jdbcType=CHAR}, #{item.remark,jdbcType=VARCHAR}</foreach></insert><!-- 更新對象 --><update id="updateByPrimaryKey" parameterType="com.wongoing.sys.model.SysPartners">update sys_partners<set><if test="partnerNum != null">PartnerNum = #{partnerNum,jdbcType=VARCHAR},</if><if test="signKey != null">SignKey = #{signKey,jdbcType=VARCHAR},</if><if test="partnerName != null">PartnerName = #{partnerName,jdbcType=VARCHAR},</if><if test="companyName != null">CompanyName = #{companyName,jdbcType=VARCHAR},</if><if test="contactName != null">ContactName = #{contactName,jdbcType=VARCHAR},</if><if test="contactMobile != null">ContactMobile = #{contactMobile,jdbcType=VARCHAR},</if><if test="contactAddress != null">ContactAddress = #{contactAddress,jdbcType=VARCHAR},</if><if test="extension != null">Extension = #{extension,jdbcType=VARCHAR},</if><if test="contactFixed != null">ContactFixed = #{contactFixed,jdbcType=VARCHAR},</if><if test="contactCardNum != null">ContactCardNum = #{contactCardNum,jdbcType=VARCHAR},</if><if test="email != null">Email = #{email,jdbcType=VARCHAR},</if><if test="province != null">Province = #{province,jdbcType=VARCHAR},</if><if test="city != null">City = #{city,jdbcType=VARCHAR},</if><if test="district != null">District = #{district,jdbcType=VARCHAR},</if><if test="contractStatus != null">ContractStatus = #{contractStatus,jdbcType=INTEGER},</if><if test="contractStatusName != null">ContractStatusName = #{contractStatusName,jdbcType=VARCHAR},</if><if test="testContractTime != null">TestContractTime = #{testContractTime,jdbcType=TIMESTAMP},</if><if test="formalContractTime != null">FormalContractTime = #{formalContractTime,jdbcType=TIMESTAMP},</if><if test="vipRestRoomPrice != null">VipRestRoomPrice = #{vipRestRoomPrice,jdbcType=DECIMAL},</if><if test="cipRestRoomPrice != null">CipRestRoomPrice = #{cipRestRoomPrice,jdbcType=DECIMAL},</if><if test="passPrice != null">PassPrice = #{passPrice,jdbcType=DECIMAL},</if><if test="currentAdvanceMoney != null">CurrentAdvanceMoney = #{currentAdvanceMoney,jdbcType=DECIMAL},</if><if test="qqNum != null">QqNum = #{qqNum,jdbcType=VARCHAR},</if><if test="microBlog != null">MicroBlog = #{microBlog,jdbcType=VARCHAR},</if><if test="modifyUserId != null">ModifyUserId = #{modifyUserId,jdbcType=INTEGER},</if><if test="modifyUserName != null">ModifyUserName = #{modifyUserName,jdbcType=VARCHAR},</if><if test="recordTime != null">RecordTime = #{recordTime,jdbcType=TIMESTAMP},</if><if test="status != null">Status = #{status,jdbcType=CHAR},</if><if test="remark != null">Remark = #{remark,jdbcType=VARCHAR},</if></set><where><if test="id != null">Id = #{id,jdbcType=INTEGER}</if></where></update><!-- 批量更新 -->?<update id="updateBatch" parameterType="com.wongoing.sys.model.SysPartners"><foreach collection="list" item="item" separator=";">update sys_partners<set><if test="item.partnerNum != null">PartnerNum = #{item.partnerNum,jdbcType=VARCHAR},</if><if test="item.signKey != null">SignKey = #{item.signKey,jdbcType=VARCHAR},</if><if test="item.partnerName != null">PartnerName = #{item.partnerName,jdbcType=VARCHAR},</if><if test="item.companyName != null">CompanyName = #{item.companyName,jdbcType=VARCHAR},</if><if test="item.contactName != null">ContactName = #{item.contactName,jdbcType=VARCHAR},</if><if test="item.contactMobile != null">ContactMobile = #{item.contactMobile,jdbcType=VARCHAR},</if><if test="item.contactAddress != null">ContactAddress = #{item.contactAddress,jdbcType=VARCHAR},</if><if test="item.extension != null">Extension = #{item.extension,jdbcType=VARCHAR},</if><if test="item.contactFixed != null">ContactFixed = #{item.contactFixed,jdbcType=VARCHAR},</if><if test="item.contactCardNum != null">ContactCardNum = #{item.contactCardNum,jdbcType=VARCHAR},</if><if test="item.email != null">Email = #{item.email,jdbcType=VARCHAR},</if><if test="item.province != null">Province = #{item.province,jdbcType=VARCHAR},</if><if test="item.city != null">City = #{item.city,jdbcType=VARCHAR},</if><if test="item.district != null">District = #{item.district,jdbcType=VARCHAR},</if><if test="item.contractStatus != null">ContractStatus = #{item.contractStatus,jdbcType=INTEGER},</if><if test="item.contractStatusName != null">ContractStatusName = #{item.contractStatusName,jdbcType=VARCHAR},</if><if test="item.testContractTime != null">TestContractTime = #{item.testContractTime,jdbcType=TIMESTAMP},</if><if test="item.formalContractTime != null">FormalContractTime = #{item.formalContractTime,jdbcType=TIMESTAMP},</if><if test="item.vipRestRoomPrice != null">VipRestRoomPrice = #{item.vipRestRoomPrice,jdbcType=DECIMAL},</if><if test="item.cipRestRoomPrice != null">CipRestRoomPrice = #{item.cipRestRoomPrice,jdbcType=DECIMAL},</if><if test="item.passPrice != null">PassPrice = #{item.passPrice,jdbcType=DECIMAL},</if><if test="item.currentAdvanceMoney != null">CurrentAdvanceMoney = #{item.currentAdvanceMoney,jdbcType=DECIMAL},</if><if test="item.qqNum != null">QqNum = #{item.qqNum,jdbcType=VARCHAR},</if><if test="item.microBlog != null">MicroBlog = #{item.microBlog,jdbcType=VARCHAR},</if><if test="item.modifyUserId != null">ModifyUserId = #{item.modifyUserId,jdbcType=INTEGER},</if><if test="item.modifyUserName != null">ModifyUserName = #{item.modifyUserName,jdbcType=VARCHAR},</if><if test="item.recordTime != null">RecordTime = #{item.recordTime,jdbcType=TIMESTAMP},</if><if test="item.status != null">Status = #{item.status,jdbcType=CHAR},</if><if test="item.remark != null">Remark = #{item.remark,jdbcType=VARCHAR},</if></set><where><if test="item.id != null">Id = #{item.id,jdbcType=INTEGER}</if></where></foreach></update><!-- 根據主鍵刪除 -->?<delete id="deleteByPrimaryKey" parameterType="java.io.Serializable">delete from sys_partners where Id = #{id, jdbcType=INTEGER}</delete><delete id="deleteByPrimaryKeys" parameterType="java.util.Map">delete from sys_partners where Id = #{id}</delete><!-- 根據參數刪除 --><delete id="deleteByParam" parameterType="java.util.Map">delete from sys_partners<where><if test="id != null">Id= #{id}</if><if test="partnerNum != null"> and PartnerNum = #{partnerNum}</if><if test="signKey != null"> and SignKey = #{signKey}</if><if test="partnerName != null"> and PartnerName = #{partnerName}</if><if test="companyName != null"> and CompanyName = #{companyName}</if><if test="contactName != null"> and ContactName = #{contactName}</if><if test="contactMobile != null"> and ContactMobile = #{contactMobile}</if><if test="contactAddress != null"> and ContactAddress = #{contactAddress}</if><if test="extension != null"> and Extension = #{extension}</if><if test="contactFixed != null"> and ContactFixed = #{contactFixed}</if><if test="contactCardNum != null"> and ContactCardNum = #{contactCardNum}</if><if test="email != null"> and Email = #{email}</if><if test="province != null"> and Province = #{province}</if><if test="city != null">and City= #{city}</if><if test="district != null"> and District = #{district}</if><if test="contractStatus != null"> and ContractStatus = #{contractStatus}</if><if test="contractStatusName != null"> and ContractStatusName = #{contractStatusName}</if><if test="testContractTime != null"> and TestContractTime = #{testContractTime}</if><if test="formalContractTime != null"> and FormalContractTime = #{formalContractTime}</if><if test="vipRestRoomPrice != null"> and VipRestRoomPrice = #{vipRestRoomPrice}</if><if test="cipRestRoomPrice != null"> and CipRestRoomPrice = #{cipRestRoomPrice}</if><if test="passPrice != null"> and PassPrice = #{passPrice}</if><if test="currentAdvanceMoney != null"> and CurrentAdvanceMoney = #{currentAdvanceMoney}</if><if test="qqNum != null"> and QqNum = #{qqNum}</if><if test="microBlog != null"> and MicroBlog = #{microBlog}</if><if test="modifyUserId != null"> and ModifyUserId = #{modifyUserId}</if><if test="modifyUserName != null"> and ModifyUserName = #{modifyUserName}</if><if test="recordTime != null"> and RecordTime = #{recordTime}</if><if test="status != null"> and Status = #{status}</if><if test="remark != null"> and Remark = #{remark}</if></where></delete><!-- 批量刪除 --><delete id="deleteBatch">delete from sys_partners where Id in<trim prefix="(" suffix=")" suffixOverrides=","><foreach collection="list" item="pk" separator=",">#{pk}</foreach></trim></delete><!-- 按where條件字符串(不包含where關鍵詞)刪除 --><delete id="deleteByWhere" parameterType="java.util.Map">delete from sys_partners where 1=1 and ${where}</delete><!-- 清空表中記錄,即截斷表(truncate) --><delete id="clean">truncate table sys_partners</delete></mapper>自己編寫的mapper層
<?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="**.sys.model.SysPartners"><!-- 結果集 -->???<resultMap id="SysPartnersResultMap" type="**.sys.model.ext.SysPartnersExt" extends="BaseResultMap"><result column="ContractStatusName" property="contractStatusName" jdbcType="VARCHAR" /></resultMap><select id="getPartnersListByParam" parameterType="java.util.Map" resultMap="SysPartnersResultMap">select sp.*,sd.CodeName ContactNameInCodefrom sys_partners spleft join sys_code sdon sp.ContractStatus = sd.CodeValueand sd.CodeType ="contractStatus"????<where>???<if test="partnerName"> and sp.partnerName like CONCAT('%',#{partnerName},'%' )</if><if test="companyName"> and sp.companyName like CONCAT('%',#{companyName},'%' )</if><if test="partnerNum"> and sp.partnerNum like CONCAT('%',#{partnerNum},'%' )</if><if test="remark"> and sp.Remark like CONCAT('%',#{remark},'%' )</if><if test="status"> and sp.Status = #{status}</if><if test="startDate"> and? sp.RecordTime >=CONCAT(#{startDate},' 00:00:00' ) </if><if test="endDate"> and CONCAT(#{endDate},' 23:59:59' )>= sp.RecordTime </if></where><if test="orderColumn != null">order by ${orderColumn}<if test="orderTurn != null">${orderTurn}</if></if><if test="limit != null">limit<if test="offset != null">${offset},</if>${limit}</if></select><select id="countOfPartnersListByParam" parameterType="java.util.Map" resultType="int">selectcount(1)from sys_partners spleft join sys_code sdon sp.ContractStatus = sd.CodeValueand sd.CodeType ="contractStatus"<where><if test="partnerName"> and sp.partnerName like CONCAT('%',#{partnerName},'%' )</if><if test="companyName"> and sp.companyName like CONCAT('%',#{companyName},'%' )</if><if test="partnerNum"> and sp.partnerNum like CONCAT('%',#{partnerNum},'%' )</if><if test="remark"> and sp.Remark like CONCAT('%',#{remark},'%' )</if><if test="status"> and sp.Status = #{status}</if><if test="startDate"> and? sp.RecordTime >=CONCAT(#{startDate},' 00:00:00' ) </if><if test="endDate"> and CONCAT(#{endDate},' 23:59:59' )>= sp.RecordTime </if></where></select></mapper>7.編寫model層
代碼生成工具生成:
public class SysPartners implements java.io.Serializable{private Integer id;private String partnerNum;private String signKey;private String partnerName;private String companyName;private String contactName;private String contactMobile;private String contactAddress;private String extension;private String contactFixed;private String contactCardNum;private String email;private String province;private String city;private String district;private Integer contractStatus;private String contractStatusName;private Date testContractTime;private Date formalContractTime;private BigDecimal vipRestRoomPrice;private BigDecimal cipRestRoomPrice;private BigDecimal passPrice;private BigDecimal currentAdvanceMoney;private String qqNum;private String microBlog;private Integer modifyUserId;private String modifyUserName;private Date recordTime;private String status;private String remark;省略set、get方法自己編寫的model:
public class SysPartnersExt? extends SysPartners{private String contractStatusNameInCode;public String getContractStatusNameInCode() {return contractStatusNameInCode;}public void setContractStatusNameInCode(String contractStatusNameInCode) {this.contractStatusNameInCode = contractStatusNameInCode;} }8.編寫jsp頁面
列表展示的主頁面:
<!-- 頂部模塊[如:功能按鈕、搜索面板] --> <div class="bjui-pageHeader" style="background:#FFF;"> <form id="" style="display: none;" method="post" action="${ctx}/sys/"> </form><form id="pagerForm" data-toggle="ajaxsearch" action="${ctx}/sys/cooperativePartnersManageAction/toList" method="post"><input type="hidden" name="pageSize" value="${pageResult.pageSize}"><input type="hidden" name="pageCurrent" value="${pageResult.pageCurrent}"><input type="hidden" name="orderField" value="${pageResult.orderField}"><input type="hidden" name="orderDirection" value="${pageResult.orderDirection}"><div style="margin-top: 5px;"><!-- 刷新按鈕--><button class="btn btn-orange" data-icon="refresh">刷新</button><!-- 添加按鈕--><shiro:hasPermission name="partnerAdd"><a href="${ctx}/sys/cooperativePartnersManageAction/toAdd" class="btn btn-green" data-icon="plus" data-toggle="dialog" data-width="800" data-height="400" data-id="dialog-user" data-mask="true">添加</a></shiro:hasPermission><!-- 編輯按鈕--><shiro:hasPermission name="partnerEdit"><ahref="${ctx}/sys/cooperativePartnersManageAction/toEdit?id={#bjui-selected}" class="btn btn-blue" data-icon="edit" data-toggle="dialog" data-width="800" data-height="400" data-id="dialog-user" data-mask="true">編輯</a></shiro:hasPermission><!-- 刪除按鈕--><%--? ?<shiro:hasPermission name="customerDel"><ahref="${ctx}/sys/sysCustomerAction/doDel?id={#bjui-selected}" class="btn btn-red" data-toggle="doajax" data-confirm-msg="確定要刪除選中記錄嗎?" data-icon="remove">刪除</a></shiro:hasPermission> --%><!-- <button class="btn btn-blue" data-icon="sign-out" onclick="exportCustomerExcel(this)">導出</button> --></div><hr style="margin-top: 5px;margin-bottom: 5px"><div style="margin-bottom:5px"><label>合作方名稱:<input id="partnerName" type="text" name="partnerName" value="${pageResult.ext.partnerName}" placeholder="請輸入合作方名稱"? style="width:140px;"/></label><label>合作方公司名稱:<input id="companyName" type="text" name="companyName" value="${pageResult.ext.companyName}" placeholder="請輸入合作方公司名稱"? style="width:140px;"/></label></div>??<div style="margin-bottom:5px"><button class="btn-default" data-icon="search">查詢</button><button class="btn-default" data-clear-query="true"? data-icon="undo" data-toggle="reloadsearch">清空查詢</button></div>??</form> </div> <!-- 內容區 --> <div class="bjui-pageContent tableContent" id="customer_list"><table id="doc-datagrid-table" class="table table-bordered table-hover table-striped table-top" ><thead><tr style="height:30px;"><th>狀態</th><th>合作方身份編號</th><th>合作方名稱</th><th>合作方公司名稱</th><th>合作方聯系人名稱</th><th>合作方聯系人電話</th><th>當前簽約狀態</th><th>修改人編號</th>???? ??<th>修改人名稱</th><th>查看詳情</th></tr></thead><tbody><c:forEach items="${pageResult.list}" var="u"><tr data-id="${u.id}"><td><input name="customer_radio" type="radio"? /></td><td>${u.partnerNum}</td><td>${u.partnerName}</td><td>${u.companyName}</td><td>${u.contactName}</td><td>${u.contactMobile}</td><td>${u.contractStatusName}</td><td>${u.modifyUserId}</td><td>${u.modifyUserName}</td>??? ????? ??<td><button type="button" class="btn btn-default"data-toggle="dialog"data-options="{id:'orderDetailDialog',url:'${ctx}/sys/cooperativePartnersManageAction/toDetails',type:'post',data:{id:${u.id}}}"data-width="900" data-height="600"data-id="dialog-user-role"data-title="${u.partnerName}詳情">詳情</button></td></tr></c:forEach></tbody></table> </div> <!-- 底部模塊[如:工具條、分頁組件]? --> <div class="bjui-pageFooter"><div class="pages"><span>每頁 </span><div class="selectPagesize"><select data-toggle="selectpicker" data-toggle-change="changepagesize"><option value="10">10</option><option value="30">30</option><option value="60">60</option><option value="100">100</option></select></div><span> 條,共 ${pageResult.total} 條</span></div><div class="pagination-box" data-toggle="pagination" data-total="${pageResult.total}" data-page-size="${pageResult.pageSize}" data-page-current="${pageResult.pageCurrent}"></div> </div>
?配置BJUI
要想在BJUI的頁面上載左邊點擊菜單欄,右邊出現此頁面還要進行權限配置
具體參照:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/84232271
實現添加以及編輯
關于BJUI的校驗,參照:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/84065856
關于編輯以及添加功能的實現大同小異,具體參照:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/84098171
完整代碼
action:
?
@Controller @RequestMapping("/sys/cooperativePartnersManageAction") public class SysCooperativePartnerManageAction? extends BaseAction{private? SysPartnersService sysPartnersService;private SysCodeService codeService;@Autowiredpublic void setCodeService(SysCodeService codeService) {this.codeService = codeService;}@Autowiredpublic void setSysPartnersService(SysPartnersService sysPartnersService) {this.sysPartnersService = sysPartnersService;}/**** 功能說明:分頁展示* 修改說明:* @author badao* @date 2018/11/13 周二: 9:03:48.49* @param pageSize 每頁記錄數* @param pageCurrent 當前頁索引* @param orderField 排序字段* @param orderDirection 排序方向?* @return*/@RequestMapping(value = "/toList")public? ModelAndView toList(Integer pageSize, Integer pageCurrent, String orderField, String orderDirection,String partnerName,String companyName) {ModelAndView mv = null;try {PageResult<SysPartnersExt> pageResult = PageUtil.pageSet(this.getClass(), pageSize, pageCurrent, orderField, orderDirection);pageResult.getParam().put("status", "0");//插入模糊搜索數據if (partnerName != null && !"".equals(partnerName)) {pageResult.getParam().put("partnerName", partnerName);pageResult.getExt().put("partnerName", partnerName);}if (companyName != null && !"".equals(companyName)) {pageResult.getParam().put("companyName", companyName);pageResult.getExt().put("companyName", companyName);}pageResult.setOrderField("sp.RecordTime");pageResult.setOrderDirection("DESC");pageResult = this.sysPartnersService.getPartnerListPageResult(pageResult);mv = new ModelAndView();mv.addObject(ModelAndViewConstants.PAGE_RESULT, pageResult);mv.setViewName(ModelAndViewConstants.PARTNER_MAIN_VIEW);} catch (Exception e) {mv = new ModelAndView(ModelAndViewConstants.ERROR_VIEW);LogService.getInstance(this).debug(e);}return mv;}/*** 功能說明:進入詳情顯示界面* 修改說明:* @author badao* @date 2018/11/13 周二:13:15:21.56* @param pageSize 每頁記錄數* @param pageCurrent 當前頁索引* @param orderField 排序字段* @param orderDirection 排序方向* @param paramCompanyName 參數字段:客戶名稱* @param paramRemark 參數字段:備注* @return*/@RequestMapping(value="/toDetails")public ModelAndView toDetails(Integer id) {ModelAndView mv = null;try {SysPartnersExt partner=this.sysPartnersService.getDetailsByPrimaryKey(id);partner.setStatus("0");mv = new ModelAndView();mv.addObject(ModelAndViewConstants.PARTMER, partner);mv.setViewName(ModelAndViewConstants.PARTNER_DETAILS_VIEW);LogService.getInstance(this).debug("獲取分頁數據成功:"+ModelAndViewConstants.PARTNER_DETAILS_VIEW);}catch(Exception ex) {LogService.getInstance(this).error("獲取分頁數據失敗:" + ex.getMessage(), ex);mv = new ModelAndView(ModelAndViewConstants.ERROR_VIEW);}return mv;}/*** 功能說明:進入添加界面操作* 修改說明:* @author badao* @date 2018/11/13 周二:16:32:49.00* @return*/@RequestMapping(value="/toAdd")public ModelAndView toAdd(){ModelAndView mv = null;try {//查詢簽約狀態Map<String, Object> param = new HashMap<String, Object>();param.put("status", "0");param.put("codeType", "contractStatus");List<SysCode> contractStatus = codeService.getByParam(param);mv = new ModelAndView();//傳遞簽約狀態mv.addObject("contractStatus", contractStatus);//傳遞當前的操作類型的標識,左邊是op常量參數,表示操作類型,右邊是add常量參數,表示是添加操作mv.addObject(ModelAndViewConstants.OPERATION_KEY,ModelAndViewConstants.OPERATION_VALUE_ADD);//傳遞到共用頁面的標題參數,左邊是title常量參數,右邊是要顯示的標題的內容mv.addObject(ModelAndViewConstants.TITLE_KEY, "添加合作商戶信息");//跳轉的具體的頁面mv.setViewName(ModelAndViewConstants.PARTNER_EDIT_VIEW);LogService.getInstance(this).error("進入添加功能成功:" +ModelAndViewConstants.PARTNER_EDIT_VIEW);}catch(Exception ex) {LogService.getInstance(this).error("進入添加失敗:" + ex.getMessage(), ex);mv = new ModelAndView("redirect:/error.jsp");}return mv;}/*** 功能說明:執行保存操作* 修改說明:* @author badao* @date 2018/11/14 周三:10:40:41.65* @param entity 客戶信息實體* @paramopop=add為添加操作,op=edit為編輯操作* @return 返回json對象*/@ResponseBody@RequestMapping(value="/doSave")public Map<String, Object> doSave(SysPartners entity, String op) {Map<String, Object> jsonResult = null;try {//與配置權限管理中相對應,實現添加或編輯完實時更新String tabid = tabid(ModelAndViewConstants.PARTNER_SYS_ID);//如果是測試簽約if(entity.getContractStatus()==0) {entity.setTestContractTime(new Date());entity.setContractStatusName("測試簽約");}//如果是正式簽約if(entity.getContractStatus()==1) {entity.setFormalContractTime(new Date());entity.setContractStatusName("正式簽約");}entity.setRecordTime(new Date());//獲得當前用戶的id和name,加入客戶對象中ShiroUser currentUser = (ShiroUser)SecurityUtils.getSubject().getPrincipal();entity.setModifyUserId(currentUser.getUserId());entity.setModifyUserName(currentUser.getAccount());//如果op標志參數為空,或者為add 那么就執行添加操作if (null == op || ModelAndViewConstants.OPERATION_VALUE_ADD.equals(op)) {//此字段表示數據未被更改entity.setStatus("0");//執行插入數據操作,方法是有代碼生成工具自動生成int count = this.sysPartnersService.insert(entity);if (count > 0) {LogService.getInstance(this).debug("添加信息成功!");}}else {//如果不是,則就是編輯后的保存操作//獲取現存數據,也是通過代碼生成工具生成的方法SysPartners currentSysPartner = this.sysPartnersService.getByPrimaryKey(entity);int count = this.sysPartnersService.updateByPrimaryKey(entity);if (count > 0) {LogService.getInstance(this).debug("編輯信息成功!");}}Integer statusCode = 200;String msg = "保存成功";jsonResult = JsonResult.jsonReturn(statusCode, msg, tabid);}catch(Exception ex) {LogService.getInstance(this).error("保存信息失敗:" + ex.getMessage(), ex);String msg =? "保存信息失敗:" + ex.getMessage();jsonResult = JsonResult.jsonReturnErr(msg);}return jsonResult;}/*** 功能說明:進入編輯界面* 修改說明:* @author badao* @date 2018/11/13 周二:16:32:49.00* @param id 用戶id,主鍵值* @return*/@RequestMapping(value="/toEdit")public ModelAndView toEdit(Integer id) {ModelAndView mv = null;try {//根據ID先查詢要編輯的數據SysPartners partner = this.sysPartnersService.getByPrimaryKey(id);//獲取簽約狀態,此處是通過關聯碼表來實現Map<String, Object> param = new HashMap<String, Object>();//0 表示正常數據param.put("status", "0");param.put("codeType", "contractStatus");//根據參數將相關碼表內容查詢出來List<SysCode> contractStatus = codeService.getByParam(param);mv = new ModelAndView();//傳遞簽約狀態mv.addObject("contractStatus", contractStatus);//傳遞操作類型,這里是編輯操作mv.addObject(ModelAndViewConstants.OPERATION_KEY,ModelAndViewConstants.OPERATION_VALUE_EDIT);//jsp頁面要顯示的標題titlemv.addObject(ModelAndViewConstants.TITLE_KEY, "修改信息");//將查詢到的實體Model類傳遞mv.addObject(ModelAndViewConstants.PARTMER, partner);//跳轉到編輯界面mv.setViewName(ModelAndViewConstants.PARTNER_EDIT_VIEW);}catch(Exception ex) {LogService.getInstance(this).error("進入編輯失敗:" + ex.getMessage(), ex);mv = new ModelAndView(ModelAndViewConstants.ERROR_VIEW);}return mv;}}service
public interface SysPartnersService extends BaseService<SysPartners, java.io.Serializable> {/*** 功能說明:通過PageResult獲取分頁數據* 修改說明:* @author badao* @date 2018/11/13 周二: 9:20:55.03* @param pageResult 分頁查詢對象,包含查詢條件* @return 返回分頁查詢對象,包含頁面數據*/public PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult);/*** 功能說明:通過id獲取合作伙伴詳情數據* 修改說明:* @author badao* @date 2018/11/13 周二: 9:20:55.03***/public SysPartnersExt getDetailsByPrimaryKey(Integer id);
?
serviceImpl
@Service("sysPartnersService") public class SysPartnersServiceImpl extends BaseServiceImpl<SysPartners> implements SysPartnersService {private SysPartnersDao dao;@Autowiredpublic void setDao(SysPartnersDao dao) {super.setDao(dao);this.dao = dao;}@Overridepublic PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult) {// TODO Auto-generated method stubreturn this.dao.getPartnerListPageResult(pageResult);}@Overridepublic SysPartnersExt getDetailsByPrimaryKey(Integer id) {// TODO Auto-generated method stubreturn dao.getDetailsByPrimaryKey(id);} }dao
public interface SysPartnersDao extends BaseDao<SysPartners, Serializable>{/*** 功能說明:通過PageResult獲取分頁數據* 修改說明:* @author badao* @date 2018/11/13 周二: 9:55:54.57* @param pageResult 分頁查詢對象,包含查詢條件* @return 返回分頁查詢對象,包含頁面數據*/public PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult);public SysPartnersExt getDetailsByPrimaryKey(Integer id);}?
daoImpl
@Repository("sysPartnersDao") public class SysPartnersDaoImpl extends BaseDaoImpl<SysPartners, Serializable> implements SysPartnersDao {/*** 功能說明:獲取分頁數據* 修改說明:* @author badao* @date 2018/11/13 周二:10:55:37.38* @param params 查詢參數* @return 返回符合條件的公司記錄集合*/public List<SysPartnersExt> getPartnersListByParam(Map<String, Object> params) {String stmtId = this.getNameSpace() + MapperIdConstants._GETPARTNERSLISTBYPARAM;return this.getSqlSession().selectList(stmtId, params);}/*** 功能說明:獲取分頁數據的總頁數* 修改說明:* @author baado* @date 2018/11/13 周二:10:55:37.38* @param params 查詢參數* @return 返回符合條件的總頁數*/public Integer countOfPartnersListByParam(Map<String, Object> params) {String stmtId = this.getNameSpace() + MapperIdConstants._COUNTOFPARTNERSLISTBYPARAM;return this.getSqlSession().selectOne(stmtId, params);}/*** 功能說明:通過PageResult獲取公司分頁數據* 修改說明:* @author badao* @date 2018/11/13 周二:10:00:43.03* @param pageResult 分頁查詢對象,包含查詢條件* @return 返回分頁查詢對象,包含頁面數據*/@Overridepublic PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult) {pageResult.getParam().put("offset", pageResult.getPageSize() * (pageResult.getPageCurrent() - 1));pageResult.getParam().put("limit", pageResult.getPageSize());if (!"".equals(pageResult.getOrderField())) { pageResult.getParam().put("orderColumn", pageResult.getOrderField()); }pageResult.getParam().put("orderTurn", pageResult.getOrderDirection());List<SysPartnersExt> data = this.getPartnersListByParam(pageResult.getParam());pageResult.setList(data);int totalSize = this.countOfPartnersListByParam(pageResult.getParam());pageResult.setTotal(totalSize);return pageResult;}@Overridepublic SysPartnersExt getDetailsByPrimaryKey(Integer id) {// TODO Auto-generated method stubString stmtId = this.getNameSpace() + MapperIdConstants._GETDETAILSBYPRIMARYKEY;return this.getSqlSession().selectOne(stmtId, id);}}Mapper
?
<mapper namespace="**.sys.model.SysPartners"><!-- 結果集 -->???<resultMap id="SysPartnersResultMap" type="**.sys.model.ext.SysPartnersExt" extends="BaseResultMap"><result column="ContractStatusName" property="contractStatusName" jdbcType="VARCHAR" /></resultMap><select id="getPartnersListByParam" parameterType="java.util.Map" resultMap="SysPartnersResultMap">select sp.*,sd.CodeName ContactNameInCodefrom sys_partners spleft join sys_code sdon sp.ContractStatus = sd.CodeValueand sd.CodeType ="contractStatus"????<where>???<if test="partnerName"> and sp.partnerName like CONCAT('%',#{partnerName},'%' )</if><if test="companyName"> and sp.companyName like CONCAT('%',#{companyName},'%' )</if><if test="partnerNum"> and sp.partnerNum like CONCAT('%',#{partnerNum},'%' )</if><if test="remark"> and sp.Remark like CONCAT('%',#{remark},'%' )</if><if test="status"> and sp.Status = #{status}</if><if test="startDate"> and? sp.RecordTime >=CONCAT(#{startDate},' 00:00:00' ) </if><if test="endDate"> and CONCAT(#{endDate},' 23:59:59' )>= sp.RecordTime </if></where><if test="orderColumn != null">order by ${orderColumn}<if test="orderTurn != null">${orderTurn}</if></if><if test="limit != null">limit<if test="offset != null">${offset},</if>${limit}</if></select><select id="countOfPartnersListByParam" parameterType="java.util.Map" resultType="int">selectcount(1)from sys_partners spleft join sys_code sdon sp.ContractStatus = sd.CodeValueand sd.CodeType ="contractStatus"<where><if test="partnerName"> and sp.partnerName like CONCAT('%',#{partnerName},'%' )</if><if test="companyName"> and sp.companyName like CONCAT('%',#{companyName},'%' )</if><if test="partnerNum"> and sp.partnerNum like CONCAT('%',#{partnerNum},'%' )</if><if test="remark"> and sp.Remark like CONCAT('%',#{remark},'%' )</if><if test="status"> and sp.Status = #{status}</if><if test="startDate"> and? sp.RecordTime >=CONCAT(#{startDate},' 00:00:00' ) </if><if test="endDate"> and CONCAT(#{endDate},' 23:59:59' )>= sp.RecordTime </if></where></select><select id="getDetailsByPrimaryKey" parameterType="java.util.Map" resultMap="SysPartnersResultMap">select sp.*,sd.CodeName ContactNameInCodefrom sys_partners spleft join sys_code sdon sp.ContractStatus = sd.CodeValueand sd.CodeType ="contractStatus"where sp.id = #{id}????</select></mapper>Model
public class SysPartners implements java.io.Serializable{private Integer id;private String partnerNum;private String signKey;private String partnerName;private String companyName;private String contactName;private String contactMobile;private String contactAddress;private String extension;private String contactFixed;private String contactCardNum;private String email;private String province;private String city;private String district;private Integer contractStatus;private String contractStatusName;private Date testContractTime;private Date formalContractTime;private BigDecimal vipRestRoomPrice;private BigDecimal cipRestRoomPrice;private BigDecimal passPrice;private BigDecimal currentAdvanceMoney;private String qqNum;private String microBlog;private Integer modifyUserId;private String modifyUserName;private Date recordTime;private String status;private String remark;public class SysPartnersExt? extends SysPartners{private String contractStatusNameInCode;public String getContractStatusNameInCode() {return contractStatusNameInCode;}public void setContractStatusNameInCode(String contractStatusNameInCode) {this.contractStatusNameInCode = contractStatusNameInCode;}}
JSP
主頁面:
<!-- 頂部模塊[如:功能按鈕、搜索面板] --> <div class="bjui-pageHeader" style="background:#FFF;"> <form id="" style="display: none;" method="post" action="${ctx}/sys/"> </form><form id="pagerForm" data-toggle="ajaxsearch" action="${ctx}/sys/cooperativePartnersManageAction/toList" method="post"><input type="hidden" name="pageSize" value="${pageResult.pageSize}"><input type="hidden" name="pageCurrent" value="${pageResult.pageCurrent}"><input type="hidden" name="orderField" value="${pageResult.orderField}"><input type="hidden" name="orderDirection" value="${pageResult.orderDirection}"><div style="margin-top: 5px;"><!-- 刷新按鈕--><button class="btn btn-orange" data-icon="refresh">刷新</button><!-- 添加按鈕--><shiro:hasPermission name="partnerAdd"><a href="${ctx}/sys/cooperativePartnersManageAction/toAdd" class="btn btn-green" data-icon="plus" data-toggle="dialog" data-width="800" data-height="400" data-id="dialog-user" data-mask="true">添加</a></shiro:hasPermission><!-- 編輯按鈕--><shiro:hasPermission name="partnerEdit"><ahref="${ctx}/sys/cooperativePartnersManageAction/toEdit?id={#bjui-selected}" class="btn btn-blue" data-icon="edit" data-toggle="dialog" data-width="800" data-height="400" data-id="dialog-user" data-mask="true">編輯</a></shiro:hasPermission><!-- 刪除按鈕--><%--? ?<shiro:hasPermission name="customerDel"><ahref="${ctx}/sys/sysCustomerAction/doDel?id={#bjui-selected}" class="btn btn-red" data-toggle="doajax" data-confirm-msg="確定要刪除選中記錄嗎?" data-icon="remove">刪除</a></shiro:hasPermission> --%><!-- <button class="btn btn-blue" data-icon="sign-out" onclick="exportCustomerExcel(this)">導出</button> --></div><hr style="margin-top: 5px;margin-bottom: 5px"><div style="margin-bottom:5px"><label>合作方名稱:<input id="partnerName" type="text" name="partnerName" value="${pageResult.ext.partnerName}" placeholder="請輸入合作方名稱"? style="width:140px;"/></label><label>合作方公司名稱:<input id="companyName" type="text" name="companyName" value="${pageResult.ext.companyName}" placeholder="請輸入合作方公司名稱"? style="width:140px;"/></label></div>??<div style="margin-bottom:5px"><button class="btn-default" data-icon="search">查詢</button><button class="btn-default" data-clear-query="true"? data-icon="undo" data-toggle="reloadsearch">清空查詢</button></div>??</form> </div> <!-- 內容區 --> <div class="bjui-pageContent tableContent" id="customer_list"><table id="doc-datagrid-table" class="table table-bordered table-hover table-striped table-top" ><thead><tr style="height:30px;"><th>狀態</th><th>合作方身份編號</th><th>合作方名稱</th><th>合作方公司名稱</th><th>合作方聯系人名稱</th><th>合作方聯系人電話</th><th>當前簽約狀態</th><th>修改人編號</th>???? ??<th>修改人名稱</th><th>查看詳情</th></tr></thead><tbody><c:forEach items="${pageResult.list}" var="u"><tr data-id="${u.id}"><td><input name="customer_radio" type="radio"? /></td><td>${u.partnerNum}</td><td>${u.partnerName}</td><td>${u.companyName}</td><td>${u.contactName}</td><td>${u.contactMobile}</td><td>${u.contractStatusName}</td><td>${u.modifyUserId}</td><td>${u.modifyUserName}</td>??? ????? ??<td><button type="button" class="btn btn-default"data-toggle="dialog"data-options="{id:'orderDetailDialog',url:'${ctx}/sys/cooperativePartnersManageAction/toDetails',type:'post',data:{id:${u.id}}}"data-width="900" data-height="600"data-id="dialog-user-role"data-title="${u.partnerName}詳情">詳情</button></td></tr></c:forEach></tbody></table> </div> <!-- 底部模塊[如:工具條、分頁組件]? --> <div class="bjui-pageFooter"><div class="pages"><span>每頁 </span><div class="selectPagesize"><select data-toggle="selectpicker" data-toggle-change="changepagesize"><option value="10">10</option><option value="30">30</option><option value="60">60</option><option value="100">100</option></select></div><span> 條,共 ${pageResult.total} 條</span></div><div class="pagination-box" data-toggle="pagination" data-total="${pageResult.total}" data-page-size="${pageResult.pageSize}" data-page-current="${pageResult.pageCurrent}"></div> </div>詳情頁面:
<div class="bjui-pageContent"><table class="table table-bordered table-hover table-striped table-top"><thead><tr ><td colspan="6" align="left" valign="bottom"class="pass_width_percent_50"><h5><strong>合作方名稱:${partner.partnerName}</strong></h5></td></tr><tr><td class="pass_width_ave_6_column">合作方身份編號:</td><td class="pass_width_ave_6_column">合作方名稱:</td><td class="pass_width_ave_6_column">合作方公司名稱:</td><td class="pass_width_ave_6_column">合作方聯系人名稱:</td>??<td class="pass_width_ave_6_column">合作方聯系人電話:</td><td class="pass_width_ave_6_column">聯系人地址:</td></tr></thead><tbody><tr ><td class="pass_width_ave_6_column">${partner.partnerNum}</td><td class="pass_width_ave_6_column">${partner.partnerName}</td><td class="pass_width_ave_6_column">${partner.companyName}</td><td class="pass_width_ave_6_column">${partner.contactName}</td><td class="pass_width_ave_6_column">${partner.contactMobile}</td><td class="pass_width_ave_6_column">${partner.contactAddress}</td></tr></tbody><thead><tr? height="50px">??????<td class="pass_width_ave_6_column">記錄時間:</td></tr></thead><tbody><tr><td class="pass_width_ave_6_column"><fmt:formatDate type="both"pattern="yyyy-MM-dd HH:mm:ss" value="${partner.recordTime}" /></td>??????</tr></tbody>????</table> </div> <div class="bjui-pageFooter"><ul><li><button type="button" class="btn-close" data-icon="close">關閉</button></li><li><button type="submit" class="btn-default" data-icon="save">保存</button></li></ul> </div>添加編輯共享頁面:
<div class="bjui-pageContent"><form action="${ctx}/sys/cooperativePartnersManageAction/doSave" class="pageForm"data-toggle="validate"? autocomplete="off"><input type="hidden" name="op" id="j_dialog_op"value="${param.op}${op}"><input type="hidden" name="id"id="j_dialog_id" value="${partner.id}"><c:if test="${!empty role}"><input type="hidden" name="status" id="j_dialog_op"value="${partner.status}"></c:if><table class="table table-condensed table-hover"><tbody><tr><td colspan="2" align="center" valign="middle"><h4>${title}</h4></td></tr><tr><td><label for="name" class="control-label x90">合作方名稱:</label><input class="" id="partnerName" type="text" name="partnerName" data-rule="required;"autocomplete="off" value="${partner.partnerName}" /></td><td><label class="control-label x90">合作方公司名稱:</label><input class="" id="companyName" type="text" name="companyName" data-rule="required;"autocomplete="off" value="${partner.companyName}" /></td></tr><tr><td><label for="name" class="control-label x90">合作方聯系人名稱:</label><input class="" id="contactName" type="text" name="contactName"value="${partner.contactName}" /></td><td><label for="name" class="control-label x90">聯系人地址:</label> <inputclass="" id="contactAddress" type="text" name="contactAddress"value="${partner.contactAddress}" /></td></tr><tr><td><label for="name" class="control-label x90">分機號:</label><input class="" id="extension" type="text" name="extension" data-rule="number;"value="${partner.extension}" /></td><td><label for="name" class="control-label x90">聯系固話:</label><input class="" type="text"? id="contactFixed" name="contactFixed" data-rule="number;length[6~20];"value="${partner.contactFixed}" /></td></tr><tr><td><label? class="control-label x90">證件號碼:</label><input class="" type="text"? id="contactCardNum" name="contactCardNum"value="${partner.contactCardNum}" /></td><td><label class="control-label x90">郵箱:</label><input class="" type="text"? id="email" name="email"data-rule="required;email;"data-rule-email="[/\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/g, '請填寫正確的郵箱']"value="${partner.email}" /></td></tr><tr><td ><label class="control-label x90">所在省份:</label><input class=""? type="text" name="province" id="province"value="${partner.province}" /></td><td ><label for="name" class="control-label x90">所在城市:</label><input class=""? type="text" name="city" id="city"value="${partner.city}" /></td></tr><tr><td ><label for="name" class="control-label x90">所在區縣:</label><input class=""? type="text" name="district" id="district"value="${partner.district}" /></td><td ><label for="name" class="control-label x90">當前簽約狀態:</label><select data-toggle="selectpicker" name="contractStatus"><c:forEach? items= "${contractStatus}" var="cu"><option ${partner.contractStatus == 1?"disabled='disabled'":"" } value="${cu.codeValue}" ${partner.contractStatus == cu.codeValue?"selected='selected'":""}>${cu.codeName}</option>????????????????</c:forEach></select></td></tr><tr><td ><label for="name" class="control-label x90">VIP休息室價格:</label><input class=""? type="text" name="vipRestRoomPrice" id="vipRestRoomPrice" data-rule="required;number;"value="${partner.vipRestRoomPrice}" /></td><td ><label for="name" class="control-label x90">CIP休息室價格:</label><input class=""? type="text" name="cipRestRoomPrice" id="cipRestRoomPrice" data-rule="required;number;"value="${partner.cipRestRoomPrice}" /></td></tr><tr><td ><label for="name" class="control-label x90">單次通道價格:</label><input class=""? type="text" name="passPrice" id="passPrice" data-rule="required;number;"value="${partner.passPrice}" /></td><td ><label for="name" class="control-label x90">合作方聯系人電話:</label><input class="" id="contactMobile" type="text" name="contactMobile" data-rule="required;mobile;"data-rule-mobile="[/(^1[3|5|7|8][0-9]{9}$)/, '請填寫正確的手機號']"autocomplete="off" value="${partner.contactMobile}" /></td></tr><tr><td ><label for="name" class="control-label x90">qq號:</label><input class=""? type="text" name="qqNum" id="qqNum"value="${partner.qqNum}" /></td><td ><label for="name" class="control-label x90">微博號:</label><input class=""? type="text" name="microBlog" id="microBlog"value="${partner.microBlog}" /></td></tr><tr><td colspan="2"><label for="name" class="control-label x90">備注:</label><textarea name="remark" id="remark" rows="5" cols="58">${partner.remark}</textarea></td></tr></tbody></table></form> </div> <script></script> <div class="bjui-pageFooter"><ul><li><button type="button" class="btn-close" data-icon="close">關閉</button></li><li><button type="submit" class="btn-default" data-icon="save">保存</button></li></ul> </div>?
總結
以上是生活随笔為你收集整理的SSM+BJUI实现CRUD的报表功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: BJUI接受TabID实现添加或编辑后自
- 下一篇: JS获取当前时间的前n天/后n天