|
@@ -0,0 +1,185 @@
|
|
|
+package com.xjrsoft.module.material.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.page.PageOutput;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.material.dto.*;
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.xjrsoft.module.material.entity.MaterialTypeAssign;
|
|
|
+import com.xjrsoft.module.material.service.IMaterialTypeAssignService;
|
|
|
+import com.xjrsoft.module.material.vo.MaterialTypeAssignVo;
|
|
|
+import com.xjrsoft.module.organization.entity.Department;
|
|
|
+import com.xjrsoft.module.organization.entity.UserDeptRelation;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentUser;
|
|
|
+import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import java.io.IOException;
|
|
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+import com.xjrsoft.module.material.entity.MaterialType;
|
|
|
+import com.xjrsoft.module.material.service.IMaterialTypeService;
|
|
|
+import com.xjrsoft.module.material.vo.MaterialTypePageVo;
|
|
|
+
|
|
|
+import com.xjrsoft.module.material.vo.MaterialTypeVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 材料提交任务类型
|
|
|
+* @Author baicai
|
|
|
+* @Date: 2023-10-31
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/material" + "/materialtype")
|
|
|
+@Api(value = "/material" + "/materialtype",tags = "材料提交任务类型代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class MaterialTypeController {
|
|
|
+
|
|
|
+
|
|
|
+ private final IMaterialTypeService materialTypeService;
|
|
|
+
|
|
|
+ private final IMaterialTypeAssignService materialTypeAssignService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/page")
|
|
|
+ @ApiOperation(value="材料提交任务类型列表(分页)")
|
|
|
+ @SaCheckPermission("materialtype:detail")
|
|
|
+ public RT<PageOutput<MaterialTypePageVo>> page(@Valid MaterialTypePageDto dto){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<MaterialType> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .orderByDesc(MaterialType::getId)
|
|
|
+ .select(MaterialType.class,x -> VoToColumnUtil.fieldsToColumns(MaterialTypePageVo.class).contains(x.getProperty()));
|
|
|
+ IPage<MaterialType> page = materialTypeService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ PageOutput<MaterialTypePageVo> pageOutput = ConventPage.getPageOutput(page, MaterialTypePageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ @ApiOperation(value="材料提交任务类型列表(权限)")
|
|
|
+ public RT<List<MaterialTypeVo>> list() {
|
|
|
+
|
|
|
+ List<MaterialTypeVo> pageOutput = materialTypeService.selectJoinList(MaterialTypeVo.class, new MPJLambdaWrapper<MaterialType>()
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .eq(MaterialTypeAssign::getUserId, StpUtil.getLoginIdAsLong())
|
|
|
+ .select(MaterialType::getId)
|
|
|
+ .select(MaterialType.class,x -> VoToColumnUtil.fieldsToColumns(MaterialTypeVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(MaterialTypeAssign.class, MaterialTypeAssign::getMaterialTypeId, MaterialType::getId)
|
|
|
+ );
|
|
|
+
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ApiOperation(value="根据id查询材料提交任务类型信息")
|
|
|
+ @SaCheckPermission("materialtype:detail")
|
|
|
+ public RT<MaterialTypeVo> info(@RequestParam Long id){
|
|
|
+ MaterialType materialType = materialTypeService.getByIdDeep(id);
|
|
|
+ if (materialType == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
+ }
|
|
|
+ return RT.ok(BeanUtil.toBean(materialType, MaterialTypeVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增材料提交任务类型")
|
|
|
+ @SaCheckPermission("materialtype:add")
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddMaterialTypeDto dto){
|
|
|
+ MaterialType materialType = BeanUtil.toBean(dto, MaterialType.class);
|
|
|
+ boolean isSuccess = materialTypeService.add(materialType);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation(value = "修改材料提交任务类型")
|
|
|
+ @SaCheckPermission("materialtype:edit")
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateMaterialTypeDto dto){
|
|
|
+
|
|
|
+ MaterialType materialType = BeanUtil.toBean(dto, MaterialType.class);
|
|
|
+ return RT.ok(materialTypeService.update(materialType));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping
|
|
|
+ @ApiOperation(value = "删除材料提交任务类型")
|
|
|
+ @SaCheckPermission("materialtype:delete")
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(materialTypeService.delete(ids));
|
|
|
+
|
|
|
+ }
|
|
|
+ @PostMapping("/import")
|
|
|
+ @ApiOperation(value = "导入")
|
|
|
+ public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
|
|
|
+ List<MaterialTypePageVo> savedDataList = EasyExcel.read(file.getInputStream()).head(MaterialTypePageVo.class).sheet().doReadSync();
|
|
|
+ Boolean result = materialTypeService.saveBatch(BeanUtil.copyToList(savedDataList, MaterialType.class));
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export")
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ public ResponseEntity<byte[]> exportData(@Valid MaterialTypePageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
|
|
|
+ List<MaterialTypePageVo> customerList = isTemplate != null && isTemplate ? new ArrayList<>() : ((PageOutput<MaterialTypePageVo>) page(dto).getData()).getList();
|
|
|
+ ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(bot, MaterialTypePageVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
|
|
|
+
|
|
|
+ return RT.fileStream(bot.toByteArray(), "MaterialType" + ExcelTypeEnum.XLSX.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/assign/page")
|
|
|
+ @ApiOperation(value="材料提交任务类型权限列表(分页)")
|
|
|
+ @SaCheckPermission("materialtypeassign:detail")
|
|
|
+ public RT<PageOutput<MaterialTypeAssignVo>> assignPage(@Valid MaterialTypeAssignPageDto dto){
|
|
|
+
|
|
|
+ MPJLambdaWrapper<MaterialTypeAssign> queryWrapper = new MPJLambdaWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .eq(MaterialTypeAssign::getMaterialTypeId,dto.getMaterialTypeId())
|
|
|
+ .select(MaterialTypeAssign::getId)
|
|
|
+ .select(MaterialType.class,x -> VoToColumnUtil.fieldsToColumns(MaterialTypeAssignVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(XjrUser.class,XjrUser::getId,MaterialTypeAssign::getUserId,ext->ext.selectAs(XjrUser::getUserName,MaterialTypeAssignVo::getUserName))
|
|
|
+ .leftJoin(UserDeptRelation.class,UserDeptRelation::getUserId,MaterialTypeAssign::getUserId)
|
|
|
+ .leftJoin(Department.class,Department::getId,UserDeptRelation::getDeptId,ext->ext.selectAs(Department::getName,MaterialTypeAssignVo::getDeptName))
|
|
|
+ ;
|
|
|
+
|
|
|
+ IPage<MaterialTypeAssign> page = materialTypeAssignService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ PageOutput<MaterialTypeAssignVo> pageOutput = ConventPage.getPageOutput(page, MaterialTypeAssignVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/assign/add")
|
|
|
+ @ApiOperation(value = "材料提交任务类型权限")
|
|
|
+ @SaCheckPermission("materialtypeassign:add")
|
|
|
+ public RT<Boolean> assignAdd(@Valid @RequestBody AddMaterialTypeAssignDto dto){
|
|
|
+ boolean isSuccess = materialTypeAssignService.add(dto);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping(value = "/assign/delete")
|
|
|
+ @ApiOperation(value = "删除材料提交任务类型")
|
|
|
+ @SaCheckPermission("materialtypeassign:delete")
|
|
|
+ public RT<Boolean> assignDelete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(materialTypeAssignService.delete(ids));
|
|
|
+ }
|
|
|
+}
|