|
@@ -0,0 +1,136 @@
|
|
|
+package com.xjrsoft.module.student.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.page.PageOutput;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.organization.entity.Department;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentCadreDto;
|
|
|
+import com.xjrsoft.module.student.dto.BaseStudentCadrePageDto;
|
|
|
+import com.xjrsoft.module.student.dto.UpdateBaseStudentCadreDto;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentCadre;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentPost;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentCadreService;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentCadrePageVo;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentCadreVo;
|
|
|
+import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 学生干部管理
|
|
|
+* @Author dzx
|
|
|
+* @Date: 2023-11-14
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/student" + "/basestudentcadre")
|
|
|
+@Api(value = "/student" + "/basestudentcadre",tags = "学生干部管理代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class BaseStudentCadreController {
|
|
|
+
|
|
|
+
|
|
|
+ private final IBaseStudentCadreService baseStudentCadreService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/page")
|
|
|
+ @ApiOperation(value="学生干部管理列表(分页)")
|
|
|
+ @SaCheckPermission("basestudentcadre:detail")
|
|
|
+ public RT<PageOutput<BaseStudentCadrePageVo>> page(@Valid BaseStudentCadrePageDto dto){
|
|
|
+
|
|
|
+ MPJLambdaWrapper<BaseStudentCadre> queryWrapper = new MPJLambdaWrapper<>();
|
|
|
+ queryWrapper.disableLogicDel()
|
|
|
+ .like(StrUtil.isNotBlank(dto.getUserName()), XjrUser::getName, dto.getUserName())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(dto.getOrgId()), BaseStudentCadre::getOrgId, dto.getOrgId())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(dto.getClassId()), BaseStudentCadre::getClassId, dto.getClassId())
|
|
|
+ .orderByDesc(BaseStudentCadre::getId)
|
|
|
+ .selectAs(BaseStudent::getStudentId, BaseStudentCadre::getStudentId)
|
|
|
+ .selectAs(XjrUser::getName, BaseStudentCadre::getUserName)
|
|
|
+ .selectAs(BaseClass::getName, BaseStudentCadre::getClassName)
|
|
|
+ .selectAs(BaseStudentPost::getPost, BaseStudentCadre::getPost)
|
|
|
+ .selectAs(BaseStudentPost::getLevel, BaseStudentCadre::getLevel)
|
|
|
+ .selectAs(Department::getName, BaseStudentCadre::getOrgName)
|
|
|
+ .select(BaseStudentCadre.class,x -> VoToColumnUtil.fieldsToColumns(BaseStudentCadrePageVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(XjrUser.class, XjrUser::getId, BaseStudentCadre::getUserId)
|
|
|
+ .innerJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentCadre::getUserId)
|
|
|
+ .innerJoin(BaseStudentPost.class, BaseStudentPost::getId, BaseStudentCadre::getPostId)
|
|
|
+ .innerJoin(BaseClass.class, BaseClass::getId, BaseStudentCadre::getClassId)
|
|
|
+ .innerJoin(Department.class, Department::getId, BaseClass::getOrgId);
|
|
|
+ IPage<BaseStudentCadre> page = baseStudentCadreService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ PageOutput<BaseStudentCadrePageVo> pageOutput = ConventPage.getPageOutput(page, BaseStudentCadrePageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ApiOperation(value="根据id查询学生干部管理信息")
|
|
|
+ @SaCheckPermission("basestudentcadre:detail")
|
|
|
+ public RT<BaseStudentCadreVo> info(@RequestParam Long id){
|
|
|
+ BaseStudentCadre baseStudentCadre = baseStudentCadreService.getById(id);
|
|
|
+ if (baseStudentCadre == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
+ }
|
|
|
+ return RT.ok(BeanUtil.toBean(baseStudentCadre, BaseStudentCadreVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增学生干部管理")
|
|
|
+ @SaCheckPermission("basestudentcadre:add")
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddBaseStudentCadreDto dto){
|
|
|
+ BaseStudentCadre baseStudentCadre = BeanUtil.toBean(dto, BaseStudentCadre.class);
|
|
|
+ boolean isSuccess = baseStudentCadreService.save(baseStudentCadre);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation(value = "修改学生干部管理")
|
|
|
+ @SaCheckPermission("basestudentcadre:edit")
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentCadreDto dto){
|
|
|
+
|
|
|
+ BaseStudentCadre baseStudentCadre = BeanUtil.toBean(dto, BaseStudentCadre.class);
|
|
|
+ return RT.ok(baseStudentCadreService.updateById(baseStudentCadre));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping
|
|
|
+ @ApiOperation(value = "删除学生干部管理")
|
|
|
+ @SaCheckPermission("basestudentcadre:delete")
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(baseStudentCadreService.removeBatchByIds(ids));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export")
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ public ResponseEntity<byte[]> exportData(@Valid BaseStudentCadrePageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
|
|
|
+ List<BaseStudentCadrePageVo> customerList = isTemplate != null && isTemplate ? new ArrayList<>() : ((PageOutput<BaseStudentCadrePageVo>) page(dto).getData()).getList();
|
|
|
+ ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(bot, BaseStudentCadrePageVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
|
|
|
+
|
|
|
+ return RT.fileStream(bot.toByteArray(), "BaseStudentCadre" + ExcelTypeEnum.XLSX.getValue());
|
|
|
+ }
|
|
|
+}
|