| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import cn.hutool.core.util.PhoneUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.dto.IdDto; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUserApplet; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TAppUser; |
| | | import com.ruoyi.system.model.TBanner; |
| | | import com.ruoyi.system.model.TNotice; |
| | | import com.ruoyi.system.service.TBannerService; |
| | | import com.ruoyi.system.service.TNoticeService; |
| | | import com.ruoyi.system.model.TBigGiftPackage; |
| | | import com.ruoyi.system.model.TPhysicalGoods; |
| | | import com.ruoyi.system.query.AppletPhysicalGoodsQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.SupervisorUserVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 首页相关接口 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/index") |
| | | @Api(tags = "首页模块") |
| | | @Api(tags = "首页相关接口") |
| | | @Validated |
| | | @RequiredArgsConstructor(onConstructor_ = {@Lazy}) |
| | | public class IndexController { |
| | | |
| | | private final TBannerService tBannerService; |
| | | private final TNoticeService tNoticeService; |
| | | private final TAppUserService tAppUserService; |
| | | private final TokenService tokenService; |
| | | private final ISysUserService sysUserService; |
| | | private final TBigGiftPackageService bigGiftPackageService; |
| | | private final TPhysicalGoodsService physicalGoodsService; |
| | | |
| | | public IndexController(TBannerService tBannerService, TNoticeService tNoticeService) { |
| | | this.tBannerService = tBannerService; |
| | | this.tNoticeService = tNoticeService; |
| | | @ApiOperation("根据推广码获取上级用户信息") |
| | | @GetMapping("/getSuperiorInfo") |
| | | public R<SupervisorUserVO> getSuperiorInfo(@ApiParam(name = "superiorType", value = "上级类型 1:股东;2:营销员") |
| | | @NotNull(message = "上级类型不能为空") @RequestParam Integer superiorType, |
| | | @ApiParam(name = "spreadCode", value = "推广码") |
| | | @NotNull(message = "推广码不能为空") @RequestParam String spreadCode) { |
| | | SupervisorUserVO supervisorUserVO = new SupervisorUserVO(); |
| | | //根据上级类型获取上级用户信息 |
| | | if (superiorType.equals(1)) { |
| | | SysUser sysUser = sysUserService.selectByCode(spreadCode); |
| | | if (Objects.nonNull(sysUser)) { |
| | | supervisorUserVO.setId(sysUser.getUserId().intValue()); |
| | | supervisorUserVO.setPhone((String) PhoneUtil.hideBetween(sysUser.getPhonenumber())); |
| | | supervisorUserVO.setNickName(sysUser.getNickName()); |
| | | supervisorUserVO.setAvatar(""); //todo 设置默认头像 |
| | | } |
| | | } else { |
| | | tAppUserService.lambdaQuery().eq(TAppUser::getCode, spreadCode).ne(TAppUser::getStatus, 3).last("LIMIT 1").oneOpt() |
| | | .ifPresent(appUser -> { |
| | | supervisorUserVO.setId(appUser.getId()); |
| | | supervisorUserVO.setPhone((String) PhoneUtil.hideBetween(appUser.getPhone())); |
| | | supervisorUserVO.setAvatar(appUser.getProfilePhoto()); |
| | | supervisorUserVO.setNickName(appUser.getName()); |
| | | }); |
| | | } |
| | | return R.ok(supervisorUserVO); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("确认上级用户-接受邀请") |
| | | @GetMapping("/confirmSuperior") |
| | | public R<?> confirmSuperior(@ApiParam(name = "superiorType", value = "上级类型 1:股东;2:营销员") |
| | | @NotNull(message = "上级类型不能为空") @RequestParam Integer superiorType, |
| | | @ApiParam(name = "superiorId", value = "上级用户ID") |
| | | @NotNull(message = "上级ID不能为空") @RequestParam Integer superiorId) { |
| | | LoginUserApplet loginUserApplet = tokenService.getLoginUserApplet(); |
| | | tAppUserService.confirmSuperior(superiorType, superiorId, loginUserApplet); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "首页模块--轮播图",response = TBanner.class) |
| | | @GetMapping(value = "/getBannerList") |
| | |
| | | @GetMapping(value = "/getBannerDetail/{id}") |
| | | public R<TBanner> getBannerDetail(@PathVariable String id) { |
| | | TBanner tBanner = tBannerService.getById(id); |
| | | //增加阅读量 |
| | | tBanner.setReadCount(tBanner.getReadCount() + 1); |
| | | tBannerService.updateById(tBanner); |
| | | return R.ok(tBanner); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "首页模块--公告活动",response = TNotice.class) |
| | | @GetMapping(value = "/getNoticeList") |
| | | public R<List<TNotice>> getNoticeList() { |
| | | List<TNotice> tNoticeList = tNoticeService.list(); |
| | | return R.ok(tNoticeList); |
| | | @ApiOperation("获取大礼包列表") |
| | | @GetMapping("/big-gift/list") |
| | | public R<List<TBigGiftPackage>> getBigGiftList() { |
| | | return R.ok(bigGiftPackageService.list()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "首页模块--公告活动详情",response = TNotice.class) |
| | | @GetMapping(value = "/getNoticeDetail/{id}") |
| | | public R<TNotice> getNoticeDetail(@PathVariable String id) { |
| | | TNotice notice = tNoticeService.getById(id); |
| | | notice.setReadCount(notice.getReadCount() + 1); |
| | | tNoticeService.updateById(notice); |
| | | return R.ok(notice); |
| | | @ApiOperation("大礼包商品详情") |
| | | @GetMapping("/big-gift/detail/{id}") |
| | | public R<TBigGiftPackage> getBigGiftDetail(@ApiParam(name = "id", value = "大礼包ID") @PathVariable Integer id) { |
| | | return R.ok(bigGiftPackageService.getById(id)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("实物商品分页列表") |
| | | @PostMapping("/physical-goods/page") |
| | | public R<IPage<TPhysicalGoods>> getPhysicalGoodsPageList(@RequestBody AppletPhysicalGoodsQuery query) { |
| | | return R.ok(physicalGoodsService.getPageList(query)); |
| | | } |
| | | @ApiOperation("实物商品详情") |
| | | @GetMapping("/physical-goods/detail/{id}") |
| | | public R<TPhysicalGoods> getPhysicalGoodsDetail(@ApiParam(name = "id", value = "实物商品ID")@PathVariable Integer id) { |
| | | return R.ok(physicalGoodsService.getById(id)); |
| | | } |
| | | } |