Created
June 21, 2018 02:27
-
-
Save coolcoolercool/68f9afb88d148c5d5ddac4ce1af1aa8f to your computer and use it in GitHub Desktop.
dao部分
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package cn.itcast.jk.service; | |
| import cn.itcast.jk.domain.Dept; | |
| import cn.itcast.jk.utils.Page; | |
| import java.io.Serializable; | |
| import java.util.Collection; | |
| import java.util.List; | |
| /** | |
| * author: zzw5005 | |
| * date: 2018/6/8 21:24 | |
| */ | |
| public interface DeptService { | |
| //查询所有,带条件查询 | |
| public List<Dept> find(String hql, Class<Dept> entityClass, Object[] params); | |
| //获取一条记录 | |
| public Dept get(Class<Dept> entityClass, Serializable id); | |
| //分页查询,将数据封装到一个page分页工具类对象 | |
| public Page<Dept> findPage(String hql, Page<Dept> page, Class<Dept> entityClass, Object[] params); | |
| //新增和修改保存 | |
| public void saveOrUpdate(Dept entity); | |
| //批量新增和修改保存 | |
| public void saveOrUpdateAll(Collection<Dept> entitys); | |
| //单条删除,按id | |
| public void deleteById(Class<Dept> entityClass, Serializable id); | |
| //批量删除 | |
| public void delete(Class<Dept> entityClass, Serializable[] ids); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package cn.itcast.jk.service.impl; | |
| import java.io.Serializable; | |
| import java.util.Collection; | |
| import java.util.List; | |
| import cn.itcast.jk.dao.BaseDao; | |
| import cn.itcast.jk.domain.Dept; | |
| import cn.itcast.jk.service.DeptService; | |
| import cn.itcast.jk.utils.Page; | |
| import cn.itcast.jk.utils.UtilFuns; | |
| public class DeptServiceImpl implements DeptService { | |
| private BaseDao baseDao; | |
| public void setBaseDao(BaseDao baseDao) { | |
| this.baseDao = baseDao; | |
| } | |
| public List<Dept> find(String hql, Class<Dept> entityClass, Object[] params) { | |
| return baseDao.find(hql, entityClass, params); | |
| } | |
| public Dept get(Class<Dept> entityClass, Serializable id) { | |
| return baseDao.get(entityClass, id); | |
| } | |
| public Page<Dept> findPage(String hql, Page<Dept> page, Class<Dept> entityClass, Object[] params) { | |
| return baseDao.findPage(hql, page, entityClass, params); | |
| } | |
| public void saveOrUpdate(Dept entity) { | |
| if(UtilFuns.isEmpty(entity.getId())){ | |
| //新增 | |
| entity.setState(1);//1启用 0停用 默认为启用 | |
| } | |
| baseDao.saveOrUpdate(entity); | |
| } | |
| public void saveOrUpdateAll(Collection<Dept> entitys) { | |
| baseDao.saveOrUpdateAll(entitys); | |
| } | |
| public void deleteById(Class<Dept> entityClass, Serializable id) { | |
| baseDao.deleteById(entityClass, id); | |
| } | |
| public void delete(Class<Dept> entityClass, Serializable[] ids) { | |
| baseDao.delete(entityClass, ids); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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:tx="http://www.springframework.org/schema/tx" | |
| 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/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/context | |
| http://www.springframework.org/schema/context/spring-context.xsd"> | |
| <!-- service --> | |
| <!--<bean id="customerService" class="cn.itcast.crm.service.CustomerServiceImpl"> | |
| <property name="customerDao" ref="customerDao"></property> | |
| </bean>--> | |
| <bean id="deptService" class="cn.itcast.jk.service.impl.DeptServiceImpl"> | |
| <property name="baseDao" ref="baseDao"></property> | |
| </bean> | |
| </beans> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <h2>Hello World!</h2> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE web-app PUBLIC | |
| "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | |
| "http://java.sun.com/dtd/web-app_2_3.dtd" > | |
| <web-app> | |
| <display-name>Archetype Created Web Application</display-name> | |
| </web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment