zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package org.jeecg.modules.patent.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.patent.entity.PaSoftbookFile;
import org.jeecg.modules.patent.service.IPaSoftBookFileService;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
 
 
@Slf4j
@Api(tags = "专利软著文件")
@RestController
@RequestMapping("/pa/file")
public class PaSoftBookFileController extends JeecgController<PaSoftbookFile, IPaSoftBookFileService> {
 
    @Autowired
    private IPaSoftBookFileService paSoftBookFileService;
 
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<IPage<PaSoftbookFile>> queryPageList(PaSoftbookFile PaSoftbookFile, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                   @RequestParam(name = "pageSize", defaultValue = "100") Integer pageSize, HttpServletRequest req) {
        Result<IPage<PaSoftbookFile>> result = new Result<IPage<PaSoftbookFile>>();
        QueryWrapper<PaSoftbookFile> queryWrapper = QueryGenerator.initQueryWrapper(PaSoftbookFile, req.getParameterMap());
        Page<PaSoftbookFile> page = new Page<PaSoftbookFile>(pageNo, pageSize);
        IPage<PaSoftbookFile> pageList = paSoftBookFileService.page(page, queryWrapper);
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
 
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @AutoLog(value = "添加专利软著文件")
    @Transactional
    public Result<PaSoftbookFile> add(@RequestBody PaSoftbookFile paSoftbookFile, HttpServletRequest request) {
        Result<PaSoftbookFile> result = new Result<PaSoftbookFile>();
        try {
            String fileList = paSoftbookFile.getFileList();
            String[] split = fileList.split(",");
            for (int i = 0; i <split.length; i++) {
                String filePath =  split[i];
                PaSoftbookFile file = new PaSoftbookFile();
                file.setPid(paSoftbookFile.getPid());
                file.setWjms(paSoftbookFile.getWjms());
                file.setWjlj(filePath);
                file.setMc(paSoftbookFile.getMc());
                file.setWjmc(filePath.substring(filePath.lastIndexOf("/")+1));
                paSoftBookFileService.save(file);
            }
            result.success("添加成功!");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("操作失败");
        }
 
        return result;
    }
 
 
 
 
    @AutoLog(value = "修改专利软著")
    @RequestMapping(value = "/edit", method = RequestMethod.PUT)
    public Result<PaSoftbookFile> edit(@RequestBody PaSoftbookFile PaSoftbookFile) {
        Result<PaSoftbookFile> result = new Result<PaSoftbookFile>();
        paSoftBookFileService.updateById(PaSoftbookFile);
        result.success("修改成功!");
        result.setResult(PaSoftbookFile);
        return result;
    }
    @AutoLog(value = "删除专利软著")
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
        paSoftBookFileService.removeById(id);
        return Result.ok("删除成功");
    }
 
    
 
 
}