ソースを参照

用户

master
yaoq 2年前
コミット
871a9a1f30
6個のファイルの変更72行の追加54行の削除
  1. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/VerifyCodeController.java
  2. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java
  3. +21
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java
  4. +3
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java
  5. +40
    -37
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java
  6. +5
    -13
      smtweb-framework/bpm/src/main/resources/static/event/bpm/sys/user/user/userList.js

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/VerifyCodeController.java ファイルの表示

@@ -42,7 +42,7 @@ public class VerifyCodeController {
int fontSize = 28; //code的字体大小
int fontMargin = fontSize / 18; //字符间隔
int width = 90; //图片长度
int height = 40; //图片高度,根据字体大小自动调整;调整这个系数可以调整字体占图片的比例
int height = 38; //图片高度,根据字体大小自动调整;调整这个系数可以调整字体占图片的比例
int avgWidth = (int) (width / count / 1.2); //字符平均占位宽度
int maxDegree = 26; //最大旋转度数
//生成随机类


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java ファイルの表示

@@ -77,8 +77,8 @@ public class PageDataset {
return ModelTableCache.getInstance().get(masterTable);
}

public boolean isCurTable(String table_name) {
return table_name.equals(getModelTable().getName());
public boolean isCurDataSet(String dataset) {
return this.name.equals(dataset);
}

/**


+ 21
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java ファイルの表示

@@ -10,9 +10,15 @@ 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.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.user.UserCache;
import lombok.extern.slf4j.Slf4j;

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

@Slf4j
@SwService
public class AuthService {
@@ -22,6 +28,21 @@ public class AuthService {
@SwParam
private SessionManager sessionManager;

@SwPerm()
public R getParty(@SwParam("username") String username) {
Set<Party> partySet = PartyCache.getInstance().getTopSet();
List<SwMap> list = new ArrayList<>();
for (Party party : partySet) {
SwMap data = new SwMap();
data.put("id", party.getId());
data.put("text", party.getName());
data.put("isLeaf", true);
data.put("children", new ArrayList<>());
list.add(data);
}
return R.success(list);
}

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


+ 3
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java ファイルの表示

@@ -24,6 +24,8 @@ import java.util.*;
* @Desc:
*/
public class MenuHandler {
private final static String Ds_menuCard = "menuCard";

static class MenuLoadHandler extends DynPageLoadHandler {
@Override
public DynPageTreeHandler getTreeWorker(SwMap filter, PageDataset pageDataSet) {
@@ -65,7 +67,7 @@ public class MenuHandler {

@Override
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) {
if (pageDataSet.isCurTable(Menu.ENTITY_NAME)) {
if (pageDataSet.isCurDataSet(Ds_menuCard)) {
//处理请求内容
SwMap sm_content = new SwMap();
sm_content.put("pageId", data.readString("sm_page_id"));


+ 40
- 37
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java ファイルの表示

@@ -9,8 +9,6 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageDelHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler;
@@ -21,6 +19,7 @@ import cc.smtweb.system.bpm.web.sys.user.role.RoleCache;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
@@ -28,6 +27,8 @@ import java.util.Set;
* 区划保存
*/
public class UserHandler {
private final static String DS_UserParty = "userPartyList";
private final static String DS_UserCard = "userCard";

public static EntityDao<User> getUserDao() {
return DbEngine.getInstance().findDao(User.ENTITY_NAME);
@@ -48,24 +49,32 @@ public class UserHandler {
static class UserSaveHandler extends DynPageSaveHandler {
private UserStatu userStatu;
private List<UserRole> roleList;
private List<UserParty> partyList;

@Override
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) {
if (pageDataSet.isCurTable(UserParty.ENTITY_NAME)) {
roleList = new ArrayList<>();
Set<Long> userRoles = data.readLongSet("sup_roles");
if (pageDataSet.isCurDataSet(DS_UserCard)) {
DefaultEntity bean = super.readBeanFromPage(pageDataSet, data);
if (PubUtil.isEmpty(userRoles)) {
return bean;
roleList = new ArrayList<>();
partyList = new ArrayList<>();
List<Map<String, Object>> rows = data.readListMap("partyData");
for (Map<String, Object> row : rows) {
UserParty userParty = new UserParty();
userParty.init();
userParty.getData().putAll(row);
userParty.setUserId(bean.getEntityId());
userParty.setEntityId(DbEngine.getInstance().nextId());
partyList.add(userParty);

for (String role_id : row.get("sup_roles").toString().split(",")) {
UserRole userRole = new UserRole();
userRole.init();
userRole.setEntityId(DbEngine.getInstance().nextId());
userRole.setSupId(userParty.getEntityId());
userRole.setRoleId(Long.valueOf(role_id));
roleList.add(userRole);
}
}
userRoles.forEach(k -> {
UserRole userRole = new UserRole();
userRole.init();
userRole.setEntityId(DbEngine.getInstance().nextId());
userRole.setSupId(bean.getEntityId());
userRole.setRoleId(k);
roleList.add(userRole);
});
return bean;
}
return super.readBeanFromPage(pageDataSet, data);
@@ -85,13 +94,18 @@ public class UserHandler {
if (bean.isNew()) {
((User) bean).setPwd(LoginHelper.encodePwd(bean.getEntityId(), SwConsts.DEF_PWD));
}
}
if (bean instanceof UserParty) {
Set<Long> ur = UserRoleCache.getInstance().getByParty(bean.getEntityId());
Set<Long> up = UserPartyCache.getInstance().getIdByUser(bean.getEntityId());
Set<Long> ur = UserRoleCache.getInstance().getIdByUser(bean.getEntityId());
getUserRoleDao().deleteEntity(ur);
getUserPartyDao().deleteEntity(up);
getUserRoleDao().batchInsertEntity(roleList);
getUserPartyDao().batchInsertEntity(partyList);

UserRoleCache.getInstance().removeList(ur);
UserPartyCache.getInstance().removeList(up);
UserRoleCache.getInstance().putList(roleList);
UserPartyCache.getInstance().putList(partyList);
}
super.saveBean(bean);
}
@@ -100,6 +114,11 @@ public class UserHandler {
static class UserDelHandler extends DynPageDelHandler {

@Override
protected void checkBean(PageDataset pageDataSet, long id) {

}

@Override
protected void localDel(long id, ModelTable table) {
super.localDel(id, table);
if (table.getName().equals(User.ENTITY_NAME)) {
@@ -107,10 +126,6 @@ public class UserHandler {
getUserPartyDao().deleteEntity(UserPartyCache.getInstance().getIdByUser(id));
getUserRoleDao().deleteEntity(UserRoleCache.getInstance().getIdByUser(id));
}
if (table.getName().equals(UserParty.ENTITY_NAME)) {
getUserPartyDao().deleteEntity(id);
getUserRoleDao().deleteEntity(UserRoleCache.getInstance().getByParty(id));
}
}

@Override
@@ -120,10 +135,6 @@ public class UserHandler {
UserPartyCache.getInstance().removeList(UserPartyCache.getInstance().getIdByUser(id));
UserRoleCache.getInstance().removeList(UserRoleCache.getInstance().getIdByUser(id));
}
if (table.getName().equals(UserParty.ENTITY_NAME)) {
UserPartyCache.getInstance().remove(id);
UserRoleCache.getInstance().removeList(UserRoleCache.getInstance().getByParty(id));
}
}
}

@@ -135,9 +146,10 @@ public class UserHandler {

@Override
protected void afterQuery(List<SwMap> listData) {
if (pageDataSet.isCurTable(UserParty.ENTITY_NAME)) {
if (pageDataSet.isCurDataSet(DS_UserParty)) {
listData.forEach(sw -> {
sw.put("sup_roles", RoleCache.getInstance().getNamesByIds(UserRoleCache.getInstance().getRoleByParty(sw.readLong("sup_id"))));
sw.put("sup_roles", UserRoleCache.getInstance().getRoleByParty(sw.readLong("sup_id")));
sw.put("sup_roles_text", RoleCache.getInstance().getNamesByIds(UserRoleCache.getInstance().getRoleByParty(sw.readLong("sup_id"))));
});
return;
}
@@ -153,15 +165,6 @@ public class UserHandler {
listHandler.init(params, us);
return listHandler;
}


@Override
protected void afterLoadBean(PageDataset dataset, SwMap bean) {
super.afterLoadBean(dataset, bean);
if (dataset.isCurTable(UserParty.ENTITY_NAME)) {
bean.put("sup_roles", CommUtil.getSqlInIds(UserRoleCache.getInstance().getRoleByParty(bean.readLong("sup_id"))));
}
}
}

static class UserCustHandler extends AbstractHandler {


+ 5
- 13
smtweb-framework/bpm/src/main/resources/static/event/bpm/sys/user/user/userList.js ファイルの表示

@@ -7,22 +7,14 @@ window.$swEvent.setup("bpm.sys.user.user.userList", {
const {$params, $refs, $widgets, $model, $utils, $tabRouter, $api} = page || {};
const {$$message, $$http} = $utils || {};

//
const batchDelParty = () => {
const data = $refs.tbparty.getSelectIds();
if (data.length == 0) {
$$message.notify.warning("请选择要删除的记录!");
return;
}
$$http.post("bpm/user/batchDelParty", {ids: data.join(",")}).then((rt) => {
// 8.弹出成功消息
$$message.notify.success("操作成功");
page.$api.loadOne("userPartyList");
});

// 示例
const onBeforeSave = () => {
$model.userCard.setFormVal("partyData", $model.userPartyList.data.list.rows);
};

return {
batchDelParty,
onBeforeSave,
}
}
});

読み込み中…
キャンセル
保存