|
|
@@ -0,0 +1,224 @@
|
|
|
+package com.fs.live.controller;
|
|
|
+
|
|
|
+import com.fs.common.annotation.Log;
|
|
|
+import com.fs.common.core.controller.BaseController;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
+import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.company.mapper.CompanyUserMapper;
|
|
|
+import com.fs.live.domain.Live;
|
|
|
+import com.fs.live.domain.LiveTrainingCamp;
|
|
|
+import com.fs.live.domain.LiveTrainingPeriod;
|
|
|
+import com.fs.live.param.LiveTrainingLiveAuditBody;
|
|
|
+import com.fs.live.service.ILiveService;
|
|
|
+import com.fs.live.service.ILiveTrainingCampService;
|
|
|
+import com.fs.live.service.ILiveTrainingPeriodService;
|
|
|
+import com.fs.live.vo.TrainingLiveAuditVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 总后台:直播训练营 / 营期 / 营期直播间(跨企业)及训练营直播间审核
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/live/trainingCamp/admin")
|
|
|
+public class LiveTrainingCampAdminController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ILiveTrainingCampService liveTrainingCampService;
|
|
|
+ @Autowired
|
|
|
+ private ILiveTrainingPeriodService liveTrainingPeriodService;
|
|
|
+ @Autowired
|
|
|
+ private ILiveService liveService;
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserMapper companyUserMapper;
|
|
|
+
|
|
|
+ // ---------- 训练营 ----------
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:list')")
|
|
|
+ @GetMapping("/camp/list")
|
|
|
+ public TableDataInfo campList(LiveTrainingCamp query) {
|
|
|
+ startPage();
|
|
|
+ List<LiveTrainingCamp> list = liveTrainingCampService.selectLiveTrainingCampListAdmin(query);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:query')")
|
|
|
+ @GetMapping("/camp/{campId}")
|
|
|
+ public AjaxResult getCamp(@PathVariable Long campId, @RequestParam(required = false) Long companyId) {
|
|
|
+ LiveTrainingCamp c = liveTrainingCampService.selectLiveTrainingCampByIdForAdmin(campId, companyId);
|
|
|
+ return c != null ? AjaxResult.success(c) : AjaxResult.error("训练营不存在或无权限");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:add')")
|
|
|
+ @Log(title = "总后台直播训练营", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/camp")
|
|
|
+ public AjaxResult addCamp(@RequestBody LiveTrainingCamp camp) {
|
|
|
+ if (camp.getCompanyId() == null) {
|
|
|
+ return AjaxResult.error("请选择企业");
|
|
|
+ }
|
|
|
+ camp.setCreateBy(getUsername());
|
|
|
+ camp.setCreateTime(new java.util.Date());
|
|
|
+ if (camp.getSortOrder() == null) {
|
|
|
+ camp.setSortOrder(0);
|
|
|
+ }
|
|
|
+ if (camp.getStatus() == null) {
|
|
|
+ camp.setStatus(0);
|
|
|
+ }
|
|
|
+ return toAjax(liveTrainingCampService.insertLiveTrainingCamp(camp));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:edit')")
|
|
|
+ @Log(title = "总后台直播训练营", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/camp")
|
|
|
+ public AjaxResult editCamp(@RequestBody LiveTrainingCamp camp) {
|
|
|
+ if (camp.getCampId() == null || camp.getCompanyId() == null) {
|
|
|
+ return AjaxResult.error("参数不完整");
|
|
|
+ }
|
|
|
+ camp.setUpdateBy(getUsername());
|
|
|
+ camp.setUpdateTime(new java.util.Date());
|
|
|
+ return toAjax(liveTrainingCampService.updateLiveTrainingCamp(camp));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:remove')")
|
|
|
+ @Log(title = "总后台直播训练营", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/camp/{campIds}")
|
|
|
+ public AjaxResult removeCamp(@PathVariable Long[] campIds, @RequestParam Long companyId) {
|
|
|
+ return toAjax(liveTrainingCampService.deleteLiveTrainingCampByIds(campIds, companyId, null));
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---------- 营期 ----------
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:list')")
|
|
|
+ @GetMapping("/period/list")
|
|
|
+ public TableDataInfo periodList(LiveTrainingPeriod query) {
|
|
|
+ startPage();
|
|
|
+ List<LiveTrainingPeriod> list = liveTrainingPeriodService.selectLiveTrainingPeriodListAdmin(query);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:query')")
|
|
|
+ @GetMapping("/period/{periodId}")
|
|
|
+ public AjaxResult getPeriod(@PathVariable Long periodId, @RequestParam(required = false) Long companyId) {
|
|
|
+ LiveTrainingPeriod p = liveTrainingPeriodService.selectLiveTrainingPeriodByIdForAdmin(periodId, companyId);
|
|
|
+ if (p == null) {
|
|
|
+ return AjaxResult.error("营期不存在或无权限");
|
|
|
+ }
|
|
|
+ LiveTrainingCamp camp = liveTrainingCampService.selectLiveTrainingCampByIdForAdmin(p.getCampId(), null);
|
|
|
+ if (camp != null) {
|
|
|
+ p.setCompanyId(camp.getCompanyId());
|
|
|
+ }
|
|
|
+ return AjaxResult.success(p);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:add')")
|
|
|
+ @Log(title = "总后台直播营期", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/period")
|
|
|
+ public AjaxResult addPeriod(@RequestBody LiveTrainingPeriod period) {
|
|
|
+ if (period.getCampId() == null) {
|
|
|
+ return AjaxResult.error("请选择训练营");
|
|
|
+ }
|
|
|
+ LiveTrainingCamp camp = liveTrainingCampService.selectLiveTrainingCampByIdForAdmin(period.getCampId(), null);
|
|
|
+ if (camp == null) {
|
|
|
+ return AjaxResult.error("训练营不存在");
|
|
|
+ }
|
|
|
+ period.setCompanyId(camp.getCompanyId());
|
|
|
+ period.setCreateBy(camp.getCreateBy());
|
|
|
+ period.setCreateTime(new java.util.Date());
|
|
|
+ if (period.getSortOrder() == null) {
|
|
|
+ period.setSortOrder(0);
|
|
|
+ }
|
|
|
+ if (period.getStatus() == null) {
|
|
|
+ period.setStatus(0);
|
|
|
+ }
|
|
|
+ return toAjax(liveTrainingPeriodService.insertLiveTrainingPeriod(period));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:edit')")
|
|
|
+ @Log(title = "总后台直播营期", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/period")
|
|
|
+ public AjaxResult editPeriod(@RequestBody LiveTrainingPeriod period) {
|
|
|
+ if (period.getPeriodId() == null || period.getCompanyId() == null) {
|
|
|
+ return AjaxResult.error("参数不完整");
|
|
|
+ }
|
|
|
+ period.setUpdateBy(getUsername());
|
|
|
+ period.setUpdateTime(new java.util.Date());
|
|
|
+ return toAjax(liveTrainingPeriodService.updateLiveTrainingPeriod(period));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:remove')")
|
|
|
+ @Log(title = "总后台直播营期", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/period/{periodIds}")
|
|
|
+ public AjaxResult removePeriod(@PathVariable Long[] periodIds, @RequestParam Long companyId) {
|
|
|
+ return toAjax(liveTrainingPeriodService.deleteLiveTrainingPeriodByIds(periodIds, companyId, null));
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---------- 营期下直播间 ----------
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:list')")
|
|
|
+ @GetMapping("/live/list")
|
|
|
+ public TableDataInfo trainingLiveList(Live query, @RequestParam Long companyId) {
|
|
|
+ if (query.getTrainingPeriodId() == null) {
|
|
|
+ return getDataTable(Collections.emptyList());
|
|
|
+ }
|
|
|
+ LiveTrainingPeriod p = liveTrainingPeriodService.selectLiveTrainingPeriodByIdForAdmin(
|
|
|
+ query.getTrainingPeriodId(), companyId);
|
|
|
+ if (p == null) {
|
|
|
+ return getDataTable(Collections.emptyList());
|
|
|
+ }
|
|
|
+ query.setCompanyId(companyId);
|
|
|
+ List<CompanyUser> users = companyUserMapper.selectCompanyUserByCompanyId(companyId);
|
|
|
+ if (users != null && !users.isEmpty()) {
|
|
|
+ query.setCompanyUserId(users.get(0).getUserId());
|
|
|
+ }
|
|
|
+ startPage();
|
|
|
+ List<Live> list = liveService.selectLiveList(query);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:live:add')")
|
|
|
+ @Log(title = "总后台训练营直播间", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/live")
|
|
|
+ public AjaxResult addTrainingLive(@RequestBody Live live, @RequestParam Long companyId) {
|
|
|
+ if (StringUtils.isEmpty(live.getCreateBy())) {
|
|
|
+ live.setCreateBy(String.valueOf(getUserId()));
|
|
|
+ }
|
|
|
+ return toAjax(liveTrainingPeriodService.insertTrainingLiveForAdmin(live, companyId));
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---------- 训练营直播间审核 ----------
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:audit:list')")
|
|
|
+ @GetMapping("/live/auditList")
|
|
|
+ public TableDataInfo auditList(Live query) {
|
|
|
+ startPage();
|
|
|
+ List<TrainingLiveAuditVO> list = liveService.selectTrainingLiveAuditList(query);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('live:trainingCampAdmin:audit:edit')")
|
|
|
+ @Log(title = "训练营直播间审核", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/live/audit")
|
|
|
+ public AjaxResult audit(@RequestBody LiveTrainingLiveAuditBody body) {
|
|
|
+ if (body == null || body.getLiveId() == null || body.getPassed() == null) {
|
|
|
+ return AjaxResult.error("参数不完整");
|
|
|
+ }
|
|
|
+ Live db = liveService.selectLiveDbByLiveId(body.getLiveId());
|
|
|
+ if (db == null || db.getTrainingPeriodId() == null) {
|
|
|
+ return AjaxResult.error("仅支持训练营直播间审核");
|
|
|
+ }
|
|
|
+ Live upd = new Live();
|
|
|
+ upd.setLiveId(body.getLiveId());
|
|
|
+ upd.setIsAudit(Boolean.TRUE.equals(body.getPassed()) ? 1 : 2);
|
|
|
+ if (StringUtils.isNotEmpty(body.getRemark())) {
|
|
|
+ upd.setRemark(body.getRemark());
|
|
|
+ }
|
|
|
+ return toAjax(liveService.updateLive(upd));
|
|
|
+ }
|
|
|
+}
|