springboot+mybatis项目流程

以下均为代码(思路)流程,不包括创建项目等。

 1. 根据功能设计数据库表————>>PowerDesigner
 2. 在MySQL中生成对应的表
 3. 根据数据库表完成实体类(bean)
 4. MyBatis的映射文件(用注释的则不用写XML映射文件)
 注解方式:
【
public interface SystemUserMapper {

@Select("select * from system_user where username=#{username}")
//@Result 修饰返回的结果集,关联实体类属性和数据库字段一一对应,如果实体类属性和数据库属性名保持一致,就不需要这个属性来修饰。
SystemUser findUserByUsername(String username);

@Select("select * from system_user")
@Results({
        @Result(property = "uuid",  column = "uuid", javaType = String.class),
        @Result(property = "username", column = "username",javaType = String.class),
        @Result(property = "password", column = "password",javaType = String.class),
        @Result(property = "isRoot", column = "isRoot",javaType = String.class),
        @Result(property = "registerDate", column = "registerDate",javaType = java.util.Date.class),
        @Result(property = "status", column = "status",javaType = Integer.class),
})
List findAllUser();

@Insert("insert into system_user(uuid,username,password,isRoot,registerDate,status) " +
        " values(#{uuid}, #{username}, #{password},#{isRoot},#{registerDate},#{status})")
void saveUser(SystemUser user);

@Delete("delete from system_user where uuid =#{uuid}")
void deleteUserByUUID(String uuid);

@Update("update system_user set password=#{password},status=#{status} where uuid=#{uuid}")
void updateUser(SystemUser user);
】
   非注解:
   先写映射文件,再根据映射文件写dao层

 5.service
 6.controller
 7.html

你可能感兴趣的:(springboot+mybatis项目流程)