@ -1,11 +1,13 @@
package com.yipin.liuwanr.controller ;
import com.yipin.liuwanr.entity.* ;
import com.yipin.liuwanr.helper.QueryStudentUtils ;
import com.yipin.liuwanr.helper.RedisHelper ;
import com.yipin.liuwanr.service.StaffService ;
import com.yipin.liuwanr.service.StudentService ;
import com.yipin.liuwanr.service.UserInfoService ;
import com.yipin.liuwanr.vo.UserInfoVO ;
import jdk.nashorn.internal.ir.IfNode ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.web.bind.annotation.* ;
@ -13,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletResponse ;
import java.util.Arrays ;
import java.util.HashMap ;
import java.util.List ;
@ -32,6 +35,129 @@ public class UserInfoController {
@Autowired
RedisHelper redisHelper ;
/ * *
* 接收参数 :
* UserInfo : account , userName , roleId , uniqueIdentificationAccount , phone , email
* OrganizationRelationship : workNumber , professionalClassId , gradeId , classId
* /
@PostMapping ( "/addStudent" )
Response addUserInfo ( @RequestBody UserInfoVO vo ) {
Response response = new Response ( ) ;
// Student student = vo.getStudent();
UserInfo userInfo = vo . getUserInfo ( ) ;
OrganizationRelationship organizationRelationship = vo . getOrganizationRelationship ( ) ;
String account = userInfo . getAccount ( ) ;
String userName = userInfo . getUserName ( ) ;
Integer roleId = userInfo . getRoleId ( ) ;
String uniqueIdentificationAccount = userInfo . getUniqueIdentificationAccount ( ) ;
String phone = userInfo . getPhone ( ) ;
String email = userInfo . getEmail ( ) ;
String workNumber = organizationRelationship . getWorkNumber ( ) ;
Integer professionalId = organizationRelationship . getProfessionalId ( ) ;
Integer gradeId = organizationRelationship . getGradeId ( ) ;
Integer classId = organizationRelationship . getClassId ( ) ;
// UserM user = vo.getUser();
if ( account = = null | | userName = = null | | roleId ! = 4 | | uniqueIdentificationAccount = = null | | workNumber = = null | | professionalId < = 0 | | gradeId < = 0 | | classId < = 0 ) {
response . setStatus ( 300 ) ;
response . setErrmessage ( "Parameter Invalid" ) ;
} else {
HashMap < String , Object > ret = userInfoService . addUserInfo ( userInfo ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
response . setStatus ( status ) ;
response . setMessage ( ret . get ( "retvalue" ) ) ;
HashMap < String , Object > ret1 = userInfoService . addOrganizationRelationship ( organizationRelationship ) ;
int status1 = ( int ) ret . get ( "retcode" ) ;
if ( status1 = = 200 ) {
response . setStatus ( status1 ) ;
response . setMessage ( ret1 . get ( "retvalue" ) ) ;
} else {
response . setStatus ( status1 ) ;
response . setErrmessage ( ret1 . get ( "retvalue" ) . toString ( ) ) ;
throw new RuntimeException ( ) ;
}
} else {
response . setStatus ( status ) ;
response . setErrmessage ( ret . get ( "retvalue" ) . toString ( ) ) ;
throw new RuntimeException ( ) ;
}
}
return response ;
}
/ * *
* 查询学生信息
* @param schoolId
* @param professionalIds
* @param searchContent
* @param gradeIds
* @param classIds
* @param pageNo
* @param pageSize
* @return
* /
@GetMapping ( "/queryStudent" )
Response queryStudent ( @RequestParam Integer schoolId , Integer [ ] professionalIds , String searchContent , Integer [ ] gradeIds , Integer [ ] classIds , Integer pageNo , Integer pageSize ) {
Response response = new Response ( ) ;
UserInfo userInfo = new UserInfo ( ) ;
OrganizationRelationship ship = new OrganizationRelationship ( ) ;
HashMap < Object , Object > ids = new HashMap < > ( 8 ) ;
if ( schoolId = = null ) {
response . setStatus ( 300 ) ;
response . setErrmessage ( "学校信息为空" ) ;
} else {
if ( searchContent ! = null & & searchContent ! = "" ) {
userInfo . setSearchContent ( searchContent ) ;
}
if ( professionalIds . length > 0 ) {
// List<Integer> professionalList = Arrays.asList(professionalId);
for ( Integer professionalId : professionalIds ) {
ship . setProfessionalId ( professionalId ) ;
}
}
if ( gradeIds . length > 0 ) {
// List<Integer> gradeList = Arrays.asList(gradeIds);
for ( Integer gradeId : gradeIds ) {
ship . setGradeId ( gradeId ) ;
}
}
if ( classIds . length > 0 ) {
// List<Integer> classList = Arrays.asList(classIds);
for ( Integer classId : classIds ) {
ship . setClassId ( classId ) ;
}
}
userInfo . setSchoolId ( schoolId ) ;
// HashMap map = userInfoService.queryStudent(userInfo,ship,pageNo,pageSize);
// QueryStudentUtils.statusInformationController(response,map, "retcode", "retvalue");
}
return response ;
}
/ * *
* 批量删除学生
*
* @param ids 用户id
* @return
* /
@GetMapping ( "/deleteStudent" )
Response deleteStudent ( Integer [ ] ids ) {
Response response = new Response ( ) ;
if ( ids . length > 0 ) {
userInfoService . deleteStudent ( ids ) ;
response . setStatus ( 200 ) ;
} else {
response . setStatus ( 500 ) ;
response . setErrmessage ( "学生id不能为空" ) ;
}
return response ;
}
/ * *
* 添加用户
* /
@ -59,41 +185,41 @@ public class UserInfoController {
Integer cityId = user . getCityId ( ) ;
//学校id
Integer schoolId = user . getSchoolId ( ) ;
if ( name = = null | | name = = "" ) {
if ( name = = null | | name = = "" ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "姓名不能为空!" ) ;
} else if ( provinceId = = null ) {
} else if ( provinceId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "省份不能为空!" ) ;
} else if ( cityId = = null ) {
} else if ( cityId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "城市不能为空!" ) ;
} else if ( schoolId = = null ) {
} else if ( schoolId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "学校不能为空!" ) ;
} else {
} else {
HashMap < String , Object > ret = userInfoService . addUser ( user ) ;
Integer userId = user . getUserId ( ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
resp . setStatus ( status ) ;
resp . setMessage ( ret . get ( "retvalue" ) ) ;
HashMap < String , Object > stu = userInfoService . addPersonalFile ( userProfilesList , userId ) ;
HashMap < String , Object > stu = userInfoService . addPersonalFile ( userProfilesList , userId ) ;
int stuStatus = ( int ) stu . get ( "retcode" ) ;
if ( stuStatus = = 200 ) {
if ( stuStatus = = 200 ) {
resp . setStatus ( stuStatus ) ;
resp . setMessage ( stu . get ( "retvalue" ) ) ;
} else {
} else {
resp . setStatus ( stuStatus ) ;
resp . setErrmessage ( stu . get ( "retvalue" ) . toString ( ) ) ;
throw new RuntimeException ( ) ;
}
HashMap < String , Object > sta = userInfoService . addStuStaff ( ORList , userId ) ;
HashMap < String , Object > sta = userInfoService . addStuStaff ( ORList , userId ) ;
int staStatus = ( int ) sta . get ( "retcode" ) ;
if ( staStatus = = 200 ) {
if ( staStatus = = 200 ) {
resp . setStatus ( staStatus ) ;
resp . setMessage ( sta . get ( "retvalue" ) ) ;
} else {
} else {
resp . setStatus ( staStatus ) ;
resp . setErrmessage ( sta . get ( "retvalue" ) . toString ( ) ) ;
throw new RuntimeException ( ) ;
@ -115,42 +241,43 @@ public class UserInfoController {
Response resp = new Response ( ) ;
UserInfo userInfo = new UserInfo ( ) ;
//设置国家
if ( countries ! = null & & countries ! = "" ) {
if ( countries ! = null & & countries ! = "" ) {
userInfo . setCountries ( countries ) ;
}
//设置省份
if ( provinceId ! = null ) {
if ( provinceId ! = null ) {
userInfo . setProvinceId ( provinceId ) ;
}
//设置城市
if ( cityId ! = null ) {
if ( cityId ! = null ) {
userInfo . setCityId ( cityId ) ;
}
//学校
if ( schoolId ! = null ) {
if ( schoolId ! = null ) {
userInfo . setSchoolId ( schoolId ) ;
}
//角色
if ( roleId ! = null ) {
if ( roleId ! = null ) {
userInfo . setRoleId ( roleId ) ;
}
//搜索内容
if ( searchContent ! = null & & searchContent ! = "" ) {
if ( searchContent ! = null & & searchContent ! = "" ) {
userInfo . setSearchContent ( searchContent ) ;
}
//月份
if ( month ! = null ) {
userInfo . setMonth ( month ) ; ;
if ( month ! = null ) {
userInfo . setMonth ( month ) ;
;
}
//创建时间
if ( creationTime ! = null & & creationTime ! = "" ) {
if ( creationTime ! = null & & creationTime ! = "" ) {
userInfo . setCreationTime ( creationTime ) ;
}
//结束时间
if ( endTime ! = null & & endTime ! = "" ) {
if ( endTime ! = null & & endTime ! = "" ) {
userInfo . setEndTime ( endTime ) ;
}
HashMap < String , Object > ret = userInfoService . queryUserInfo ( userInfo , pageNo , pageSize ) ;
HashMap < String , Object > ret = userInfoService . queryUserInfo ( userInfo , pageNo , pageSize ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
resp . setStatus ( status ) ;
@ -169,7 +296,7 @@ public class UserInfoController {
@PostMapping ( "/deleteUserInfo" )
public Response deleteUserInfo ( @RequestBody List < Integer > userIdList ) {
Response resp = new Response ( ) ;
if ( userIdList = = null ) {
if ( userIdList = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id为空,删除用户失败!" ) ;
} else {
@ -183,12 +310,12 @@ public class UserInfoController {
if ( 200 = = staStatus ) {
resp . setStatus ( staStatus ) ;
resp . setMessage ( sta . get ( "retvalue" ) ) ;
} else {
} else {
resp . setStatus ( staStatus ) ;
resp . setErrmessage ( sta . get ( "retvalue" ) . toString ( ) ) ;
throw new RuntimeException ( ) ;
}
} else {
} else {
resp . setStatus ( status ) ;
resp . setErrmessage ( ret . get ( "retvalue" ) . toString ( ) ) ;
throw new RuntimeException ( ) ;
@ -205,7 +332,7 @@ public class UserInfoController {
public Response updateUserInfo ( @RequestBody UserInfo userInfo ) {
Response resp = new Response ( ) ;
Integer userId = userInfo . getUserId ( ) ;
if ( userId = = null ) {
if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户ID为空,修改用户失败!" ) ;
} else {
@ -281,13 +408,13 @@ public class UserInfoController {
Response loginSchool ( @RequestParam ( "account" ) String account , @RequestParam ( "password" ) String password , HttpServletRequest req , HttpServletResponse res ) {
Response resp = new Response ( ) ;
UserInfo userInfo = new UserInfo ( ) ;
if ( account = = null | | account = = "" ) {
if ( account = = null | | account = = "" ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户账号为空,登录失败!" ) ;
} else if ( password = = null | | password = = "" ) {
} else if ( password = = null | | password = = "" ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户密码为空,登录失败!" ) ;
} else {
} else {
userInfo . setAccount ( account ) ;
userInfo . setPassword ( password ) ;
HashMap < String , Object > ret = userInfoService . loginSchool ( userInfo ) ;
@ -307,20 +434,19 @@ public class UserInfoController {
* 登陆
* /
@GetMapping ( "/logins" )
Response logins ( @RequestParam ( "userId" ) Integer userId , @RequestParam ( "schoolId" ) Integer schoolId , @RequestParam ( "roleId" ) Integer roleId , HttpServletRequest req , HttpServletResponse res ) {
Response logins ( @RequestParam ( "userId" ) Integer userId , @RequestParam ( "schoolId" ) Integer schoolId , @RequestParam ( "roleId" ) Integer roleId , HttpServletRequest req , HttpServletResponse res ) {
Response resp = new Response ( ) ;
UserInfo userInfo = new UserInfo ( ) ;
if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id为空,登录失败!" ) ;
} else if ( schoolId = = null ) {
} else if ( schoolId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户学校id为空,登录失败!" ) ;
} else if ( roleId = = null ) {
} else if ( roleId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户角色id为空,登录失败!" ) ;
}
else {
} else {
userInfo . setRoleId ( roleId ) ;
userInfo . setUserId ( userId ) ;
userInfo . setSchoolId ( schoolId ) ;
@ -347,10 +473,10 @@ public class UserInfoController {
if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id为空,登录失败!" ) ;
} else if ( schoolId = = null ) {
} else if ( schoolId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "角色id为空,登录失败!" ) ;
} else {
} else {
OR . setUserId ( userId ) ;
OR . setSchoolId ( schoolId ) ;
HashMap < String , Object > ret = userInfoService . loginRole ( OR ) ;
@ -372,10 +498,10 @@ public class UserInfoController {
@GetMapping ( "/queryUserInfoDetails" )
Response queryUserInfoDetails ( @RequestParam Integer userId ) {
Response resp = new Response ( ) ;
if ( userId = = null ) {
if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id为空!查询失败!" ) ;
} else {
} else {
HashMap < String , Object > ret = userInfoService . queryUserInfoDetails ( userId ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
@ -393,16 +519,16 @@ public class UserInfoController {
* 查询用户组织架构OR ( organization relationship )
* /
@GetMapping ( "/queryUserOR" )
Response queryUserOR ( @RequestParam Integer userId , Integer platformId ) {
Response queryUserOR ( @RequestParam Integer userId , Integer platformId ) {
Response resp = new Response ( ) ;
if ( userId = = null ) {
if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id为空!查询失败!" ) ;
} else if ( platformId = = null ) {
} else if ( platformId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "平台id为空!查询失败!" ) ;
} else {
HashMap < String , Object > ret = userInfoService . queryUserOR ( userId , platformId ) ;
HashMap < String , Object > ret = userInfoService . queryUserOR ( userId , platformId ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
resp . setStatus ( status ) ;
@ -421,10 +547,10 @@ public class UserInfoController {
@GetMapping ( "/queryUserProfiles" )
Response queryUserProfiles ( @RequestParam Integer userId ) {
Response resp = new Response ( ) ;
if ( userId = = null ) {
if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id为空!查询失败!" ) ;
} else {
} else {
HashMap < String , Object > ret = userInfoService . queryUserProfiles ( userId ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
@ -441,11 +567,11 @@ public class UserInfoController {
@PostMapping ( "/uploadUserAvatars" )
Response uploadUserAvatars ( MultipartFile file , Integer userId ) {
Response resp = new Response ( ) ;
if ( userId = = null ) { //前台传来的值是否为空
if ( userId = = null ) { //前台传来的值是否为空
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "Parameter Invalid" ) ;
} else {
HashMap < String , Object > ret = userInfoService . uploadUserAvatars ( file , userId ) ;
} else {
HashMap < String , Object > ret = userInfoService . uploadUserAvatars ( file , userId ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
@ -468,13 +594,13 @@ public class UserInfoController {
Integer userId = user . getUserId ( ) ;
String phone = user . getPhone ( ) ;
Integer accountRole = user . getAccountRole ( ) ;
if ( userId = = null ) {
if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id不能为空!" ) ;
} else if ( phone = = null | | phone = = "" ) {
} else if ( phone = = null | | phone = = "" ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户电话不能为空!" ) ;
} else if ( accountRole = = null ) {
} else if ( accountRole = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户角色不能为空!" ) ;
} else {
@ -490,13 +616,14 @@ public class UserInfoController {
}
return resp ;
}
/ * *
* 用户模块查询客户
* /
@GetMapping ( "/queryCustomer" )
Response queryCustomer ( @RequestParam String searchContent , @RequestParam List < Integer > customerIds ) {
Response queryCustomer ( @RequestParam String searchContent , @RequestParam List < Integer > customerIds ) {
Response resp = new Response ( ) ;
HashMap < String , Object > ret = userInfoService . queryCustomer ( searchContent , customerIds ) ;
HashMap < String , Object > ret = userInfoService . queryCustomer ( searchContent , customerIds ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
resp . setStatus ( status ) ;
@ -514,10 +641,10 @@ public class UserInfoController {
@GetMapping ( "/queryAccountIsExist" )
Response queryAccountIsExist ( @RequestParam String account ) {
Response resp = new Response ( ) ;
if ( account = = null & & account = = "" ) {
if ( account = = null & & account = = "" ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "账号为空!" ) ;
} else {
} else {
HashMap < String , Object > ret = userInfoService . queryAccountIsExist ( account ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
@ -535,17 +662,16 @@ public class UserInfoController {
* 查询学号 、 工号是否存在
* /
@GetMapping ( "/queryWorkNumberIsExist" )
Response queryWorkNumberIsExist ( @RequestParam String workNumber , Integer roleId , Integer schoolId ) {
Response queryWorkNumberIsExist ( @RequestParam String workNumber , Integer roleId , Integer schoolId ) {
Response resp = new Response ( ) ;
if ( workNumber = = null ) {
if ( workNumber = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "学号、工号为空!" ) ;
} else if ( roleId = = null ) {
} else if ( roleId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "角色id为空!" ) ;
}
else {
HashMap < String , Object > ret = userInfoService . queryWorkNumberIsExist ( workNumber , roleId , schoolId ) ;
} else {
HashMap < String , Object > ret = userInfoService . queryWorkNumberIsExist ( workNumber , roleId , schoolId ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
resp . setStatus ( status ) ;
@ -566,10 +692,10 @@ public class UserInfoController {
Response resp = new Response ( ) ;
UserInfo userInfo = new UserInfo ( ) ;
//平台id
if ( platformId = = null & & platformId = = "" ) {
if ( platformId = = null & & platformId = = "" ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "平台id为空!" ) ;
} else {
} else {
HashMap < String , Object > ret = userInfoService . queryPlatform ( platformId ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
@ -592,15 +718,14 @@ public class UserInfoController {
Integer platformId = OR . getPlatformId ( ) ;
Integer userId = OR . getUserId ( ) ;
//平台id
if ( platformId = = null ) {
if ( platformId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "平台id为空!" ) ;
} else if ( userId = = null ) {
} else if ( userId = = null ) {
resp . setStatus ( 300 ) ;
resp . setErrmessage ( "用户id为空!" ) ;
}
else {
HashMap < String , Object > ret = userInfoService . deletePlatform ( platformId , userId ) ;
} else {
HashMap < String , Object > ret = userInfoService . deletePlatform ( platformId , userId ) ;
int status = ( int ) ret . get ( "retcode" ) ;
if ( 200 = = status ) {
resp . setStatus ( status ) ;