|
@@ -1,12 +1,10 @@
|
|
|
package com.rf.psychological.user.rest;
|
|
|
|
|
|
-import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.rf.psychological.base.rest.BaseController;
|
|
|
import com.rf.psychological.enums.UserRole;
|
|
|
-import com.rf.psychological.enums.UserStatus;
|
|
|
import com.rf.psychological.group.dao.model.GroupEntity;
|
|
|
import com.rf.psychological.group.rest.GroupInfoController;
|
|
|
import com.rf.psychological.group.service.GroupInfoService;
|
|
@@ -20,7 +18,6 @@ import com.rf.psychological.security.SafetyProcess;
|
|
|
import com.rf.psychological.user.dao.model.UserEntity;
|
|
|
import com.rf.psychological.user.service.UserService;
|
|
|
import com.rf.psychological.utils.Constant;
|
|
|
-import com.rf.psychological.utils.JWTUtil;
|
|
|
import com.rf.psychological.utils.Result;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -31,13 +28,9 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.util.DigestUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.servlet.http.HttpSession;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import static cn.hutool.core.date.DatePattern.PURE_DATETIME_PATTERN;
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* @author zsy
|
|
@@ -377,4 +370,55 @@ public class UserController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加管理员
|
|
|
+ * @param jsonParam
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/addAdminUser")
|
|
|
+ @ApiOperation(value = "添加管理员",notes = "json字符串形式传参(加密),data参数包括:data:注册用户基本信息《gender:性别,password:密码,roleType:角色,institutionNo:机构编号,phone:账号,mobile:手机号,petName:名称》")
|
|
|
+ @SafetyProcess
|
|
|
+ public Result addAdminUser(@RequestBody String jsonParam){
|
|
|
+ try {
|
|
|
+ String data = AesEncryptUtils.decrypt(JSONObject.parseObject(jsonParam).getString("data"));
|
|
|
+ JSONObject jsonData = JSONObject.parseObject(data);
|
|
|
+ UserEntity userEntity = jsonData.toJavaObject(UserEntity.class);
|
|
|
+ String institutionNo = userEntity.getInstitutionNo();
|
|
|
+ if (StringUtils.isEmpty(institutionNo)){
|
|
|
+ return fail("","机构编号不能为空");
|
|
|
+ }
|
|
|
+ //判断机构编号是否存在
|
|
|
+ InstitutionEntity institutionEntity = this.institutionService.findByInstitutionNo(institutionNo);
|
|
|
+ if (institutionEntity == null) {
|
|
|
+ return fail("", "机构编号不存在!");
|
|
|
+ }
|
|
|
+ userEntity.setInstitutionName(institutionEntity.getInstitutionName());
|
|
|
+ UserEntity userInfo = this.userService.findPhoneAndInstitutionNoAndRoleType(userEntity.getPhone(), userEntity.getInstitutionNo(),userEntity.getRoleType());
|
|
|
+ if (userInfo == null) {
|
|
|
+ userEntity.setCreateTime(DateUtil.now());
|
|
|
+ userEntity.setStructureNo(institutionNo);
|
|
|
+ userEntity.setPassword(DigestUtils.md5DigestAsHex(userEntity.getPassword().getBytes()));
|
|
|
+ this.userService.save(userEntity);
|
|
|
+ return success();
|
|
|
+ } else {
|
|
|
+ return fail("", "账号已注册");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getAdminUser")
|
|
|
+ @ApiOperation(value = "获取管理员")
|
|
|
+ @SafetyProcess
|
|
|
+ public Result getAdminUser(@RequestParam int pageNum,@RequestParam int pageSize, @RequestParam String institutionNo,@RequestParam String phone){
|
|
|
+ try {
|
|
|
+ Page<UserEntity> userEntityPage = userService.findAdmin(pageNum,pageSize,institutionNo,phone);
|
|
|
+ return success(userEntityPage);
|
|
|
+ }catch (Exception e){
|
|
|
+ return fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|