|
@@ -448,6 +448,9 @@ public class UsersService extends AbstractService {
|
|
|
return userPrepareRelationList;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, String> adminMap = new HashMap<String, String>(){{
|
|
|
+ put("", "u");
|
|
|
+ }};
|
|
|
/**
|
|
|
* 获取购买过课程的用户
|
|
|
* @param page
|
|
@@ -456,9 +459,23 @@ public class UsersService extends AbstractService {
|
|
|
* @param courseId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Page<User> listByCourse(int page, int pageSize, String keyword, Integer courseId){
|
|
|
+ public Page<User> listAdminByCourse(int page, int pageSize, String keyword, Integer courseId, String order, DirectionStatus direction){
|
|
|
+ if(order == null || order.isEmpty()){
|
|
|
+ order = "id";
|
|
|
+ }
|
|
|
+ order = Tools.underscoreName(order);
|
|
|
+ if(adminMap.containsKey(order)){
|
|
|
+ order = adminMap.get(order)+".`"+order+"`";
|
|
|
+ }else{
|
|
|
+ order = adminMap.get("")+".`"+order+"`";
|
|
|
+ }
|
|
|
+ if (direction == null){
|
|
|
+ direction = DirectionStatus.DESC;
|
|
|
+ }
|
|
|
+ String finalOrder = order;
|
|
|
+ DirectionStatus finalDirection = direction;
|
|
|
Page<User> p = page(()->{
|
|
|
- userRelationMapper.listByCourse(keyword, courseId);
|
|
|
+ userRelationMapper.listByCourse(keyword, courseId, finalOrder, finalDirection.key);
|
|
|
}, page, pageSize);
|
|
|
|
|
|
Collection ids = Transform.getIds(p, User.class, "id");
|
|
@@ -488,6 +505,52 @@ public class UsersService extends AbstractService {
|
|
|
userRelationMapper.accumulation(userId, money);
|
|
|
}
|
|
|
|
|
|
+ public Page<User> listAdmin(int page, int pageSize, String keyword, Boolean real, Boolean wechat, Boolean prepare, String startTime, String endTime, String order, DirectionStatus direction){
|
|
|
+ Example example = new Example(User.class);
|
|
|
+ if(keyword != null)
|
|
|
+ example.and(
|
|
|
+ example.createCriteria()
|
|
|
+ .orLike("id", "%"+keyword+"%")
|
|
|
+ .orLike("mobile", "%"+keyword+"%")
|
|
|
+ );
|
|
|
+ if (real != null)
|
|
|
+ example.and(
|
|
|
+ example.createCriteria().andEqualTo("realStatus", real?1:0)
|
|
|
+ );
|
|
|
+ if (wechat != null)
|
|
|
+ example.and(
|
|
|
+ wechat ? example.createCriteria().andNotEqualTo("wechatUnionid", "") : example.createCriteria().andEqualTo("wechatUnionid", "")
|
|
|
+ );
|
|
|
+ if (prepare != null)
|
|
|
+ example.and(
|
|
|
+ prepare ? example.createCriteria().andIsNotNull("prepareTime"):example.createCriteria().andIsNull("prepareTime")
|
|
|
+ );
|
|
|
+ if (startTime != null){
|
|
|
+ example.and(
|
|
|
+ example.createCriteria().andGreaterThanOrEqualTo("createTime", startTime)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if(endTime != null){
|
|
|
+ example.and(
|
|
|
+ example.createCriteria().andLessThan("createTime", endTime)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if(order==null||order.isEmpty()) order = "id";
|
|
|
+ if (direction != null){
|
|
|
+ switch(direction){
|
|
|
+ case ASC:
|
|
|
+ example.orderBy(order).asc();
|
|
|
+ break;
|
|
|
+ case DESC:
|
|
|
+ default:
|
|
|
+ example.orderBy(order).desc();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ example.orderBy(order).desc();
|
|
|
+ }
|
|
|
+ return select(userMapper, example, page, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
public boolean equalsPassword(User user, String password){
|
|
|
return Objects.equals(user.getPassword(), Tools.stringMD5(Tools.stringMD5(password)));
|
|
|
}
|
|
@@ -539,51 +602,6 @@ public class UsersService extends AbstractService {
|
|
|
|
|
|
public Page<User> select(int page, int pageSize){return select(userMapper, page, pageSize);
|
|
|
}
|
|
|
- public Page<User> select(int page, int pageSize, String keyword, Boolean real, Boolean wechat, Boolean prepare, String startTime, String endTime, String order, DirectionStatus direction){
|
|
|
- Example example = new Example(User.class);
|
|
|
- if(keyword != null)
|
|
|
- example.and(
|
|
|
- example.createCriteria()
|
|
|
- .orLike("id", "%"+keyword+"%")
|
|
|
- .orLike("mobile", "%"+keyword+"%")
|
|
|
- );
|
|
|
- if (real != null)
|
|
|
- example.and(
|
|
|
- example.createCriteria().andEqualTo("realStatus", real?1:0)
|
|
|
- );
|
|
|
- if (wechat != null)
|
|
|
- example.and(
|
|
|
- wechat ? example.createCriteria().andNotEqualTo("wechatUnionid", "") : example.createCriteria().andEqualTo("wechatUnionid", "")
|
|
|
- );
|
|
|
- if (prepare != null)
|
|
|
- example.and(
|
|
|
- prepare ? example.createCriteria().andIsNotNull("prepareTime"):example.createCriteria().andIsNull("prepareTime")
|
|
|
- );
|
|
|
- if (startTime != null){
|
|
|
- example.and(
|
|
|
- example.createCriteria().andGreaterThanOrEqualTo("createTime", startTime)
|
|
|
- );
|
|
|
- }
|
|
|
- if(endTime != null){
|
|
|
- example.and(
|
|
|
- example.createCriteria().andLessThan("createTime", endTime)
|
|
|
- );
|
|
|
- }
|
|
|
- if(order==null||order.isEmpty()) order = "id";
|
|
|
- if (direction != null){
|
|
|
- switch(direction){
|
|
|
- case ASC:
|
|
|
- example.orderBy(order).asc();
|
|
|
- break;
|
|
|
- case DESC:
|
|
|
- default:
|
|
|
- example.orderBy(order).desc();
|
|
|
- }
|
|
|
- } else {
|
|
|
- example.orderBy(order).desc();
|
|
|
- }
|
|
|
- return select(userMapper, example, page, pageSize);
|
|
|
- }
|
|
|
|
|
|
public Page<User> select(Integer[] ids){
|
|
|
return page(()->select(userMapper, ids), 1, ids.length);
|