model、dao、service、controller之间的关系,还有util和task的简介

总体关系:model→dao→service→controller

model:

数据库中的表一一对应,实现set和get的方法。 

/**   
 * 项目名:
 * 日期:    2017-08-17 14:37:18  
 * Copyright (c) 2015--版权所有     
 */
package com.huanke.model;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

@Entity
@Table(name = "user_work_statics", catalog = "")
public class UserWorkStatics implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// columns START
	//
	private Integer id;
	//
	private Integer userId;
	//
	private Integer draftNum;
	//
	private Integer waitCheckNum;
	//
	private Integer waitPublishNum;
	//
	private Integer returnNum;
	//
	private Integer havePublishedNum;
	//
	private Integer processingNum;
	//
	private Integer haveCheckNum;
	//
	private Integer haveAssignNum;

	//
	private Integer score;
	//
	private Date updateTime;
	//
	private Byte isdelete;
	// columns END

	public void setId(Integer value) {
		this.id = value;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "Id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	@Column(name = "user_id")
	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer value) {
		this.userId = value;
	}

	@Column(name = "draft_num")
	public Integer getDraftNum() {
		return this.draftNum;
	}

	public void setDraftNum(Integer value) {
		this.draftNum = value;
	}

	@Column(name = "wait_check_num")
	public Integer getWaitCheckNum() {
		return this.waitCheckNum;
	}

	public void setWaitCheckNum(Integer value) {
		this.waitCheckNum = value;
	}

	@Column(name = "wait_publish_num")
	public Integer getWaitPublishNum() {
		return this.waitPublishNum;
	}

	public void setWaitPublishNum(Integer value) {
		this.waitPublishNum = value;
	}

	@Column(name = "return_num")
	public Integer getReturnNum() {
		return this.returnNum;
	}

	public void setReturnNum(Integer value) {
		this.returnNum = value;
	}

	@Column(name = "have_published_num")
	public Integer getHavePublishedNum() {
		return this.havePublishedNum;
	}

	public void setHavePublishedNum(Integer value) {
		this.havePublishedNum = value;
	}

	@Column(name = "processing_num")
	public Integer getProcessingNum() {
		return this.processingNum;
	}

	public void setProcessingNum(Integer value) {
		this.processingNum = value;
	}

	@Column(name = "have_check_num")
	public Integer getHaveCheckNum() {
		return this.haveCheckNum;
	}

	public void setHaveCheckNum(Integer value) {
		this.haveCheckNum = value;
	}

	@Column(name = "have_assign_num")
	public Integer getHaveAssignNum() {
		return this.haveAssignNum;
	}

	public void setHaveAssignNum(Integer value) {
		this.haveAssignNum = value;
	}

	@Column(name = "score")
	public Integer getScore() {
		return this.score;
	}

	public void setScore(Integer value) {
		this.score = value;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date value) {
		this.updateTime = value;
	}

	@Column(name = "isdelete")
	public Byte getIsdelete() {
		return this.isdelete;
	}

	public void setIsdelete(Byte value) {
		this.isdelete = value;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId())
				.append("userId", getUserId()).append("draftNum", getDraftNum())
				.append("waitCheckNum", getWaitCheckNum()).append("waitPublishNum", getWaitPublishNum())
				.append("havePublishedNum", getHavePublishedNum()).append("processingNum", getProcessingNum())
				.append("returnNum", getReturnNum()).append("haveCheckNum", getHaveCheckNum())
				.append("haveAssignNum", getHaveAssignNum()).append("score", getScore())
				.append("updateTime", getUpdateTime()).append("isdelete", getIsdelete()).toString();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(getId()).toHashCode();
	}

	public boolean equals(Object obj) {
		if (obj instanceof UserWorkStatics == false)
			return false;
		if (this == obj)
			return true;
		UserWorkStatics other = (UserWorkStatics) obj;
		return new EqualsBuilder().append(getId(), other.getId()).isEquals();
	}
}
所对应数据库的表如下: 


dao:

DAO,数据存取对象。与数据库打交道时,如果为每一个场景都去写一些SQL语句,会很麻烦和冗余,为了让代码清晰干净整洁,
就需要数据库封装一下,让我们和数据库的交道看起来比较像和一个对象打交道。这个对象通常就是DAO,当我们操作这个对象的时候,
这个对象会自动的产生SQL语句来和数据库打交道,而我们只需要和DAO打交道就可以了。 
多数情况我们都是xxxDao继承总Dao:
/**   
 * 项目名:
 * 日期:    2017-08-17 14:37:18  
 * Copyright (c) 2015- huanke-版权所有     
 */
package com.xxxx.dao;

import com.xxxx.model.UserWorkStatics;

import core.dao.Dao;

public interface UserWorkStaticsDao extends Dao<UserWorkStatics> {

}

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

总Dao中封装了很多常用的增删改查方法,比如deleteByProperties、getByProerties、queryByProerties、updateByProper,如下:

package core.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.Session;

import com.huanke.bean.Pager;

import core.support.BaseParameter;
import core.support.QueryResult;

public interface Dao
   
   
    
     {

    public Session getSession();

    /**
     * 彻底清除会话
     */
    public void clear();

    /**
     * 查询出对象实体的所有数目
     * 
     * @return 返回对象实体所有数目
     */
    public Long countAll();

    /**
     * 删除对象实体
     * 
     * @param entity
     *            对象实体
     */
    public void delete(E entity);

    /**
     * 根据多个id参数删除对象
     * 
     * @param id
     *            多个id,以英文逗号隔开
     * @return 返回true或者false
     */
    public boolean deleteByPK(Serializable... id);

    /**
     * 以HQL的方式,根据单个属性删除对象实体
     * 
     * @param propName
     *            属性名称
     * @param propValue
     *            属性值
     */
    public void deleteByProperties(String propName, Object propValue);

    /**
     * 以HQL的方式,根据多个属性删除对象实体
     * 
     * @param propName
     *            属性名称
     * @param propValue
     *            属性值
     */
    public void deleteByProperties(String[] propName, Object[] propValue);

    /**
     * 根据各种查询条件返回对象实体数目
     * 
     * @param parameter
     *            各种查询条件
     * @return 返回对象实体数目
     */
    public Long doCount(BaseParameter parameter);

    /**
     * 根据各种查询条件返回分页列表
     * 
     * @param parameter
     *            各种查询条件
     * @return 返回分页列表
     */
    public QueryResult
    
    
     
      doPaginationQuery(BaseParameter parameter);

    /**
     * 根据各种查询条件返回分页列表
     * 
     * @param parameter
     *            各种查询条件
     * @param bool
     *            默认为true;如果为false,增加属性是否为空等查询条件
     * @return 返回分页列表
     */
    public QueryResult
     
     
      
       doPaginationQuery(BaseParameter parameter, boolean bool);

    /**
     * 根据各种查询条件返回对象实体列表
     * 
     * @param parameter
     *            各种查询条件
     * @return 返回对象实体列表
     */
    public List
      
      
       
        doQuery(BaseParameter parameter);

    /**
     * 查询出所有的对象实体列表
     * 
     * @return 返回对象实体列表
     */
    public List
       
       
         doQueryAll(); /** * 根据要返回的记录数目查询出对象实体列表 * * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
        
          doQueryAll(Integer top); /** * 根据排序条件和要返回的记录数目查询出对象实体列表 * * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
         
           doQueryAll(Map 
          
            sortedCondition, Integer top); /** * 邹猛 doQueryByInMethods(这里用一句话描述这个方法的作用) 用in方法的查询 * * @param param * @return List 
           
             * @exception @since * 1.0.0 */ public List 
            
              doQueryByInMethods(BaseParameter param); /** * 从会话缓存中删除此对象实体 * * @param entity * 待删除的对象实体 */ public void evict(E entity); /** * 根据ID立即加载持久化对象实体 * * @param id * ID值 * @return 返回对象实体 */ public E get(Serializable id); /** * 根据属性获取单个对象实体 * * @param propName * 属性名称 * @param propValue * 属性值 * @return 返回对象实体 */ public E getByProerties(String propName, Object propValue); /** * 根据属性和排序条件获取单个对象实体 * * @param propName * 属性名称 * @param propValue * 属性值 * @param sortedCondition * 排序条件 * @return 返回对象实体 */ public E getByProerties(String propName, Object propValue, Map 
             
               sortedCondition); /** * 根据属性数组获取单个对象实体 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @return 返回对象实体 */ public E getByProerties(String[] propName, Object[] propValue); /** * 根据属性数组和排序条件获取单个对象实体 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @return 返回对象实体 */ public E getByProerties(String[] propName, Object[] propValue, Map 
              
                sortedCondition); /** * 邹猛 getMaxId(这里用一句话描述这个方法的作用) 获取订单号种子id最大值 * * @return Long * @exception @since * 1.0.0 */ public Long getMaxId(); /** * 根据查询条件获取相应表的数据 KevinCui * * @param tableName * 表名 * @param columns * 列名(如果有多个,则中间用英文半角逗号分隔) * @param condition * 查询条件片断 * @return 操作成功返回集合,否则返回Null。 */ public List 
                
                
                  > getObjectList(String tableName, String columns, String condition); /** * 根据ID延迟加载持久化对象实体 * * @param id * ID值 * @return 返回对象实体 */ public E load(Serializable id); /** * 合并给定的对象实体状态到当前的持久化上下文 * * @param entity * 给定的对象实体 * @return 返回对象实体 */ public E merge(E entity); /** * 持久化对象实体 * * @param entity * 对象实体 * @return */ public Serializable persist(E entity); /** * 根据属性获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @return 返回对象实体列表 */ public List 
                 
                   queryByProerties(String propName, Object propValue); /** * 根据属性和要返回的记录数目获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                  
                    queryByProerties(String propName, Object propValue, Integer top); /** * 根据属性和排序条件获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @param sortedCondition * 排序条件 * @return 返回对象实体列表 */ public List 
                   
                     queryByProerties(String propName, Object propValue, Map 
                    
                      sortedCondition); /** * 根据属性、排序条件和要返回的记录数目获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                     
                       queryByProerties(String propName, Object propValue, Map 
                      
                        sortedCondition, Integer top); /** * 根据属性获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @return */ public List 
                       
                         queryByProerties(String[] propName, Object[] propValue); /** * 根据属性和要返回的记录数目获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                        
                          queryByProerties(String[] propName, Object[] propValue, Integer top); /** * 根据属性和排序条件获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @return 返回对象实体列表 */ public List 
                         
                           queryByProerties(String[] propName, Object[] propValue, Map 
                          
                            sortedCondition); /** * 根据属性、排序条件和要返回的记录数目获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                           
                             queryByProerties(String[] propName, Object[] propValue, Map 
                            
                              sortedCondition, Integer top); /** * 根据属性、排序条件和要返回的记录数目分页获取对象实体列表(使用hql方法) * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                             
                               queryByProertiesByPage(String[] propName, Object[] propValue, Map 
                              
                                sortedCondition, Integer firstIndex, Integer count); public Pager 
                               
                                 queryByProertiesPage(String[] propName, Object[] propValue, Map 
                                
                                  sortedCondition, int pageNo, int pageSize); /** * 根据给定的Detached对象标识符更新对象实体 * * @param entity * 对象实体 */ public void update(E entity); /** * 先删除再插入去更新对象实体 * * @param entity * 待更新的对象实体 * @param oldId * 已存在的对象实体主键 */ public void update(E entity, Serializable oldId); /** * 根据单个属性条件更新对象实体单个属性 * * @param conditionName * WHERE子句条件的属性名称 * @param conditionValue * WHERE子句条件的属性值 * @param propertyName * UPDATE子句属性名称 * @param propertyValue * UPDATE子句属性值 */ public void updateByProperties(String conditionName, Object conditionValue, String propertyName, Object propertyValue); /** * 根据多个属性条件更新对象实体单个属性 * * @param conditionName * WHERE子句条件的属性名称 * @param conditionValue * WHERE子句条件的属性值 * @param propertyName * UPDATE子句属性数组名称 * @param propertyValue * UPDATE子句属性数组值 */ public void updateByProperties(String conditionName, Object conditionValue, String[] propertyName, Object[] propertyValue); /** * 根据单个属性条件更新对象实体多个属性 * * @param conditionName * WHERE子句条件的属性数组名称 * @param conditionValue * WHERE子句条件的属性数组值 * @param propertyName * UPDATE子句属性名称 * @param propertyValue * UPDATE子句属性值 */ public void updateByProperties(String[] conditionName, Object[] conditionValue, String propertyName, Object propertyValue); /** * 根据多个属性条件更新对象实体多个属性 * * @param conditionName * WHERE子句条件的属性数组名称 * @param conditionValue * WHERE子句条件的属性数组值 * @param propertyName * UPDATE子句属性数组名称 * @param propertyValue * UPDATE子句属性数组值 */ public void updateByProperties(String[] conditionName, Object[] conditionValue, String[] propertyName, Object[] propertyValue); /** * zm 多model删除 deleteByEntities * * @param propName * @param propValue * @param hql * void * @exception @since * 1.0.0 */ public void deleteByEntities(String[] propName, Object[] propValue, String entities); /** * zm 存储过程 * * @param types * @param procedureName * @param hql * void * @exception @since * 1.0.0 */ public Long callProcedure(String types, String procedureName); // 查询+分页 public List executeQueryByPage(String hql, Object[] parameters, int pageNum, int PagesSize); public List executeQuery(String hql, Object[] parameters); /** * 执行sql语句 * * @param hql */ public void executeHql(String hql, Object[] parameters); // sql原生查询 public void executeSql(String sql, Object[] parameters); public void executeSqlUpdate(String sql, Object[] parameters); public void executeHqlUpdate(String hql, Object[] parameters); // 查询+分页 public List executeHqlQueryByPage(String hql, Object[] parameters, int pageNum, int PagesSize); public List executeHqlQuery(String hql, Object[] parameters); public void deleteByEntities(String propName, Object propValue, String entities); // 外键做主键的类的sql 查询 public List 
                                 
                                   queryByPropertiesSql(String sheetName, String[] propName, Object[] propValue); // 外键做主键的类的sql 查询 public E getByPropertiesSql(String sheetName, String[] propName, Object[] propValue); public Object getColumnByPropertiesSql(String sheetName, String column, String[] propName, Object[] propValue); public List 
                                   queryColumnByPropertiesSql(String sheetName, String column, String[] propName, Object[] propValue); } 

                                    
                                    
  • package core.dao;
    
    import java.io.Serializable;
    import java.util.List;
    import java.util.Map;
    
    import org.hibernate.Session;
    
    import com.huanke.bean.Pager;
    
    import core.support.BaseParameter;
    import core.support.QueryResult;
    
    public interface Dao
                                             
                                             
                                              
                                               {
    
        public Session getSession();
    
        /**
         * 彻底清除会话
         */
        public void clear();
    
        /**
         * 查询出对象实体的所有数目
         * 
         * @return 返回对象实体所有数目
         */
        public Long countAll();
    
        /**
         * 删除对象实体
         * 
         * @param entity
         *            对象实体
         */
        public void delete(E entity);
    
        /**
         * 根据多个id参数删除对象
         * 
         * @param id
         *            多个id,以英文逗号隔开
         * @return 返回true或者false
         */
        public boolean deleteByPK(Serializable... id);
    
        /**
         * 以HQL的方式,根据单个属性删除对象实体
         * 
         * @param propName
         *            属性名称
         * @param propValue
         *            属性值
         */
        public void deleteByProperties(String propName, Object propValue);
    
        /**
         * 以HQL的方式,根据多个属性删除对象实体
         * 
         * @param propName
         *            属性名称
         * @param propValue
         *            属性值
         */
        public void deleteByProperties(String[] propName, Object[] propValue);
    
        /**
         * 根据各种查询条件返回对象实体数目
         * 
         * @param parameter
         *            各种查询条件
         * @return 返回对象实体数目
         */
        public Long doCount(BaseParameter parameter);
    
        /**
         * 根据各种查询条件返回分页列表
         * 
         * @param parameter
         *            各种查询条件
         * @return 返回分页列表
         */
        public QueryResult
                                              
                                              
                                               
                                                doPaginationQuery(BaseParameter parameter);
    
        /**
         * 根据各种查询条件返回分页列表
         * 
         * @param parameter
         *            各种查询条件
         * @param bool
         *            默认为true;如果为false,增加属性是否为空等查询条件
         * @return 返回分页列表
         */
        public QueryResult
                                               
                                               
                                                
                                                 doPaginationQuery(BaseParameter parameter, boolean bool);
    
        /**
         * 根据各种查询条件返回对象实体列表
         * 
         * @param parameter
         *            各种查询条件
         * @return 返回对象实体列表
         */
        public List
                                                
                                                
                                                 
                                                  doQuery(BaseParameter parameter);
    
        /**
         * 查询出所有的对象实体列表
         * 
         * @return 返回对象实体列表
         */
        public List
                                                 
                                                 
                                                   doQueryAll(); /** * 根据要返回的记录数目查询出对象实体列表 * * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                                                  
                                                    doQueryAll(Integer top); /** * 根据排序条件和要返回的记录数目查询出对象实体列表 * * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                                                   
                                                     doQueryAll(Map 
                                                    
                                                      sortedCondition, Integer top); /** * 邹猛 doQueryByInMethods(这里用一句话描述这个方法的作用) 用in方法的查询 * * @param param * @return List 
                                                     
                                                       * @exception @since * 1.0.0 */ public List 
                                                      
                                                        doQueryByInMethods(BaseParameter param); /** * 从会话缓存中删除此对象实体 * * @param entity * 待删除的对象实体 */ public void evict(E entity); /** * 根据ID立即加载持久化对象实体 * * @param id * ID值 * @return 返回对象实体 */ public E get(Serializable id); /** * 根据属性获取单个对象实体 * * @param propName * 属性名称 * @param propValue * 属性值 * @return 返回对象实体 */ public E getByProerties(String propName, Object propValue); /** * 根据属性和排序条件获取单个对象实体 * * @param propName * 属性名称 * @param propValue * 属性值 * @param sortedCondition * 排序条件 * @return 返回对象实体 */ public E getByProerties(String propName, Object propValue, Map 
                                                       
                                                         sortedCondition); /** * 根据属性数组获取单个对象实体 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @return 返回对象实体 */ public E getByProerties(String[] propName, Object[] propValue); /** * 根据属性数组和排序条件获取单个对象实体 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @return 返回对象实体 */ public E getByProerties(String[] propName, Object[] propValue, Map 
                                                        
                                                          sortedCondition); /** * 邹猛 getMaxId(这里用一句话描述这个方法的作用) 获取订单号种子id最大值 * * @return Long * @exception @since * 1.0.0 */ public Long getMaxId(); /** * 根据查询条件获取相应表的数据 KevinCui * * @param tableName * 表名 * @param columns * 列名(如果有多个,则中间用英文半角逗号分隔) * @param condition * 查询条件片断 * @return 操作成功返回集合,否则返回Null。 */ public List 
                                                          
                                                          
                                                            > getObjectList(String tableName, String columns, String condition); /** * 根据ID延迟加载持久化对象实体 * * @param id * ID值 * @return 返回对象实体 */ public E load(Serializable id); /** * 合并给定的对象实体状态到当前的持久化上下文 * * @param entity * 给定的对象实体 * @return 返回对象实体 */ public E merge(E entity); /** * 持久化对象实体 * * @param entity * 对象实体 * @return */ public Serializable persist(E entity); /** * 根据属性获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @return 返回对象实体列表 */ public List 
                                                           
                                                             queryByProerties(String propName, Object propValue); /** * 根据属性和要返回的记录数目获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                                                            
                                                              queryByProerties(String propName, Object propValue, Integer top); /** * 根据属性和排序条件获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @param sortedCondition * 排序条件 * @return 返回对象实体列表 */ public List 
                                                             
                                                               queryByProerties(String propName, Object propValue, Map 
                                                              
                                                                sortedCondition); /** * 根据属性、排序条件和要返回的记录数目获取对象实体列表 * * @param propName * 属性名称 * @param propValue * 属性值 * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                                                               
                                                                 queryByProerties(String propName, Object propValue, Map 
                                                                
                                                                  sortedCondition, Integer top); /** * 根据属性获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @return */ public List 
                                                                 
                                                                   queryByProerties(String[] propName, Object[] propValue); /** * 根据属性和要返回的记录数目获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                                                                  
                                                                    queryByProerties(String[] propName, Object[] propValue, Integer top); /** * 根据属性和排序条件获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @return 返回对象实体列表 */ public List 
                                                                   
                                                                     queryByProerties(String[] propName, Object[] propValue, Map 
                                                                    
                                                                      sortedCondition); /** * 根据属性、排序条件和要返回的记录数目获取对象实体列表 * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                                                                     
                                                                       queryByProerties(String[] propName, Object[] propValue, Map 
                                                                      
                                                                        sortedCondition, Integer top); /** * 根据属性、排序条件和要返回的记录数目分页获取对象实体列表(使用hql方法) * * @param propName * 属性数组名称 * @param propValue * 属性数组值 * @param sortedCondition * 排序条件 * @param top * 要返回的记录数目 * @return 返回对象实体列表 */ public List 
                                                                       
                                                                         queryByProertiesByPage(String[] propName, Object[] propValue, Map 
                                                                        
                                                                          sortedCondition, Integer firstIndex, Integer count); public Pager 
                                                                         
                                                                           queryByProertiesPage(String[] propName, Object[] propValue, Map 
                                                                          
                                                                            sortedCondition, int pageNo, int pageSize); /** * 根据给定的Detached对象标识符更新对象实体 * * @param entity * 对象实体 */ public void update(E entity); /** * 先删除再插入去更新对象实体 * * @param entity * 待更新的对象实体 * @param oldId * 已存在的对象实体主键 */ public void update(E entity, Serializable oldId); /** * 根据单个属性条件更新对象实体单个属性 * * @param conditionName * WHERE子句条件的属性名称 * @param conditionValue * WHERE子句条件的属性值 * @param propertyName * UPDATE子句属性名称 * @param propertyValue * UPDATE子句属性值 */ public void updateByProperties(String conditionName, Object conditionValue, String propertyName, Object propertyValue); /** * 根据多个属性条件更新对象实体单个属性 * * @param conditionName * WHERE子句条件的属性名称 * @param conditionValue * WHERE子句条件的属性值 * @param propertyName * UPDATE子句属性数组名称 * @param propertyValue * UPDATE子句属性数组值 */ public void updateByProperties(String conditionName, Object conditionValue, String[] propertyName, Object[] propertyValue); /** * 根据单个属性条件更新对象实体多个属性 * * @param conditionName * WHERE子句条件的属性数组名称 * @param conditionValue * WHERE子句条件的属性数组值 * @param propertyName * UPDATE子句属性名称 * @param propertyValue * UPDATE子句属性值 */ public void updateByProperties(String[] conditionName, Object[] conditionValue, String propertyName, Object propertyValue); /** * 根据多个属性条件更新对象实体多个属性 * * @param conditionName * WHERE子句条件的属性数组名称 * @param conditionValue * WHERE子句条件的属性数组值 * @param propertyName * UPDATE子句属性数组名称 * @param propertyValue * UPDATE子句属性数组值 */ public void updateByProperties(String[] conditionName, Object[] conditionValue, String[] propertyName, Object[] propertyValue); /** * zm 多model删除 deleteByEntities * * @param propName * @param propValue * @param hql * void * @exception @since * 1.0.0 */ public void deleteByEntities(String[] propName, Object[] propValue, String entities); /** * zm 存储过程 * * @param types * @param procedureName * @param hql * void * @exception @since * 1.0.0 */ public Long callProcedure(String types, String procedureName); // 查询+分页 public List executeQueryByPage(String hql, Object[] parameters, int pageNum, int PagesSize); public List executeQuery(String hql, Object[] parameters); /** * 执行sql语句 * * @param hql */ public void executeHql(String hql, Object[] parameters); // sql原生查询 public void executeSql(String sql, Object[] parameters); public void executeSqlUpdate(String sql, Object[] parameters); public void executeHqlUpdate(String hql, Object[] parameters); // 查询+分页 public List executeHqlQueryByPage(String hql, Object[] parameters, int pageNum, int PagesSize); public List executeHqlQuery(String hql, Object[] parameters); public void deleteByEntities(String propName, Object propValue, String entities); // 外键做主键的类的sql 查询 public List 
                                                                           
                                                                             queryByPropertiesSql(String sheetName, String[] propName, Object[] propValue); // 外键做主键的类的sql 查询 public E getByPropertiesSql(String sheetName, String[] propName, Object[] propValue); public Object getColumnByPropertiesSql(String sheetName, String column, String[] propName, Object[] propValue); public List 
                                                                             queryColumnByPropertiesSql(String sheetName, String column, String[] propName, Object[] propValue); } 
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364
    • 365
    • 366
    • 367
    • 368
    • 369
    • 370
    • 371
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • 437
    • 438
    • 439
    • 440
    • 441
    • 442
    • 443
    • 444
    • 445
    • 446
    • 447
    • 448
    • 449
    • 450
    • 451
    • 452
    • 453
    • 454
    • 455
    • 456
    • 457
    • 458
    • 459
    • 460
    • 461
    • 462
    • 463
    • 464
    • 465
    • 466
    • 467
    • 468
    • 469
    • 470
    • 471
    • 472
    • 473
    • 474
    • 475
    • 476
    • 477
    • 478
    • 479
    • 480
    • 481
    • 482
    • 483
    • 484
    • 485
    • 486
    • 487
    • 488
    • 489
    • 490
    • 491
    • 492
    • 493
    • 494
    • 495
    • 496
    • 497
    • 498
    • 499
    • 500
    • 501
    • 502
    • 503
    • 504
    • 505
    • 506
    • 507
    • 508
    • 509
    • 510
    • 511
    • 512
    • 513
    • 514
    • 515
    • 516
    • 517
    • 518
    • 519
    • 520
    • 521
    • 这些常用的方法的具体实现是在BaseDao中,所以xxxDaoImpl(即xxxDao的具体实现)需要继承BaseDao。 如下:

      /** 
      * 项目名: 
      * 日期: 2017-08-17 14:37:18 
      * Copyright (c) 2015 -版权所有 
      */ 
      package com.xxxx.dao.impl;

      import org.springframework.stereotype.Repository;

      import com.xxx.dao.UserWorkStaticsDao; 
      import com.xxx.model.UserWorkStatics;

      import core.dao.BaseDao;

      @Repository 
      public class UserWorkStaticsDaoImpl extends BaseDao implements UserWorkStaticsDao {

      public UserWorkStaticsDaoImpl() {
          super(UserWorkStatics.class);
      }
      



      service:

      业务层,给controller层的类提供接口进行调用。一般就是自己写的方法封装起来,就是声明一下,具体实现在serviceImplz中。 
      service如下: 

      /**   
       * 项目名:huanke
       * 日期:    2017-08-17 14:37:18  
       * Copyright (c) 2015- huanke-版权所有     
       */
      package com.huanke.service;
      
      import java.util.List;
      import java.util.Map;
      
      import com.huanke.model.UserWorkStatics;
      
      import core.service.Service;
      
      public interface UserWorkStaticsService extends Service
                                                                                  
                                                                                  
                                                                                   
                                                                                    {
      	public List
                                                                                   
                                                                                   
                                                                                    
                                                                                    
                                                                                     
                                                                                     > draftNum();
      
      	public List
                                                                                     
                                                                                     
                                                                                      
                                                                                      
                                                                                        > waitCheckNum(); public List 
                                                                                        
                                                                                        
                                                                                          > waitPublishNum(); public List 
                                                                                          
                                                                                          
                                                                                            > processingNum(); public List 
                                                                                            
                                                                                            
                                                                                              > havePublishedNum(); public List 
                                                                                              
                                                                                              
                                                                                                > returnNum(); public List 
                                                                                                
                                                                                                
                                                                                                  > haveChenckNum(); public List 
                                                                                                  
                                                                                                  
                                                                                                    > haveAssignNum(); public List 
                                                                                                    
                                                                                                    
                                                                                                      > bankScript(Integer roleId, Integer type); public List 
                                                                                                      
                                                                                                      
                                                                                                        > allScript(Integer roleId, Integer type); public List 
                                                                                                        
                                                                                                        
                                                                                                          > allUser(Integer roleId, Integer type); public List 
                                                                                                          
                                                                                                          
                                                                                                            > allActiveUser(Integer roleId, Integer type); // 定时任务 public void setScriptNumOnTime(); public List 
                                                                                                            
                                                                                                            
                                                                                                              > staticsList(Integer userId, String status, Integer type, Integer roleId) throws Exception; public List 
                                                                                                              
                                                                                                              
                                                                                                                > havecheckedList(Integer userId, String status, Integer type, Integer roleId) throws Exception; public List 
                                                                                                                
                                                                                                                
                                                                                                                  > bankScriptList(Integer roleId, Integer type); public List 
                                                                                                                  
                                                                                                                  
                                                                                                                    > newScriptList(Integer roleId, Integer type, String status); public List 
                                                                                                                    
                                                                                                                    
                                                                                                                      > newDraftList(Integer roleId, Integer type, String status); } 
                                                                                                                     
                                                                                                                   
                                                                                                                 
                                                                                                               
                                                                                                             
                                                                                                           
                                                                                                         
                                                                                                       
                                                                                                     
                                                                                                   
                                                                                                 
                                                                                               
                                                                                             
                                                                                           
                                                                                         
                                                                                      
                                                                                    
                                                                                    
                                                                                  
                                                                                  

      方法的具体实现则是写在serviceImpl中的。

          controller:
        控制层,负责具体模块的业务流程控制,需要调用service逻辑设计层的接口来控制业务流程, 与前端接口的对接和每个功能接口的实现方法都写在这里,可以说是代码的主干部分。
      util   :
      工具类,因为一个项目的开发肯定是多人协同完成,每个人负责一块,这样每个人编程时可能会用的很多相同的常用方法,比如日期、base64、定时任务、文件上传,如果每个人都再各自写一遍这些东西,就很浪费时间且冗余,这就是工具类util需要解决的,把一些大家经常会用到的“工具”式函数放在util里,大家用时只要一调用就可以了。

            task:
          可以把定时任务的实现写到task中,这个之后我们会说到。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值