HandleAffairsCommonController.java 4.59 KB
package com.trash.office.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.trash.office.domain.Conference;
import com.trash.office.domain.UploadFile;
import com.trash.office.domain.vo.ConferenceVo;
import com.trash.office.domain.vo.HandleAffairsCommonVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.trash.common.annotation.Log;
import com.trash.common.core.controller.BaseController;
import com.trash.common.core.domain.AjaxResult;
import com.trash.common.enums.BusinessType;
import com.trash.office.domain.HandleAffairsCommon;
import com.trash.office.service.IHandleAffairsCommonService;
import com.trash.common.utils.poi.ExcelUtil;
import com.trash.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 办文办事-普通类Controller
 * 
 * @author 2c
 * @date 2023-05-11
 */
@RestController
@RequestMapping("/office/handleAffairsCommon")
public class HandleAffairsCommonController extends BaseController
{
    @Autowired
    private IHandleAffairsCommonService handleAffairsCommonService;

    /**
     * 查询办文办事-普通类列表
     */
    @PreAuthorize("@ss.hasPermi('office:handleAffairsCommon:list')")
    @GetMapping("/list")
    public TableDataInfo list(HandleAffairsCommon handleAffairsCommon)
    {
        startPage();
        List<HandleAffairsCommon> list = handleAffairsCommonService.selectHandleAffairsCommonList(handleAffairsCommon);
        return getDataTable(list);
    }

    /**
     * 导出办文办事-普通类列表
     */
    @PreAuthorize("@ss.hasPermi('office:handleAffairsCommon:export')")
    @Log(title = "办文办事-普通类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HandleAffairsCommon handleAffairsCommon)
    {
        List<HandleAffairsCommon> list = handleAffairsCommonService.selectHandleAffairsCommonList(handleAffairsCommon);

    	for(int i = 0;i<list.size();i++){
        	list.get(i).setId((long)i+1);
        }
        ExcelUtil<HandleAffairsCommon> util = new ExcelUtil<HandleAffairsCommon>(HandleAffairsCommon.class);
        return util.exportExcel(list, "办文办事-普通");
    }

    /**
     * 获取办文办事-普通类详细信息
     */
    @PreAuthorize("@ss.hasPermi('office:handleAffairsCommon:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(handleAffairsCommonService.selectHandleAffairsCommonById(id));
    }

    /**
     * 新增办文办事-普通类
     */
    @PreAuthorize("@ss.hasPermi('office:handleAffairsCommon:add')")
    @Log(title = "办文办事-普通类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestParam(value = "fileList") MultipartFile[] files, HandleAffairsCommon handleAffairsCommon) throws IOException
    {
        return toAjax(handleAffairsCommonService.insertHandleAffairsCommon(files,handleAffairsCommon));
    }

    /**
     * 修改办文办事-普通类
     */
    @PreAuthorize("@ss.hasPermi('office:handleAffairsCommon:edit')")
    @Log(title = "办文办事-普通类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestParam(value = "fileList") MultipartFile[] files,String handleAffairsCommon,String[] uploadFilesList) throws IOException
    {
        HandleAffairsCommonVo handleAffairsCommonVo = new HandleAffairsCommonVo();
        handleAffairsCommonVo.setHandleAffairsCommon(JSON.parseObject(handleAffairsCommon, HandleAffairsCommon.class));
        List<UploadFile> uploadFileList = new ArrayList<>();
        for (String uploadFile : uploadFilesList) {
            UploadFile uploadFile1 = JSON.parseObject(uploadFile,UploadFile.class);
            if(uploadFile1!=null){
                if(uploadFile1.getId()!=null){
                    uploadFileList.add(uploadFile1);
                }
            }
        }
        handleAffairsCommonVo.setUploadFiles(uploadFileList);
        return toAjax(handleAffairsCommonService.updateHandleAffairsCommon(files,handleAffairsCommonVo));
    }

    /**
     * 删除办文办事-普通类
     */
    @PreAuthorize("@ss.hasPermi('office:handleAffairsCommon:remove')")
    @Log(title = "办文办事-普通类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(handleAffairsCommonService.deleteHandleAffairsCommonByIds(ids));
    }
}