|
@@ -4,7 +4,9 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.crypto.hash.Sha256Hash;
|
|
|
+import org.apache.shiro.subject.Subject;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -71,6 +73,13 @@ public class UserCtl extends BaseCtl {
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(vo.getOrgid())) {
|
|
|
model.setOrgid(vo.getOrgid());
|
|
|
+ } else {
|
|
|
+ // 当前用户下的组织
|
|
|
+ Subject subject = SecurityUtils.getSubject();
|
|
|
+ UserModel user = (UserModel) subject.getPrincipal();
|
|
|
+ if (!Constants.USER_TYPE_SA.equals(user.getRylx())) {
|
|
|
+ model.setOrgid(user.getOrgid());
|
|
|
+ }
|
|
|
}
|
|
|
List<UserModel> list = userService.findAllByCond(model);
|
|
|
PageInfo<UserModel> pageResult = new PageInfo<>(list);
|
|
@@ -107,6 +116,16 @@ public class UserCtl extends BaseCtl {
|
|
|
// 登录密码:123456
|
|
|
String pwd = new Sha256Hash("123456").toHex();
|
|
|
model.setLoginPassword(pwd);
|
|
|
+ // 是否经营人
|
|
|
+ if (Constants.CHK_YES.equals(vo.getIfAdmin())) {
|
|
|
+ model.setRylx(Constants.USER_TYPE_1);
|
|
|
+ } else {
|
|
|
+ model.setRylx(Constants.USER_TYPE_2);
|
|
|
+ }
|
|
|
+ // 所属船代
|
|
|
+ if (Constants.CHK_YES.equals(vo.getIfShip())) {
|
|
|
+ model.setRylx(Constants.USER_TYPE_3);
|
|
|
+ }
|
|
|
userService.add(model);
|
|
|
UserInfoModel userInfoModel = new UserInfoModel();
|
|
|
BeanUtils.copyProperties(vo, userInfoModel);
|
|
@@ -130,7 +149,20 @@ public class UserCtl extends BaseCtl {
|
|
|
} else {
|
|
|
// 更新
|
|
|
UserModel model = userService.findById(vo.getId());
|
|
|
- BeanUtils.copyProperties(vo, model, new String[] { "loginPassword" });
|
|
|
+ BeanUtils.copyProperties(vo, model, new String[] { "loginPassword", "rylx" });
|
|
|
+ // 非管理员变更用户类型
|
|
|
+ if (!Constants.USER_TYPE_SA.equals(model.getRylx())) {
|
|
|
+ // 是否经营人
|
|
|
+ if (Constants.CHK_YES.equals(vo.getIfAdmin())) {
|
|
|
+ model.setRylx(Constants.USER_TYPE_1);
|
|
|
+ } else {
|
|
|
+ model.setRylx(Constants.USER_TYPE_2);
|
|
|
+ }
|
|
|
+ // 所属船代
|
|
|
+ if (Constants.CHK_YES.equals(vo.getIfShip())) {
|
|
|
+ model.setRylx(Constants.USER_TYPE_3);
|
|
|
+ }
|
|
|
+ }
|
|
|
userService.update(model);
|
|
|
UserInfoModel userInfoModel = new UserInfoModel();
|
|
|
BeanUtils.copyProperties(vo, userInfoModel);
|