月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-06-02 dc0d4a7907f3affdbc116288cac24ad4ba05f319
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
package com.lf.server.controller.all;
 
import com.lf.server.entity.all.HttpStatus;
import com.lf.server.entity.all.ResponseMsg;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
 
/**
 * Controller基类
 * @author WWW
 */
public class BaseController {
    public Log log = LogFactory.getLog(getClass());
 
    public <T> ResponseMsg<T> success(T result) {
        return new ResponseMsg<T>(HttpStatus.OK, result);
    }
 
    public <T> ResponseMsg<T> success(String msg, T result) {
        return new ResponseMsg<T>(HttpStatus.OK, msg, result);
    }
 
    public <T> ResponseMsg<T> success(long count, T result) {
        return new ResponseMsg<T>(HttpStatus.OK, count, result);
    }
 
    public <T> ResponseMsg<T> success(String msg, long count, T result) {
        return new ResponseMsg<T>(HttpStatus.OK, msg, count, result);
    }
 
    public <T> ResponseMsg<T> fail(T result) {
        return new ResponseMsg<T>(HttpStatus.ERROR, result);
    }
 
    public <T> ResponseMsg<T> fail(String msg, T result) {
        return new ResponseMsg<T>(HttpStatus.ERROR, msg, result);
    }
 
    public <T> ResponseMsg<T> fail(Exception ex, T result) {
        log.error(ex.getMessage(), ex);
 
        return new ResponseMsg<T>(HttpStatus.ERROR, ex.getMessage(), result);
    }
}