cloudroam
2024-12-12 db6da36b94e1e43096a818052ee65dbfcd5e6d98
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
package com.mzl.flower.base;
 
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.entity.log.OperationRecord;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
 
import java.io.Serializable;
 
public class BaseController<T> implements Serializable {
    public BaseController() {
    }
 
    protected ResponseEntity<ReturnDataDTO<?>> returnData(String code, Object data,String msg) {
        return new ResponseEntity(new ReturnDataDTO(code, data, msg), HttpStatus.OK);
    }
 
    protected ResponseEntity<ReturnDataDTO<?>> returnData(String code, Object data) {
        return new ResponseEntity(new ReturnDataDTO(code, data, ""), HttpStatus.OK);
    }
 
    protected ResponseEntity<ReturnDataDTO<?>> returnData(String code, Object data, OperationRecord info) {
        return new ResponseEntity(new ReturnDataInfoDTO(code, data, "",info), HttpStatus.OK);
    }
 
    public OperationRecord getOperationRecord(String content) {
        OperationRecord operationRecord = new OperationRecord();
        operationRecord.setContent(content);
        operationRecord.create(SecurityUtils.getUserId());
        return operationRecord;
    }
}