登录,查询增删改查 农业大学考试题

本文档展示了如何配置日志系统,并详细描述了使用Spring和MyBatis进行登录验证以及增删改查操作的过程。涉及到的文件包括log4j配置、UserMapper接口及XML映射文件、User实体类以及相关的控制器方法。
摘要由CSDN通过智能技术生成

# Configure logging for testing: optionally with log file
log4j.rootLogger=DEBUG, stdout
# log4j.rootLogger=WARN, stdout, logfile

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=target/spring.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

<?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="org.mypro.dao.UserMapper">
    <resultMap id="BaseResultMap" type="org.mypro.entity.User">

        <id column="id" jdbcType="INTEGER" property="id" />

        <result column="username" jdbcType="VARCHAR" property="username" />

        <result column="name" jdbcType="VARCHAR" property="name" />

        <result column="password" jdbcType="VARCHAR" property="password" />

        <result column="sex" jdbcType="VARCHAR" property="sex" />

        <result column="birthday" jdbcType="VARCHAR" property="birthday" />

        <result column="tel" jdbcType="VARCHAR" property="tel" />

        <result column="address" jdbcType="VARCHAR" property="address" />

        <result column="role" jdbcType="VARCHAR" property="role" />
    </resultMap>

    <sql id="Base_Column_List">
        id,username,name,password,sex,birthday,tel,address,role
    </sql>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from
        Userlnfo
        where id = #{id}
    </delete>
    <insert id="insert" parameterType="org.mypro.entity.User">
        insert into Userlnfo
        (id,username,name,password,sex,birthday,tel,address,role
        )
        values
        (#{id},#{username},#{name},#{password},#{sex},#{birthday},#{tel},#{address},#{role}
        )
    </insert>

    <select id="selectByExample" parameterType="org.mypro.entity.UserExample"
        resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from Userlnfo
        <where>
            <if test="where != null">
                ${where}
            </if>
        </where>
    </select>


    <select id="countByExample" parameterType="org.mypro.entity.UserExample"
        resultType="Integer">
        select
        count(*)
        from Userlnfo
        <where>
            <if test="where != null">
                ${where}
            </if>
        </where>
    </select>


    <select id="selectByPrimaryKey" parameterType="java.lang.Integer"
        resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from Userlnfo
        where id = #{id}
    </select>

    <update id="updateByPrimaryKeySelective" parameterType="org.mypro.entity.User">
        update Userlnfo
        <set>

            <if test="id != null">
                id = #{id},
            </if>

            <if test="username != null">
                username = #{username},
            </if>

            <if test="name != null">
                name = #{name},
            </if>

            <if test="password != null">
                password = #{password},
            </if>

            <if test="sex != null">
                sex = #{sex},
            </if>

            <if test="birthday != null">
                birthday = #{birthday},
            </if>

            <if test="tel != null">
                tel = #{tel},
            </if>

            <if test="address != null">
                address = #{address},
            </if>

            <if test="role != null">
                role = #{role},
            </if>
        </set>
        where id = #{id}
    </update>


</mapper>

package org.mypro.entity;

public class User {

    // 管理员id信息
    private Integer id;

    // 管理员id数据获取方法
    public Integer getId() {
        return id;
    }

    // 管理员id数据设置方法
    public void setId(Integer id) {
        this.id = id;
    }

    // 用户编码数据信息
    private String username;

    // 用户编码数据获取方法
    public String getUsername() {
        return username;
    }

    // 用户编码数据设置方法
    public void setUsername(String username) {
        this.username = username;
    }

    // 用户名称数据信息
    private String name;

    // 用户名称数据获取方法
    public String getName() {
        return name;
    }

    // 用户名称数据设置方法
    public void setName(String name) {
        this.name = name;
    }

    // 用户密码数据信息
    private String password;

    // 用户密码数据获取方法
    public String getPassword() {
        return password;
    }

    // 用户密码数据设置方法
    public void setPassword(String password) {
        this.password = password;
    }

    // 用户性别数据信息
    private String sex;

    // 用户性别数据获取方法
    public String getSex() {
        return sex;
    }

    // 用户性别数据设置方法
    public void setSex(String sex) {
        this.sex = sex;
    }

    // 出生日期数据信息
    private String birthday;

    // 出生日期数据获取方法
    public String getBirthday() {
        return birthday;
    }

    // 出生日期数据设置方法
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    // 用户电话数据信息
    private String tel;

    // 用户电话数据获取方法
    public String getTel() {
        return tel;
    }

    // 用户电话数据设置方法
    public void setTel(String tel) {
        this.tel = tel;
    }

    // 用户地址数据信息
    private String address;

    // 用户地址数据获取方法
    public String getAddress() {
        return address;
    }

    // 用户地址数据设置方法
    public void setAddress(String address) {
        this.address = address;
    }

    // 用户角色数据信息
    private String role;

    // 用户角色数据获取方法
    public String getRole() {
        return role;
    }

    // 用户角色数据设置方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值