Kite的学习历程之SSM搭建OA系统的初步搭建前端页面组织查询

Kite学习历程的第四十天

目录

  • Kite学习历程的第四十天
    • 1. 创建OA项目
      • 1.1 通过pom.xml 引入依赖文件
      • 1.2 实体类,mapper, dao的创建我这里使用的是代码工具生成的
      • 1.3 生成的Dao层
      • 1.4 mapper配置
      • 1.5 service层代码
      • 1.6 controller层代码
      • 1.6 配置文件相关代码
    • 2.前端的代码我这里使用的h-ui模板的代码
    • 3. 运行结果

1. 创建OA项目

数据库的生成我这就部说了
首先看一下目录结构
Kite的学习历程之SSM搭建OA系统的初步搭建前端页面组织查询_第1张图片

1.1 通过pom.xml 引入依赖文件

之一一定要注意版本的对应我这里使用的spring5,数据库用的8.0,所以记住版本对应,为此找错误找了1天多


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>
    <groupId>cn.kiteygroupId>
    <artifactId>oaartifactId>
    <version>1.0-SNAPSHOTversion>
    <packaging>warpackaging>
    <name>oaname>

    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <spring.version>5.0.3.RELEASEspring.version>
        <jackson.version>2.9.8jackson.version>
    properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.datagroupId>
            <artifactId>spring-data-jpaartifactId>
            <version>2.3.1.RELEASEversion>
        dependency>


        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
            <version>4.12version>
            <scope>testscope>
        dependency>

        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-coreartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-beansartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-contextartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-txartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webmvcartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jdbcartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-testartifactId>
            <version>${spring.version}version>
            <scope>testscope>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-ormartifactId>
            <version>${spring.version}version>
            <scope>testscope>
        dependency>

        
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatisartifactId>
            <version>3.5.5version>
        dependency>

        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatis-springartifactId>
            <version>2.0.5version>
        dependency>

        

        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>8.0.13version>
        dependency>

        
        <dependency>
            <groupId>com.google.code.gsongroupId>
            <artifactId>gsonartifactId>
            <version>2.8.0version>
        dependency>

        <dependency>
            <groupId>org.aspectjgroupId>
            <artifactId>aspectjweaverartifactId>
            <version>1.8.4version>
        dependency>

        
        <dependency>
            <groupId>log4jgroupId>
            <artifactId>log4jartifactId>
            <version>1.2.17version>
        dependency>

        
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>servlet-apiartifactId>
            <version>3.0-alpha-1version>
            <scope>providedscope>
        dependency>

        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>jstlartifactId>
            <version>1.2version>
        dependency>

        <dependency>
            <groupId>org.codehaus.jacksongroupId>
            <artifactId>jackson-mapper-aslartifactId>
            <version>1.9.13version>
        dependency>

        <dependency>
            <groupId>com.mchangegroupId>
            <artifactId>c3p0artifactId>
            <version>0.9.5.2version>
        dependency>


        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-annotationsartifactId>
            <version>${jackson.version}version>
        dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-coreartifactId>
            <version>${jackson.version}version>
        dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
            <version>${jackson.version}version>
        dependency>

        
        <dependency>
            <groupId>commons-iogroupId>
            <artifactId>commons-ioartifactId>
            <version>2.4version>
        dependency>

        <dependency>
            <groupId>commons-fileuploadgroupId>
            <artifactId>commons-fileuploadartifactId>
            <version>1.2.2version>
        dependency>

        
        <dependency>
            <groupId>com.github.pagehelpergroupId>
            <artifactId>pagehelperartifactId>
            <version>4.1.6version>
        dependency>

        <dependency>
            <groupId>com.github.jsqlparsergroupId>
            <artifactId>jsqlparserartifactId>
            <version>0.9.4version>
        dependency>

        
        <dependency>
            <groupId>org.activitigroupId>
            <artifactId>activiti-engineartifactId>
            <version>5.15.1version>
        dependency>
        <dependency>
            <groupId>org.activitigroupId>
            <artifactId>activiti-springartifactId>
            <version>5.15.1version>
        dependency>
        <dependency>
            <groupId>org.activitigroupId>
            <artifactId>activiti-bpmn-modelartifactId>
            <version>5.15.1version>
        dependency>
        <dependency>
            <groupId>org.activitigroupId>
            <artifactId>activiti-bpmn-layoutartifactId>
            <version>5.15.1version>
        dependency>
        <dependency>
            <groupId>org.activitigroupId>
            <artifactId>activiti-bpmn-converterartifactId>
            <version>5.15.1version>
        dependency>
        <dependency>
            <groupId>org.activitigroupId>
            <artifactId>activiti-process-validationartifactId>
            <version>5.15.1version>
        dependency>

        
        <dependency>
            <groupId>org.slf4jgroupId>
            <artifactId>slf4j-apiartifactId>
            <version>1.7.6version>
        dependency>
        <dependency>
            <groupId>joda-timegroupId>
            <artifactId>joda-timeartifactId>
            <version>2.1version>
        dependency>
        <dependency>
            <groupId>org.slf4jgroupId>
            <artifactId>jcl-over-slf4jartifactId>
            <version>1.7.6version>
        dependency>
        <dependency>
            <groupId>org.slf4jgroupId>
            <artifactId>slf4j-log4j12artifactId>
            <version>1.7.6version>
        dependency>

        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-lang3artifactId>
            <version>3.1version>
        dependency>
        <dependency>
            <groupId>javax.annotationgroupId>
            <artifactId>javax.annotation-apiartifactId>
            <version>1.2version>
        dependency>


        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-quartzartifactId>
            <version>1.3.2version>
        dependency>

        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-springartifactId>
            <version>1.3.2version>
        dependency>

        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-guiceartifactId>
            <version>1.3.2version>
        dependency>

        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-hazelcastartifactId>
            <version>1.3.2version>
        dependency>

        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-ehcacheartifactId>
            <version>1.3.2version>
        dependency>

        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-casartifactId>
            <version>1.3.2version>
        dependency>

        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-aspectjartifactId>
            <version>1.3.2version>
        dependency>

        <dependency>
            <groupId>org.apache.shirogroupId>
            <artifactId>shiro-coreartifactId>
            <version>1.3.2version>
        dependency>

    dependencies>

    <build>
        <finalName>OAfinalName>

        
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.mavengroupId>
                <artifactId>tomcat7-maven-pluginartifactId>
                <configuration>
                    <port>8008port>
                    <path>/oapath>
                configuration>
            plugin>
        plugins>
    build>

project>

1.2 实体类,mapper, dao的创建我这里使用的是代码工具生成的

实体类:
Kite的学习历程之SSM搭建OA系统的初步搭建前端页面组织查询_第2张图片
Org代码:

package cn.kitey.entity;

import java.util.Date;

public class Org {
  
    private Long orgId;
  
    private Long orgParentId;

    private Short isParent;

    private String orgName;

    private String orgPath;

    private String orgDesc;

    private Short dispIndex;

    private Short state;

    private Date createdDate;

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public Long getOrgParentId() {
        return orgParentId;
    }

    public void setOrgParentId(Long orgParentId) {
        this.orgParentId = orgParentId;
    }

    public Short getIsParent() {
        return isParent;
    }

    public void setIsParent(Short isParent) {
        this.isParent = isParent;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName == null ? null : orgName.trim();
    }

    public String getOrgPath() {
        return orgPath;
    }

    public void setOrgPath(String orgPath) {
        this.orgPath = orgPath == null ? null : orgPath.trim();
    }

    public String getOrgDesc() {
        return orgDesc;
    }

    public void setOrgDesc(String orgDesc) {
        this.orgDesc = orgDesc == null ? null : orgDesc.trim();
    }

    public Short getDispIndex() {
        return dispIndex;
    }

    public void setDispIndex(Short dispIndex) {
        this.dispIndex = dispIndex;
    }

    public Short getState() {
        return state;
    }

    public void setState(Short state) {
        this.state = state;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    @Override
    public String toString() {
        return "Org{" +
                "orgId=" + orgId +
                ", orgParentId=" + orgParentId +
                ", isParent=" + isParent +
                ", orgName='" + orgName + '\'' +
                ", orgPath='" + orgPath + '\'' +
                ", orgDesc='" + orgDesc + '\'' +
                ", dispIndex=" + dispIndex +
                ", state=" + state +
                ", createdDate=" + createdDate +
                '}';
    }
}

Page

package cn.kitey.entity;

import java.util.List;

public class Page<T> {

	/**
	 * 当前页
	 */
	private Integer currentPage = 1;
	
	/**
	 * 每页显示的条数
	 */
	private Integer pageSize = 5;
	
	/**
	 * 总页数
	 */
	private Integer totalPage;
	
	/**
	 * 总条数
	 */
	private Integer totalCount;
	
	/**
	 * 当前页显示的数据
	 */
	private List<T> list;
	
	/**
	 * 点击下一页请求地址
	 */
	private String url;

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
		this.totalPage =  totalCount % pageSize == 0 ? totalCount / pageSize : (totalCount / pageSize) + 1;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Override
	public String toString() {
		return "Page [currentPage=" + currentPage + ", pageSize=" + pageSize + ", totalPage=" + totalPage
				+ ", totalCount=" + totalCount + ", list=" + list + ", url=" + url + "]";
	}
	
}

User

package cn.kitey.entity;

import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class User {
    private Long userId;

    private Long orgId;
    
    private String orgName;

    private String userName;

    private String userPassword;

    private String mobilePhone;

    private String email;

    private String userChName;
    
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date userBirthday;

    private Short userSex;

    private String userPhotoUrl;

    private Integer provinceId;

    private String provinceName;

    private Integer cityId;

    private String cityName;

    private Integer countryId;

    private String contryName;

    private String hobby;

    private String introduce;

    private Date createdDate;

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }
    
    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public String getUserName() {
        return userName;
    }

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

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword == null ? null : userPassword.trim();
    }

    public String getMobilePhone() {
        return mobilePhone;
    }

    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone == null ? null : mobilePhone.trim();
    }

    public String getEmail() {
        return email;
    }

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

    public String getUserChName() {
        return userChName;
    }

    public void setUserChName(String userChName) {
        this.userChName = userChName == null ? null : userChName.trim();
    }

    public Date getUserBirthday() {
        return userBirthday;
    }

    public void setUserBirthday(Date userBirthday) {
        this.userBirthday = userBirthday;
    }

    public Short getUserSex() {
        return userSex;
    }

    public void setUserSex(Short userSex) {
        this.userSex = userSex;
    }

    public String getUserPhotoUrl() {
        return userPhotoUrl;
    }

    public void setUserPhotoUrl(String userPhotoUrl) {
        this.userPhotoUrl = userPhotoUrl == null ? null : userPhotoUrl.trim();
    }

    public Integer getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(Integer provinceId) {
        this.provinceId = provinceId;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName == null ? null : provinceName.trim();
    }

    public Integer getCityId() {
        return cityId;
    }

    public void setCityId(Integer cityId) {
        this.cityId = cityId;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName == null ? null : cityName.trim();
    }

    public Integer getCountryId() {
        return countryId;
    }

    public void setCountryId(Integer countryId) {
        this.countryId = countryId;
    }

    public String getContryName() {
        return contryName;
    }

    public void setContryName(String contryName) {
        this.contryName = contryName == null ? null : contryName.trim();
    }

    public String getHobby() {
        return hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby == null ? null : hobby.trim();
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce == null ? null : introduce.trim();
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	@Override
	public String toString() {
		return "User [userId=" + userId + ", orgId=" + orgId + ", orgName=" + orgName + ", userName=" + userName
				+ ", userPassword=" + userPassword + ", mobilePhone=" + mobilePhone + ", email=" + email
				+ ", userChName=" + userChName + ", userBirthday=" + userBirthday + ", userSex=" + userSex
				+ ", userPhotoUrl=" + userPhotoUrl + ", provinceId=" + provinceId + ", provinceName=" + provinceName
				+ ", cityId=" + cityId + ", cityName=" + cityName + ", countryId=" + countryId + ", contryName="
				+ contryName + ", hobby=" + hobby + ", introduce=" + introduce + ", createdDate=" + createdDate + "]";
	}
	
	
}

1.3 生成的Dao层

主要代码再IBaseDao,其他基本为继承该类
IBaseDao代码

package cn.kitey.dao;

import cn.kitey.entity.Org;

import java.util.List;

public interface IBaseDao<T> {
    int deleteByPrimaryKey(Long orgId);

    int insert(T t);

    int insertSelective(T record);

     T selectByPrimaryKey(Long orgId);

    int updateByPrimaryKeySelective(T record);

    int updateByPrimaryKey(T record);

    public List<T> getList();

    public int batchDel(Long[] ids);

}

IUserDao

package cn.kitey.dao;

public interface IUserDao {
}

OrgMapper

package cn.kitey.dao;

import cn.kitey.entity.Org;

public interface OrgMapper extends IBaseDao<Org>{

}

1.4 mapper配置

OrgMapper.xml 配置
这个也是通过代码工具进行生成的



<mapper namespace="cn.kitey.dao.OrgMapper">
  <resultMap id="BaseResultMap" type="cn.kitey.entity.Org">
    
    <id column="ORG_ID" jdbcType="BIGINT" property="orgId" />
    <result column="ORG_PARENT_ID" jdbcType="BIGINT" property="orgParentId" />
    <result column="IS_PARENT" jdbcType="SMALLINT" property="isParent" />
    <result column="ORG_NAME" jdbcType="VARCHAR" property="orgName" />
    <result column="ORG_PATH" jdbcType="VARCHAR" property="orgPath" />
    <result column="ORG_DESC" jdbcType="VARCHAR" property="orgDesc" />
    <result column="DISP_INDEX" jdbcType="SMALLINT" property="dispIndex" />
    <result column="STATE" jdbcType="SMALLINT" property="state" />
    <result column="CREATED_DATE" jdbcType="TIMESTAMP" property="createdDate" />
  resultMap>
  <sql id="Base_Column_List">
    
    ORG_ID, ORG_PARENT_ID, IS_PARENT, ORG_NAME, ORG_PATH, ORG_DESC, DISP_INDEX, STATE, 
    CREATED_DATE
  sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    
    select 
    <include refid="Base_Column_List" />
    from sys_org
    where ORG_ID = #{orgId,jdbcType=BIGINT}
  select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    
    delete from sys_org
    where ORG_ID = #{orgId,jdbcType=BIGINT}
  delete>
  <insert id="insert" parameterType="cn.kitey.entity.Org">
    
    insert into sys_org (ORG_ID, ORG_PARENT_ID, IS_PARENT, 
      ORG_NAME, ORG_PATH, ORG_DESC, 
      DISP_INDEX, STATE, CREATED_DATE
      )
    values (#{orgId,jdbcType=BIGINT}, #{orgParentId,jdbcType=BIGINT}, #{isParent,jdbcType=SMALLINT}, 
      #{orgName,jdbcType=VARCHAR}, #{orgPath,jdbcType=VARCHAR}, #{orgDesc,jdbcType=VARCHAR}, 
      #{dispIndex,jdbcType=SMALLINT}, #{state,jdbcType=SMALLINT}, #{createdDate,jdbcType=TIMESTAMP}
      )
  insert>
  <insert id="insertSelective" parameterType="cn.kitey.entity.Org">
    
    insert into sys_org
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        ORG_ID,
      if>
      <if test="orgParentId != null">
        ORG_PARENT_ID,
      if>
      <if test="isParent != null">
        IS_PARENT,
      if>
      <if test="orgName != null">
        ORG_NAME,
      if>
      <if test="orgPath != null">
        ORG_PATH,
      if>
      <if test="orgDesc != null">
        ORG_DESC,
      if>
      <if test="dispIndex != null">
        DISP_INDEX,
      if>
      <if test="state != null">
        STATE,
      if>
      <if test="createdDate != null">
        CREATED_DATE,
      if>
    trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        #{orgId,jdbcType=BIGINT},
      if>
      <if test="orgParentId != null">
        #{orgParentId,jdbcType=BIGINT},
      if>
      <if test="isParent != null">
        #{isParent,jdbcType=SMALLINT},
      if>
      <if test="orgName != null">
        #{orgName,jdbcType=VARCHAR},
      if>
      <if test="orgPath != null">
        #{orgPath,jdbcType=VARCHAR},
      if>
      <if test="orgDesc != null">
        #{orgDesc,jdbcType=VARCHAR},
      if>
      <if test="dispIndex != null">
        #{dispIndex,jdbcType=SMALLINT},
      if>
      <if test="state != null">
        #{state,jdbcType=SMALLINT},
      if>
      <if test="createdDate != null">
        #{createdDate,jdbcType=TIMESTAMP},
      if>
    trim>
  insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.kitey.entity.Org">
    
    update sys_org
    <set>
      <if test="orgParentId != null">
        ORG_PARENT_ID = #{orgParentId,jdbcType=BIGINT},
      if>
      <if test="isParent != null">
        IS_PARENT = #{isParent,jdbcType=SMALLINT},
      if>
      <if test="orgName != null">
        ORG_NAME = #{orgName,jdbcType=VARCHAR},
      if>
      <if test="orgPath != null">
        ORG_PATH = #{orgPath,jdbcType=VARCHAR},
      if>
      <if test="orgDesc != null">
        ORG_DESC = #{orgDesc,jdbcType=VARCHAR},
      if>
      <if test="dispIndex != null">
        DISP_INDEX = #{dispIndex,jdbcType=SMALLINT},
      if>
      <if test="state != null">
        STATE = #{state,jdbcType=SMALLINT},
      if>
      <if test="createdDate != null">
        CREATED_DATE = #{createdDate,jdbcType=TIMESTAMP},
      if>
    set>
    where ORG_ID = #{orgId,jdbcType=BIGINT}
  update>
  <update id="updateByPrimaryKey" parameterType="cn.kitey.entity.Org">
    
    update sys_org
    set ORG_PARENT_ID = #{orgParentId,jdbcType=BIGINT},
      IS_PARENT = #{isParent,jdbcType=SMALLINT},
      ORG_NAME = #{orgName,jdbcType=VARCHAR},
      ORG_PATH = #{orgPath,jdbcType=VARCHAR},
      ORG_DESC = #{orgDesc,jdbcType=VARCHAR},
      DISP_INDEX = #{dispIndex,jdbcType=SMALLINT},
      STATE = #{state,jdbcType=SMALLINT},
      CREATED_DATE = #{createdDate,jdbcType=TIMESTAMP}
    where ORG_ID = #{orgId,jdbcType=BIGINT}
  update>

  <select id="getList" resultMap="BaseResultMap">
    select * from sys_org
  select>
mapper>

1.5 service层代码

IBaseService

public interface IBaseService<T> {
    public int add(T t);

    public int update(T t);

    public int delete(Long id);

    public T getById(Long id);

    public PageInfo<T> getPage(Page<T> page);

    /**
     * 批量删除
     */
    public int batchDel(Long ids[]);
}

BaseServiceImpl

public abstract class BaseServiceImpl<T> implements IBaseService<T> {

    protected abstract IBaseDao<T> baseDao();

    @Override
    public int add(T t) {
        return baseDao().insertSelective(t);
    }

    @Override
    public int update(T t) {
        return baseDao().updateByPrimaryKeySelective(t);
    }

    @Override
    public int delete(Long id) {
        return baseDao().deleteByPrimaryKey(id);
    }

    @Override
    public T getById(Long id) {
        return baseDao().selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<T> getPage(Page<T> page) {
        //1. 设置分页参数
        PageHelper.startPage(page.getCurrentPage(),page.getPageSize());

        //2. 查询当前页数据
        List<T> list = baseDao().getList();

        //3. 转换为PageInfo
        return new PageInfo<>(list);
    }

    @Override
    public int batchDel(Long[] ids) {
        return baseDao().batchDel(ids);
    }
}

IOrgService

public interface IOrgService extends IBaseService<Org> {
}

OrgServiceImpl

@Service
public class OrgServiceImpl extends BaseServiceImpl<Org> implements IOrgService {
    @Autowired
    private OrgMapper orgMapper;

    @Override
    protected IBaseDao<Org> baseDao() {
        return orgMapper;
    }
}

1.6 controller层代码

@Controller
@RequestMapping(value="/orgController")
public class OrgController {
    @Autowired
    private IOrgService orgService;

    @RequestMapping(value="/getOrgPage")
    public String getOrgPage(Page<Org> page ,ModelMap map ) {

        PageInfo<Org> pageInfo = orgService.getPage(page);
        map.put("page", pageInfo);
        map.put("url", "orgController/getOrgPage?");
        System.out.println("controller 运行成功!");
        return "org/orgList";

    }
}

1.6 配置文件相关代码

  1. applicationContext.xml
	<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jpa="http://www.springframework.org/schema/data/jpa"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
         http://www.springframework.org/schema/data/jpa
     	http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd">


	<context:component-scan base-package="cn.kitey"
		use-default-filters="false">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Service" />
	</context:component-scan>



	<!-- 1.加载属性文件 -->
	<context:property-placeholder location="classpath:jdbc.properties" />

	<!--&lt;!&ndash; 2.数据源 &ndash;&gt;-->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="user" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
		<property name="jdbcUrl" value="${jdbc.url}" />
		<property name="driverClass" value="${jdbc.driverClass}" />
	</bean>


	<!-- 3.sqlsessionFactory -->
	<bean id="sqlsessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="typeAliasesPackage" value="cn.kitey.entity" />
		<property name="mapperLocations" value="classpath:cn/kitey/mapper/*.xml"></property>
		<property name="configLocation" value="classpath:mybatis-config.xml"></property>
	</bean>

	<!-- 自动创建Dao层实现类(代理) -->
	<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- 设置Dao层接口名称 -->
		<property name="basePackage" value="cn.kitey.dao" />

		<!-- 设置SessionFactory名字 -->
		<property name="sqlSessionFactoryBeanName" value="sqlsessionFactory" />
	</bean>

	<!-- 事务管理器 -->
	<bean id="tx"  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>

	<!-- 事务的属性 -->
	<tx:advice id="txAdives" transaction-manager="tx">
		<tx:attributes>
			<tx:method name="get*" isolation="DEFAULT" propagation="REQUIRED" read-only="true"/>
			<tx:method name="add*" isolation="DEFAULT" propagation="REQUIRED" read-only="false"/>
			<tx:method name="update*" isolation="DEFAULT" propagation="REQUIRED" read-only="false"/>
			<tx:method name="delete*" isolation="DEFAULT" propagation="REQUIRED" read-only="false"/>
		</tx:attributes>
	</tx:advice>

	<!-- AOP的配置 -->
	<aop:config>
		<aop:advisor advice-ref="txAdives" pointcut="execution( * cn.kitey.service.*.*(..))"/>
	</aop:config>
</beans>
  1. jdbc.properties
jdbc.driverClass=com.mysql.cj.jdbc.Driver
jdbc.url =jdbc:mysql://localhost:3306/oa?serverTimezone=UTC&useSSL=false
jdbc.username=root
jdbc.password=25002500
  1. log4j.properties

# Set root category priority to INFO and its only appender to CONSOLE.
#log4j.rootCategory=INFO, CONSOLE            debug   info   warn error fatal
log4j.rootCategory=info, CONSOLE, LOGFILE

# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=d:\axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n



  1. mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

	<plugins>
		<plugin interceptor="com.github.pagehelper.PageHelper">
				<!-- 使用的数据库 -->
				<property name="dialect" value="mysql" />
		</plugin>
	</plugins>
	
</configuration>
  1. springmvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
         http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop.xsd">
	<mvc:annotation-driven/>
    <mvc:default-servlet-handler/>

	<context:component-scan base-package="cn.kitey.controller" use-default-filters="false">
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

	<!-- 视图解析器 -->
	<bean id="jspViewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">

		<!-- 视图名称 -->
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />

		<!-- 视图额前缀 -->
		<property name="prefix" value="/application/" />

		<!-- 视图的后缀 -->
		<property name="suffix" value=".jsp" />
	</bean>


	 <!--静态资源忽略-->
	<!--<mvc:resources location="/static/h-ui/css/" mapping="/static/**"></mvc:resources>-->
	<!--<mvc:resources location="/static/h-ui.admin/css/" mapping="/static/**"></mvc:resources>-->

	<!--<mvc:resources location="/static/h-ui/images/" mapping="/images/**"></mvc:resources>-->
	<!--<mvc:resources location="/static/h-ui.admin/images/" mapping="/images/**"></mvc:resources>-->

	<!--<mvc:resources location="/static/h-ui/js/" mapping="/js/**"></mvc:resources>-->
	<!--<mvc:resources location="/static/h-ui.admin/js/" mapping="/js/**"></mvc:resources>-->

	<!--<mvc:resources location="/lib/" mapping="/lib/**"></mvc:resources>-->
	<!--<mvc:resources location="/static/h-ui.admin/skin/" mapping="/skin/**"></mvc:resources>-->

	<!--&lt;!&ndash; 静态资源忽略 &ndash;&gt;-->
	<!--<mvc:resources location="/css/" mapping="/css/**"></mvc:resources>-->
	<!--<mvc:resources location="/images/" mapping="/images/**"></mvc:resources>-->
	<!--<mvc:resources location="/js/" mapping="/js/**"></mvc:resources>-->
	<!--<mvc:resources location="/lib/" mapping="/lib/**"></mvc:resources>-->
	<!--<mvc:resources location="/skin/" mapping="/skin/**"></mvc:resources>-->

	<!-- 文件上传的解析器 -->
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<!-- 设置编码格式 -->
		<property name="defaultEncoding" value="utf-8"></property>
	</bean>	
	
	<!--&lt;!&ndash; 开启shiro的注解配置 &ndash;&gt;-->
	<!--<aop:config proxy-target-class="true"></aop:config>-->
	<!---->
	<!--&lt;!&ndash; 开启注解授权的bean &ndash;&gt;-->
	<!--<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">-->
		<!--<property name="securityManager" ref="securityManager" />-->
	<!--</bean>-->
	<!---->
	<!-- 配置全局的异常处理 -->

	<!--<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">-->
		<!--<property name="defaultErrorView" value="error"/>-->
		<!--<property name="exceptionAttribute" value="ex"/>-->
		<!--<property name="exceptionMappings">-->
			<!--<props>-->
				<!--<prop key="org.apache.shiro.authz.UnauthorizedException">../common/unauthorized</prop>-->
			<!--</props>-->
		<!--</property>-->
	<!--</bean>-->
	
</beans>
  1. web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

	<filter>
		<filter-name>CharacterEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>utf-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>CharacterEncodingFilter</filter-name>
		<url-pattern>/*
	


	
	
		
		
		
			
			
		
	

	
		
		
	

	
		org.springframework.web.context.ContextLoaderListener
	
	
	
		contextConfigLocation
		classpath:applicationContext.xml
	


    
        default
        *.css
        /css/*
    


    
		DispatcherServlet
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			classpath:springmvc.xml
		
		1
	


	
		DispatcherServlet
		/
	



2.前端的代码我这里使用的h-ui模板的代码

这里展示一下index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="/favicon.ico" >
	<link rel="Shortcut Icon" href="/favicon.ico" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="lib/html5shiv.js"></script>
	<script type="text/javascript" src="lib/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<!--[if IE 6]>
	<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title>H-ui.admin v3.1</title>
	<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
	<meta name="description" content="H-ui.admin v3.1,是一款由国人开发的轻量级扁平化网站后台模板,完全免费开源的网站后台管理系统模版,适合中小型CMS后台系统。">
</head>
<body>
<header class="navbar-wrapper">
	<div class="navbar navbar-fixed-top">
		<div class="container-fluid cl"> <a class="logo navbar-logo f-l mr-10 hidden-xs" href="/aboutHui.shtml">H-ui.admin</a> <a class="logo navbar-logo-m f-l mr-10 visible-xs" href="/aboutHui.shtml">H-ui</a>
			<span class="logo navbar-slogan f-l mr-10 hidden-xs">v3.1</span>
			<a aria-hidden="false" class="nav-toggle Hui-iconfont visible-xs" href="javascript:;">&#xe667;</a>
			<nav class="nav navbar-nav">
				<ul class="cl">
					<li class="dropDown dropDown_hover"><a href="javascript:;" class="dropDown_A"><i class="Hui-iconfont">&#xe600;</i> 新增 <i class="Hui-iconfont">&#xe6d5;</i></a>
						<ul class="dropDown-menu menu radius box-shadow">
							<li><a href="javascript:;" onclick="article_add('添加资讯','article-add.html')"><i class="Hui-iconfont">&#xe616;</i> 资讯</a></li>
							<li><a href="javascript:;" onclick="picture_add('添加资讯','picture-add.html')"><i class="Hui-iconfont">&#xe613;</i> 图片</a></li>
							<li><a href="javascript:;" onclick="product_add('添加资讯','product-add.html')"><i class="Hui-iconfont">&#xe620;</i> 产品</a></li>
							<li><a href="javascript:;" onclick="member_add('添加用户','member-add.html','','510')"><i class="Hui-iconfont">&#xe60d;</i> 用户</a></li>
						</ul>
					</li>
				</ul>
			</nav>
			<nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
				<ul class="cl">
					<li>超级管理员</li>
					<li class="dropDown dropDown_hover">
						<a href="#" class="dropDown_A">admin <i class="Hui-iconfont">&#xe6d5;</i></a>
						<ul class="dropDown-menu menu radius box-shadow">
							<li><a href="javascript:;" onClick="myselfinfo()">个人信息</a></li>
							<li><a href="#">切换账户</a></li>
							<li><a href="#">退出</a></li>
						</ul>
					</li>
					<li id="Hui-msg"> <a href="#" title="消息"><span class="badge badge-danger">1</span><i class="Hui-iconfont" style="font-size:18px">&#xe68a;</i></a> </li>
					<li id="Hui-skin" class="dropDown right dropDown_hover"> <a href="javascript:;" class="dropDown_A" title="换肤"><i class="Hui-iconfont" style="font-size:18px">&#xe62a;</i></a>
						<ul class="dropDown-menu menu radius box-shadow">
							<li><a href="javascript:;" data-val="default" title="默认(黑色)">默认(黑色)</a></li>
							<li><a href="javascript:;" data-val="blue" title="蓝色">蓝色</a></li>
							<li><a href="javascript:;" data-val="green" title="绿色">绿色</a></li>
							<li><a href="javascript:;" data-val="red" title="红色">红色</a></li>
							<li><a href="javascript:;" data-val="yellow" title="黄色">黄色</a></li>
							<li><a href="javascript:;" data-val="orange" title="橙色">橙色</a></li>
						</ul>
					</li>
				</ul>
			</nav>
		</div>
	</div>
</header>
<aside class="Hui-aside">
	<div class="menu_dropdown bk_2">
		<dl id="menu-article">
			<dt><i class="Hui-iconfont">&#xe616;</i>组织管理<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
			<dd>
				<ul>
					<%--
						h-ui的前端矿建的链接要写在data-href中
					--%>
					<li><a data-href="orgController/getOrgPage" data-title="组织管理" href="javascript:void(0)">组织管理</a></li>
				</ul>
			</dd>
		</dl>
	</div>
</aside>
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>
<section class="Hui-article-box">
	<div id="Hui-tabNav" class="Hui-tabNav hidden-xs">
		<div class="Hui-tabNav-wp">
			<ul id="min_title_list" class="acrossTab cl">
				<li class="active">
					<span title="我的桌面" data-href="welcome.html">我的桌面</span>
					<em></em></li>
			</ul>
		</div>
		<div class="Hui-tabNav-more btn-group"><a id="js-tabNav-prev" class="btn radius btn-default size-S" href="javascript:;"><i class="Hui-iconfont">&#xe6d4;</i></a><a id="js-tabNav-next" class="btn radius btn-default size-S" href="javascript:;"><i class="Hui-iconfont">&#xe6d7;</i></a></div>
	</div>
	<div id="iframe_box" class="Hui-article">
		<div class="show_iframe">
			<div style="display:none" class="loading"></div>
			<iframe scrolling="yes" frameborder="0" src="welcome.html"></iframe>
		</div>
	</div>
</section>

<div class="contextMenu" id="Huiadminmenu">
	<ul>
		<li id="closethis">关闭当前 </li>
		<li id="closeall">关闭全部 </li>
	</ul>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript">
	$(function(){
		/*$("#min_title_list li").contextMenu('Huiadminmenu', {
            bindings: {
                'closethis': function(t) {
                    console.log(t);
                    if(t.find("i")){
                        t.find("i").trigger("click");
                    }
                },
                'closeall': function(t) {
                    alert('Trigger was '+t.id+'\nAction was Email');
                },
            }
        });*/
	});
	/*个人信息*/
	function myselfinfo(){
		layer.open({
			type: 1,
			area: ['300px','200px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: '查看信息',
			content: '
管理员信息
'
}); } /*资讯-添加*/ function article_add(title,url){ var index = layer.open({ type: 2, title: title, content: url }); layer.full(index); } /*图片-添加*/ function picture_add(title,url){ var index = layer.open({ type: 2, title: title, content: url }); layer.full(index); } /*产品-添加*/ function product_add(title,url){ var index = layer.open({ type: 2, title: title, content: url }); layer.full(index); } /*用户-添加*/ function member_add(title,url,w,h){ layer_show(title,url,w,h); } </script> <!--此乃百度统计代码,请自行删除--> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?080836300300be57b7f34f4b3e97d911"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <!--/此乃百度统计代码,请自行删除--> </body> </html>

3. 运行结果

Kite的学习历程之SSM搭建OA系统的初步搭建前端页面组织查询_第3张图片
Kite的学习历程之SSM搭建OA系统的初步搭建前端页面组织查询_第4张图片

你可能感兴趣的:(企业级权限管理)