|
@@ -28,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
+import java.time.ZoneOffset;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -83,7 +84,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
UserVO userVO = new UserVO();
|
|
|
BeanUtils.copyProperties(userList.get(0), userVO);
|
|
|
//还要多返回一个公司名字
|
|
|
- userVO.setCompanyName(companyMapper.selectById(userVO.getCompanyId()).getCompanyName());
|
|
|
+ userVO.setCompanyName(company.getCompanyName());
|
|
|
+ LocalDateTime remainingTime = company.getExpirationDate() == null ? LocalDateTime.now() : company.getExpirationDate();
|
|
|
+ userVO.setRemainingTime(remainingTime.toInstant(ZoneOffset.of("+8")).toEpochMilli() - LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
|
httpRespMsg.data = userVO;
|
|
|
} else {
|
|
|
httpRespMsg.setError("密码错误");
|
|
@@ -116,13 +119,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
}
|
|
|
} else {
|
|
|
if (company.getExpirationDate().isBefore(LocalDateTime.now())) {
|
|
|
- httpRespMsg.setError("账号会员已到期,请联系公司负责人续费会员套餐");
|
|
|
- return httpRespMsg;
|
|
|
+ httpRespMsg.setError("账号会员已到期,请联系公司负责人续费会员套餐");
|
|
|
+ return httpRespMsg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//检测密码正确时
|
|
|
- httpRespMsg.data = userList.get(0);
|
|
|
+ UserVO userVO = new UserVO();
|
|
|
+ BeanUtils.copyProperties(userList.get(0), userVO);
|
|
|
+ //还要多返回一个公司名字
|
|
|
+ LocalDateTime remainingTime = company.getExpirationDate() == null ? LocalDateTime.now() : company.getExpirationDate();
|
|
|
+ userVO.setRemainingTime(remainingTime.toInstant(ZoneOffset.of("+8")).toEpochMilli() - LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
|
+ httpRespMsg.data = userVO;
|
|
|
} else {
|
|
|
httpRespMsg.setError("密码错误");
|
|
|
}
|
|
@@ -219,6 +227,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
Company company = new Company().setCompanyName(companyName)
|
|
|
.setExpirationDate(LocalDateTime.now().plusDays(3));
|
|
|
companyMapper.insert(company);
|
|
|
+ if (userMapper.selectCount(new QueryWrapper<User>().eq("company_id", company.getId())) >= (companyMapper.selectById(company.getId()).getStaffCountMax())) {
|
|
|
+ httpRespMsg.setError("公司人员已达上限");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
//然后生成一个负责人
|
|
|
Long id = SnowFlake.nextId();
|
|
|
User user = new User()
|
|
@@ -262,6 +274,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
.setPhone(phone)
|
|
|
.setRole(role)
|
|
|
.setCompanyId(creator.getCompanyId());
|
|
|
+ if (userMapper.selectCount(new QueryWrapper<User>().eq("company_id", creator.getCompanyId())) >= (companyMapper.selectById(creator.getCompanyId()).getStaffCountMax())) {
|
|
|
+ httpRespMsg.setError("公司人员已达上限");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
if (userMapper.insert(user) == 0) {
|
|
|
httpRespMsg.setError("操作失败");
|
|
|
}
|