Browse Source

新增登录通知开关接口

fuyuchuan 1 day ago
parent
commit
72c3804906

+ 21 - 3
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/SysUserPersonController.java

@@ -1,9 +1,13 @@
 package com.usky.system.controller.web;
 
-
+import com.usky.common.core.bean.ApiResult;
+import com.usky.system.service.SysUserPersonService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 
-import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * <p>
@@ -13,9 +17,23 @@ import org.springframework.stereotype.Controller;
  * @author JCB
  * @since 2022-08-22
  */
-@Controller
+@RestController
 @RequestMapping("/sysUserPerson")
 public class SysUserPersonController {
 
+    @Autowired
+    private SysUserPersonService sysUserPersonService;
+
+    /**
+     * 修改登录通知开关状态
+     * @param useId 用户id
+     * @param isLoginNotify 1:开启 0:关闭
+     * @return 0:失败
+     */
+    @PutMapping("/upIsLoginNotify")
+    public ApiResult<Integer> upIsLoginNotice(@RequestParam Long useId,
+                                              @RequestParam Integer isLoginNotify) {
+        return ApiResult.success(sysUserPersonService.upIsLoginNotify(useId, isLoginNotify));
+    }
 }
 

+ 1 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/SysUserPersonService.java

@@ -13,4 +13,5 @@ import com.usky.common.mybatis.core.CrudService;
  */
 public interface SysUserPersonService extends CrudService<SysUserPerson> {
 
+    public Integer upIsLoginNotify(Long useId, Integer isLoginNotify);
 }

+ 25 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysUserPersonServiceImpl.java

@@ -1,9 +1,12 @@
 package com.usky.system.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.usky.common.core.exception.BusinessException;
 import com.usky.system.domain.SysUserPerson;
 import com.usky.system.mapper.SysUserPersonMapper;
 import com.usky.system.service.SysUserPersonService;
 import com.usky.common.mybatis.core.AbstractCrudService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +20,26 @@ import org.springframework.stereotype.Service;
 @Service
 public class SysUserPersonServiceImpl extends AbstractCrudService<SysUserPersonMapper, SysUserPerson> implements SysUserPersonService {
 
+    @Autowired
+    private SysUserPersonMapper sysUserPersonMapper;
+
+    @Override
+    public Integer upIsLoginNotify(Long userId, Integer isLoginNotify) {
+
+        if (isLoginNotify != 0 && isLoginNotify != 1) {
+            throw new BusinessException("参数设置错误");
+        }
+
+        LambdaUpdateWrapper<SysUserPerson> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(SysUserPerson::getUserId, userId)
+                .set(SysUserPerson::getIsLoginNotify, isLoginNotify);
+        int result = sysUserPersonMapper.update(null, wrapper);
+
+        if (result <= 0) {
+            log.error("用户:{},操作登录通知开关操作失败!");
+            throw new BusinessException("登录通知开关操作失败!请重试");
+        }
+
+        return result;
+    }
 }