<file_sep># ssm_crud
功能
ssm分页查询、添加、修改、单个删除、批量删除
技术
ssm、bootstrap、ajax
<file_sep>package com.ssm.dao;

import com.ssm.entity.DeptEntity;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface DeptDao{

    int insert(DeptEntity deptEntity);

    int updateById(DeptEntity deptEntity);

    List<DeptEntity> selectById(DeptEntity deptEntity);

}<file_sep>package com.ssm.dao;

import com.ssm.entity.EmployeeEntity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;


/**
 * @author lijinghua
 * @Description:
 * @date
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:mybatis-config.xml" , "classpath:applicationContext.xml" })
public class EmployeeDaoTest {

    @Autowired
    private EmployeeDao employeeDao;

    private EmployeeEntity employeeEntity = new EmployeeEntity();

    @Test
    public void insert() {
        for(int i = 1; i <= 100; i++){
            employeeEntity.setdId(1);
            employeeEntity.setEmpName("陈奕迅");
            employeeEntity.setEmail("<EMAIL>");
            employeeEntity.setGender("1");
            int result = employeeDao.insert(employeeEntity);
            System.out.println(result);
        }

    }

    @Test
    public void updateById() {
        employeeEntity.setdId(1);
        employeeEntity.setEmpName("刘若英");
        employeeEntity.setEmail("<EMAIL>");
        employeeEntity.setEmpId(1);
        employeeEntity.setGender("0");
        int result = employeeDao.updateById(employeeEntity);
        System.out.println(result);

    }

    @Test
    public void selectById() {
        //List<EmployeeEntity> result = employeeDao.selectById(employeeEntity);
        EmployeeEntity result = employeeDao.selectByPrimaryKey(1);
        System.out.println(result);
    }
}<file_sep>package com.ssm.dao;

import com.ssm.entity.DeptEntity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;


/**
 * @author lijinghua
 * @Description:
 * @date
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:mybatis-config.xml" , "classpath:applicationContext.xml" })
public class DeptDaoTest {

    @Autowired
    private  DeptDao deptDao;

    private DeptEntity deptEntity = new DeptEntity();

    @Test
    public void insert() {
        DeptEntity deptEntity = new DeptEntity();
        deptEntity.setDeptId(11);
        deptEntity.setDeptName("中台研发部");
        int result = deptDao.insert(deptEntity);
        System.out.println(result);
    }

    @Test
    public void updateById() {

        deptEntity.setDeptName("海关业务部");
        deptEntity.setDeptId(11);
        int result = deptDao.updateById(deptEntity);
        System.out.println(result);
    }

    @Test
    public void selectById() {

        List<DeptEntity> result = deptDao.selectById(deptEntity);
        System.out.println(result);
    }
}