| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.UserLog; |
| | | import com.moral.api.mapper.UserLogMapper; |
| | | import com.moral.api.service.UserLogService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.util.TokenUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class UserLogServiceImpl extends ServiceImpl<UserLogMapper, UserLog> implements UserLogService { |
| | | |
| | | @Autowired |
| | | private UserLogMapper userLogMapper; |
| | | |
| | | @Override |
| | | public Page<UserLog> selectLogs(Map<String, Object> parameters) { |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization"); |
| | | Object orgId = orgInfo.get("id"); |
| | | QueryWrapper<UserLog> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("organization_id", orgId); |
| | | List<Object> types = (List<Object>) parameters.get("types"); |
| | | if (!types.isEmpty()) { |
| | | queryWrapper.in("type", types); |
| | | } |
| | | queryWrapper.orderByDesc("create_time"); |
| | | Integer page = (Integer) parameters.get("page"); |
| | | Integer size = (Integer) parameters.get("size"); |
| | | Page<UserLog> userLogPage = new Page<>(page, size); |
| | | userLogMapper.selectPage(userLogPage, queryWrapper); |
| | | return userLogPage; |
| | | } |
| | | } |