后台日志管理,优惠卷列表以及增加优惠卷
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package cn.ysk.cashier.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class LogVO {
|
||||
|
||||
|
||||
/** 请求ip */
|
||||
private String requestIp;
|
||||
|
||||
|
||||
/** 描述 */
|
||||
private String description;
|
||||
|
||||
/** 操作用户 */
|
||||
private String username;
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private Timestamp createTime;
|
||||
}
|
||||
@@ -36,4 +36,5 @@ public interface LogRepository extends JpaRepository<Log,Long>, JpaSpecification
|
||||
@Modifying
|
||||
@Query(value = "delete from sys_log where log_type = ?1", nativeQuery = true)
|
||||
void deleteByLogType(String logType);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package cn.ysk.cashier.rest;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.service.LogService;
|
||||
import cn.ysk.cashier.service.dto.LogQueryCriteria;
|
||||
import cn.ysk.cashier.service.dto.LogQueryCriteriaExt;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -29,6 +30,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -106,4 +108,16 @@ public class LogController {
|
||||
logService.delAllByInfo();
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/shopInfo")
|
||||
public ResponseEntity<Object> queryShopInfoLog(LogQueryCriteriaExt criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(logService.shopInfoLog(criteria, pageable),HttpStatus.OK);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.service.dto.LogQueryCriteria;
|
||||
import cn.ysk.cashier.domain.Log;
|
||||
import cn.ysk.cashier.service.dto.LogQueryCriteriaExt;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -24,6 +25,7 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -89,4 +91,6 @@ public interface LogService {
|
||||
* 删除所有INFO日志
|
||||
*/
|
||||
void delAllByInfo();
|
||||
|
||||
Map<String, Object> shopInfoLog(LogQueryCriteriaExt criteria, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ public class LogQueryCriteria {
|
||||
@Query
|
||||
private String logType;
|
||||
|
||||
@Query
|
||||
private Integer shopId;
|
||||
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<Timestamp> createTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.ysk.cashier.service.dto;
|
||||
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日志查询类扩展
|
||||
* @author Zheng Jie
|
||||
* @date 2019-6-4 09:23:07
|
||||
*/
|
||||
@Data
|
||||
public class LogQueryCriteriaExt {
|
||||
@Query
|
||||
private String logType = "INFO";
|
||||
|
||||
@Query
|
||||
private Integer shopId;
|
||||
|
||||
}
|
||||
@@ -20,9 +20,11 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.ysk.cashier.domain.Log;
|
||||
import cn.ysk.cashier.domain.LogVO;
|
||||
import cn.ysk.cashier.repository.LogRepository;
|
||||
import cn.ysk.cashier.service.LogService;
|
||||
import cn.ysk.cashier.service.dto.LogQueryCriteria;
|
||||
import cn.ysk.cashier.service.dto.LogQueryCriteriaExt;
|
||||
import cn.ysk.cashier.service.mapstruct.LogErrorMapper;
|
||||
import cn.ysk.cashier.service.mapstruct.LogSmallMapper;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
@@ -41,6 +43,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -174,4 +177,23 @@ public class LogServiceImpl implements LogService {
|
||||
public void delAllByInfo() {
|
||||
logRepository.deleteByLogType("INFO");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> shopInfoLog(LogQueryCriteriaExt criteria, Pageable pageable) {
|
||||
Page<Log> page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)), pageable);
|
||||
List<LogVO> logVOList = new ArrayList<>();
|
||||
for (Log log :page.getContent()) {
|
||||
LogVO logVO = new LogVO();
|
||||
logVO.setDescription(log.getDescription());
|
||||
logVO.setCreateTime(log.getCreateTime());
|
||||
logVO.setUsername(log.getUsername());
|
||||
logVO.setRequestIp(log.getRequestIp());
|
||||
logVOList.add(logVO);
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",logVOList);
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user