无关风月
2026-01-29 dc29f2f4f03cb93367b759c38c7e98c358e1f90e
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package com.ruoyi.web.controller.api;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.config.FileUploadConfig;
import com.ruoyi.common.core.controller.FileController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.StoryListQuery;
import com.ruoyi.system.query.WorkPresentationQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.ScreenUserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
 
/**
 * 数据统计面板 前端控制器
 *
 * @author xiaochen
 * @since 2025-12-23
 */
@RestController
@RequestMapping("/work-presentation")
@Api(tags = "工作展示")
@RequiredArgsConstructor(onConstructor_ = @Lazy)
public class WorkPresentationController {
 
    @Autowired
    private WorkPresentationService workPresentationService;
 
 
 
    @Autowired
    private FileUploadConfig fileUploadConfig;
 
    @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名")
    @PostMapping(value = "upload", headers = "content-type=multipart/form-data")
    public R<?> uploadImageMany(@RequestParam(value = "file") MultipartFile mf) throws IOException {
        if (mf.isEmpty()) {
            return R.fail("请传入文件!");
        }
        String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
//        String realPath = fileUploadConfig.getLocation() + TimeDir;
        String realPath =  "F:\\file\\estate\\files";
        File file = new File(realPath);
 
        // 没有目录就创建
        if (!file.exists()) {
            file.mkdirs();
        }
        // 获取文件名称
        String filename = mf.getOriginalFilename();
        String originalFilename=filename;
        // 获取文件后缀
        String ext = filename.substring(filename.lastIndexOf("."), filename.length());
        // 检查文件类型
        if (!fileUploadConfig.getAllowExt().contains(ext)) {
            return R.fail("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt());
        }
        filename = UUID.randomUUID()+ ext;
        File targetFile = new File(realPath, filename);//目标文件
 
        // 获取文件的大小size
        long size = mf.getSize();
        System.out.println(size);
        //开始从源文件拷贝到目标文件
        //传图片一步到位
        mf.transferTo(targetFile);
        //拼接数据
//        String imgstr = fileUploadConfig.getAccessPath() + TimeDir +"\\"+ filename;
        filename = filename.substring(0, filename.lastIndexOf("."));
 
        UserFile userFile = new UserFile();
        userFile.setName(filename);
        userFile.setContentType(mf.getContentType());
        String s = ext.replaceAll("\\.", "");
        userFile.setExtension(s);
        userFile.setSize(size);
        userFile.setOriginFileName(originalFilename);
        userFile.setCreateTime(new Date());
        userFile.setDeleted(false);
        userFile.setUpdateTime(userFile.getCreateTime());
        userFile.insert();
 
 
        return R.ok(filename);
    }
 
 
    @ApiOperation(value = "获取工作展示列表",response = WorkPresentation.class)
    @PostMapping("/getWorkPresentationList")
    public R<Page<WorkPresentation>> getStoryList(@RequestBody WorkPresentationQuery query) {
        Page<WorkPresentation> page = new Page<>(query.getPageNum(), query.getPageSize());
 
        LambdaQueryWrapper<WorkPresentation> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(WorkPresentation::getClientId,query.getClientId());
        if(query.getState()!=null){
            wrapper.eq(WorkPresentation::getState, query.getState());
        }
        if(query.getType()!=null){
            wrapper.eq(WorkPresentation::getType, query.getType());
        }
        if(query.getTime()!=null && !query.getTime().isEmpty()){
            String sTime = query.getTime().split(" - ")[0]+" 00:00:00";
            String eTime = query.getTime().split(" - ")[1]+" 23:59:59";
            wrapper.between(WorkPresentation::getCreateTime,sTime,eTime);
        }
        if(query.getContent()!=null && !query.getContent().isEmpty()){
            wrapper.like(WorkPresentation::getTitle, query.getContent());
        }
        wrapper.orderByDesc(WorkPresentation::getCreateTime);
        Page<WorkPresentation> accidentBriefPage = workPresentationService.page(page, wrapper);
        return R.ok(accidentBriefPage);
    }
 
 
    @ApiOperation(value = "获取工作展示详情",response = WorkPresentation.class)
    @GetMapping("/getWorkPresentationDetail/{id}")
    public R<WorkPresentation> getStoryDetail(@PathVariable Integer id) {
        WorkPresentation workPresentation = workPresentationService.getById(id);
        return R.ok(workPresentation);
    }
 
 
    @ApiOperation(value = "添加工作展示",response = WorkPresentation.class)
    @PostMapping("/addWorkPresentation")
    public R<WorkPresentation> addWorkPresentation(@RequestBody WorkPresentation workPresentation) {
        workPresentationService.save(workPresentation);
        return R.ok(workPresentation);
    }
 
 
    @ApiOperation(value = "修改工作展示",response = WorkPresentation.class)
    @PostMapping("/updateWorkPresentation")
    public R<WorkPresentation> updateWorkPresentation(@RequestBody WorkPresentation workPresentation) {
        workPresentationService.updateById(workPresentation);
        return R.ok(workPresentation);
    }
 
 
    @ApiOperation(value = "删除工作展示",response = WorkPresentation.class)
    @DeleteMapping("/deleteWorkPresentation/{id}")
    public R<WorkPresentation> deleteWorkPresentation(@PathVariable Integer id ) {
        workPresentationService.removeById(id);
        return R.ok();
    }
 
 
    @ApiOperation(value = "操作工作展示",response = WorkPresentation.class)
    @PostMapping("/operateWorkPresentation")
    public R<WorkPresentation> operateWorkPresentation(@RequestParam Integer id) {
        WorkPresentation workPresentation = workPresentationService.getById(id);
        if(workPresentation.getState()==1){
            workPresentation.setState(2);
        }else{
            workPresentation.setState(1);
        }
        workPresentationService.updateById(workPresentation);
        return R.ok(workPresentation);
    }
 
 
}