Kaynağa Gözat

枚举combo

登录
4.0
yaoq 2 yıl önce
ebeveyn
işleme
c4ee399bae
5 değiştirilmiş dosya ile 94 ekleme ve 6 silme
  1. +27
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java
  2. +40
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/dev/EnumComboService.java
  3. +11
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/User.java
  4. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java
  5. +15
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserRoleCache.java

+ 27
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java Dosyayı Görüntüle

@@ -10,10 +10,13 @@ import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.session.SessionManager;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.system.bpm.web.sys.user.party.Party;
import cc.smtweb.system.bpm.web.sys.user.party.PartyCache;
import cc.smtweb.system.bpm.web.sys.user.role.RoleCache;
import cc.smtweb.system.bpm.web.sys.user.user.User;
import cc.smtweb.system.bpm.web.sys.user.user.UserCache;
import cc.smtweb.system.bpm.web.sys.user.user.UserRoleCache;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
@@ -44,6 +47,30 @@ public class AuthService {
return R.success(list);
}

@SwPerm()
public R userInfo(@SwBody SwMap params, UserSession us) {
SwMap data = new SwMap();
try {
User user = (User) UserCache.getInstance().get(us.getUserId()).clone();
user.setId(us.getUserId());
user.put("create_time", PubUtil.checkLastTime(user.getCreate()));
user.put("sur_party", PartyCache.getInstance().get(us.getPartyId()));
user.put("sur_roles", RoleCache.getInstance().getNamesByIds(UserRoleCache.getInstance().getRoleIdByUP(us.getUserId(), us.getPartyId())));
data.put("user", user);
} catch (CloneNotSupportedException e) {

}
return R.success(data);
}

@SwPerm()
public R saveUser(@SwBody SwMap params, UserSession us) {
SwMap userInfo = params.readMap("userInfo");
User user = UserCache.getInstance().get(us.getUserId());
user.getData().putAll(userInfo);
return R.success();
}

@SwPerm(SwPerm.NONE)
public R login(@SwBody LoginVO loginPO) {
SwMap data = new SwMap();


+ 40
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/dev/EnumComboService.java Dosyayı Görüntüle

@@ -1,8 +1,19 @@
package cc.smtweb.system.bpm.web.sys.dev;

import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.AbstractEnum;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;

import java.util.ArrayList;
import java.util.List;

/**
* Created by 1 at 2022-08-03 16:09:30
@@ -13,15 +24,39 @@ public class EnumComboService extends DynPageService {
//public final static String TYPE_DEMO = "demo";
@Override
protected AbstractHandler createHandler(String type) {
if (TYPE_LOAD.equals(type)) return new ComboHandler.EnumLoadHandler();
return super.createHandler(type);
}

/* demo
//自定义
public R demo(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_DEMO, handler -> ((DemoHandler)handler).demo());
public R loadOne(@SwBody SwMap params, UserSession us) {
SwListData swListData = buildListData(params.readString("cls"));
DynRetBean bean = DynRetBean.createList(swListData);
return R.success(bean);
}
*/

private SwListData buildListData(String cls) {
if (PubUtil.isEmpty(cls)) return SwListData.create(new ArrayList(), 0);
List<SwMap> list = new ArrayList<>();
try {
AbstractEnum e;
try {
e = (AbstractEnum) Class.forName(cls).getDeclaredField("inst").get(null);
} catch (Exception e1) {
e = (AbstractEnum) Class.forName(cls).getDeclaredField("instance").get(null);
}
for (Object v : e.mapAll.values()) {
AbstractEnum.EnumBean bean = (AbstractEnum.EnumBean) v;
SwMap row = new SwMap();
row.put("value", bean.value.toString());
row.put("name", bean.name);
list.add(row);
}
} catch (Exception ue) {
return SwListData.create(new ArrayList(), 0);
}
return SwListData.create(list, 0);
}


}

+ 11
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/User.java Dosyayı Görüntüle

@@ -5,7 +5,7 @@ import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;

/**
* Created by 1 at 2022-07-28 15:24:49
* Created by 1 at 2022-08-15 09:40:57
* 实体【[用户账号](SYS_USER)】的Entity类
*/
@SwTable("SYS_USER")
@@ -142,4 +142,14 @@ public class User extends DefaultEntity {
public void setRemark(String sur_remark) {
put("sur_remark", sur_remark);
}

/** 创建时间 */
public long getCreate() {
return getLong("sur_create");
}

/** 创建时间 */
public void setCreate(long sur_create) {
put("sur_create", sur_create);
}
}

+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java Dosyayı Görüntüle

@@ -97,6 +97,7 @@ public class UserHandler {
UserStatuCache.getInstance().put(userStatu);
}
if (bean.isNew()) {
((User) bean).setCreate(PubUtil.getLastTime());
((User) bean).setPwd(LoginHelper.encodePwd(bean.getEntityId(), SwConsts.DEF_PWD));
}



+ 15
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserRoleCache.java Dosyayı Görüntüle

@@ -72,6 +72,21 @@ public class UserRoleCache extends AbstractEntityCache<UserRole> {
return roleSet;
}

public final Set<Long> getRoleIdByUP(Long user_id, Long party_id) {
Set<Long> ids = new HashSet<>();
Set<UserParty> upSet = UserPartyCache.getInstance().getListByKey(UserPartyCache.mk_u, String.valueOf(user_id));
if (PubUtil.isEmpty(upSet)) return ids;
upSet.forEach(up -> {
if (up.getPartyId() != party_id) return;
Set<UserRole> urSet = getListByKey(mk_s, String.valueOf(up.getId()));
if (PubUtil.isEmpty(urSet)) return;
for (UserRole userRole : urSet) {
ids.add(userRole.getRoleId());
}
});
return ids;
}

public final Set<Long> getIdByUser(Long key) {
return getIdByUser(String.valueOf(key));
}


Yükleniyor…
İptal
Kaydet