1
zj
2026-01-11 e17f787bb9450a90ec4d0731ca068b8284f044b2
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
package com.nq.controller.backend;
 
 
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
 
import com.google.common.collect.Maps;
 
import com.nq.common.ServerResponse;
 
import com.nq.pojo.SiteAdmin;
 
import com.nq.service.IFileUploadService;
 
import com.nq.service.ISiteAdminService;
 
import com.nq.utils.PropertiesUtil;
 
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Map;
import java.util.UUID;
 
import javax.servlet.http.HttpServletRequest;
 
import javax.servlet.http.HttpSession;
 
import org.slf4j.Logger;
 
import org.slf4j.LoggerFactory;
 
import org.springframework.beans.factory.annotation.Autowired;
 
import org.springframework.stereotype.Controller;
 
import org.springframework.web.bind.annotation.RequestMapping;
 
import org.springframework.web.bind.annotation.RequestParam;
 
import org.springframework.web.bind.annotation.ResponseBody;
 
import org.springframework.web.multipart.MultipartFile;
 
 
@Controller
@RequestMapping({"/admin/"})
public class AdminController {
 
    private static final Logger log = LoggerFactory.getLogger(AdminController.class);
 
 
    @Autowired
    ISiteAdminService iSiteAdminService;
 
 
    @Autowired
    IFileUploadService iFileUploadService;
 
    //分页查询管理设置 所有管理列表数据及模糊查询
    @RequestMapping({"list.do"})
    @ResponseBody
    public ServerResponse<PageInfo> list(@RequestParam(value = "adminName", required = false) String adminName, @RequestParam(value = "adminPhone", required = false) String adminPhone, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, HttpServletRequest request) {
        return this.iSiteAdminService.listByAdmin(adminName, adminPhone, request, pageNum, pageSize);
    }
 
    //修改管理员状态 锁定管理员/解锁管理员
    @RequestMapping({"updateLock.do"})
    @ResponseBody
    public ServerResponse updateLock(Integer adminId) {
        return this.iSiteAdminService.updateLock(adminId);
    }
 
    //管理设置 添加管理员
    @RequestMapping({"add.do"})
    @ResponseBody
    public ServerResponse add(SiteAdmin siteAdmin) {
        return this.iSiteAdminService.add(siteAdmin);
    }
 
    //管理设置 修改管理员密码
    @RequestMapping({"update.do"})
    @ResponseBody
    public ServerResponse update(SiteAdmin siteAdmin) {
        return this.iSiteAdminService.update(siteAdmin);
    }
 
    //查询首页 资金情况、持仓情况、盈亏信息、提现情况、股票信息、代理信息
    @RequestMapping({"count.do"})
    @ResponseBody
    public ServerResponse count() {
        return this.iSiteAdminService.count();
    }
 
    //处理图片上传
    @RequestMapping({"upload.do"})
    @ResponseBody
    public ServerResponse upload(HttpSession session, @RequestParam(value = "upload_file", required = false) MultipartFile file, HttpServletRequest request) {
 
        // 兼容c端组件上传原理
        String fileType = file.getOriginalFilename();
        if (StrUtil.isEmpty(fileType) || fileType.contains("blob")) {
            fileType = "blob.png";
        }
 
        String fileName = file.getOriginalFilename();
        String fileExtentionName = fileName.substring(fileName.lastIndexOf(".") + 1);
 
        // 生成唯一的文件名
        String id = UUID.randomUUID().toString();
        String path = LocalDate.now() + "/" + id + "." + fileExtentionName;
 
        // 确保目标文件夹存在
        File targetDir = new File(PropertiesUtil.getProperty("loca.images.dir")  + "/" + LocalDate.now());
        if (!targetDir.exists()) {
            targetDir.mkdirs();
        }
 
        // 构建本地文件路径
        File localFile = new File(targetDir, id + "." + fileExtentionName);
 
        // 打印上传路径
        log.info("LocalFileUploadService uploadFile localFilePath: {}", localFile.getAbsolutePath());
 
        try {
            // 将文件保存到本地
            file.transferTo(localFile);
 
        } catch (IOException e) {
            log.error("LocalFileUploadService uploadFile IOException", e.getMessage(), e);
        }
        String url = PropertiesUtil.getProperty("ftp.server.http.prefix") + path;
        // 返回相对路径
        return ServerResponse.createBySuccess(url);
 
    }
 
    //删除管理员
    @RequestMapping({"deleteAdmin.do"})
    @ResponseBody
    public ServerResponse deleteAdmin(Integer adminId) {
        return this.iSiteAdminService.deleteAdmin(adminId);
    }
}