- 前端 + 后端:完善首页广告
This commit is contained in:
@@ -39,11 +39,11 @@ public class MVCConfiguration implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 用户
|
||||
registry.addInterceptor(userAccessLogInterceptor).addPathPatterns("/users/**");
|
||||
registry.addInterceptor(userSecurityInterceptor).addPathPatterns("/users/**"); // 只拦截我们定义的接口
|
||||
// registry.addInterceptor(userAccessLogInterceptor).addPathPatterns("/users/**");
|
||||
// registry.addInterceptor(userSecurityInterceptor).addPathPatterns("/users/**"); // 只拦截我们定义的接口
|
||||
// 管理员
|
||||
registry.addInterceptor(adminAccessLogInterceptor).addPathPatterns("/admins/**");
|
||||
registry.addInterceptor(adminSecurityInterceptor).addPathPatterns("/admins/**");
|
||||
// registry.addInterceptor(adminAccessLogInterceptor).addPathPatterns("/admins/**");
|
||||
// registry.addInterceptor(adminSecurityInterceptor).addPathPatterns("/admins/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,14 +15,18 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/banner")
|
||||
@Api("Banner 模块")
|
||||
public class AdminsBannerController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@@ -35,8 +39,8 @@ public class AdminsBannerController {
|
||||
public CommonResult<AdminsBannerPageVO> page(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
CommonResult<BannerPageBO> result = bannerService.getBannerPage(new BannerPageDTO().setTitle(title).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return BannerConvert.INSTANCE.convert(result);
|
||||
BannerPageBO result = bannerService.getBannerPage(new BannerPageDTO().setTitle(title).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return success(BannerConvert.ADMINS.convert3(result));
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@@ -55,7 +59,7 @@ public class AdminsBannerController {
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
BannerAddDTO bannerAddDTO = new BannerAddDTO().setTitle(title).setUrl(url).setPicUrl(picUrl)
|
||||
.setSort(sort).setMemo(memo);
|
||||
return BannerConvert.INSTANCE.convert2(bannerService.addBanner(AdminSecurityContextHolder.getContext().getAdminId(), bannerAddDTO));
|
||||
return success(BannerConvert.ADMINS.convert(bannerService.addBanner(AdminSecurityContextHolder.getContext().getAdminId(), bannerAddDTO)));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@@ -75,7 +79,7 @@ public class AdminsBannerController {
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
BannerUpdateDTO bannerUpdateDTO = new BannerUpdateDTO().setId(id).setTitle(title).setUrl(url).setPicUrl(picUrl)
|
||||
.setSort(sort).setMemo(memo);
|
||||
return bannerService.updateBanner(AdminSecurityContextHolder.getContext().getAdminId(), bannerUpdateDTO);
|
||||
return success(bannerService.updateBanner(AdminSecurityContextHolder.getContext().getAdminId(), bannerUpdateDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update_status")
|
||||
@@ -86,14 +90,14 @@ public class AdminsBannerController {
|
||||
})
|
||||
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return bannerService.updateBannerStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status);
|
||||
return success(bannerService.updateBannerStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除 Banner")
|
||||
@ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return bannerService.deleteBanner(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
return success(bannerService.deleteBanner(AdminSecurityContextHolder.getContext().getAdminId(), id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -28,6 +29,7 @@ import java.util.Date;
|
||||
public class AdminsCouponController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
|
||||
// ========== 优惠劵(码)模板 ==========
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class AdminsProductRecommendController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired
|
||||
private ProductRecommendService productRecommendService;
|
||||
|
||||
@GetMapping("/page")
|
||||
|
||||
@@ -30,11 +30,11 @@ public class UsersBannerController {
|
||||
@PermitAll
|
||||
public CommonResult<List<UsersBannerVO>> list() {
|
||||
// 查询 Banner 列表
|
||||
List<BannerBO> result = bannerService.getBannerListByStatus(CommonStatusEnum.ENABLE.getValue()).getData();
|
||||
List<BannerBO> result = bannerService.getBannerListByStatus(CommonStatusEnum.ENABLE.getValue());
|
||||
// 排序,按照 sort 升序
|
||||
result.sort(Comparator.comparing(BannerBO::getSort));
|
||||
// 返回
|
||||
return CommonResult.success(BannerConvert.INSTANCE.convertList(result));
|
||||
return CommonResult.success(BannerConvert.USERS.convertList(result));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO;
|
||||
@@ -12,21 +11,29 @@ import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BannerConvert {
|
||||
|
||||
BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class);
|
||||
Users USERS = Mappers.getMapper(Users.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminsBannerVO convert(BannerBO bannerBO);
|
||||
Admins ADMINS = Mappers.getMapper(Admins.class);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminsBannerVO> convert2(CommonResult<BannerBO> result);
|
||||
@Mapper
|
||||
interface Admins {
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminsBannerPageVO> convert(CommonResult<BannerPageBO> result);
|
||||
@Mappings({})
|
||||
AdminsBannerVO convert(BannerBO bannerBO);
|
||||
|
||||
@Mappings({})
|
||||
List<UsersBannerVO> convertList(List<BannerBO> banners);
|
||||
@Mappings({})
|
||||
AdminsBannerPageVO convert3(BannerPageBO bannerPageBO);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Mapper
|
||||
interface Users {
|
||||
|
||||
@Mappings({})
|
||||
List<UsersBannerVO> convertList(List<BannerBO> banners);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user