|
|
@@ -24,8 +24,10 @@ import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.CertifyApiController;
|
|
|
import com.goafanti.common.dao.AdminMapper;
|
|
|
+import com.goafanti.common.dao.UserRoleMapper;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
import com.goafanti.common.model.AdminLocation;
|
|
|
+import com.goafanti.common.model.UserRole;
|
|
|
import com.goafanti.common.utils.PasswordUtil;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
@@ -67,7 +69,13 @@ public class AdminSuperviserApiController extends CertifyApiController {
|
|
|
@RequestMapping(value = "/insertAdmin", method = RequestMethod.POST)
|
|
|
public Result insertAdmin(@RequestParam(value = "roles[]", required = false) String[] roleIds, String data) {
|
|
|
Result res = new Result();
|
|
|
- JSONObject jo = (JSONObject) JSON.parse(data);
|
|
|
+ JSONObject jo = (JSONObject) JSON.parse(data);
|
|
|
+ List<String> roles = new ArrayList<String>();
|
|
|
+ if (roleIds != null && roleIds.length > 0) {
|
|
|
+ for (String role : roleIds) {
|
|
|
+ roles.add(role);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (roleIds==null||roleIds.length<=0) {
|
|
|
res.getError().add(buildError("","角色不能为空"));
|
|
|
return res;
|
|
|
@@ -88,6 +96,10 @@ public class AdminSuperviserApiController extends CertifyApiController {
|
|
|
res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
|
|
|
return res;
|
|
|
}
|
|
|
+ if (newAdminService.checkAdminRole(roles)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "", "咨询师管理员"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
Admin ad = new Admin();
|
|
|
@@ -101,12 +113,7 @@ public class AdminSuperviserApiController extends CertifyApiController {
|
|
|
ad.setPassword(AFTConstants.INITIALPASSWORD);
|
|
|
}
|
|
|
ad.setPassword(passwordUtil.getEncryptPwd(ad));
|
|
|
- List<String> roles = new ArrayList<String>();
|
|
|
- if (roleIds != null && roleIds.length > 0) {
|
|
|
- for (String role : roleIds) {
|
|
|
- roles.add(role);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
res.setData(newAdminService.insertNewAdmin(ad,roles));
|
|
|
}
|
|
|
|
|
|
@@ -120,6 +127,12 @@ public class AdminSuperviserApiController extends CertifyApiController {
|
|
|
public Result updateAdmin(@RequestParam(value = "roles[]", required = false) String[] roleIds, String data) {
|
|
|
Result res = new Result();
|
|
|
JSONObject jo = (JSONObject) JSON.parse(data);
|
|
|
+ List<String> roles = new ArrayList<String>();
|
|
|
+ if (roleIds != null && roleIds.length > 0) {
|
|
|
+ for (String role : roleIds) {
|
|
|
+ roles.add(role);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (null != jo) {
|
|
|
Admin admin = jo.toJavaObject(Admin.class);
|
|
|
|
|
|
@@ -143,12 +156,16 @@ public class AdminSuperviserApiController extends CertifyApiController {
|
|
|
res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
Admin a = newAdminService.selectByPrimaryKey(admin.getId());
|
|
|
if (null == a) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ if (newAdminService.checkAdminRole(roles)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "", "咨询师管理员"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
//*********用户编号判断**************
|
|
|
String sdepNo=adminMapper.selectUserNoBySuperiorId(admin.getSuperiorId());
|
|
|
int Count=adminMapper.selectCountBySuperiorId(admin.getSuperiorId());
|
|
|
@@ -188,16 +205,13 @@ public class AdminSuperviserApiController extends CertifyApiController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- List<String> roles = new ArrayList<String>();
|
|
|
- if (roleIds != null && roleIds.length > 0) {
|
|
|
- for (String role : roleIds) {
|
|
|
- roles.add(role);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
res.setData(newAdminService.updateByPrimaryKeySelective(ad, roles));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
return res;
|
|
|
- }
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 重置管理员密码
|