|
|
package com.example.demo.mapper;
import com.example.demo.domain.entity.User; import com.example.demo.domain.entity.UserGold; import com.example.demo.domain.vo.UserVo; import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper public interface UserMapper { @Select({ "select jwcode from user" }) List<String> selectJwcode(); @Select({ "<script>", "select name from user", "<where>", "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>", "</where>", "</script>" }) User select(String user); @Select({ "<script>", "select * from user_gold", "<where>", "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>", "</where>", "</script>" }) UserGold selectGold(String userGold); @Select({ "<script>", "select * from user", "<where>", "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>", "</where>", "</script>" }) User get(String jwcode);
@Select({ "SELECT\n" + " u.*,user.name,user.area," + " MIN(d.create_time) AS first_recharge_date, \n" + " SUM(CASE WHEN d.update_type = '0' THEN d.recharge_coin ELSE 0 END) AS total_recharge_gold, \n" + " SUM(CASE WHEN d.update_type = '1' THEN d.recharge_coin ELSE 0 END) AS total_spend_gold, \n" + " COUNT(CASE WHEN d.update_type = '0' THEN 1 END) AS recharge_times, \n" + " COUNT(CASE WHEN d.update_type = '1' THEN 1 END) AS spend_times, \n" + " COUNT(CASE WHEN a.status = 0 AND d.update_type = '0' THEN 1 END) AS pending_recharge_times, \n" + " COUNT(CASE WHEN a.status = 0 AND d.update_type = '1' THEN 1 END) AS pending_spend_times \n" + "FROM\n" + " user_gold u\n" + "LEFT JOIN user on user.jwcode=u.jwcode", "LEFT JOIN\n" + " detail d ON u.jwcode = d.jwcode\n" + "LEFT JOIN\n" + " audit a ON d.detail_id = a.detail_id AND a.audit_flag = 1\n" + "WHERE\n" + " u.jwcode =#{jwcode}\n" }) UserVo selectA(UserVo userVo);
@Select({ "<script>", "select * from user", "<where>", "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>", "</where>", "</script>" }) List<User> selectAll(User user); @Select({ "select * from user where name=#{name}" }) User selectByName(String name); @Select({ "select * from user_gold where jwcode=#{jwcode}" }) User selectByJwcode(String jwcode);
@Update({ "<script>", "update user_gold", "<set>", "<if test='buyJb!=null'>buy_jb=#{buyJb},</if>", "<if test='coreJb!=null'>core_jb=#{coreJb},</if>", "<if test='free6!=null'>free_6=#{free6},</if>", "<if test='free12!=null'>free_12=#{free12},</if>", "</set>", "where jwcode=#{jwcode}", "</script>", }) int update(User user); @Update({ "<script>", "update user_gold", "<set>", "<if test='buyJb!=null'>buy_jb=#{buyJb},</if>", "<if test='coreJb!=null'>core_jb=#{coreJb},</if>", "<if test='free6!=null'>free_6=#{free6},</if>", "<if test='free12!=null'>free_12=#{free12},</if>", "last_time= now()", "</set>", "where jwcode=#{jwcode}", "</script>", }) int updateGold(UserGold userGold);
@Select({ "SELECT DISTINCT area FROM `user`" }) List<String> selectArea();
// //去掉免费金币,先去6个月,再去12月
// @Update({
// "<script>",
// "update user",
// "<set>",
// "<if test='Free6!=null'>free_6=#{Free6},</if>",
// "<if test='Free12!=null'>free_12=#{Free12},</if>",
// "</set>",
// "where jwcode=#{jwcode}",
// "</script>",
// })
// int updatecoin();
}
|