MCPcopy Create free account
hub / github.com/Hello-hao/Tbed / ClientService

Class ClientService

src/main/java/cn/hellohao/service/impl/ClientService.java:30–307  ·  view source on GitHub ↗

@author Hellohao @version 1.0 @date 2021/10/28 16:38

Source from the content-addressed store, hash-verified

28 * @date 2021/10/28 16:38
29 */
30@Service
31public class ClientService {
32 private static Logger logger = LoggerFactory.getLogger(ClientService.class);
33 @Autowired private ConfdataService confdataService;
34 @Autowired private SysConfigService sysConfigService;
35 @Autowired private UserMapper userMapper;
36 @Autowired private KeysMapper keysMapper;
37 @Autowired private UploadConfigMapper uploadConfigMapper;
38 @Autowired private ImgServiceImpl imgServiceImpl;
39 @Autowired private ImgTempService imgTempService;
40 @Autowired private GetSource getSource;
41 @Autowired private ImgViolationJudgeServiceImpl imgViolationJudgeService;
42
43 public Msg uploadImg(
44 HttpServletRequest request, MultipartFile multipartFile, String email, String pass,Integer setday) {
45 Msg msg = new Msg();
46 try {
47 Confdata dataJson = confdataService.selectConfdata("config");
48 JSONObject confdata = JSONObject.parseObject(dataJson.getJsondata());
49 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
50 String imageFileName = "未命名图像";
51 Integer sourceKeyId = 0;
52 String md5key = null;
53 JSONObject jsonObject = new JSONObject();
54 String userip = GetIPS.getIpAddr(request);
55 UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
56 if (uploadConfig.getApi() != 1) {
57 msg.setCode("4003");
58 msg.setInfo("管理员关闭了API接口");
59 return msg;
60 }
61 imageFileName = multipartFile.getOriginalFilename();
62 File file = SetFiles.changeFile_new(multipartFile);
63 FileInputStream stream = new FileInputStream(file);
64 User u2 = new User();
65 if (!file.exists() || email == null || pass == null) {
66 msg.setCode("4005");
67 msg.setInfo("必要参数不能为空");
68 try {
69 if(stream!=null){stream.close();}
70 file.delete();
71 } catch (Exception e) { }
72 return msg;
73 }
74 if (uploadConfig.getBlacklist() != null) {
75 String[] iparr = uploadConfig.getBlacklist().split(";");
76 for (String s : iparr) {
77 if (s.equals(userip)) {
78 msg.setCode("4010");
79 msg.setInfo("你暂时不能上传");
80 try {
81 if(stream!=null){stream.close();}
82 file.delete();
83 } catch (Exception e) { }
84 return msg;
85 }
86 }
87 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected