|
@@ -0,0 +1,94 @@
|
|
|
+package com.caimei.controller.admin.auth;
|
|
|
+
|
|
|
+
|
|
|
+import com.caimei.annotation.CurrentUser;
|
|
|
+import com.caimei.model.ResponseJson;
|
|
|
+import com.caimei.model.po.CmBrandBannerPo;
|
|
|
+import com.caimei.model.po.SysUser;
|
|
|
+import com.caimei.model.vo.DoctorFormVo;
|
|
|
+import com.caimei.service.auth.BannerService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 首页BannerAPIApi
|
|
|
+ *
|
|
|
+ * @author : Kaick
|
|
|
+ * @date : 2023/3/23
|
|
|
+ */
|
|
|
+@Api(tags = "首页BannerAPI")
|
|
|
+@RestController
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RequestMapping("/banner")
|
|
|
+public class BannerApi {
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(BannerApi.class);
|
|
|
+ private final BannerService bannerService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页Banner回显数据
|
|
|
+ */
|
|
|
+ @ApiOperation("首页Banner回显数据")
|
|
|
+ @ApiImplicitParam(name = "authUserId", required = true, value = "供应商id")
|
|
|
+ @GetMapping("/form/data")
|
|
|
+ public ResponseJson<DoctorFormVo> getBannerFormData(@CurrentUser SysUser sysUser) {
|
|
|
+ if (null == sysUser) {
|
|
|
+ return ResponseJson.error("用户信息异常", null);
|
|
|
+ }
|
|
|
+ // 获取供应商用户id
|
|
|
+ Integer userIdentity = sysUser.getUserIdentity();
|
|
|
+ Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
|
|
|
+ if (null == authUserId) {
|
|
|
+ return ResponseJson.error("供应商用户id不能为空", null);
|
|
|
+ }
|
|
|
+ return bannerService.getBanner(authUserId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加/编辑首页Banner
|
|
|
+ */
|
|
|
+ @ApiOperation("添加/编辑首页Banner")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public ResponseJson saveBanner(@CurrentUser SysUser sysUser,@RequestBody CmBrandBannerPo bannerPo) {
|
|
|
+ if (null == sysUser) {
|
|
|
+ return ResponseJson.error("用户信息异常", null);
|
|
|
+ }
|
|
|
+ // 获取供应商用户id
|
|
|
+ Integer userIdentity = sysUser.getUserIdentity();
|
|
|
+ Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
|
|
|
+ if (null == authUserId) {
|
|
|
+ return ResponseJson.error("供应商用户id不能为空", null);
|
|
|
+ }
|
|
|
+ if (null != bannerPo) {
|
|
|
+ if (null != bannerPo.getHeadPcBanner() && null != bannerPo.getHeadAppBanner()) {
|
|
|
+ if (null == bannerPo.getJumpStatus() || 2 < bannerPo.getJumpStatus()) {
|
|
|
+ return ResponseJson.error("首页Banner跳转方式状态参数不正确", null);
|
|
|
+ } else {
|
|
|
+ if (1 == bannerPo.getJumpStatus()) {
|
|
|
+ if (null == bannerPo.getJumpPcPicture() && null == bannerPo.getJumpAppPicture()) {
|
|
|
+ return ResponseJson.error("首页Banner跳转图片 Pc端,移动端都必须添加", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("首页Banner Pc端,移动端都必须添加", null);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ logger.info("【图片上传】>>>>>>>>>>>>>>>>图片上传失败:");
|
|
|
+ return ResponseJson.error("首页Banner上传失败");
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ 组装首页Banner数据
|
|
|
+ */
|
|
|
+ bannerPo.setAuthUserId(authUserId);
|
|
|
+ return bannerService.saveBanner(bannerPo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|