|
@@ -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);
|