springmvc Mapper注解写法

package cn.com.chinautrust.idm.repo.mybatis.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

import cn.com.chinautrust.idm.bo.user.AdminVO;
import cn.com.chinautrust.idm.repo.mybatis.base.IBaseMapper;
import cn.com.chinautrust.idm.repo.mybatis.provider.AdminVOProvider;

public interface IAdminMapper extends IBaseMapper<AdminVO>{

    @Options(useGeneratedKeys=true)
    @Insert("INSERT INTO ADMIN_INFO(adminName, adminLoginName, adminRole, deptName, pwd, lastTime, deptCodeLimit, deptCodeSkip) VALUES(#{adminName}, #{adminLoginName}, #{adminRole}, #{deptName}, #{pwd}, #{lastTime}, #{deptCodeLimit}, #{deptCodeSkip})")
    public int insert(AdminVO bean);
    
    @UpdateProvider(type = AdminVOProvider.class, method="update")
    public void update(AdminVO bean);
    
    @Delete("DELETE FROM ADMIN_INFO WHERE id = #{value}")
    public void delById(Integer id);
    
    @ResultType(AdminVO.class)
    @Select("SELECT id, adminName,adminLoginName,adminRole,deptName,pwd,lastTime,deptCodeLimit,deptCodeSkip  FROM ADMIN_INFO where id=#{value}")
    public AdminVO findOneById(Integer id);
    
    @ResultType(AdminVO.class)
    @SelectProvider(type = AdminVOProvider.class, method="findListByBean")
    public List<AdminVO> findListByBean(AdminVO bean);
    
    @Select("SELECT COUNT(*)  FROM ADMIN_INFO where ${value}")
    public long countBySql(String sql);
    
    @ResultType(AdminVO.class)
    @SelectProvider(type = AdminVOProvider.class, method="findListBySql")
    public List<AdminVO> findListBySql(String sql, String contextSql);
    
    @ResultType(AdminVO.class)
    @Select("SELECT id, adminName,adminLoginName,adminRole,deptName,pwd,lastTime,deptCodeLimit,deptCodeSkip  FROM ADMIN_INFO where deptName=#{value} ORDER BY lastTime DESC")
    List<AdminVO> getAllAdminDeptId(String deptName);
    
    @Delete("DELETE FROM ADMIN_INFO WHERE adminLoginName=#{value}")
    void delAdminByLoginName(String loginName);
    
    @Delete("DELETE FROM ADMIN_INFO WHERE deptName like #{value}")
    void delAdminByDeptDn(String deptDn);
    
    @ResultType(AdminVO.class)
    @Select("SELECT id, adminName,adminLoginName,adminRole,deptName,pwd,lastTime,deptCodeLimit,deptCodeSkip  FROM ADMIN_INFO where ${value}")
    List<AdminVO> find(String queryString);
    
    @Update("UPDATE ADMIN_INFO set PWD=#{pwd}, ADMINNAME=#{adminName}, ADMINROLE=#{adminRole}, LASTTIME=#{lastTime} where adminLoginName=#{adminLoginName}")
    void updateAdminByLoginName(AdminVO adminVo);
    
    @ResultType(AdminVO.class)
    @Select("SELECT id, adminName,adminLoginName,adminRole,deptName,pwd,lastTime,deptCodeLimit,deptCodeSkip  FROM ADMIN_INFO where adminLoginName=#{0} and pwd=#{1}")
    List<AdminVO> getAdminByLoginNameAndPwd(String loginName, String pwd);
    
    @ResultType(AdminVO.class)
    @Select("SELECT id, adminName,adminLoginName,adminRole,deptName,pwd,lastTime,deptCodeLimit,deptCodeSkip  FROM ADMIN_INFO where adminLoginName=#{value}")
    List<AdminVO> getAdminByLoginName(String loginName);
    
    @Update("UPDATE ADMIN_INFO set pwd=#{newpassword} where adminLoginName=#{loginName} and pwd=#{oldpassword}")
    int updatePersonPwd(@Param("loginName") String loginName, @Param("oldpassword") String oldpassword, @Param("newpassword") String newpassword);
    
    
}

 

转载于:https://www.cnblogs.com/cuijinlong/p/9605595.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值