From 74631108298263ae54590f40afd4ff18ea4b1a2f Mon Sep 17 00:00:00 2001 From: youlibin <305042026@qq.com> Date: Thu, 15 Jun 2023 10:36:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=B0=E5=A2=9E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E3=80=81=E6=9F=A5=E8=AF=A2=E6=94=AF=E4=BB=98=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/order/constant/OrderConstant.java | 11 ++ .../service/impl/OdOrderMovieServiceImpl.java | 19 ++- .../service/impl/OdOrderServiceImpl.java | 6 +- .../controller/system/SysAuthController.java | 157 ------------------ .../system/SysDictTypeController.java | 56 ------- .../system/SysNoticeController.java | 46 ----- .../system/SysProfileController.java | 4 +- .../controller/system/SysUserController.java | 63 ------- .../vue-admin/src/views/system/user/index.vue | 148 ++++++++--------- .../src/views/system/user/profile/index.vue | 8 +- web-ui/vue-web/src/layout/Header.vue | 1 + .../user/profile/order/OrderController.vue | 19 ++- web-ui/vue-web/src/views/video/index.vue | 6 +- 13 files changed, 129 insertions(+), 415 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/order/constant/OrderConstant.java delete mode 100644 ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysAuthController.java delete mode 100644 ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java delete mode 100644 ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java delete mode 100644 ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysUserController.java diff --git a/ruoyi-system/src/main/java/com/ruoyi/order/constant/OrderConstant.java b/ruoyi-system/src/main/java/com/ruoyi/order/constant/OrderConstant.java new file mode 100644 index 0000000..1679665 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/order/constant/OrderConstant.java @@ -0,0 +1,11 @@ +package com.ruoyi.order.constant; + +/** + * @AUTHOR:游李滨 + * @DATE:2023/6/15 9:52 + */ +public class OrderConstant { + public static final long ORDER_STATUS_OK = 1; + public static final long ORDER_STATUS_NO = 2; + public static final long ORDER_STATUS_CANCEL = 3; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderMovieServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderMovieServiceImpl.java index 85bfeb6..468b08d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderMovieServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderMovieServiceImpl.java @@ -1,6 +1,9 @@ package com.ruoyi.order.service.impl; +import com.ruoyi.order.constant.OrderConstant; +import com.ruoyi.order.domain.OdOrder; import com.ruoyi.order.domain.OdOrderMovie; +import com.ruoyi.order.mapper.OdOrderMapper; import com.ruoyi.order.mapper.OdOrderMovieMapper; import com.ruoyi.order.service.IOdOrderMovieService; import org.springframework.beans.factory.annotation.Autowired; @@ -19,6 +22,10 @@ public class OdOrderMovieServiceImpl implements IOdOrderMovieService { @Autowired private OdOrderMovieMapper odOrderMovieMapper; + + @Autowired + private OdOrderMapper odOrderMapper; + /** * 查询订单电影连接 * @@ -35,7 +42,17 @@ public class OdOrderMovieServiceImpl implements IOdOrderMovieService { OdOrderMovie odOrderMovie = new OdOrderMovie(); odOrderMovie.setUserId(userId); odOrderMovie.setMovieId(movieId); - return odOrderMovieMapper.selectOdOrderMovieList(odOrderMovie).size() > 0; +// 根据电影id,查询购买过的电影记录 + List odOrderMovies = odOrderMovieMapper.selectOdOrderMovieList(odOrderMovie); + int size = odOrderMovies.size(); + if (size <= 0) { +// 没有购买过该电影 + return false; + } + + // 查询该订单是否支付过 + OdOrder odOrder = odOrderMapper.selectOdOrderById(odOrderMovies.get(0).getOrderId()); + return odOrder.getStatus().equals(OrderConstant.ORDER_STATUS_OK); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderServiceImpl.java index c8e52bc..ee690c1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/order/service/impl/OdOrderServiceImpl.java @@ -4,6 +4,7 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.media.domain.Movie; import com.ruoyi.media.mapper.MovieMapper; +import com.ruoyi.order.constant.OrderConstant; import com.ruoyi.order.domain.OdOrder; import com.ruoyi.order.domain.OdOrderMovie; import com.ruoyi.order.domain.OrderVo; @@ -149,7 +150,6 @@ public class OdOrderServiceImpl implements IOdOrderService { return true; } - /** * 新增订单 * @@ -165,7 +165,8 @@ public class OdOrderServiceImpl implements IOdOrderService { // 没有支付订单 if (!hasPayOrder(odOrder)) { - return 0; +// 设置订单状态为未支付 + odOrder.setStatus(OrderConstant.ORDER_STATUS_OK); } Set movieIdSet = new HashSet<>(); @@ -189,6 +190,7 @@ public class OdOrderServiceImpl implements IOdOrderService { odOrder.setUuid(generateUUID(odOrder)); odOrder.setCreateTime(DateUtils.getNowDate()); int rows = odOrderMapper.insertOdOrder(odOrder); +// 批量插入关联 insertOdOrderMovie(odOrder); return rows; } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysAuthController.java b/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysAuthController.java deleted file mode 100644 index 4059bf8..0000000 --- a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysAuthController.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.ruoyi.web.controller.system; - -import com.ruoyi.common.config.AuthClientConfig; -import com.ruoyi.common.config.JustAuthConfig; -import com.ruoyi.common.config.RuoYiConfig; -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.entity.SysUser; -import com.ruoyi.common.utils.*; -import com.ruoyi.common.utils.file.FileUploadUtils; -import com.ruoyi.framework.manager.AsyncManager; -import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.web.service.SysLoginService; -import com.ruoyi.framework.web.service.TokenService; -import com.ruoyi.system.domain.SysAuthUser; -import com.ruoyi.system.mapper.SysUserMapper; -import com.ruoyi.system.service.ISysUserService; -import me.zhyd.oauth.cache.AuthDefaultStateCache; -import me.zhyd.oauth.cache.AuthStateCache; -import me.zhyd.oauth.model.AuthCallback; -import me.zhyd.oauth.model.AuthResponse; -import me.zhyd.oauth.model.AuthUser; -import me.zhyd.oauth.request.AuthRequest; -import me.zhyd.oauth.utils.AuthStateUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -/** - * 第三方认证授权处理 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/auth") -public class SysAuthController extends BaseController { - private AuthStateCache authStateCache; - - @Autowired - private SysUserMapper userMapper; - - { - authStateCache = AuthDefaultStateCache.INSTANCE; - } - - @Autowired - JustAuthConfig justAuthConfig; - - /** - * 认证授权 - * - * @param source - * @throws IOException - */ - @GetMapping("/render/{source}") - @ResponseBody - public AjaxResult renderAuth(@PathVariable("source") String source) throws IOException { - AuthClientConfig config = justAuthConfig.getConfig(source); - if (config == null) { - return error("没有" + source + "的授权client信息!"); - } - AuthRequest authRequest = AuthUtils.getAuthRequest(source, config.getClientId(), config.getClientSecret(), justAuthConfig.getRedirectUri() + source, authStateCache); - String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); - Map data = new HashMap(); - data.put("authorizeUrl", authorizeUrl); - return success(data); - } - - - @Autowired - SysLoginService sysLoginService; - - @Autowired - TokenService tokenService; - - @Autowired - ISysUserService userService; - - /** - * 回调结果 - */ - @SuppressWarnings("unchecked") - @GetMapping("/callback/{source}") - @ResponseBody - public void callbackAuth(@PathVariable("source") String source, AuthCallback callback, HttpServletRequest request) throws IOException { - AuthClientConfig config = justAuthConfig.getConfig(source); - if (config == null) { - ServletUtils.getResponse().sendRedirect(justAuthConfig.getWebsiteUrl() + 500); - } - AuthRequest authRequest = AuthUtils.getAuthRequest(source, config.getClientId(), config.getClientSecret(), justAuthConfig.getRedirectUri() + source, authStateCache); - AuthResponse response = authRequest.login(callback); - if (response.ok()) { - SysUser user = userMapper.selectAuthUserByUuid(source + response.getData().getUuid()); - if (StringUtils.isNotNull(user)) { - String token = sysLoginService.login(user); - ServletUtils.getResponse().sendRedirect(justAuthConfig.getWebsiteUrl() + "?thirdToken=" + token); - } else { - SysUser sysUser = new SysUser(); - sysUser.setUserName(response.getData().getUsername()); - sysUser.setNickName(response.getData().getNickname()); - sysUser.setPassword(SecurityUtils.encryptPassword(justAuthConfig.getDefaultPwd())); - String avatar = FileUploadUtils.uploadByUrl(RuoYiConfig.getAvatarPath(), response.getData().getAvatar()); - sysUser.setAvatar(avatar); - boolean regFlag = userService.registerUser(sysUser); - if (!regFlag) { - //return error("请求远程授权失败!"); - } - AsyncManager.me().execute(AsyncFactory.recordLogininfor(sysUser.getUserName(), Constants.REGISTER, - MessageUtils.message("user.register.success"))); - String token = sysLoginService.login(sysUser); - // 若已经登录则直接绑定系统账号 - SysAuthUser authUser = new SysAuthUser(); - authUser.setAvatar(avatar); - authUser.setUuid(source + response.getData().getUuid()); - authUser.setUserId(sysUser.getUserId()); - authUser.setUserName(response.getData().getNickname()); - authUser.setLoginName(response.getData().getUsername()); - authUser.setEmail(response.getData().getEmail()); - authUser.setSource(source); - userMapper.insertAuthUser(authUser); - ServletUtils.getResponse().sendRedirect(justAuthConfig.getWebsiteUrl() + "?thirdToken=" + token); - } - } else { - ServletUtils.getResponse().sendRedirect(justAuthConfig.getWebsiteUrl() + 500); - } - } - - /** - * 检查是否授权 - */ - @PostMapping("/checkAuthUser") - @ResponseBody - public AjaxResult checkAuthUser(SysAuthUser authUser) { - Long userId = SecurityUtils.getUserId(); - String source = authUser.getSource(); - if (userMapper.checkAuthUser(userId, source) > 0) { - return error(source + "平台账号已经绑定"); - } - return success(); - } - - /** - * 取消授权 - */ - @PostMapping("/unlock") - @ResponseBody - public AjaxResult unlockAuth(SysAuthUser authUser) { - return toAjax(userMapper.deleteAuthUser(authUser.getAuthId())); - } - -} diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java b/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java deleted file mode 100644 index e77466b..0000000 --- a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.ruoyi.web.controller.system; - -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.entity.SysDictType; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.system.service.ISysDictTypeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 数据字典信息 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/system/dict/type") -public class SysDictTypeController extends BaseController { - @Autowired - private ISysDictTypeService dictTypeService; - - @GetMapping("/list") - public TableDataInfo list(SysDictType dictType) { - startPage(); - List list = dictTypeService.selectDictTypeList(dictType); - return getDataTable(list); - } - - - /** - * 查询字典类型详细 - */ - @GetMapping(value = "/{dictId}") - public AjaxResult getInfo(@PathVariable Long dictId) { - return success(dictTypeService.selectDictTypeById(dictId)); - } - - - /** - * 获取字典选择框列表 - */ - @GetMapping("/optionselect") - public AjaxResult optionselect() { - List dictTypes = dictTypeService.selectDictTypeAll(); - return success(dictTypes); - } -} diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java deleted file mode 100644 index a5d7738..0000000 --- a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.ruoyi.web.controller.system; - -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.system.domain.SysNotice; -import com.ruoyi.system.service.ISysNoticeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 公告 信息操作处理 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/system/notice") -public class SysNoticeController extends BaseController { - @Autowired - private ISysNoticeService noticeService; - - /** - * 获取通知公告列表 - */ - @GetMapping("/list") - public TableDataInfo list(SysNotice notice) { - startPage(); - List list = noticeService.selectNoticeList(notice); - return getDataTable(list); - } - - /** - * 根据通知公告编号获取详细信息 - */ - @GetMapping(value = "/{noticeId}") - public AjaxResult getInfo(@PathVariable Long noticeId) { - return success(noticeService.selectNoticeById(noticeId)); - } -} diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index d0be3c3..81189b0 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -2,14 +2,12 @@ package com.ruoyi.web.controller.system; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.config.RuoYiConfig; -import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.MimeTypeUtils; @@ -34,7 +32,7 @@ public class SysProfileController extends BaseController { private TokenService tokenService; /** - * 个人信息 + * 通过token拿取个人信息 */ @GetMapping public AjaxResult profile() { diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysUserController.java deleted file mode 100644 index 0abea68..0000000 --- a/ruoyi-web/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.ruoyi.web.controller.system; - -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.entity.SysUser; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.system.service.ISysUserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 用户信息 - * - * @author ylb - */ -@RestController -@RequestMapping("/system/user") -public class SysUserController extends BaseController { - @Autowired - private ISysUserService userService; - - /** - * 获取用户列表 - */ - @PreAuthorize("@ss.hasPermi('system:user:list')") - @GetMapping("/list") - public TableDataInfo list(SysUser user) { - startPage(); - List list = userService.selectUserList(user); - return getDataTable(list); - } - - /** - * 重置密码 - */ - @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") - @Log(title = "用户管理", businessType = BusinessType.UPDATE) - @PutMapping("/resetPwd") - public AjaxResult resetPwd(@RequestBody SysUser user) { - userService.checkUserAllowed(user); - user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - user.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(userService.resetPwd(user)); - } - - /** - * 状态修改 - */ - @PreAuthorize("@ss.hasPermi('system:user:edit')") - @Log(title = "用户管理", businessType = BusinessType.UPDATE) - @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysUser user) { - userService.checkUserAllowed(user); - user.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(userService.updateUserStatus(user)); - } -} diff --git a/web-ui/vue-admin/src/views/system/user/index.vue b/web-ui/vue-admin/src/views/system/user/index.vue index 782d3e2..4250661 100644 --- a/web-ui/vue-admin/src/views/system/user/index.vue +++ b/web-ui/vue-admin/src/views/system/user/index.vue @@ -2,31 +2,31 @@
- -
- -
-
- -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + @@ -113,26 +113,26 @@ v-hasPermi="['system:user:remove']" >删除 - - 导入 - - - 导出 - + + + + + + + + + + + + + + + + + + + +
@@ -141,7 +141,7 @@ - +