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 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 返回分页查询对象,包含页面数据
  */
 @Override
 public 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;
 }

 @Override
 public SysPartnersExt getDetailsByPrimaryKey(Integer id) {
  // TODO Auto-generated method stub
  String 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 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>
 
 <select id="getDetailsByPrimaryKey" 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 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> <input
      class="" 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>

猜你喜欢

转载自blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/84284844