| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- package com.ym.mec.web.controller;
- import com.ym.mec.auth.api.client.SysUserFeignService;
- import com.ym.mec.auth.api.entity.SysUser;
- import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
- import com.ym.mec.biz.dal.dao.EmployeeDao;
- import com.ym.mec.biz.dal.entity.Employee;
- import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
- import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
- import com.ym.mec.biz.dal.entity.StudentRegistration;
- import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
- import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
- import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
- import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
- import com.ym.mec.common.controller.BaseController;
- import com.ym.mec.common.entity.HttpResponseResult;
- import com.ym.mec.common.exception.BizException;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.MediaType;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.ui.ModelMap;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.bind.annotation.*;
- import java.util.*;
- import java.util.stream.Collectors;
- @RequestMapping("musicGroupPaymentCalender")
- @Api(tags = "乐团缴费日历服务")
- @RestController
- public class MusicGroupPaymentCalenderController extends BaseController {
- @Autowired
- private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
- @Autowired
- private MusicGroupPaymentCalenderCourseSettingsService musicGroupPaymentCalenderCourseSettingsService;
- @Autowired
- private SysUserFeignService sysUserFeignService;
- @Autowired
- private EmployeeDao employeeDao;
- @Autowired
- private ClassGroupStudentMapperDao classGroupStudentMapperDao;
- @ApiOperation(value = "分页查询乐团缴费日历列表")
- @GetMapping(value = "/queryPage", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/queryPage')")
- public Object queryPage(MusicGroupPaymentCalenderQueryInfo queryInfo) {
- return succeed(musicGroupPaymentCalenderService.queryPage(queryInfo));
- }
- @ApiOperation(value = "获取缴费信息")
- @GetMapping("/getDetail")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getDetail')")
- public Object getDetail(Long id) {
- return succeed(musicGroupPaymentCalenderService.getDetail(id));
- }
- @ApiOperation(value = "新增乐团缴费日历")
- @PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/add')")
- public Object add(@RequestBody MusicGroupPaymentCalender musicGroupPaymentCalender) {
- Long musicGroupPaymentCalenderId = musicGroupPaymentCalenderService.create(musicGroupPaymentCalender);
- ModelMap map = new ModelMap();
- map.put("musicGroupPaymentCalenderId", musicGroupPaymentCalenderId);
- return succeed(map);
- }
- @ApiOperation(value = "删除乐团缴费日历")
- @PostMapping("/del")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/del')")
- public Object del(Long id) {
- musicGroupPaymentCalenderService.del(id);
- return succeed();
- }
- @ApiOperation(value = "修改乐团缴费时间")
- @PostMapping("/update")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/update')")
- public Object update(@RequestBody MusicGroupPaymentCalender paymentCalender) {
- Long musicGroupPaymentCalenderId = musicGroupPaymentCalenderService.merge(paymentCalender);
- ModelMap map = new ModelMap();
- map.put("musicGroupPaymentCalenderId", musicGroupPaymentCalenderId);
- return succeed();
- }
- @ApiOperation(value = "乐团缴费日历审核列表")
- @GetMapping("/auditList")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/auditList')")
- public Object auditList(MusicGroupPaymentCalenderQueryInfo queryInfo) {
- SysUser sysUser = sysUserFeignService.queryUserInfo();
- if (sysUser == null) {
- return failed("用户信息获取失败");
- }
- if(!sysUser.getIsSuperAdmin()){
- Employee employee = employeeDao.get(sysUser.getId());
- if (StringUtils.isEmpty(queryInfo.getOrganId())) {
- queryInfo.setOrganId(employee.getOrganIdList());
- }else if(StringUtils.isEmpty(employee.getOrganIdList())){
- return failed("用户所在分部异常");
- }else {
- List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
- if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
- return failed("非法请求");
- }
- }
- }
- return succeed(musicGroupPaymentCalenderService.auditList(queryInfo));
- }
- @ApiOperation(value = "乐团缴费日历审核列表详情")
- @GetMapping("/auditListDetail")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/auditListDetail')")
- public Object auditListDetail(Long calenderId) {
- return succeed(musicGroupPaymentCalenderService.auditListDetail(calenderId));
- }
- @ApiOperation(value = "乐团缴费日历审核通过")
- @PostMapping("/auditPass")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/auditPass')")
- public Object auditPass(Long calenderId,String auditMemo) {
- musicGroupPaymentCalenderService.auditPass(calenderId,auditMemo);
- return succeed();
- }
- @ApiOperation(value = "乐团缴费日历审核拒绝")
- @PostMapping("/auditRefuse")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/auditRefuse')")
- public Object auditRefuse(Long calenderId,String auditMemo) {
- musicGroupPaymentCalenderService.auditRefuse(calenderId,auditMemo);
- return succeed();
- }
- @ApiOperation(value = "获取指定学员在指定乐团下本次课排课时长")
- @GetMapping("/getMusicCourseSettingsWithStudents")
- @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getMusicCourseSettingsWithStudents')")
- public HttpResponseResult<Map<String, Integer>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds, Long classGroupId){
- List<Integer> studentIdList = new ArrayList<>();
- if(StringUtils.isNotBlank(studentIds)){
- studentIdList = Arrays.stream(studentIds.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
- }
- if(Objects.nonNull(classGroupId)){
- List<StudentRegistration> studentList = classGroupStudentMapperDao.findClassStudentList(classGroupId.intValue(), ClassGroupStudentStatusEnum.NORMAL);
- studentIdList = studentList.stream().map(StudentRegistration::getUserId).collect(Collectors.toList());
- }
- if(CollectionUtils.isEmpty(studentIdList)){
- throw new BizException("未指定学员");
- }
- return succeed(musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId,studentIdList));
- }
- }
|