1. 程式人生 > >SSM+BJUI實現CRUD的報表功能

SSM+BJUI實現CRUD的報表功能

場景

常見的一種業務就是根據資料庫中的單表或者通過關聯多表的資料顯示在主頁面並實現分頁、按條件篩選、檢視詳情

新增記錄、編輯記錄等。

實現效果

程式碼實現

查詢操作

1.編寫action

@Controller
@RequestMapping("/sys/cooperativePartnersManageAction")
public class SysCooperativePartnerManageAction  extends BaseAction{
 
 private  SysPartnersService sysPartnersService;
 
 private SysCodeService codeService;
 
 @Autowired
    public void setCodeService(SysCodeService codeService) {
  this.codeService = codeService;
 }
 @Autowired
 public 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;

 @Autowired
 public void setDao(SysPartnersDao dao) {
  super.setDao(dao);
  this.dao = dao;
 }

 @Override
 public PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult) {
  // TODO Auto-generated method stub
  return 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_partners
  where Id = #{id}
 </select>

 <select id="getByPrimaryKeys" parameterType="java.util.Map" resultMap="BaseResultMap">
  select
  <include refid="Base_Column_List" />
  from sys_partners
  where 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_partners
  where 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 t
  where 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 ContactNameInCode
  from sys_partners sp
  left join sys_code sd
  on sp.ContractStatus = sd.CodeValue
  and 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">
  select
  count(1)
  from sys_partners sp
  left join sys_code sd
  on sp.ContractStatus = sd.CodeValue
  and 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;
 
 @Autowired
    public void setCodeService(SysCodeService codeService) {
  this.codeService = codeService;
 }
 @Autowired
 public 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頁面要顯示的標題title
   mv.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;

 @Autowired
 public void setDao(SysPartnersDao dao) {
  super.setDao(dao);
  this.dao = dao;
 }

 @Override
 public PageResult<SysPartnersExt> getPartnerListPageResult(PageResult<SysPartnersExt> pageResult) {
  // TODO Auto-generated method stub
  return this.dao.getPartnerListPageResult(pageResult);
 }
 @Override
 public SysPartnersExt getDetailsByPrimaryKey(Integer id) {
  // TODO Auto-generated method stub
  return 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 BaseDaoI