Browse Source

刷数据批量选应用

master
nili 7 months ago
parent
commit
aa7fbc8166
  1. 9
      game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixMockScheduleMapper.java
  2. 2
      game-service/src/main/java/awesome/group/game/service/bo/AddMockScheduleReq.java
  3. 35
      game-service/src/main/java/awesome/group/game/service/matrix/AdminService.java
  4. 2
      game-web/src/main/java/awesome/group/game/web/rest/matrix/AdminController.java

9
game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixMockScheduleMapper.java

@ -2,12 +2,21 @@ package awesome.group.game.dao.mapper;
import awesome.group.game.dao.bean.MatrixMockSchedule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import java.util.List;
public interface MatrixMockScheduleMapper extends BaseMapper<MatrixMockSchedule> {
@Update("update matrix_mock_schedule set status=#{status} where id = #{id}")
int updateStatus(int status, int id);
@Update("update matrix_mock_schedule set mock_income = mock_income + #{incrMockIncome} where id = #{id}")
int updateMockIncome(long incrMockIncome, int id);
@Insert("<script>insert into matrix_mock_schedule (app_id, channel, income_yuan, schedule_time) values " +
"<foreach collection='scheduleList' item='item' index='index' separator=','>" +
"(#{item.appId}, #{item.channel}, #{item.incomeYuan}, #{item.scheduleTime})" +
"</foreach></script>")
int insertBatch(List<MatrixMockSchedule> scheduleList);
}

2
game-service/src/main/java/awesome/group/game/service/bo/AddMockScheduleReq.java

@ -3,7 +3,7 @@ package awesome.group.game.service.bo;
import java.util.List;
public class AddMockScheduleReq {
public Integer appId;
public List<Integer> appId;
public Integer incomeYuan;
public List<Long> scheduleTime;//毫秒
}

35
game-service/src/main/java/awesome/group/game/service/matrix/AdminService.java

@ -23,6 +23,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -312,20 +313,28 @@ public class AdminService {
return data;
}
public void addMockSchedule(AddMockScheduleReq bo) {
MatrixApp app = appMapper.selectById(bo.appId);
if (app == null || !StringUtils.hasText(app.getChannel())) {
throw new PaganiException(PaganiExceptionCode.ILLEGAL_REQUEST, "应用不存在或渠道为空");
}
bo.scheduleTime.forEach(x -> {
MatrixMockSchedule schedule = new MatrixMockSchedule();
schedule.setAppId(bo.appId);
schedule.setScheduleTime(new Timestamp(x));
schedule.setChannel(app.getChannel());
schedule.setIncomeYuan(bo.incomeYuan);
mockScheduleMapper.insert(schedule);
});
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<MatrixMockSchedule> list = new ArrayList<>();
for(Integer appId: bo.appId) {
MatrixApp app = appMapper.selectById(appId);
if (app == null || !StringUtils.hasText(app.getChannel())) {
throw new PaganiException(PaganiExceptionCode.ILLEGAL_REQUEST, "应用不存在或渠道为空");
}
bo.scheduleTime.forEach(x -> {
MatrixMockSchedule schedule = new MatrixMockSchedule();
schedule.setAppId(appId);
schedule.setScheduleTime(new Timestamp(x));
schedule.setChannel(app.getChannel());
schedule.setIncomeYuan(bo.incomeYuan);
list.add(schedule);
});
}
mockScheduleMapper.insertBatch(list);
}
public OverviewBo incomeOverview(int adminId, String code) {

2
game-web/src/main/java/awesome/group/game/web/rest/matrix/AdminController.java

@ -133,7 +133,7 @@ public class AdminController {
@PostMapping("/addSchedule")
@RestApi
public R<Void> addSchedule(@RequestBody AddMockScheduleReq bo) {
adminService.addMockSchedule(bo);
adminService.addMockSchedule(bo, RequestContext.getAdminID());
return new R<>(R.CODE_SUCCESS, "ok", null);
}

Loading…
Cancel
Save