|
|
|
@ -1,11 +1,14 @@ |
|
|
|
|
package com.share.help.service; |
|
|
|
|
|
|
|
|
|
import com.share.help.Util; |
|
|
|
|
import com.share.help.dao.UserMapper; |
|
|
|
|
import com.share.help.entity.UserEntity; |
|
|
|
|
import com.share.help.form.FindUserForm; |
|
|
|
|
import com.share.help.form.UserLoginForm; |
|
|
|
|
import com.share.help.form.UserRegisterForm; |
|
|
|
|
import com.share.help.res.JSONResponse; |
|
|
|
|
import com.share.help.res.Result; |
|
|
|
|
import com.share.help.res.account.FindUserRes; |
|
|
|
|
import com.share.help.res.account.LoginRes; |
|
|
|
|
import com.share.help.res.account.RegisterRes; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -13,11 +16,13 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.util.DigestUtils; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用户服务层 |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
public class UserService extends ImageService{ |
|
|
|
|
public class UserService{ |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private UserMapper userMapper; |
|
|
|
@ -25,6 +30,16 @@ public class UserService extends ImageService{ |
|
|
|
|
@Value("${user.register.time-score}") |
|
|
|
|
private int timeScore; |
|
|
|
|
|
|
|
|
|
//用户分页配置
|
|
|
|
|
@Value("${activity.page-size}") |
|
|
|
|
private int pageSize; |
|
|
|
|
|
|
|
|
|
@Value("${activity.row-size}") |
|
|
|
|
private int rowSize; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ImageService imageService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 注册 |
|
|
|
|
* @param userRegisterForm 注册表单 |
|
|
|
@ -44,7 +59,7 @@ public class UserService extends ImageService{ |
|
|
|
|
userEntity.setName(userRegisterForm.getName()); |
|
|
|
|
userEntity.setSex(userRegisterForm.getSex()); |
|
|
|
|
//保存头像
|
|
|
|
|
String imageName=saveImg(userRegisterForm.getImgFile()); |
|
|
|
|
String imageName=imageService.saveImg(userRegisterForm.getImgFile()); |
|
|
|
|
if(imageName==null){ |
|
|
|
|
return new JSONResponse<>(RegisterRes.fail, Result.FAIL); |
|
|
|
|
} |
|
|
|
@ -71,4 +86,18 @@ public class UserService extends ImageService{ |
|
|
|
|
return userEntity==null?new JSONResponse<>(LoginRes.Res.valid_error,Result.FAIL) |
|
|
|
|
:new JSONResponse<LoginRes.Res,LoginRes>(LoginRes.Res.ok,Result.OK).setBody(new LoginRes(userEntity)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public JSONResponse<FindUserRes.Res,FindUserRes> find(FindUserForm findUserForm){ |
|
|
|
|
FindUserRes findUserRes=userMapper.count(pageSize,findUserForm.getUserTypes(),findUserForm.getInfo(),findUserForm.getServiceAddress()); |
|
|
|
|
findUserRes.setPageSize(pageSize); |
|
|
|
|
findUserRes.setCurrentPage(findUserForm.getCurrentPage()); |
|
|
|
|
List<UserEntity> userEntityList=userMapper.getPage((findUserForm.getCurrentPage()-1)*pageSize,pageSize,findUserForm.getUserTypes(), |
|
|
|
|
findUserForm.getInfo(),findUserForm.getServiceAddress()); |
|
|
|
|
if(!userEntityList.isEmpty()){ |
|
|
|
|
findUserRes.setBody(Util.splitList(UserEntity.class,userEntityList,rowSize)); |
|
|
|
|
return new JSONResponse<FindUserRes.Res,FindUserRes>(FindUserRes.Res.ok,Result.OK).setBody(findUserRes); |
|
|
|
|
}else{ |
|
|
|
|
return new JSONResponse<>(FindUserRes.Res.empty, Result.FAIL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|