《锋迷商城》系列项目
链接: 《一》 项目搭建
链接: 《二》数据库的创建
链接: 《三》业务流程设计
文章目录
六、《锋迷商城》设计实现-用户管理
6.1实现流程
6.2 后端接口开发
6.2.1完成DAO 操作
-
创建实体类
package com.sjtest.fmmall.entity; import io.swagger.annotations.ApiModel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; @Data @NoArgsConstructor @AllArgsConstructor @ApiModel(value = "用户信息",description = "卖家信息") public class User { private int userId; private String username; private String password; private String nickname; private String realname; private String userImg; private String userMobile; private String userEmail; private String userSex; private Date userBirth; private Date userRegtime; private Date userModtime; }
-
创建DAO接口,定义操作方法
package com.sjtest.fmmall.dao; import com.sjtest.fmmall.entity.User; public interface UserDao { /** * 用户注册 * @param user * @return */ int insertUser(User user); /** * 根据用户名查询用户信息 * @param name * @return */ User queryUserByName(String name); }
-
创建DAO 接口的mapper文件完成配置
<?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.sjtest.fmmall.dao.UserDao"> <resultMap id="userMap" type="User"> <id column="user_id" property="userId"/> <result column="username" property="username"/> <result column="password" property="password"/> <result column="nickname" property="nickname"/> <result column="realname" property="realname"/> <result column