zoukankan      html  css  js  c++  java
  • 充值-dao+sql

    package com.zhenshan.dao;

    import java.util.List;

    import org.apache.ibatis.annotations.Param;

    import com.zhenshan.entity.BorrowCar;
    import com.zhenshan.entity.Condition;

    public interface BorrowCarDao {

    List<BorrowCar> findAll(Condition con);

    List<BorrowCar> list();

    int jia(BorrowCar borrowCar);

    int add(@Param("borrowCar")BorrowCar borrowCar);

    BorrowCar toChe(Integer bid);

    int updateAmount(BorrowCar borrowCar);

    int updateNumber(BorrowCar borrowCar);



    }

    ------------------------------------------------------sql

    <?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">
    <!-- 命名空间的值为dao层接口的权限定名 -->
    <mapper namespace="com.zhenshan.dao.BorrowCarDao" >

    <select id="findAll" resultMap="carMapper">
    select * from borrow_car b LEFT JOIN borrow_car_detail c ON b.bid=c.user_id
    <where>
    <if test="userName!=null and userName!='' ">
    and b.user_name like "%" #{userName} "%"
    </if>
    <if test="carNumber!=null and carNumber!='' ">
    and c.car_number like "%" #{carNumber} "%"
    </if>
    <if test="borrowCarDate!=null and borrowCarDate!='' ">
    and c.borrow_car_date like "%" #{borrowCarDate} "%"
    </if>
    <if test="borrowCarAmount!=null">
    and b.borrow_car_amount =#{borrowCarAmount}
    </if>

    </where>
    <if test="paixu!=null and paixu!='' ">
    order BY ${paixu}
    </if>

    </select>
    <resultMap type="BorrowCar" id="carMapper">
    <id property="bid" column="bid" />
    <result property="userName" column="user_name" />
    <result property="totalAmount" column="total_amount" />
    <result property="borrowCarNumber" column="borrow_car_number" />
    <result property="boorowCarAmount" column="borrow_car_amount" />
    <association property="bcd" javaType="BorrowCarDetail">
    <id property="cid" column="cid" />
    <result property="borrowCarDate" column="borrow_car_date" />
    <result property="userId" column="user_id" />
    <result property="carNumber" column="car_number" />
    <result property="borrowAmount" column="borrow_amount" />
    </association>
    </resultMap>

    <select id="list" resultType="BorrowCar">
    select * from borrow_car
    </select>

    <update id="jia">
    update borrow_car set total_amount=total_amount+#{totalAmount} where user_name=#{userName}
    </update>

    <insert id="add">
    insert into borrow_car values(null,#{borrowCar.userName},#{borrowCar.totalAmount},#{borrowCar.borrowCarNumber},#{borrowCar.boorowCarAmount})
    </insert>

    <select id="toChe" resultMap="carMapper">
    select * from borrow_car b LEFT JOIN borrow_car_detail c ON b.bid=c.user_id where b.bid=#{bid}
    </select>

    <update id="updateAmount">
    update borrow_car set borrow_car_amount=borrow_car_amount+1 where user_name=#{userName}
    </update>

    <update id="updateNumber">
    update borrow_car set borrow_car_number=borrow_car_number+1 where user_name=#{userName}
    </update>

    </mapper>

  • 相关阅读:
    Swift3.0P1 语法指南——闭包
    OS X EI Capitan安装refind时出现Could not set boot device property: 0xe00002bc
    Swift3.0P1 语法指南——函数
    Swift3.0P1 语法指南——控制流
    [转]ios push
    给新浪微博审核提供下载地址
    xcode gdb/lldb调试命令
    博弈的真谛到底是什么?
    图基本算法 拓扑排序(基于dfs)
    HDU 1325 Is It A Tree? 判断是否为一棵树
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12971351.html
Copyright © 2011-2022 走看看