commit
71e20e9f84
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package top.charles7c.cnadmin.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应拦截忽略注解
|
||||||
|
*
|
||||||
|
* @author BULL_BCLS
|
||||||
|
* @since 2023/10/8 20:44
|
||||||
|
*/
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface NoResponseAdvice {}
|
@ -37,6 +37,7 @@ import cn.hutool.core.lang.tree.Tree;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.CrudRequestMapping;
|
import top.charles7c.cnadmin.common.annotation.CrudRequestMapping;
|
||||||
|
import top.charles7c.cnadmin.common.annotation.NoResponseAdvice;
|
||||||
import top.charles7c.cnadmin.common.constant.StringConsts;
|
import top.charles7c.cnadmin.common.constant.StringConsts;
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||||
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
||||||
@ -77,10 +78,9 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
|||||||
@Operation(summary = "分页查询列表", description = "分页查询列表")
|
@Operation(summary = "分页查询列表", description = "分页查询列表")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public R<PageDataVO<V>> page(Q query, @Validated PageQuery pageQuery) {
|
public PageDataVO<V> page(Q query, @Validated PageQuery pageQuery) {
|
||||||
this.checkPermission(Api.LIST);
|
this.checkPermission(Api.LIST);
|
||||||
PageDataVO<V> pageDataVO = baseService.page(query, pageQuery);
|
return baseService.page(query, pageQuery);
|
||||||
return R.ok(pageDataVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,10 +95,9 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
|||||||
@Operation(summary = "查询树列表", description = "查询树列表")
|
@Operation(summary = "查询树列表", description = "查询树列表")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping("/tree")
|
@GetMapping("/tree")
|
||||||
public R<List<Tree<Long>>> tree(Q query, SortQuery sortQuery) {
|
public List<Tree<Long>> tree(Q query, SortQuery sortQuery) {
|
||||||
this.checkPermission(Api.LIST);
|
this.checkPermission(Api.LIST);
|
||||||
List<Tree<Long>> list = baseService.tree(query, sortQuery, false);
|
return baseService.tree(query, sortQuery, false);
|
||||||
return R.ok(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,10 +112,9 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
|||||||
@Operation(summary = "查询列表", description = "查询列表")
|
@Operation(summary = "查询列表", description = "查询列表")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public R<List<V>> list(Q query, SortQuery sortQuery) {
|
public List<V> list(Q query, SortQuery sortQuery) {
|
||||||
this.checkPermission(Api.LIST);
|
this.checkPermission(Api.LIST);
|
||||||
List<V> list = baseService.list(query, sortQuery);
|
return baseService.list(query, sortQuery);
|
||||||
return R.ok(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,10 +128,9 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
|||||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<D> get(@PathVariable Long id) {
|
public D get(@PathVariable Long id) {
|
||||||
this.checkPermission(Api.LIST);
|
this.checkPermission(Api.LIST);
|
||||||
D detail = baseService.get(id);
|
return baseService.get(id);
|
||||||
return R.ok(detail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,6 +196,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
|||||||
* 响应对象
|
* 响应对象
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "导出数据", description = "导出数据")
|
@Operation(summary = "导出数据", description = "导出数据")
|
||||||
|
@NoResponseAdvice
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(Q query, SortQuery sortQuery, HttpServletResponse response) {
|
public void export(Q query, SortQuery sortQuery, HttpServletResponse response) {
|
||||||
this.checkPermission(Api.EXPORT);
|
this.checkPermission(Api.EXPORT);
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package top.charles7c.cnadmin.common.handler;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import org.springframework.core.MethodParameter;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.server.ServerHttpRequest;
|
||||||
|
import org.springframework.http.server.ServerHttpResponse;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import top.charles7c.cnadmin.common.annotation.NoResponseAdvice;
|
||||||
|
import top.charles7c.cnadmin.common.model.vo.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局响应结果处理器
|
||||||
|
*
|
||||||
|
* @author BULL_BCLS
|
||||||
|
* @since 2023/10/8 20:19
|
||||||
|
*/
|
||||||
|
@RestControllerAdvice
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GlobalResponseBodyAdviceHandler implements ResponseBodyAdvice<Object> {
|
||||||
|
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||||
|
return !methodParameter.getParameterType().isAssignableFrom(R.class)
|
||||||
|
&& !methodParameter.hasMethodAnnotation(NoResponseAdvice.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
|
||||||
|
Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request,
|
||||||
|
ServerHttpResponse response) {
|
||||||
|
if (String.class.equals(returnType.getGenericParameterType())) {
|
||||||
|
try {
|
||||||
|
return objectMapper.writeValueAsString(R.ok(body));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.ok(body);
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,6 @@ import top.charles7c.cnadmin.auth.model.vo.UserInfoVO;
|
|||||||
import top.charles7c.cnadmin.auth.service.LoginService;
|
import top.charles7c.cnadmin.auth.service.LoginService;
|
||||||
import top.charles7c.cnadmin.common.constant.CacheConsts;
|
import top.charles7c.cnadmin.common.constant.CacheConsts;
|
||||||
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
||||||
import top.charles7c.cnadmin.common.model.vo.R;
|
|
||||||
import top.charles7c.cnadmin.common.util.ExceptionUtils;
|
import top.charles7c.cnadmin.common.util.ExceptionUtils;
|
||||||
import top.charles7c.cnadmin.common.util.RedisUtils;
|
import top.charles7c.cnadmin.common.util.RedisUtils;
|
||||||
import top.charles7c.cnadmin.common.util.SecureUtils;
|
import top.charles7c.cnadmin.common.util.SecureUtils;
|
||||||
@ -67,7 +66,7 @@ public class LoginController {
|
|||||||
@SaIgnore
|
@SaIgnore
|
||||||
@Operation(summary = "用户登录", description = "根据用户名和密码进行登录认证")
|
@Operation(summary = "用户登录", description = "根据用户名和密码进行登录认证")
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public R<LoginVO> login(@Validated @RequestBody LoginRequest loginRequest) {
|
public LoginVO login(@Validated @RequestBody LoginRequest loginRequest) {
|
||||||
String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, loginRequest.getUuid());
|
String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, loginRequest.getUuid());
|
||||||
String captcha = RedisUtils.getCacheObject(captchaKey);
|
String captcha = RedisUtils.getCacheObject(captchaKey);
|
||||||
ValidationUtils.throwIfBlank(captcha, "验证码已失效");
|
ValidationUtils.throwIfBlank(captcha, "验证码已失效");
|
||||||
@ -78,7 +77,7 @@ public class LoginController {
|
|||||||
ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(loginRequest.getPassword()));
|
ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(loginRequest.getPassword()));
|
||||||
ValidationUtils.throwIfBlank(rawPassword, "密码解密失败");
|
ValidationUtils.throwIfBlank(rawPassword, "密码解密失败");
|
||||||
String token = loginService.login(loginRequest.getUsername(), rawPassword);
|
String token = loginService.login(loginRequest.getUsername(), rawPassword);
|
||||||
return R.ok(LoginVO.builder().token(token).build());
|
return LoginVO.builder().token(token).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
@ -86,29 +85,27 @@ public class LoginController {
|
|||||||
@Parameter(name = "Authorization", description = "令牌", required = true, example = "Bearer xxxx-xxxx-xxxx-xxxx",
|
@Parameter(name = "Authorization", description = "令牌", required = true, example = "Bearer xxxx-xxxx-xxxx-xxxx",
|
||||||
in = ParameterIn.HEADER)
|
in = ParameterIn.HEADER)
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
public R logout() {
|
public void logout() {
|
||||||
StpUtil.logout();
|
StpUtil.logout();
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(ignore = true)
|
@Log(ignore = true)
|
||||||
@Operation(summary = "获取用户信息", description = "获取登录用户信息")
|
@Operation(summary = "获取用户信息", description = "获取登录用户信息")
|
||||||
@GetMapping("/user/info")
|
@GetMapping("/user/info")
|
||||||
public R<UserInfoVO> getUserInfo() {
|
public UserInfoVO getUserInfo() {
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
UserDetailVO userDetailVO = userService.get(loginUser.getId());
|
UserDetailVO userDetailVO = userService.get(loginUser.getId());
|
||||||
UserInfoVO userInfoVO = BeanUtil.copyProperties(userDetailVO, UserInfoVO.class);
|
UserInfoVO userInfoVO = BeanUtil.copyProperties(userDetailVO, UserInfoVO.class);
|
||||||
userInfoVO.setPermissions(loginUser.getPermissions());
|
userInfoVO.setPermissions(loginUser.getPermissions());
|
||||||
userInfoVO.setRoles(loginUser.getRoleCodes());
|
userInfoVO.setRoles(loginUser.getRoleCodes());
|
||||||
return R.ok(userInfoVO);
|
return userInfoVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(ignore = true)
|
@Log(ignore = true)
|
||||||
@Operation(summary = "获取路由信息", description = "获取登录用户的路由信息")
|
@Operation(summary = "获取路由信息", description = "获取登录用户的路由信息")
|
||||||
@GetMapping("/route")
|
@GetMapping("/route")
|
||||||
public R<List<RouteVO>> listRoute() {
|
public List<RouteVO> listRoute() {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
List<RouteVO> routeTree = loginService.buildRouteTree(userId);
|
return loginService.buildRouteTree(userId);
|
||||||
return R.ok(routeTree);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -69,7 +69,7 @@ public class CaptchaController {
|
|||||||
|
|
||||||
@Operation(summary = "获取图片验证码", description = "获取图片验证码(Base64编码,带图片格式:data:image/gif;base64)")
|
@Operation(summary = "获取图片验证码", description = "获取图片验证码(Base64编码,带图片格式:data:image/gif;base64)")
|
||||||
@GetMapping("/img")
|
@GetMapping("/img")
|
||||||
public R<CaptchaVO> getImageCaptcha() {
|
public CaptchaVO getImageCaptcha() {
|
||||||
// 生成验证码
|
// 生成验证码
|
||||||
CaptchaProperties.CaptchaImage captchaImage = captchaProperties.getImage();
|
CaptchaProperties.CaptchaImage captchaImage = captchaProperties.getImage();
|
||||||
Captcha captcha = captchaImage.getCaptcha();
|
Captcha captcha = captchaImage.getCaptcha();
|
||||||
@ -78,7 +78,7 @@ public class CaptchaController {
|
|||||||
String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, uuid);
|
String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, uuid);
|
||||||
RedisUtils.setCacheObject(captchaKey, captcha.text(),
|
RedisUtils.setCacheObject(captchaKey, captcha.text(),
|
||||||
Duration.ofMinutes(captchaImage.getExpirationInMinutes()));
|
Duration.ofMinutes(captchaImage.getExpirationInMinutes()));
|
||||||
return R.ok(CaptchaVO.builder().uuid(uuid).img(captcha.toBase64()).build());
|
return CaptchaVO.builder().uuid(uuid).img(captcha.toBase64()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱")
|
@Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱")
|
||||||
|
@ -97,42 +97,39 @@ public class CommonController {
|
|||||||
|
|
||||||
@Operation(summary = "查询部门树", description = "查询树结构的部门列表")
|
@Operation(summary = "查询部门树", description = "查询树结构的部门列表")
|
||||||
@GetMapping("/tree/dept")
|
@GetMapping("/tree/dept")
|
||||||
public R<List<Tree<Long>>> listDeptTree(DeptQuery query, SortQuery sortQuery) {
|
public List<Tree<Long>> listDeptTree(DeptQuery query, SortQuery sortQuery) {
|
||||||
List<Tree<Long>> treeList = deptService.tree(query, sortQuery, true);
|
return deptService.tree(query, sortQuery, true);
|
||||||
return R.ok(treeList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询菜单树", description = "查询树结构的菜单列表")
|
@Operation(summary = "查询菜单树", description = "查询树结构的菜单列表")
|
||||||
@GetMapping("/tree/menu")
|
@GetMapping("/tree/menu")
|
||||||
public R<List<Tree<Long>>> listMenuTree(MenuQuery query, SortQuery sortQuery) {
|
public List<Tree<Long>> listMenuTree(MenuQuery query, SortQuery sortQuery) {
|
||||||
List<Tree<Long>> treeList = menuService.tree(query, sortQuery, true);
|
return menuService.tree(query, sortQuery, true);
|
||||||
return R.ok(treeList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询角色字典", description = "查询角色字典列表")
|
@Operation(summary = "查询角色字典", description = "查询角色字典列表")
|
||||||
@GetMapping("/dict/role")
|
@GetMapping("/dict/role")
|
||||||
public R<List<LabelValueVO<Long>>> listRoleDict(RoleQuery query, SortQuery sortQuery) {
|
public List<LabelValueVO<Long>> listRoleDict(RoleQuery query, SortQuery sortQuery) {
|
||||||
List<RoleVO> list = roleService.list(query, sortQuery);
|
List<RoleVO> list = roleService.list(query, sortQuery);
|
||||||
List<LabelValueVO<Long>> labelValueVOList = roleService.buildDict(list);
|
return roleService.buildDict(list);
|
||||||
return R.ok(labelValueVOList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询字典", description = "查询字典列表")
|
@Operation(summary = "查询字典", description = "查询字典列表")
|
||||||
@Parameter(name = "code", description = "字典编码", example = "announcement_type", in = ParameterIn.PATH)
|
@Parameter(name = "code", description = "字典编码", example = "announcement_type", in = ParameterIn.PATH)
|
||||||
@GetMapping("/dict/{code}")
|
@GetMapping("/dict/{code}")
|
||||||
@Cacheable(key = "#code", cacheNames = CacheConsts.DICT_KEY_PREFIX)
|
@Cacheable(key = "#code", cacheNames = CacheConsts.DICT_KEY_PREFIX)
|
||||||
public R<List<LabelValueVO>> listDict(@PathVariable String code) {
|
public List<LabelValueVO> listDict(@PathVariable String code) {
|
||||||
Optional<Class<?>> enumClass = this.getEnumClassByName(code);
|
Optional<Class<?>> enumClass = this.getEnumClassByName(code);
|
||||||
return enumClass.map(this::listEnumDict).orElseGet(() -> R.ok(dictItemService.listByDictCode(code)));
|
return enumClass.map(this::listEnumDict).orElseGet(() -> dictItemService.listByDictCode(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
@Operation(summary = "查询参数", description = "查询参数")
|
@Operation(summary = "查询参数", description = "查询参数")
|
||||||
@GetMapping("/option")
|
@GetMapping("/option")
|
||||||
@Cacheable(cacheNames = CacheConsts.OPTION_KEY_PREFIX)
|
@Cacheable(cacheNames = CacheConsts.OPTION_KEY_PREFIX)
|
||||||
public R<List<LabelValueVO>> listOption(@Validated OptionQuery query) {
|
public List<LabelValueVO> listOption(@Validated OptionQuery query) {
|
||||||
return R.ok(optionService.list(query).stream().map(option -> new LabelValueVO(option.getCode(),
|
return optionService.list(query).stream().map(option -> new LabelValueVO(option.getCode(),
|
||||||
StrUtil.nullToDefault(option.getValue(), option.getDefaultValue()))).collect(Collectors.toList()));
|
StrUtil.nullToDefault(option.getValue(), option.getDefaultValue()))).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,12 +154,11 @@ public class CommonController {
|
|||||||
* 枚举类型
|
* 枚举类型
|
||||||
* @return 枚举字典
|
* @return 枚举字典
|
||||||
*/
|
*/
|
||||||
private R<List<LabelValueVO>> listEnumDict(Class<?> enumClass) {
|
private List<LabelValueVO> listEnumDict(Class<?> enumClass) {
|
||||||
Object[] enumConstants = enumClass.getEnumConstants();
|
Object[] enumConstants = enumClass.getEnumConstants();
|
||||||
List<LabelValueVO> labelValueList = Arrays.stream(enumConstants).map(e -> {
|
return Arrays.stream(enumConstants).map(e -> {
|
||||||
BaseEnum<Integer> baseEnum = (BaseEnum<Integer>)e;
|
BaseEnum<Integer> baseEnum = (BaseEnum<Integer>)e;
|
||||||
return new LabelValueVO<>(baseEnum.getDescription(), baseEnum.getValue(), baseEnum.getColor());
|
return new LabelValueVO<>(baseEnum.getDescription(), baseEnum.getValue(), baseEnum.getColor());
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
return R.ok(labelValueList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.model.vo.R;
|
|
||||||
import top.charles7c.cnadmin.common.util.validate.ValidationUtils;
|
import top.charles7c.cnadmin.common.util.validate.ValidationUtils;
|
||||||
import top.charles7c.cnadmin.monitor.annotation.Log;
|
import top.charles7c.cnadmin.monitor.annotation.Log;
|
||||||
import top.charles7c.cnadmin.monitor.model.vo.DashboardAccessTrendVO;
|
import top.charles7c.cnadmin.monitor.model.vo.DashboardAccessTrendVO;
|
||||||
@ -59,33 +58,33 @@ public class DashboardController {
|
|||||||
|
|
||||||
@Operation(summary = "查询总计信息", description = "查询总计信息")
|
@Operation(summary = "查询总计信息", description = "查询总计信息")
|
||||||
@GetMapping("/total")
|
@GetMapping("/total")
|
||||||
public R<DashboardTotalVO> getTotal() {
|
public DashboardTotalVO getTotal() {
|
||||||
return R.ok(dashboardService.getTotal());
|
return dashboardService.getTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询访问趋势信息", description = "查询访问趋势信息")
|
@Operation(summary = "查询访问趋势信息", description = "查询访问趋势信息")
|
||||||
@Parameter(name = "days", description = "日期数", example = "30", in = ParameterIn.PATH)
|
@Parameter(name = "days", description = "日期数", example = "30", in = ParameterIn.PATH)
|
||||||
@GetMapping("/access/trend/{days}")
|
@GetMapping("/access/trend/{days}")
|
||||||
public R<List<DashboardAccessTrendVO>> listAccessTrend(@PathVariable Integer days) {
|
public List<DashboardAccessTrendVO> listAccessTrend(@PathVariable Integer days) {
|
||||||
ValidationUtils.throwIf(7 != days && 30 != days, "仅支持查询近 7/30 天访问趋势信息");
|
ValidationUtils.throwIf(7 != days && 30 != days, "仅支持查询近 7/30 天访问趋势信息");
|
||||||
return R.ok(dashboardService.listAccessTrend(days));
|
return dashboardService.listAccessTrend(days);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询热门模块列表", description = "查询热门模块列表")
|
@Operation(summary = "查询热门模块列表", description = "查询热门模块列表")
|
||||||
@GetMapping("/popular/module")
|
@GetMapping("/popular/module")
|
||||||
public R<List<DashboardPopularModuleVO>> listPopularModule() {
|
public List<DashboardPopularModuleVO> listPopularModule() {
|
||||||
return R.ok(dashboardService.listPopularModule());
|
return dashboardService.listPopularModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询访客地域分布信息", description = "查询访客地域分布信息")
|
@Operation(summary = "查询访客地域分布信息", description = "查询访客地域分布信息")
|
||||||
@GetMapping("/geo/distribution")
|
@GetMapping("/geo/distribution")
|
||||||
public R<DashboardGeoDistributionVO> getGeoDistribution() {
|
public DashboardGeoDistributionVO getGeoDistribution() {
|
||||||
return R.ok(dashboardService.getGeoDistribution());
|
return dashboardService.getGeoDistribution();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询公告列表", description = "查询公告列表")
|
@Operation(summary = "查询公告列表", description = "查询公告列表")
|
||||||
@GetMapping("/announcement")
|
@GetMapping("/announcement")
|
||||||
public R<List<DashboardAnnouncementVO>> listAnnouncement() {
|
public List<DashboardAnnouncementVO> listAnnouncement() {
|
||||||
return R.ok(dashboardService.listAnnouncement());
|
return dashboardService.listAnnouncement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||||
import top.charles7c.cnadmin.common.model.vo.R;
|
|
||||||
import top.charles7c.cnadmin.monitor.annotation.Log;
|
import top.charles7c.cnadmin.monitor.annotation.Log;
|
||||||
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
|
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
|
||||||
import top.charles7c.cnadmin.monitor.model.query.OperationLogQuery;
|
import top.charles7c.cnadmin.monitor.model.query.OperationLogQuery;
|
||||||
@ -59,33 +58,29 @@ public class LogController {
|
|||||||
@Log(module = "登录日志")
|
@Log(module = "登录日志")
|
||||||
@Operation(summary = "分页查询登录日志列表", description = "分页查询登录日志列表")
|
@Operation(summary = "分页查询登录日志列表", description = "分页查询登录日志列表")
|
||||||
@GetMapping("/login")
|
@GetMapping("/login")
|
||||||
public R<PageDataVO<LoginLogVO>> page(LoginLogQuery query, @Validated PageQuery pageQuery) {
|
public PageDataVO<LoginLogVO> page(LoginLogQuery query, @Validated PageQuery pageQuery) {
|
||||||
PageDataVO<LoginLogVO> pageDataVO = logService.page(query, pageQuery);
|
return logService.page(query, pageQuery);
|
||||||
return R.ok(pageDataVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(module = "操作日志")
|
@Log(module = "操作日志")
|
||||||
@Operation(summary = "分页查询操作日志列表", description = "分页查询操作日志列表")
|
@Operation(summary = "分页查询操作日志列表", description = "分页查询操作日志列表")
|
||||||
@GetMapping("/operation")
|
@GetMapping("/operation")
|
||||||
public R<PageDataVO<OperationLogVO>> page(OperationLogQuery query, @Validated PageQuery pageQuery) {
|
public PageDataVO<OperationLogVO> page(OperationLogQuery query, @Validated PageQuery pageQuery) {
|
||||||
PageDataVO<OperationLogVO> pageDataVO = logService.page(query, pageQuery);
|
return logService.page(query, pageQuery);
|
||||||
return R.ok(pageDataVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(module = "系统日志")
|
@Log(module = "系统日志")
|
||||||
@Operation(summary = "分页查询系统日志列表", description = "分页查询系统日志列表")
|
@Operation(summary = "分页查询系统日志列表", description = "分页查询系统日志列表")
|
||||||
@GetMapping("/system")
|
@GetMapping("/system")
|
||||||
public R<PageDataVO<SystemLogVO>> page(SystemLogQuery query, @Validated PageQuery pageQuery) {
|
public PageDataVO<SystemLogVO> page(SystemLogQuery query, @Validated PageQuery pageQuery) {
|
||||||
PageDataVO<SystemLogVO> pageDataVO = logService.page(query, pageQuery);
|
return logService.page(query, pageQuery);
|
||||||
return R.ok(pageDataVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(module = "系统日志")
|
@Log(module = "系统日志")
|
||||||
@Operation(summary = "查看系统日志详情", description = "查看系统日志详情")
|
@Operation(summary = "查看系统日志详情", description = "查看系统日志详情")
|
||||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||||
@GetMapping("/system/{id}")
|
@GetMapping("/system/{id}")
|
||||||
public R<SystemLogDetailVO> get(@PathVariable Long id) {
|
public SystemLogDetailVO get(@PathVariable Long id) {
|
||||||
SystemLogDetailVO detailVO = logService.get(id);
|
return logService.get(id);
|
||||||
return R.ok(detailVO);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ public class OnlineUserController {
|
|||||||
@Operation(summary = "分页查询列表", description = "分页查询列表")
|
@Operation(summary = "分页查询列表", description = "分页查询列表")
|
||||||
@SaCheckPermission("monitor:online:user:list")
|
@SaCheckPermission("monitor:online:user:list")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public R<PageDataVO<OnlineUserVO>> page(OnlineUserQuery query, @Validated PageQuery pageQuery) {
|
public PageDataVO<OnlineUserVO> page(OnlineUserQuery query, @Validated PageQuery pageQuery) {
|
||||||
return R.ok(onlineUserService.page(query, pageQuery));
|
return onlineUserService.page(query, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "强退在线用户", description = "强退在线用户")
|
@Operation(summary = "强退在线用户", description = "强退在线用户")
|
||||||
|
@ -28,7 +28,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.model.vo.R;
|
|
||||||
import top.charles7c.cnadmin.system.model.query.OptionQuery;
|
import top.charles7c.cnadmin.system.model.query.OptionQuery;
|
||||||
import top.charles7c.cnadmin.system.model.request.OptionRequest;
|
import top.charles7c.cnadmin.system.model.request.OptionRequest;
|
||||||
import top.charles7c.cnadmin.system.model.request.ResetOptionValueRequest;
|
import top.charles7c.cnadmin.system.model.request.ResetOptionValueRequest;
|
||||||
@ -52,23 +51,21 @@ public class OptionController {
|
|||||||
@Operation(summary = "查询参数列表", description = "查询参数列表")
|
@Operation(summary = "查询参数列表", description = "查询参数列表")
|
||||||
@SaCheckPermission("system:config:list")
|
@SaCheckPermission("system:config:list")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public R<List<OptionVO>> list(@Validated OptionQuery query) {
|
public List<OptionVO> list(@Validated OptionQuery query) {
|
||||||
return R.ok(optionService.list(query));
|
return optionService.list(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改参数", description = "修改参数")
|
@Operation(summary = "修改参数", description = "修改参数")
|
||||||
@SaCheckPermission("system:config:update")
|
@SaCheckPermission("system:config:update")
|
||||||
@PatchMapping
|
@PatchMapping
|
||||||
public R update(@Validated @RequestBody List<OptionRequest> request) {
|
public void update(@Validated @RequestBody List<OptionRequest> request) {
|
||||||
optionService.update(request);
|
optionService.update(request);
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "重置参数", description = "重置参数")
|
@Operation(summary = "重置参数", description = "重置参数")
|
||||||
@SaCheckPermission("system:config:reset")
|
@SaCheckPermission("system:config:reset")
|
||||||
@PatchMapping("/value")
|
@PatchMapping("/value")
|
||||||
public R resetValue(@Validated @RequestBody ResetOptionValueRequest request) {
|
public void resetValue(@Validated @RequestBody ResetOptionValueRequest request) {
|
||||||
optionService.resetValue(request);
|
optionService.resetValue(request);
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -61,8 +61,8 @@ public class GeneratorController {
|
|||||||
@Operation(summary = "分页查询数据表", description = "分页查询数据表")
|
@Operation(summary = "分页查询数据表", description = "分页查询数据表")
|
||||||
@SaCheckPermission("tool:generator:list")
|
@SaCheckPermission("tool:generator:list")
|
||||||
@GetMapping("/table")
|
@GetMapping("/table")
|
||||||
public R<PageDataVO<TableVO>> pageTable(TableQuery query, @Validated PageQuery pageQuery) throws SQLException {
|
public PageDataVO<TableVO> pageTable(TableQuery query, @Validated PageQuery pageQuery) throws SQLException {
|
||||||
return R.ok(generatorService.pageTable(query, pageQuery));
|
return generatorService.pageTable(query, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询字段配置列表", description = "查询字段配置列表")
|
@Operation(summary = "查询字段配置列表", description = "查询字段配置列表")
|
||||||
@ -70,17 +70,17 @@ public class GeneratorController {
|
|||||||
@Parameter(name = "requireSync", description = "是否需要同步", example = "false", in = ParameterIn.QUERY)
|
@Parameter(name = "requireSync", description = "是否需要同步", example = "false", in = ParameterIn.QUERY)
|
||||||
@SaCheckPermission("tool:generator:list")
|
@SaCheckPermission("tool:generator:list")
|
||||||
@GetMapping("/field/{tableName}")
|
@GetMapping("/field/{tableName}")
|
||||||
public R<List<FieldConfigDO>> listFieldConfig(@PathVariable String tableName,
|
public List<FieldConfigDO> listFieldConfig(@PathVariable String tableName,
|
||||||
@RequestParam(required = false, defaultValue = "false") Boolean requireSync) {
|
@RequestParam(required = false, defaultValue = "false") Boolean requireSync) {
|
||||||
return R.ok(generatorService.listFieldConfig(tableName, requireSync));
|
return generatorService.listFieldConfig(tableName, requireSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询生成配置信息", description = "查询生成配置信息")
|
@Operation(summary = "查询生成配置信息", description = "查询生成配置信息")
|
||||||
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
|
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
|
||||||
@SaCheckPermission("tool:generator:list")
|
@SaCheckPermission("tool:generator:list")
|
||||||
@GetMapping("/config/{tableName}")
|
@GetMapping("/config/{tableName}")
|
||||||
public R<GenConfigDO> getGenConfig(@PathVariable String tableName) throws SQLException {
|
public GenConfigDO getGenConfig(@PathVariable String tableName) throws SQLException {
|
||||||
return R.ok(generatorService.getGenConfig(tableName));
|
return generatorService.getGenConfig(tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "保存配置信息", description = "保存配置信息")
|
@Operation(summary = "保存配置信息", description = "保存配置信息")
|
||||||
|
Loading…
Reference in New Issue
Block a user