|
@@ -1,12 +1,20 @@
|
|
|
package com.fjs.scenic.service.system.impl;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
//import com.fjs.scenic.utils.UserUtils;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fjs.scenic.dto.ManageListDto;
|
|
|
+import com.fjs.scenic.entity.system.TypeAuthority;
|
|
|
import com.fjs.scenic.entity.user.UserStatistical;
|
|
|
import com.fjs.scenic.mapper.user.UserStatisticalMapper;
|
|
|
+import com.fjs.scenic.service.system.TypeAuthorityService;
|
|
|
import com.fjs.scenic.utils.Md5Utils;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -35,6 +43,9 @@ public class ManageServiceImpl extends BaseServiceImpl<Manage> implements Manage
|
|
|
private ManageRoleMapper manageRoleMapper;
|
|
|
@Autowired
|
|
|
private UserStatisticalMapper userStatisticalMapper;
|
|
|
+ @Autowired
|
|
|
+ private TypeAuthorityService typeAuthorityService;
|
|
|
+
|
|
|
/**
|
|
|
* 添加管理员
|
|
|
*
|
|
@@ -115,8 +126,39 @@ public class ManageServiceImpl extends BaseServiceImpl<Manage> implements Manage
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Manage> page1(Manage record) {
|
|
|
- return manageMapper.selectAll1(record);
|
|
|
+ public ReturnResult selfPage(Manage record, int currentPage, int pageSize) {
|
|
|
+ currentPage = (currentPage == 0) ? 1 : currentPage;
|
|
|
+ pageSize = (pageSize == 0) ? 10 : pageSize;
|
|
|
+ PageHelper.startPage(currentPage, pageSize);
|
|
|
+ List<Manage> manages = manageMapper.selectAll1(record);
|
|
|
+ PageInfo<Manage> pageInfo = new PageInfo<>(manages);
|
|
|
+ if (pageInfo.getSize() == 0) {
|
|
|
+ return ReturnResult.ok(pageInfo);
|
|
|
+ }
|
|
|
+ List<ManageListDto> manageListDtos = new ArrayList<>();
|
|
|
+ for (Manage m : pageInfo.getList()) {
|
|
|
+ ManageListDto manageListDto = new ManageListDto();
|
|
|
+ BeanUtils.copyProperties(m, manageListDto);
|
|
|
+ List<TypeAuthority> typeAuthorities = typeAuthorityService.list(new LambdaQueryWrapper<TypeAuthority>().eq(TypeAuthority::getManager, m.getId()));
|
|
|
+ if (!typeAuthorities.isEmpty()) {
|
|
|
+ String company = typeAuthorities.stream()
|
|
|
+ .collect(Collectors.groupingBy(TypeAuthority::getCompany))
|
|
|
+ .keySet().stream().map(Cons.COMPANYS::get)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ String scenic = typeAuthorities.stream()
|
|
|
+ .map(typeAuthority -> Cons.SCENICS.get(typeAuthority.getScenic()))
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ manageListDto.setCompany(company);
|
|
|
+ manageListDto.setScenic(scenic);
|
|
|
+ }
|
|
|
+ manageListDtos.add(manageListDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ PageInfo<ManageListDto> newPageInfo = new PageInfo<>(manageListDtos);
|
|
|
+ newPageInfo.setPageNum(newPageInfo.getPageNum());
|
|
|
+ newPageInfo.setPageSize(newPageInfo.getSize());
|
|
|
+ newPageInfo.setSize(newPageInfo.getSize());
|
|
|
+ return ReturnResult.ok(newPageInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -147,8 +189,9 @@ public class ManageServiceImpl extends BaseServiceImpl<Manage> implements Manage
|
|
|
|
|
|
/**
|
|
|
* 验证密码
|
|
|
+ *
|
|
|
* @param account
|
|
|
- * @param oldPWD 要验证的密码
|
|
|
+ * @param oldPWD 要验证的密码
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
@@ -161,8 +204,9 @@ public class ManageServiceImpl extends BaseServiceImpl<Manage> implements Manage
|
|
|
|
|
|
/**
|
|
|
* 修改密码
|
|
|
+ *
|
|
|
* @param account
|
|
|
- * @param newPWD 新密码
|
|
|
+ * @param newPWD 新密码
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
@@ -178,7 +222,7 @@ public class ManageServiceImpl extends BaseServiceImpl<Manage> implements Manage
|
|
|
String[] pids = manage.getPermissions().split(",");
|
|
|
manage.setPassword(Md5Utils.MD5(manage.getPassword()));
|
|
|
int add = manageMapper.add(manage);
|
|
|
- if(add>0){
|
|
|
+ if (add > 0) {
|
|
|
Integer id = manageMapper.queryByPhone(manage.getPhone());
|
|
|
for (String permissonId : pids) {
|
|
|
UserStatistical us = new UserStatistical();
|
|
@@ -202,9 +246,9 @@ public class ManageServiceImpl extends BaseServiceImpl<Manage> implements Manage
|
|
|
userStatisticalMapper.insertSelective(us);
|
|
|
}
|
|
|
int update = manageMapper.update(manage);
|
|
|
- if(null != manage.getPassword()){
|
|
|
- if(update >0){
|
|
|
- return manageMapper.updatePwd(id,Md5Utils.MD5(manage.getPassword()));
|
|
|
+ if (null != manage.getPassword()) {
|
|
|
+ if (update > 0) {
|
|
|
+ return manageMapper.updatePwd(id, Md5Utils.MD5(manage.getPassword()));
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
@@ -232,12 +276,12 @@ public class ManageServiceImpl extends BaseServiceImpl<Manage> implements Manage
|
|
|
|
|
|
@Override
|
|
|
public int updateStatus1(Integer id, String status) {
|
|
|
- return manageMapper.updateStatus(id,status);
|
|
|
+ return manageMapper.updateStatus(id, status);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Manage getManeger(String account, String password) {
|
|
|
- return manageMapper.getManeger(account,password);
|
|
|
+ return manageMapper.getManeger(account, password);
|
|
|
}
|
|
|
|
|
|
@Override
|