Browse Source

刷数据批量选应用

master
nili 4 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 awesome.group.game.dao.bean.MatrixMockSchedule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import java.util.List;
public interface MatrixMockScheduleMapper extends BaseMapper<MatrixMockSchedule> { public interface MatrixMockScheduleMapper extends BaseMapper<MatrixMockSchedule> {
@Update("update matrix_mock_schedule set status=#{status} where id = #{id}") @Update("update matrix_mock_schedule set status=#{status} where id = #{id}")
int updateStatus(int status, int id); int updateStatus(int status, int id);
@Update("update matrix_mock_schedule set mock_income = mock_income + #{incrMockIncome} where id = #{id}") @Update("update matrix_mock_schedule set mock_income = mock_income + #{incrMockIncome} where id = #{id}")
int updateMockIncome(long incrMockIncome, int 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; import java.util.List;
public class AddMockScheduleReq { public class AddMockScheduleReq {
public Integer appId; public List<Integer> appId;
public Integer incomeYuan; public Integer incomeYuan;
public List<Long> scheduleTime;//毫秒 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.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -312,20 +313,28 @@ public class AdminService {
return data; return data;
} }
public void addMockSchedule(AddMockScheduleReq bo) { public void addMockSchedule(AddMockScheduleReq bo, Integer adminId) {
MatrixApp app = appMapper.selectById(bo.appId); MatrixAdmin admin = adminMapper.selectById(adminId);
if (app == null || !StringUtils.hasText(app.getChannel())) { Assert.isTrue(admin != null && admin.getRole() == SUPER_ADMIN, "非法请求");
throw new PaganiException(PaganiExceptionCode.ILLEGAL_REQUEST, "应用不存在或渠道为空"); Assert.isTrue(!CollectionUtils.isEmpty(bo.scheduleTime), "时间不能为空");
} Assert.isTrue(!CollectionUtils.isEmpty(bo.appId), "应用不能为空");
bo.scheduleTime.forEach(x -> { List<MatrixMockSchedule> list = new ArrayList<>();
MatrixMockSchedule schedule = new MatrixMockSchedule(); for(Integer appId: bo.appId) {
schedule.setAppId(bo.appId); MatrixApp app = appMapper.selectById(appId);
schedule.setScheduleTime(new Timestamp(x)); if (app == null || !StringUtils.hasText(app.getChannel())) {
schedule.setChannel(app.getChannel()); throw new PaganiException(PaganiExceptionCode.ILLEGAL_REQUEST, "应用不存在或渠道为空");
schedule.setIncomeYuan(bo.incomeYuan); }
mockScheduleMapper.insert(schedule); 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) { 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") @PostMapping("/addSchedule")
@RestApi @RestApi
public R<Void> addSchedule(@RequestBody AddMockScheduleReq bo) { public R<Void> addSchedule(@RequestBody AddMockScheduleReq bo) {
adminService.addMockSchedule(bo); adminService.addMockSchedule(bo, RequestContext.getAdminID());
return new R<>(R.CODE_SUCCESS, "ok", null); return new R<>(R.CODE_SUCCESS, "ok", null);
} }

Loading…
Cancel
Save