yangdi 4 lat temu
rodzic
commit
ef5a16ebde

+ 0 - 1
huimv-mobile-video/huimv-manager/pom.xml

@@ -63,7 +63,6 @@
 			<version>4.4.12</version>
 		</dependency>
 
-
 	</dependencies>
 
 

+ 54 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUserManageController.java

@@ -0,0 +1,54 @@
+package com.huimv.manager.modular.controller;
+
+
+import com.huimv.manager.modular.entity.MobileUser;
+import com.huimv.manager.modular.service.MobileUserService;
+import com.huimv.manager.result.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/19 12:18
+ * @Description
+ */
+@Slf4j
+@CrossOrigin
+@RestController
+@RequestMapping("/UserManage")
+public class MobileUserManageController {
+
+
+    @Autowired
+    private MobileUserService service;
+
+    @RequestMapping("/add")
+    public Result add(MobileUser childcareEntity){
+        return service.add(childcareEntity);
+    }
+
+    @RequestMapping("/remove")
+    public Result remove(Integer[] ids)
+    { return service.remove(ids);
+    }
+
+    @RequestMapping("/update")
+    public Result update(MobileUser childcareEntity){
+        return service.update(childcareEntity);
+    }
+
+    @RequestMapping("/findAllById")
+    public Result findAllById(Integer id){ return service.findAllById(id); }
+
+
+    @RequestMapping("/findAll")
+    public Result findAll(String name ,Integer pageNum , Integer pageSize){
+        return service.findAll(name,pageNum,pageSize);
+    }
+
+
+
+}

+ 8 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileUserRepository.java

@@ -1,11 +1,19 @@
 package com.huimv.manager.modular.repository;
 
 import com.huimv.manager.modular.entity.MobileUser;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
 
 public interface MobileUserRepository extends JpaRepository<MobileUser, Integer>, JpaSpecificationExecutor<MobileUser> {
 
     MobileUser findByAccount(String account);
 
+
+    @Query(nativeQuery = true ,value = "select * from mobile_user where userName like %?1% limit ?2 , ?3")
+    List<MobileUser> findAll(String name, Integer startPage, Integer pageSize);
 }

+ 41 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/MobileUserService.java

@@ -3,6 +3,7 @@ package com.huimv.manager.modular.service;
 import com.huimv.manager.modular.entity.MobileUser;
 import com.huimv.manager.modular.entity.param.LoginParam;
 import com.huimv.manager.result.R;
+import com.huimv.manager.result.Result;
 
 /**
  * @Author yinhao
@@ -24,4 +25,44 @@ public interface MobileUserService {
      * @return
      */
     MobileUser findById(Integer id);
+
+
+
+    //添加
+    Result add(MobileUser entity);
+
+    //添加
+    Result remove(Integer[] ids);
+
+    //添加
+    Result update(MobileUser entity);
+
+    //查询
+    Result findAll(String name, Integer pageNum, Integer pageSize);
+
+    //根据id查找
+    Result findAllById(Integer id);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 }

+ 78 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/impl/MobileUserServiceImpl.java

@@ -10,12 +10,17 @@ import com.huimv.manager.modular.entity.param.LoginParam;
 import com.huimv.manager.modular.repository.MobileUserRepository;
 import com.huimv.manager.modular.service.MobileUserService;
 import com.huimv.manager.result.R;
+import com.huimv.manager.result.Result;
+import com.huimv.manager.result.ResultStatus;
 import com.huimv.manager.util.JwtUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.DigestUtils;
 import org.springframework.util.StringUtils;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -59,6 +64,79 @@ public class MobileUserServiceImpl implements MobileUserService {
         return Objects.requireNonNull(R.ok().put("token", token)).put("mobileUser",mobileUser);
     }
 
+
+
+    @Override
+    public Result add(MobileUser entity){
+        if (entity == null){
+            return new Result(10002, ResultStatus.addNull);
+        }
+        try {
+            mobileUserRepository.save(entity);
+            return new Result(10000,ResultStatus.addSuccess);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.addFailed);
+        }
+    }
+
+    @Override
+    public Result remove(Integer[] ids) {
+        if (ids == null || ids.length==0){
+            return new Result(10002,ResultStatus.deleteNull);
+        }
+        try {
+            for (Integer id : ids) {
+                mobileUserRepository.deleteById(id);
+            }
+            return new Result(10000,ResultStatus.deleteSuccess);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.deleteFailed);
+        }
+    }
+
+    @Override
+    public Result update(MobileUser entity) {
+        if (entity == null){
+            return new Result(10002,ResultStatus.updateNull);
+        }
+        try {
+            mobileUserRepository.save(entity);
+            return new Result(10000,ResultStatus.updateSuccess);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.updateFailed);
+        }
+    }
+
+    @Override
+    public Result findAll(String name , Integer pageNum , Integer pageSize) {
+        try {
+            Map map = new HashMap();
+            int size = mobileUserRepository.findAll().size() ;
+            Integer startPage = (pageNum-1) * pageSize;
+            List<MobileUser> all = mobileUserRepository.findAll(name,startPage,pageSize);
+            map.put("total",size);
+            map.put("totalPageNum",(size  +  pageSize  - 1) / pageSize);
+            map.put("data",all);
+
+            return new Result(10000,ResultStatus.findSuccess,map);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.findFailed,null);
+        }
+    }
+
+    @Override
+    public Result findAllById(Integer id) {
+        try {
+            MobileUser entity = mobileUserRepository.findById(id).get();
+            return new Result(10000,ResultStatus.findSuccess,entity);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.findFailed,null);
+        }
+    }
+
+
+
+
     @Override
     public MobileUser findById(Integer id) {
         return mobileUserRepository.findById(id).orElse(null);