Browse Source

监管日志

huangwenjie 4 năm trước cách đây
mục cha
commit
61f0ff6014

+ 8 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -706,5 +706,13 @@ public class BaseRequestMapping {
    public static class BaseRoleMenu extends Basic {
        public static final String PREFIX  = "/baseRoleMenu";
    }
    
    /**
     * 系统日志
     */
    public static class BaseMethodLog extends Basic{
        public static final String PREFIX  = "/baseMethodLog";
        public static final String getLog  = "/getLog";
    }
}

+ 9 - 2
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseMethodLogService.java

@ -1,6 +1,7 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.gateway.useragent.UserAgent;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -34,8 +35,14 @@ public class BaseMethodLogService {
        try{
            logger.info("saveMethodLog");
            BaseMethodLogDO log = new BaseMethodLogDO();
            log.setUuid(userAgent.getUID());
            log.setName(userAgent.getUNAME());
            if(StringUtils.isBlank(userAgent.getUID())){
                log.setUuid("system");
                log.setName("system");
            }else{
                log.setUuid(userAgent.getUID());
                log.setName(userAgent.getUNAME());
            }
            
            log.setIp(getIpAddress(request));
            log.setCreateTime(new Date());
            log.setMethod(request.getRequestURI());

+ 51 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/methodlog/MethodLogEndpoint.java

@ -0,0 +1,51 @@
package com.yihu.jw.base.endpoint.methodlog;
import com.yihu.jw.base.methlog.BaseMethodLogDO;
import com.yihu.jw.base.methlog.BaseMethodLogService;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * 系统日志
 * @author huangwenjie
 * @date 2020/4/11 10:16
 */
@RestController
@RequestMapping(value = BaseRequestMapping.BaseMethodLog.PREFIX)
@Api(value = "系统日志管理", description = "系统日志管理接口", tags = {"基础服务 - 系统日志管理管理服务接口"})
public class MethodLogEndpoint extends EnvelopRestEndpoint {
	
	@Autowired
	private BaseMethodLogService baseMethodLogService;
	
	@GetMapping(value = BaseRequestMapping.BaseMethodLog.getLog)
	@ApiOperation(value = "获取分页")
	public PageEnvelop<BaseMethodLogDO> page(
			@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
			@RequestParam(value = "fields", required = false) String fields,
			@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
			@RequestParam(value = "filters", required = false) String filters,
			@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
			@RequestParam(value = "sorts", required = false) String sorts,
			@ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
			@RequestParam(value = "page") int page,
			@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
			@RequestParam(value = "size") int size) throws Exception {
		List<BaseMethodLogDO> baseDoctors = baseMethodLogService.search(fields, filters, sorts, page, size);
		int count = (int) baseMethodLogService.getCount(filters);
		return success(baseDoctors, count, page, size);
	}
}

+ 63 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogDO.java

@ -0,0 +1,63 @@
package com.yihu.jw.base.methlog;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2020/2/19.
 */
@Entity
@Table(name = "base_method_log")
public class BaseMethodLogDO extends UuidIdentityEntity {
    private String uuid;
    private String name;
    private String ip;
    private String method;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date createTime;
    public String getUuid() {
        return uuid;
    }
    public void setUuid(String uuid) {
        this.uuid = uuid;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getIp() {
        return ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 10 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogDao.java

@ -0,0 +1,10 @@
package com.yihu.jw.base.methlog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2020/2/19.
 */
public interface BaseMethodLogDao extends PagingAndSortingRepository<BaseMethodLogDO, String>, JpaSpecificationExecutor<BaseMethodLogDO> {
}

+ 25 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogService.java

@ -0,0 +1,25 @@
package com.yihu.jw.base.methlog;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.mysql.query.BaseJpaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * Created by Trick on 2020/2/19.
 */
@Service
@Transactional
public class BaseMethodLogService  extends BaseJpaService<BaseMethodLogDO, BaseMethodLogDao> {
    private static final Logger logger = LoggerFactory.getLogger(BaseMethodLogService.class);
    @Autowired
    private BaseMethodLogDao baseMethodLogDao;
    
}