先封装字段,然后写dao层,service接口,service服务,dao.xml,最后controller
1,、界面层(输入数据,查看结果)view 显示界面
2、业务层 business | biz | blc | manager | service 算法,判断
3、数据层 dal | dao 数据存取
4、实体层 entity | moda | bean | domain 封装数据
IUser
package com.croe.service;
import java.util.List;
import com.croe.bean.UserInfo;
public interface IUser {
//查询单个
public UserInfo select (String ID);
//添加不需要返回
public int add(UserInfo userInfo );
//查询全部
public List<UserInfo> selectall();
//修改
public int update(UserInfo userInfo);
//删除
public int delete(UserInfo userInfo);
}
User
package com.croe.dao;
import java.util.List;
import com.croe.bean.UserInfo;
public interface User {
//查询单个
public UserInfo select (String ID);
//添加不需要返回
public int add(UserInfo userInfo );
//查询全部
public List<UserInfo> selectall();
//修改
public int update(UserInfo userInfo);
//删除
public int delete(UserInfo userInfo);
}
UserDAO.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.croe.dao.User">
<resultMap type="UserInfo" id="usermap">
<id column="USER_ID" property="USER_ID" />
<result column="USER_NAME" property="USER_NAME" />
<result column="USER_PASS" property="USER_PASS" />
<result column="USER_TYPE" property="USER_TYPE" />
<result column="USER_SEX" property="USER_SEX" />
<result column="USER_PHONE" property="USER_PHONE" />
<result column="USER_AGE" property="USER_AGE" />
</resultMap>
<insert id="add" parameterType="UserInfo">
insert into user
(USER_NAME,USER_PASS,USER_TYPE,USER_SEX,USER_PHONE,USER_AGE)