|
|
@ -1,25 +1,25 @@ |
|
|
|
package awesome.group.game.service.matrix; |
|
|
|
|
|
|
|
import awesome.group.game.dao.bean.MatrixApp; |
|
|
|
import awesome.group.game.dao.bean.MatrixEvilApp; |
|
|
|
import awesome.group.game.dao.bean.MatrixUser; |
|
|
|
import awesome.group.game.dao.bean.MatrixWhiteUser; |
|
|
|
import awesome.group.game.dao.mapper.MatrixAppMapper; |
|
|
|
import awesome.group.game.dao.mapper.MatrixEvilAppMapper; |
|
|
|
import awesome.group.game.dao.mapper.MatrixUserMapper; |
|
|
|
import awesome.group.game.dao.mapper.MatrixWhiteUserMapper; |
|
|
|
import awesome.group.game.dao.bean.*; |
|
|
|
import awesome.group.game.dao.mapper.*; |
|
|
|
import awesome.group.game.service.bo.AddMockScheduleReq; |
|
|
|
import awesome.group.game.service.bo.matrix.WhiteUserBo; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.sql.Timestamp; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static awesome.group.game.service.util.Constants.SUPER_ADMIN; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class SuperAdminService { |
|
|
|
|
|
|
@ -29,12 +29,21 @@ public class SuperAdminService { |
|
|
|
@Autowired |
|
|
|
private MatrixWhiteUserMapper whiteUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MatrixInnerUserMapper innerUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MatrixUserMapper userMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MatrixAppMapper appMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MatrixAdminMapper adminMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MatrixMockScheduleV2Mapper mockScheduleV2Mapper; |
|
|
|
|
|
|
|
public List<MatrixEvilApp> evilAppList() { |
|
|
|
List<MatrixEvilApp> app = evilAppMapper.selectList(null); |
|
|
|
Collections.reverse(app); |
|
|
@ -68,6 +77,26 @@ public class SuperAdminService { |
|
|
|
return Lists.reverse(res); |
|
|
|
} |
|
|
|
|
|
|
|
public List<WhiteUserBo> innerUserList() { |
|
|
|
List<MatrixInnerUser> list = innerUserMapper.selectList(null); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<Integer> userIds = list.stream().map(MatrixInnerUser::getUserId).toList(); |
|
|
|
List<MatrixUser> users = userMapper.selectBatchIds(userIds); |
|
|
|
List<Integer> appIds = users.stream().map(MatrixUser::getAppId).toList(); |
|
|
|
List<MatrixApp> apps = appMapper.selectBatchIds(appIds); |
|
|
|
Map<Integer, MatrixUser> uMap = users.stream().collect(Collectors.toMap(MatrixUser::getId, x -> x)); |
|
|
|
Map<Integer, MatrixApp> aMap = apps.stream().collect(Collectors.toMap(MatrixApp::getId, x -> x)); |
|
|
|
List<WhiteUserBo> res = new ArrayList<>(); |
|
|
|
for (MatrixInnerUser r : list) { |
|
|
|
MatrixUser u = uMap.get(r.getUserId()); |
|
|
|
res.add(new WhiteUserBo(r, u, aMap.get(u.getAppId()))); |
|
|
|
} |
|
|
|
return Lists.reverse(res); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void saveWhiteUser(Integer userId, Integer status) { |
|
|
|
MatrixWhiteUser r = whiteUserMapper.queryByUserId(userId); |
|
|
|
MatrixWhiteUser update = new MatrixWhiteUser(); |
|
|
@ -81,5 +110,39 @@ public class SuperAdminService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void saveInnerUser(Integer userId) { |
|
|
|
if (innerUserMapper.queryByUserId(userId) != null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
MatrixUser u = userMapper.selectById(userId); |
|
|
|
MatrixInnerUser innerUser = new MatrixInnerUser(); |
|
|
|
innerUser.setAppId(u.getAppId()); |
|
|
|
innerUser.setUserId(userId); |
|
|
|
innerUserMapper.insert(innerUser); |
|
|
|
} |
|
|
|
|
|
|
|
public List<MatrixMockScheduleV2> mockScheduleList() { |
|
|
|
return mockScheduleV2Mapper.selectList(new QueryWrapper<MatrixMockScheduleV2>().last("order by id desc limit 200")); |
|
|
|
} |
|
|
|
|
|
|
|
public void addMockSchedule(AddMockScheduleReq bo, Integer adminId) { |
|
|
|
MatrixAdmin admin = adminMapper.selectById(adminId); |
|
|
|
Assert.isTrue(admin != null && admin.getRole() == SUPER_ADMIN, "非法请求"); |
|
|
|
Assert.isTrue(!CollectionUtils.isEmpty(bo.scheduleTime), "时间不能为空"); |
|
|
|
Assert.isTrue(!CollectionUtils.isEmpty(bo.appId), "应用不能为空"); |
|
|
|
List<MatrixMockScheduleV2> list = new ArrayList<>(); |
|
|
|
for (Integer appId : bo.appId) { |
|
|
|
bo.scheduleTime.forEach(x -> { |
|
|
|
MatrixMockScheduleV2 schedule = new MatrixMockScheduleV2(); |
|
|
|
schedule.setAppId(appId); |
|
|
|
schedule.setScheduleTime(new Timestamp(x)); |
|
|
|
schedule.setIncomeYuan(bo.incomeYuan); |
|
|
|
list.add(schedule); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
mockScheduleV2Mapper.insertBatch(list); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|