dev-v2 #3

Merged
bunny merged 122 commits from dev-v2 into master-v2 2024-03-30 23:40:58 +08:00
27 changed files with 107 additions and 37 deletions
Showing only changes of commit e62c75b188 - Show all commits

View File

@ -10,7 +10,6 @@ import java.lang.annotation.Target;
@Target({ElementType.METHOD}) @Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface Log { // 自定义操作日志记录注解 public @interface Log { // 自定义操作日志记录注解
String title(); // 模块名称 String title(); // 模块名称
OperatorType operatorType() default OperatorType.MANAGE; // 操作人类别 OperatorType operatorType() default OperatorType.MANAGE; // 操作人类别
@ -20,5 +19,4 @@ public @interface Log { // 自定义操作日志记录注解
boolean isSaveRequestData() default true; // 是否保存请求的参数 boolean isSaveRequestData() default true; // 是否保存请求的参数
boolean isSaveResponseData() default true; // 是否保存响应的参数 boolean isSaveResponseData() default true; // 是否保存响应的参数
} }

View File

@ -21,12 +21,14 @@ public class LogAspect {
@Around(value = "@annotation(sysLog)") @Around(value = "@annotation(sysLog)")
public Object doAroundAdvice(ProceedingJoinPoint joinPoint, Log sysLog) { public Object doAroundAdvice(ProceedingJoinPoint joinPoint, Log sysLog) {
String title = sysLog.title();
log.info("请求了===>{}", title);
// 构建前置参数 // 构建前置参数
SysOperLog sysOperLog = new SysOperLog(); SysOperLog sysOperLog = new SysOperLog();
LogUtil.beforeHandleLog(sysLog, joinPoint, sysOperLog); LogUtil.beforeHandleLog(sysLog, joinPoint, sysOperLog);
Object proceed = null; Object proceed = null;
try { try {
proceed = joinPoint.proceed(); proceed = joinPoint.proceed();
// 执行业务方法 // 执行业务方法

View File

@ -17,9 +17,7 @@ import java.util.Arrays;
public class LogUtil { public class LogUtil {
// 操作执行之后调用 // 操作执行之后调用
public static void afterHandleLog(Log sysLog, Object proceed, public static void afterHandleLog(Log sysLog, Object proceed, SysOperLog sysOperLog, int status, String errorMsg) {
SysOperLog sysOperLog, int status,
String errorMsg) {
if (sysLog.isSaveResponseData()) { if (sysLog.isSaveResponseData()) {
sysOperLog.setJsonResult(JSON.toJSONString(proceed)); sysOperLog.setJsonResult(JSON.toJSONString(proceed));
} }
@ -28,9 +26,7 @@ public class LogUtil {
} }
// 操作执行之前调用 // 操作执行之前调用
public static void beforeHandleLog(Log sysLog, public static void beforeHandleLog(Log sysLog, ProceedingJoinPoint joinPoint, SysOperLog sysOperLog) {
ProceedingJoinPoint joinPoint,
SysOperLog sysOperLog) {
// 设置操作模块名称 // 设置操作模块名称
sysOperLog.setTitle(sysLog.title()); sysOperLog.setTitle(sysLog.title());
@ -40,15 +36,12 @@ public class LogUtil {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod(); Method method = methodSignature.getMethod();
sysOperLog.setMethod(method.getDeclaringClass().getName()); sysOperLog.setMethod(method.getDeclaringClass().getName());
// 获取请求相关参数 // 获取请求相关参数
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
RequestContextHolder.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest(); HttpServletRequest request = requestAttributes.getRequest();
sysOperLog.setRequestMethod(request.getMethod()); sysOperLog.setRequestMethod(request.getMethod());
sysOperLog.setOperUrl(request.getRequestURI()); sysOperLog.setOperUrl(request.getRequestURI());
sysOperLog.setOperIp(request.getRemoteAddr()); sysOperLog.setOperIp(request.getRemoteAddr());
// 设置请求参数 // 设置请求参数
if (sysLog.isSaveRequestData()) { if (sysLog.isSaveRequestData()) {
String requestMethod = sysOperLog.getRequestMethod(); String requestMethod = sysOperLog.getRequestMethod();

View File

@ -11,15 +11,14 @@ import org.springframework.context.annotation.Configuration;
public class Knife4jConfig { public class Knife4jConfig {
@Bean @Bean
public GroupedOpenApi adminApi() { public GroupedOpenApi adminApi() {
return GroupedOpenApi.builder() // 分组名称 // 分组名称
.group("admin请求接口").pathsToMatch("/admin/**") // 接口请求路径规则 return GroupedOpenApi.builder().group("admin请求接口").pathsToMatch("/admin/**").build();// 接口请求路径规则
.build();
} }
@Bean @Bean
public OpenAPI customOpenAPI() { public OpenAPI customOpenAPI() {
// 设定作者
return new OpenAPI().info(new Info().title("尚品甑选API接口文档") return new OpenAPI().info(new Info().title("尚品甑选API接口文档")
.version("1.0").description("尚品甑选API接口文档") .version("1.0").description("尚品甑选API接口文档").contact(new Contact().name("bunny")));
.contact(new Contact().name("bunny"))); // 设定作者
} }
} }

View File

@ -36,6 +36,8 @@ public class RedisConfiguration {
*/ */
@Bean @Bean
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory connectionFactory) { public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory connectionFactory) {
log.info("RedisConfiguration===>使用StringRedisSerializer序列化为字符串");
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(connectionFactory); redisTemplate.setConnectionFactory(connectionFactory);
// 设置key序列化为string // 设置key序列化为string
@ -54,6 +56,8 @@ public class RedisConfiguration {
@Bean @Bean
@SuppressWarnings("all") @SuppressWarnings("all")
public CacheManager cacheManager(RedisConnectionFactory factory) { public CacheManager cacheManager(RedisConnectionFactory factory) {
log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题");
StringRedisSerializer redisSerializer = new StringRedisSerializer(); StringRedisSerializer redisSerializer = new StringRedisSerializer();
// json序列化 // json序列化
Jackson2JsonRedisSerializer<Object> serializer = jsonRedisSerializer(); Jackson2JsonRedisSerializer<Object> serializer = jsonRedisSerializer();
@ -72,6 +76,8 @@ public class RedisConfiguration {
* 指定的日期模式 * 指定的日期模式
*/ */
public Jackson2JsonRedisSerializer<Object> jsonRedisSerializer() { public Jackson2JsonRedisSerializer<Object> jsonRedisSerializer() {
log.info("RedisConfiguration===>指定的日期模式");
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// 设置ObjectMapper访问权限 // 设置ObjectMapper访问权限
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);

View File

@ -9,6 +9,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
public class ResourceConfiguration extends WebMvcConfiguration { public class ResourceConfiguration extends WebMvcConfiguration {
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
log.info("设置静态资源映射"); log.info("设置静态资源映射");
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
} }

View File

@ -24,6 +24,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
*/ */
protected void addCorsMappings(CorsRegistry registry) { protected void addCorsMappings(CorsRegistry registry) {
log.info("WebMvcConfiguration===>开始跨域注册表..."); log.info("WebMvcConfiguration===>开始跨域注册表...");
registry.addMapping("/**")// 添加路径规则 registry.addMapping("/**")// 添加路径规则
.allowCredentials(true)// 是否允许在跨域的情况下传递Cookie .allowCredentials(true)// 是否允许在跨域的情况下传递Cookie
.allowedOriginPatterns("*")// 允许请求来源的域规则 .allowedOriginPatterns("*")// 允许请求来源的域规则
@ -37,6 +38,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
*/ */
protected void addInterceptors(InterceptorRegistry registry) { protected void addInterceptors(InterceptorRegistry registry) {
log.info("WebMvcConfiguration===>开始注册自定义拦截器..."); log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
// 需要拦截的 // 需要拦截的
registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/admin/**") registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/admin/**")
.excludePathPatterns(interceptorsProperties.getNoAuthUrls()); .excludePathPatterns(interceptorsProperties.getNoAuthUrls());

View File

@ -21,6 +21,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Result<Object> exceptionHandler(BunnyException exception) { public Result<Object> exceptionHandler(BunnyException exception) {
log.error("GlobalExceptionHandler===>自定义异常信息:{}", exception.getMessage()); log.error("GlobalExceptionHandler===>自定义异常信息:{}", exception.getMessage());
Integer code = exception.getCode() != null ? exception.getCode() : 500; Integer code = exception.getCode() != null ? exception.getCode() : 500;
return Result.error(null, code, exception.getMessage()); return Result.error(null, code, exception.getMessage());
} }
@ -48,6 +49,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Result<Object> error(ArithmeticException exception) { public Result<Object> error(ArithmeticException exception) {
log.error("GlobalExceptionHandler===>特定异常信息:{}", exception.getMessage()); log.error("GlobalExceptionHandler===>特定异常信息:{}", exception.getMessage());
return Result.error(null, 500, exception.getMessage()); return Result.error(null, 500, exception.getMessage());
} }
@ -56,6 +58,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Result<String> error(AccessDeniedException exception) throws AccessDeniedException { public Result<String> error(AccessDeniedException exception) throws AccessDeniedException {
log.error("GlobalExceptionHandler===>spring security异常{}", exception.getMessage()); log.error("GlobalExceptionHandler===>spring security异常{}", exception.getMessage());
return Result.error(ResultCodeEnum.PERMISSION); return Result.error(ResultCodeEnum.PERMISSION);
} }
@ -64,6 +67,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Result<String> exceptionHandler(SQLIntegrityConstraintViolationException exception) { public Result<String> exceptionHandler(SQLIntegrityConstraintViolationException exception) {
log.error("GlobalExceptionHandler===>处理SQL异常:{}", exception.getMessage()); log.error("GlobalExceptionHandler===>处理SQL异常:{}", exception.getMessage());
String message = exception.getMessage(); String message = exception.getMessage();
if (message.contains("Duplicate entry")) { if (message.contains("Duplicate entry")) {
// 截取用户名 // 截取用户名

View File

@ -26,6 +26,8 @@ public class LoginAuthInterceptor implements HandlerInterceptor {
@Override @Override
public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) throws Exception { public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) throws Exception {
log.info("LoginAuthInterceptor===>preHandle拦截请求前");
String method = request.getMethod(); String method = request.getMethod();
String token = request.getHeader("token"); String token = request.getHeader("token");
@ -63,6 +65,8 @@ public class LoginAuthInterceptor implements HandlerInterceptor {
*/ */
@Override @Override
public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, @Nullable Exception ex) throws Exception { public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, @Nullable Exception ex) throws Exception {
log.info("LoginAuthInterceptor===>请求完成后删除ThreadLocal");
BaseContext.removeSysUser(); BaseContext.removeSysUser();
} }
} }

View File

@ -56,10 +56,12 @@ public class MenuHelper {
*/ */
public static List<SysMenuVo> buildMenus(List<SysMenu> menus) { public static List<SysMenuVo> buildMenus(List<SysMenu> menus) {
LinkedList<SysMenuVo> sysMenuVos = new LinkedList<>(); LinkedList<SysMenuVo> sysMenuVos = new LinkedList<>();
menus.forEach(menu -> { menus.forEach(menu -> {
SysMenuVo menuVo = new SysMenuVo(); SysMenuVo menuVo = new SysMenuVo();
menuVo.setTitle(menu.getTitle()); menuVo.setTitle(menu.getTitle());
menuVo.setName(menu.getComponent()); menuVo.setName(menu.getComponent());
List<SysMenu> children = menu.getChildren(); List<SysMenu> children = menu.getChildren();
if (!CollectionUtils.isEmpty(children)) { if (!CollectionUtils.isEmpty(children)) {
menuVo.setChildren(buildMenus(children)); menuVo.setChildren(buildMenus(children));

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.BrandService; import com.atguigu.spzx.manger.service.BrandService;
import com.atguigu.spzx.model.entity.product.Brand; import com.atguigu.spzx.model.entity.product.Brand;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
@ -18,13 +19,15 @@ public class BrandController {
@Autowired @Autowired
private BrandService brandService; private BrandService brandService;
@Operation(summary = "品牌列表查询", description = "品牌列表查询") @Log(title = "品牌列表分页查询", businessType = 0)
@Operation(summary = "品牌列表分页查询", description = "品牌列表查询")
@GetMapping("{page}/{limit}") @GetMapping("{page}/{limit}")
public Result<PageInfo<Brand>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) { public Result<PageInfo<Brand>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) {
PageInfo<Brand> pageInfo = brandService.findByPage(page, limit); PageInfo<Brand> pageInfo = brandService.findByPage(page, limit);
return Result.success(pageInfo); return Result.success(pageInfo);
} }
@Log(title = "品牌添加", businessType = 1)
@Operation(summary = "品牌添加", description = "品牌添加") @Operation(summary = "品牌添加", description = "品牌添加")
@PostMapping("save") @PostMapping("save")
public Result<Brand> save(@RequestBody Brand brand) { public Result<Brand> save(@RequestBody Brand brand) {
@ -32,6 +35,7 @@ public class BrandController {
return Result.success(); return Result.success();
} }
@Log(title = "修改品牌", businessType = 2)
@Operation(summary = "修改品牌", description = "修改品牌") @Operation(summary = "修改品牌", description = "修改品牌")
@PutMapping("updateById") @PutMapping("updateById")
public Result<Brand> updateById(@RequestBody Brand brand) { public Result<Brand> updateById(@RequestBody Brand brand) {
@ -39,6 +43,7 @@ public class BrandController {
return Result.success(); return Result.success();
} }
@Log(title = "删除品牌", businessType = 3)
@Operation(summary = "删除品牌", description = "删除品牌") @Operation(summary = "删除品牌", description = "删除品牌")
@DeleteMapping("deleteById/{id}") @DeleteMapping("deleteById/{id}")
public Result<Long> deleteById(@PathVariable Long id) { public Result<Long> deleteById(@PathVariable Long id) {
@ -46,6 +51,7 @@ public class BrandController {
return Result.success(); return Result.success();
} }
@Log(title = "品牌列表", businessType = 0)
@Operation(summary = "品牌列表", description = "品牌列表接口") @Operation(summary = "品牌列表", description = "品牌列表接口")
@GetMapping("findAll") @GetMapping("findAll")
public Result<List<Brand>> findAll() { public Result<List<Brand>> findAll() {

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.CategoryBrandService; import com.atguigu.spzx.manger.service.CategoryBrandService;
import com.atguigu.spzx.model.dto.product.CategoryBrandDto; import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
import com.atguigu.spzx.model.entity.product.CategoryBrand; import com.atguigu.spzx.model.entity.product.CategoryBrand;
@ -17,6 +18,7 @@ public class CategoryBrandController {
@Autowired @Autowired
private CategoryBrandService categoryBrandService; private CategoryBrandService categoryBrandService;
@Log(title = "分类品牌列表", businessType = 0)
@Operation(summary = "分类品牌列表", description = "分类品牌列表接口") @Operation(summary = "分类品牌列表", description = "分类品牌列表接口")
@GetMapping("{page}/{limit}") @GetMapping("{page}/{limit}")
public Result<PageInfo<CategoryBrand>> findByPage(@PathVariable Integer page, @PathVariable Integer limit, CategoryBrandDto dto) { public Result<PageInfo<CategoryBrand>> findByPage(@PathVariable Integer page, @PathVariable Integer limit, CategoryBrandDto dto) {
@ -24,6 +26,7 @@ public class CategoryBrandController {
return Result.success(pageInfo); return Result.success(pageInfo);
} }
@Log(title = "添加功能", businessType = 1)
@Operation(summary = "添加功能", description = "添加功能") @Operation(summary = "添加功能", description = "添加功能")
@PostMapping("save") @PostMapping("save")
public Result<CategoryBrand> save(@RequestBody CategoryBrand categoryBrand) { public Result<CategoryBrand> save(@RequestBody CategoryBrand categoryBrand) {
@ -31,6 +34,7 @@ public class CategoryBrandController {
return Result.success(); return Result.success();
} }
@Log(title = "添加功能", businessType = 2)
@Operation(summary = "修改功能", description = "修改功能") @Operation(summary = "修改功能", description = "修改功能")
@PutMapping("updateById") @PutMapping("updateById")
public Result<CategoryBrand> updateById(@RequestBody CategoryBrand categoryBrand) { public Result<CategoryBrand> updateById(@RequestBody CategoryBrand categoryBrand) {
@ -38,6 +42,7 @@ public class CategoryBrandController {
return Result.success(); return Result.success();
} }
@Log(title = "添加功能", businessType = 3)
@Operation(summary = "删除功能", description = "删除功能") @Operation(summary = "删除功能", description = "删除功能")
@DeleteMapping("deleteById/{id}") @DeleteMapping("deleteById/{id}")
public Result<Long> deleteById(@PathVariable Long id) { public Result<Long> deleteById(@PathVariable Long id) {

View File

@ -1,7 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log; import com.atguigu.log.annotation.Log;
import com.atguigu.log.enums.OperatorType;
import com.atguigu.spzx.manger.service.CategoryService; import com.atguigu.spzx.manger.service.CategoryService;
import com.atguigu.spzx.model.entity.product.Category; import com.atguigu.spzx.model.entity.product.Category;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
@ -21,8 +20,7 @@ public class CategoryController {
@Autowired @Autowired
private CategoryService categoryService; private CategoryService categoryService;
@Log(title = "根据parentId获取下级节点", businessType = 0)
@Log(title = "根据parentId获取下级节点", businessType = 0, operatorType = OperatorType.MANAGE)
@Operation(summary = "根据parentId获取下级节点", description = "根据parentId获取下级节点") @Operation(summary = "根据parentId获取下级节点", description = "根据parentId获取下级节点")
@GetMapping(value = "findCategoryList/{parentId}") @GetMapping(value = "findCategoryList/{parentId}")
public Result<List<Category>> findByParentId(@PathVariable Long parentId) { public Result<List<Category>> findByParentId(@PathVariable Long parentId) {
@ -30,12 +28,14 @@ public class CategoryController {
return Result.success(list); return Result.success(list);
} }
@Log(title = "根据parentId获取下级节点", businessType = 0)
@Operation(summary = "导出数据", description = "导出数据") @Operation(summary = "导出数据", description = "导出数据")
@GetMapping(value = "/exportData") @GetMapping(value = "/exportData")
public void exportData(HttpServletResponse response) { public void exportData(HttpServletResponse response) {
categoryService.exportData(response); categoryService.exportData(response);
} }
@Log(title = "根据parentId获取下级节点", businessType = 0)
@Operation(summary = "导入功能", description = "导入功能") @Operation(summary = "导入功能", description = "导入功能")
@PostMapping("importData") @PostMapping("importData")
public Result<String> importData(MultipartFile file) { public Result<String> importData(MultipartFile file) {

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.FileUploadService; import com.atguigu.spzx.manger.service.FileUploadService;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -18,6 +19,7 @@ public class FileUploadController {
@Autowired @Autowired
private FileUploadService fileUploadService; private FileUploadService fileUploadService;
@Log(title = "上传文件", businessType = 0)
@Operation(summary = "上传文件", description = "上传文件内容") @Operation(summary = "上传文件", description = "上传文件内容")
@PostMapping("fileUpload") @PostMapping("fileUpload")
public Result<String> fileUploadService(@RequestParam(value = "file") MultipartFile file) { public Result<String> fileUploadService(@RequestParam(value = "file") MultipartFile file) {

View File

@ -1,6 +1,7 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.context.BaseContext; import com.atguigu.context.BaseContext;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.SysMenuService; import com.atguigu.spzx.manger.service.SysMenuService;
import com.atguigu.spzx.manger.service.SysUserService; import com.atguigu.spzx.manger.service.SysUserService;
import com.atguigu.spzx.manger.service.ValidateCodeService; import com.atguigu.spzx.manger.service.ValidateCodeService;
@ -42,6 +43,7 @@ public class IndexController {
return Result.success(vo); return Result.success(vo);
} }
@Log(title = "获取登录用户信息", businessType = 0)
@Operation(summary = "获取登录用户信息", description = "获取当前登录用户信息") @Operation(summary = "获取登录用户信息", description = "获取当前登录用户信息")
@GetMapping("getUserInfo") @GetMapping("getUserInfo")
public Result<SysUser> getUserInfo() { public Result<SysUser> getUserInfo() {
@ -56,6 +58,7 @@ public class IndexController {
return Result.success(); return Result.success();
} }
@Log(title = "动态菜单", businessType = 0)
@Operation(summary = "动态菜单", description = "动态菜单") @Operation(summary = "动态菜单", description = "动态菜单")
@GetMapping("menus") @GetMapping("menus")
public Result<List<SysMenuVo>> menus() { public Result<List<SysMenuVo>> menus() {

View File

@ -1,10 +1,10 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.OrderInfoService; import com.atguigu.spzx.manger.service.OrderInfoService;
import com.atguigu.spzx.model.dto.order.OrderStatisticsDto; import com.atguigu.spzx.model.dto.order.OrderStatisticsDto;
import com.atguigu.spzx.model.vo.order.OrderStatisticsVo; import com.atguigu.spzx.model.vo.order.OrderStatisticsVo;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -20,10 +20,11 @@ public class OrderInfoController {
@Autowired @Autowired
private OrderInfoService orderInfoService; private OrderInfoService orderInfoService;
@Log(title = "统计查询", businessType = 0)
@Operation(summary = "统计查询", description = "统计查询") @Operation(summary = "统计查询", description = "统计查询")
@GetMapping("/getOrderStatisticsData") @GetMapping("/getOrderStatisticsData")
public Result<OrderStatisticsVo> getOrderStatisticsData(OrderStatisticsDto orderStatisticsDto) { public Result<OrderStatisticsVo> getOrderStatisticsData(OrderStatisticsDto orderStatisticsDto) {
OrderStatisticsVo orderStatisticsVo = orderInfoService.getOrderStatisticsData(orderStatisticsDto); OrderStatisticsVo orderStatisticsVo = orderInfoService.getOrderStatisticsData(orderStatisticsDto);
return Result.build(orderStatisticsVo, ResultCodeEnum.SUCCESS); return Result.success(orderStatisticsVo);
} }
} }

View File

@ -1,7 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log; import com.atguigu.log.annotation.Log;
import com.atguigu.log.enums.OperatorType;
import com.atguigu.spzx.manger.service.CategoryBrandService; import com.atguigu.spzx.manger.service.CategoryBrandService;
import com.atguigu.spzx.manger.service.ProductService; import com.atguigu.spzx.manger.service.ProductService;
import com.atguigu.spzx.model.dto.product.ProductDto; import com.atguigu.spzx.model.dto.product.ProductDto;
@ -27,6 +26,7 @@ public class ProductController {
@Autowired @Autowired
private CategoryBrandService categoryBrandService; private CategoryBrandService categoryBrandService;
@Log(title = "列表查询", businessType = 0)
@Operation(summary = "列表查询", description = "列表查询") @Operation(summary = "列表查询", description = "列表查询")
@GetMapping("{page}/{limit}") @GetMapping("{page}/{limit}")
public Result<PageInfo<Product>> findByPage(@PathVariable Integer page, @PathVariable Integer limit, ProductDto dto) { public Result<PageInfo<Product>> findByPage(@PathVariable Integer page, @PathVariable Integer limit, ProductDto dto) {
@ -34,6 +34,7 @@ public class ProductController {
return Result.success(pageInfo); return Result.success(pageInfo);
} }
@Log(title = "添加功能", businessType = 1)
@Operation(summary = "添加功能", description = "添加功能") @Operation(summary = "添加功能", description = "添加功能")
@GetMapping("findBrandByCategoryId/{categoryId}") @GetMapping("findBrandByCategoryId/{categoryId}")
public Result<List<Brand>> findBrandByCategoryId(@PathVariable Long categoryId) { public Result<List<Brand>> findBrandByCategoryId(@PathVariable Long categoryId) {
@ -41,6 +42,7 @@ public class ProductController {
return Result.success(brandList); return Result.success(brandList);
} }
@Log(title = "保存商品数据接口", businessType = 2)
@Operation(summary = "保存商品数据接口", description = "保存商品数据接口") @Operation(summary = "保存商品数据接口", description = "保存商品数据接口")
@PostMapping("save") @PostMapping("save")
public Result<Product> save(@RequestBody Product product) { public Result<Product> save(@RequestBody Product product) {
@ -48,7 +50,7 @@ public class ProductController {
return Result.success(); return Result.success();
} }
@Log(title = "查询商品详情", businessType = 0, operatorType = OperatorType.MANAGE) @Log(title = "查询商品详情", businessType = 0)
@Operation(summary = "查询商品详情", description = "查询商品详情") @Operation(summary = "查询商品详情", description = "查询商品详情")
@GetMapping("getById/{id}") @GetMapping("getById/{id}")
public Result<Product> getById(@PathVariable Long id) { public Result<Product> getById(@PathVariable Long id) {
@ -56,6 +58,7 @@ public class ProductController {
return Result.success(product); return Result.success(product);
} }
@Log(title = "查询商品详情", businessType = 1)
@Operation(summary = "保存修改数据接口", description = "保存修改数据接口") @Operation(summary = "保存修改数据接口", description = "保存修改数据接口")
@PutMapping("updateById") @PutMapping("updateById")
public Result<Product> updateById(@Parameter(name = "product", description = "请求参数实体类", required = true) @RequestBody Product product) { public Result<Product> updateById(@Parameter(name = "product", description = "请求参数实体类", required = true) @RequestBody Product product) {
@ -63,6 +66,7 @@ public class ProductController {
return Result.success(); return Result.success();
} }
@Log(title = "查询商品详情", businessType = 3)
@Operation(summary = "删除商品", description = "删除商品") @Operation(summary = "删除商品", description = "删除商品")
@DeleteMapping("/deleteById/{id}") @DeleteMapping("/deleteById/{id}")
public Result<Long> deleteById(@Parameter(name = "id", description = "商品id", required = true) @PathVariable Long id) { public Result<Long> deleteById(@Parameter(name = "id", description = "商品id", required = true) @PathVariable Long id) {
@ -70,6 +74,7 @@ public class ProductController {
return Result.success(); return Result.success();
} }
@Log(title = "商品审核", businessType = 0)
@Operation(summary = "商品审核", description = "商品审核") @Operation(summary = "商品审核", description = "商品审核")
@GetMapping("/updateAuditStatus/{id}/{auditStatus}") @GetMapping("/updateAuditStatus/{id}/{auditStatus}")
public Result<Product> updateAuditStatus(@PathVariable Long id, @PathVariable Integer auditStatus) { public Result<Product> updateAuditStatus(@PathVariable Long id, @PathVariable Integer auditStatus) {
@ -77,6 +82,7 @@ public class ProductController {
return Result.success(); return Result.success();
} }
@Log(title = "商品上下架", businessType = 0)
@Operation(summary = "商品上下架", description = "商品上下架") @Operation(summary = "商品上下架", description = "商品上下架")
@GetMapping("/updateStatus/{id}/{status}") @GetMapping("/updateStatus/{id}/{status}")
public Result<Product> updateStatus(@PathVariable Long id, @PathVariable Integer status) { public Result<Product> updateStatus(@PathVariable Long id, @PathVariable Integer status) {

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.ProductSpecService; import com.atguigu.spzx.manger.service.ProductSpecService;
import com.atguigu.spzx.model.entity.product.ProductSpec; import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
@ -18,6 +19,7 @@ public class ProductSpecController {
@Autowired @Autowired
private ProductSpecService productSpecService; private ProductSpecService productSpecService;
@Log(title = "列表查询", businessType = 0)
@Operation(summary = "列表查询", description = "列表查询") @Operation(summary = "列表查询", description = "列表查询")
@GetMapping("{page}/{limit}") @GetMapping("{page}/{limit}")
public Result<PageInfo<ProductSpec>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) { public Result<PageInfo<ProductSpec>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) {
@ -25,6 +27,7 @@ public class ProductSpecController {
return Result.success(pageInfo); return Result.success(pageInfo);
} }
@Log(title = "添加功能", businessType = 1)
@Operation(summary = "添加功能", description = "添加功能") @Operation(summary = "添加功能", description = "添加功能")
@PostMapping("save") @PostMapping("save")
public Result<ProductSpec> save(@RequestBody ProductSpec productSpec) { public Result<ProductSpec> save(@RequestBody ProductSpec productSpec) {
@ -32,6 +35,7 @@ public class ProductSpecController {
return Result.success(); return Result.success();
} }
@Log(title = "修改功能", businessType = 2)
@Operation(summary = "修改功能", description = "修改功能") @Operation(summary = "修改功能", description = "修改功能")
@PutMapping("updateById") @PutMapping("updateById")
public Result<ProductSpec> updateById(@RequestBody ProductSpec productSpec) { public Result<ProductSpec> updateById(@RequestBody ProductSpec productSpec) {
@ -39,6 +43,7 @@ public class ProductSpecController {
return Result.success(); return Result.success();
} }
@Log(title = "删除功能", businessType = 3)
@Operation(summary = "删除功能", description = "删除功能") @Operation(summary = "删除功能", description = "删除功能")
@DeleteMapping("deleteById/{id}") @DeleteMapping("deleteById/{id}")
public Result<Long> removeById(@PathVariable Long id) { public Result<Long> removeById(@PathVariable Long id) {
@ -46,6 +51,7 @@ public class ProductSpecController {
return Result.success(); return Result.success();
} }
@Log(title = "加载商品规格数据", businessType = 0)
@Operation(summary = "加载商品规格数据", description = "加载商品规格数据") @Operation(summary = "加载商品规格数据", description = "加载商品规格数据")
@GetMapping("findAll") @GetMapping("findAll")
public Result<List<ProductSpec>> findAll() { public Result<List<ProductSpec>> findAll() {

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.ProductUnitService; import com.atguigu.spzx.manger.service.ProductUnitService;
import com.atguigu.spzx.model.entity.base.ProductUnit; import com.atguigu.spzx.model.entity.base.ProductUnit;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
@ -19,6 +20,7 @@ public class ProductUnitController {
@Autowired @Autowired
private ProductUnitService productUnitService; private ProductUnitService productUnitService;
@Log(title = "加载商品单元数据", businessType = 0)
@Operation(summary = "加载商品单元数据", description = "加载商品单元数据") @Operation(summary = "加载商品单元数据", description = "加载商品单元数据")
@GetMapping("findAll") @GetMapping("findAll")
public Result<List<ProductUnit>> findAll() { public Result<List<ProductUnit>> findAll() {

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.SysMenuService; import com.atguigu.spzx.manger.service.SysMenuService;
import com.atguigu.spzx.model.entity.system.SysMenu; import com.atguigu.spzx.model.entity.system.SysMenu;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
@ -19,6 +20,7 @@ public class SysMenuController {
@Autowired @Autowired
private SysMenuService sysMenuService; private SysMenuService sysMenuService;
@Log(title = "查询菜单", businessType = 0)
@Operation(summary = "查询菜单", description = "查询菜单内容") @Operation(summary = "查询菜单", description = "查询菜单内容")
@GetMapping("/findNodes") @GetMapping("/findNodes")
public Result<List<SysMenu>> findNodes() { public Result<List<SysMenu>> findNodes() {
@ -26,6 +28,7 @@ public class SysMenuController {
return Result.build(list, ResultCodeEnum.SUCCESS); return Result.build(list, ResultCodeEnum.SUCCESS);
} }
@Log(title = "添加菜单", businessType = 1)
@Operation(summary = "添加菜单", description = "添加菜单") @Operation(summary = "添加菜单", description = "添加菜单")
@PostMapping("save") @PostMapping("save")
public Result<SysMenu> save(@RequestBody SysMenu sysMenu) { public Result<SysMenu> save(@RequestBody SysMenu sysMenu) {
@ -33,6 +36,7 @@ public class SysMenuController {
return Result.success(); return Result.success();
} }
@Log(title = "修改菜单", businessType = 2)
@Operation(summary = "修改菜单", description = "修改菜单") @Operation(summary = "修改菜单", description = "修改菜单")
@PutMapping("updateById") @PutMapping("updateById")
public Result<SysMenu> updateById(@RequestBody SysMenu sysMenu) { public Result<SysMenu> updateById(@RequestBody SysMenu sysMenu) {
@ -40,6 +44,7 @@ public class SysMenuController {
return Result.success(); return Result.success();
} }
@Log(title = "删除菜单", businessType = 3)
@Operation(summary = "删除菜单", description = "删除菜单") @Operation(summary = "删除菜单", description = "删除菜单")
@PutMapping("removeById/{id}") @PutMapping("removeById/{id}")
public Result<Long> removeById(@PathVariable Long id) { public Result<Long> removeById(@PathVariable Long id) {

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.SysRoleService; import com.atguigu.spzx.manger.service.SysRoleService;
import com.atguigu.spzx.model.dto.system.AssginRoleDto; import com.atguigu.spzx.model.dto.system.AssginRoleDto;
import com.atguigu.spzx.model.dto.system.SysRoleDto; import com.atguigu.spzx.model.dto.system.SysRoleDto;
@ -19,6 +20,7 @@ public class SysRoleController {
@Autowired @Autowired
private SysRoleService sysRoleService; private SysRoleService sysRoleService;
@Log(title = "查询角色分页", businessType = 0)
@Operation(summary = "查询角色分页", description = "查询角色信息返回分页") @Operation(summary = "查询角色分页", description = "查询角色信息返回分页")
@PostMapping("findByPage/{pageNum}/{pageSize}") @PostMapping("findByPage/{pageNum}/{pageSize}")
public Result<PageInfo<SysRole>> findByPage(@RequestBody SysRoleDto sysRoleDto, public Result<PageInfo<SysRole>> findByPage(@RequestBody SysRoleDto sysRoleDto,
@ -27,6 +29,7 @@ public class SysRoleController {
return Result.success(pageInfo); return Result.success(pageInfo);
} }
@Log(title = "添加角色", businessType = 1)
@Operation(summary = "添加角色", description = "添加角色相关内容") @Operation(summary = "添加角色", description = "添加角色相关内容")
@PostMapping(value = "saveSysRole") @PostMapping(value = "saveSysRole")
public Result<SysRole> saveSysRole(@RequestBody SysRole sysRole) { public Result<SysRole> saveSysRole(@RequestBody SysRole sysRole) {
@ -34,20 +37,23 @@ public class SysRoleController {
return Result.success(); return Result.success();
} }
@Log(title = "修改角色", businessType = 2)
@Operation(summary = "修改角色", description = "修改角色相关信息") @Operation(summary = "修改角色", description = "修改角色相关信息")
@PutMapping(value = "updateSysRole") @PutMapping(value = "updateSysRole")
public Result updateSysRole(@RequestBody SysRole sysRole) { public Result<SysRole> updateSysRole(@RequestBody SysRole sysRole) {
sysRoleService.updateSysRole(sysRole); sysRoleService.updateSysRole(sysRole);
return Result.success(); return Result.success();
} }
@Log(title = "根据角色id删除角色", businessType = 3)
@Operation(summary = "根据角色id删除角色", description = "根据角色id删除角色信息") @Operation(summary = "根据角色id删除角色", description = "根据角色id删除角色信息")
@DeleteMapping(value = "deleteById/{roleId}") @DeleteMapping(value = "deleteById/{roleId}")
public Result deleteById(@PathVariable(value = "roleId") Long roleId) { public Result<AssginRoleDto> deleteById(@PathVariable(value = "roleId") Long roleId) {
sysRoleService.deleteById(roleId); sysRoleService.deleteById(roleId);
return Result.success(); return Result.success();
} }
@Log(title = "查询所有角色", businessType = 0)
@Operation(summary = "查询所有角色", description = "查询所有角色信息") @Operation(summary = "查询所有角色", description = "查询所有角色信息")
@GetMapping(value = "findAllRoles/{userId}") @GetMapping(value = "findAllRoles/{userId}")
public Result<AllRolesVo> findAllRoles(@PathVariable(value = "userId") Long userId) { public Result<AllRolesVo> findAllRoles(@PathVariable(value = "userId") Long userId) {
@ -55,9 +61,10 @@ public class SysRoleController {
return Result.success(allRolesList); return Result.success(allRolesList);
} }
@Log(title = "保存角色数据", businessType = 1)
@Operation(summary = "保存角色数据", description = "保存角色数据信息") @Operation(summary = "保存角色数据", description = "保存角色数据信息")
@PostMapping("doAssign") @PostMapping("doAssign")
public Result doAssign(@RequestBody AssginRoleDto assginRoleDto) { public Result<AssginRoleDto> doAssign(@RequestBody AssginRoleDto assginRoleDto) {
sysRoleService.doAssign(assginRoleDto); sysRoleService.doAssign(assginRoleDto);
return Result.success(); return Result.success();
} }

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.SysRoleMenuService; import com.atguigu.spzx.manger.service.SysRoleMenuService;
import com.atguigu.spzx.model.dto.system.AssginMenuDto; import com.atguigu.spzx.model.dto.system.AssginMenuDto;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
@ -16,6 +17,7 @@ public class SysRoleMenuController {
@Autowired @Autowired
private SysRoleMenuService sysRoleMenuService; private SysRoleMenuService sysRoleMenuService;
@Log(title = "查询菜单", businessType = 0)
@Operation(summary = "查询菜单", description = "查询菜单") @Operation(summary = "查询菜单", description = "查询菜单")
@GetMapping(value = "findSysRoleMenuByRoleId/{roleId}") @GetMapping(value = "findSysRoleMenuByRoleId/{roleId}")
public Result<SysRoleMenuVo> findSysRoleMenuByRoleId(@PathVariable(value = "roleId") Long roleId) { public Result<SysRoleMenuVo> findSysRoleMenuByRoleId(@PathVariable(value = "roleId") Long roleId) {
@ -23,6 +25,7 @@ public class SysRoleMenuController {
return Result.success(sysRoleMenuList); return Result.success(sysRoleMenuList);
} }
@Log(title = "保存菜单", businessType = 1)
@Operation(summary = "保存菜单", description = "保存菜单") @Operation(summary = "保存菜单", description = "保存菜单")
@PostMapping("doAssign") @PostMapping("doAssign")
public Result<AssginMenuDto> doAssign(@RequestBody AssginMenuDto assginMenuDto) { public Result<AssginMenuDto> doAssign(@RequestBody AssginMenuDto assginMenuDto) {

View File

@ -1,5 +1,6 @@
package com.atguigu.spzx.manger.controller; package com.atguigu.spzx.manger.controller;
import com.atguigu.log.annotation.Log;
import com.atguigu.spzx.manger.service.SysUserService; import com.atguigu.spzx.manger.service.SysUserService;
import com.atguigu.spzx.model.dto.system.SysUserDto; import com.atguigu.spzx.model.dto.system.SysUserDto;
import com.atguigu.spzx.model.entity.system.SysUser; import com.atguigu.spzx.model.entity.system.SysUser;
@ -17,6 +18,7 @@ public class SysUserController {
@Autowired @Autowired
private SysUserService sysUserService; private SysUserService sysUserService;
@Log(title = "查询用户", businessType = 0)
@Operation(summary = "查询用户", description = "查询用户信息") @Operation(summary = "查询用户", description = "查询用户信息")
@GetMapping(value = "findByPage/{pageNum}/{pageSize}") @GetMapping(value = "findByPage/{pageNum}/{pageSize}")
public Result<PageInfo<SysUser>> findByPage(SysUserDto sysUserDto, public Result<PageInfo<SysUser>> findByPage(SysUserDto sysUserDto,
@ -26,6 +28,7 @@ public class SysUserController {
return Result.success(userPageInfo); return Result.success(userPageInfo);
} }
@Log(title = "根据id删除用户", businessType = 3)
@Operation(summary = "添加用户", description = "添加用户信息") @Operation(summary = "添加用户", description = "添加用户信息")
@PostMapping(value = "saveSysUser") @PostMapping(value = "saveSysUser")
public Result<SysUser> saveSysUser(@RequestBody SysUser sysUser) { public Result<SysUser> saveSysUser(@RequestBody SysUser sysUser) {
@ -33,6 +36,7 @@ public class SysUserController {
return Result.success(); return Result.success();
} }
@Log(title = "根据id删除用户", businessType = 3)
@Operation(summary = "修改用户", description = "修改用户信息") @Operation(summary = "修改用户", description = "修改用户信息")
@PutMapping("updateSysUser") @PutMapping("updateSysUser")
public Result<SysUser> updateSysUser(@RequestBody SysUser sysUser) { public Result<SysUser> updateSysUser(@RequestBody SysUser sysUser) {
@ -40,6 +44,7 @@ public class SysUserController {
return Result.success(); return Result.success();
} }
@Log(title = "根据id删除用户", businessType = 3)
@Operation(summary = "根据id删除用户", description = "删除用户信息") @Operation(summary = "根据id删除用户", description = "删除用户信息")
@DeleteMapping(value = "deleteById/{userId}") @DeleteMapping(value = "deleteById/{userId}")
public Result<SysUser> deleteById(@PathVariable(value = "userId") Long userId) { public Result<SysUser> deleteById(@PathVariable(value = "userId") Long userId) {

View File

@ -9,6 +9,7 @@ import java.util.List;
public interface CategoryService { public interface CategoryService {
/** /**
* 根据父级id查找 * 根据父级id查找
*
* @param parentId 父级id * @param parentId 父级id
* @return 菜单列表 * @return 菜单列表
*/ */
@ -16,12 +17,14 @@ public interface CategoryService {
/** /**
* 导出数据 * 导出数据
*
* @param response HttpServletResponse * @param response HttpServletResponse
*/ */
void exportData(HttpServletResponse response); void exportData(HttpServletResponse response);
/** /**
* 导入功能 * 导入功能
*
* @param file Excel文件 * @param file Excel文件
*/ */
void importData(MultipartFile file); void importData(MultipartFile file);

View File

@ -30,6 +30,7 @@ public class BrandServiceImpl implements BrandService {
@Override @Override
public PageInfo<Brand> findByPage(Integer page, Integer limit) { public PageInfo<Brand> findByPage(Integer page, Integer limit) {
Page<Brand> startPage = PageHelper.startPage(page, limit); Page<Brand> startPage = PageHelper.startPage(page, limit);
// 查找分页品牌 // 查找分页品牌
List<Brand> brandList = brandMapper.findByPage(); List<Brand> brandList = brandMapper.findByPage();
startPage.close(); startPage.close();
@ -53,6 +54,7 @@ public class BrandServiceImpl implements BrandService {
*/ */
@Override @Override
public void updateById(Brand brand) { public void updateById(Brand brand) {
// 插入时不能为空
emptyUtil.isEmpty(brand, MessageConstant.DELETE_ID_IS_NOT_EMPTY); emptyUtil.isEmpty(brand, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
brandMapper.updateById(brand); brandMapper.updateById(brand);
@ -65,7 +67,9 @@ public class BrandServiceImpl implements BrandService {
*/ */
@Override @Override
public void deleteById(Long id) { public void deleteById(Long id) {
// 判断ID不能为空
emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY); emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
brandMapper.deleteById(id); brandMapper.deleteById(id);
} }

View File

@ -58,12 +58,15 @@ public class CategoryServiceImpl implements CategoryService {
// 设置响应结果类型 // 设置响应结果类型
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String filename = URLEncoder.encode("分类数据", StandardCharsets.UTF_8); String filename = URLEncoder.encode("分类数据", StandardCharsets.UTF_8);
response.setHeader("Content-disposition", "attachment;filename=" + filename + ".xlsx"); response.setHeader("Content-disposition", "attachment;filename=" + filename + ".xlsx");
// 查询数据库中的数据 // 查询数据库中的数据
List<Category> categoryList = categoryMapper.selectAll(); List<Category> categoryList = categoryMapper.selectAll();
ArrayList<CategoryExcelVo> excelVoArrayList = new ArrayList<>(); ArrayList<CategoryExcelVo> excelVoArrayList = new ArrayList<>();
// 将从数据库中查询到的Category对象转换成CategoryExcelVo对象 // 将从数据库中查询到的Category对象转换成CategoryExcelVo对象
categoryList.forEach(category -> { categoryList.forEach(category -> {
CategoryExcelVo vo = new CategoryExcelVo(); CategoryExcelVo vo = new CategoryExcelVo();

View File

@ -6,11 +6,9 @@ import lombok.Data;
@Data @Data
@Schema(description = "搜索条件实体类") @Schema(description = "搜索条件实体类")
public class CategoryBrandDto { public class CategoryBrandDto {
@Schema(description = "品牌id")
private Long brandId;
@Schema(description = "品牌id") @Schema(description = "分类id")
private Long brandId; private Long categoryId;
@Schema(description = "分类id")
private Long categoryId;
} }