4 changed files with 247 additions and 0 deletions
@ -0,0 +1,42 @@ |
|||
package cn.chjyj.szwh.mapper; |
|||
|
|||
import cn.chjyj.szwh.bean.User; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 客户MAPPER |
|||
*/ |
|||
@Component |
|||
public interface UserMapper { |
|||
/** |
|||
* 分页查询用户列表 |
|||
* @param startrs |
|||
* @param pagesize |
|||
* @return |
|||
*/ |
|||
List<User> getUserList(@Param("startRs") int startrs, |
|||
@Param("pageSize") int pagesize); |
|||
/** |
|||
* 用户isli标识码查询用户 |
|||
* @param userIsli |
|||
* @return |
|||
*/ |
|||
User getUserByIsli(String userIsli); |
|||
|
|||
/** |
|||
* 新增用户 |
|||
* @param user |
|||
* @return |
|||
*/ |
|||
int addUser(User user); |
|||
|
|||
/** |
|||
* 更新用户 |
|||
* @param user |
|||
* @return |
|||
*/ |
|||
int updateUser(User user); |
|||
} |
|||
@ -0,0 +1,160 @@ |
|||
<?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="cn.chjyj.szwh.mapper.UserMapper"> |
|||
|
|||
<sql id="column"> |
|||
id,user_isli as userIsli,username,institution_code as institutionCode,agency_type as agencyType, |
|||
cert_type as certType,idNumber,cell_phone as cellPhone,bank_account as bankAccount, |
|||
legals_name as legalsName,legals_type as legalsType,legals_idnum as legalsIdnum, |
|||
legals_phone as legalsPhone,bank_card_type as bankCardType,bank_type as bankType, |
|||
bank_name as bankName,bank_username as bankUsername,bank_userid as bankUserid, |
|||
bank_userphone as bankUserphone,bank_address as bankAddress,attest_status as attestStatus, |
|||
registertime,attesttime |
|||
</sql> |
|||
<sql id="tbName">`user`</sql> |
|||
|
|||
<!--查询记录列表--> |
|||
<select id="getUserList" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.User"> |
|||
WITH mu as ( |
|||
select <include refid="column"/> from <include refid="tbName"/>where id>#{startRs} limit #{pageSize} |
|||
)SELECT * FROM mu ORDER BY id DESC; |
|||
</select> |
|||
|
|||
<!--根据uid查询用户--> |
|||
<!-- <select id="getUserByUid" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.User">--> |
|||
<!-- select--> |
|||
<!-- <include refid="column"/>--> |
|||
<!-- from--> |
|||
<!-- <include refid="tbName"/>--> |
|||
<!-- where uid=#{uid}--> |
|||
<!-- </select>--> |
|||
|
|||
<!--查询用户名,加上密码--> |
|||
<select id="getUserByIsli" parameterType="java.lang.String" resultType="cn.chjyj.szwh.bean.User"> |
|||
select<include refid="column"/>,password |
|||
from |
|||
<include refid="tbName"/> |
|||
where user_isli=#{userIsli} limit 1; |
|||
</select> |
|||
|
|||
<!--查询用户--> |
|||
<select id="getSingleUserByOpenid" parameterType="java.lang.String" resultType="cn.chjyj.szwh.bean.Goods"> |
|||
select |
|||
<include refid="column"/> |
|||
from |
|||
<include refid="tbName"/> |
|||
where openid=#{openid}; |
|||
</select> |
|||
|
|||
<!--新增用户--> |
|||
<insert id="addUser" parameterType="cn.chjyj.szwh.bean.Goods" useGeneratedKeys="true" keyColumn="uid"> |
|||
insert into |
|||
<include refid="tbName"/> |
|||
(user_isli,username,institution_code,agency_type,cert_type,idNumber,cell_phone, |
|||
bank_account,legals_name,legals_type,legals_idnum,legals_phone,bank_card_type, |
|||
bank_type,bank_name,bank_username,bank_userid,bank_userphone,bank_address,attest_status, |
|||
registertime,attesttime |
|||
) |
|||
values ( |
|||
#{userIsli}, |
|||
#{username}, |
|||
#{institutionCode}, |
|||
#{agencyType}, |
|||
#{certType}, |
|||
#{idNumber}, |
|||
#{cellPhone}, |
|||
#{bankAccount}, |
|||
#{legalsName}, |
|||
#{legalsType}, |
|||
#{legalsIdnum}, |
|||
#{legalsPhone}, |
|||
#{bankCardType}, |
|||
#{bankType}, |
|||
#{bankName}, |
|||
#{bankUsername}, |
|||
#{bankUserid}, |
|||
#{bankUserphone}, |
|||
#{bankAddress}, |
|||
#{attestStatus}, |
|||
#{registertime}, |
|||
#{attesttime} |
|||
) |
|||
</insert> |
|||
|
|||
<update id="updateUser" parameterType="cn.chjyj.szwh.bean.Goods"> |
|||
update |
|||
<include refid="tbName"/> |
|||
<set> |
|||
<if test="userIsli!=null"> |
|||
user_isli=#{userIsli}, |
|||
</if> |
|||
<if test="username!=null"> |
|||
username=#{username}, |
|||
</if> |
|||
<if test="institutionCode!=null"> |
|||
institution_code =#{institutionCode}, |
|||
</if> |
|||
<if test="agencyType!=null"> |
|||
agency_type=#{agencyType} |
|||
</if> |
|||
<if test="certType!=null"> |
|||
cert_type=#{certType} |
|||
</if> |
|||
<if test="idNumber!=null"> |
|||
idNumber=#{idNumber} |
|||
</if> |
|||
<if test="cellPhone!=null"> |
|||
cell_phone=#{cellPhone} |
|||
</if> |
|||
<if test="bankAccount!=null"> |
|||
bank_account=#{bankAccount} |
|||
</if> |
|||
<if test="legalsName!=null"> |
|||
legals_name=#{legalsName} |
|||
</if> |
|||
<if test="legalsType!=null"> |
|||
legals_type=#{legalsType} |
|||
</if> |
|||
<if test="legalsIdnum!=null"> |
|||
legals_idnum=#{legalsIdnum} |
|||
</if> |
|||
<if test="legalsPhone!=null"> |
|||
legals_phone=#{legalsPhone} |
|||
</if> |
|||
<if test="bankCardType!=null"> |
|||
bank_card_type=#{bankCardType} |
|||
</if> |
|||
<if test="bankType!=null"> |
|||
bank_type=#{bankType} |
|||
</if> |
|||
<if test="bankName!=null"> |
|||
bank_name=#{bankName} |
|||
</if> |
|||
<if test="bankUsername!=null"> |
|||
bank_username=#{bankUsername} |
|||
</if> |
|||
<if test="bankUserid!=null"> |
|||
bank_userid=#{bankUserid} |
|||
</if> |
|||
<if test="bankUserphone!=null"> |
|||
bank_userphone=#{bankUserphone} |
|||
</if> |
|||
<if test="bankAddress!=null"> |
|||
bank_address=#{bankAddress} |
|||
</if> |
|||
<if test="attestStatus!=null"> |
|||
attest_status=#{attestStatus} |
|||
</if> |
|||
<if test="registertime!=null"> |
|||
registertime=#{registertime} |
|||
</if> |
|||
<if test="attesttime!=null"> |
|||
attesttime=#{} |
|||
</if> |
|||
</set> |
|||
where id=#{id}; |
|||
</update> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,44 @@ |
|||
package cn.chjyj.szwh.mapper; |
|||
|
|||
import cn.chjyj.szwh.bean.User; |
|||
import cn.chjyj.szwh.constant.ChConstant; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.annotation.Rollback; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
@Transactional |
|||
@SpringBootTest |
|||
@RunWith(SpringRunner.class) |
|||
public class UserMapperTest { |
|||
@Autowired |
|||
private UserMapper userMapper; |
|||
|
|||
@Test |
|||
public void getUserList() { |
|||
int stars=0; |
|||
List<User> ulist = userMapper.getUserList(stars, ChConstant.PAGESIZE); |
|||
System.out.println(ulist.size()); |
|||
} |
|||
|
|||
@Test |
|||
public void getUserByIsli() { |
|||
} |
|||
|
|||
@Rollback |
|||
@Test |
|||
public void addUser() { |
|||
} |
|||
|
|||
@Rollback |
|||
@Test |
|||
public void updateUser() { |
|||
} |
|||
} |
|||
Loading…
Reference in new issue