会员角色没有,以及基金会员申请看不到管理办法
This commit is contained in:
@@ -37,6 +37,7 @@ import org.nutz.mvc.annotation.At;
|
|||||||
import org.nutz.mvc.annotation.GET;
|
import org.nutz.mvc.annotation.GET;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
|
import org.nutz.mvc.annotation.POST;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@@ -499,6 +500,24 @@ public class SysRoleController {
|
|||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为全部 member=1 的用户设置会员角色,无需传入用户 ID、角色 ID 或列表筛选参数。
|
||||||
|
*
|
||||||
|
* @return JSON Result,data.addedCount 为新增关联数,data.enabledCount 为恢复启用关联数
|
||||||
|
*/
|
||||||
|
@At
|
||||||
|
@POST
|
||||||
|
@Ok("json")
|
||||||
|
@SaCheckPermission("sys.manager.role.user")
|
||||||
|
@SLog(tag = "一键设置会员角色", msg = "为全部member=1的人员补齐会员角色")
|
||||||
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
|
public Result doSettingMemberRole() {
|
||||||
|
NutMap counts = sysRoleService.settingMemberRole();
|
||||||
|
sysRoleService.clearCache();
|
||||||
|
sysUserService.clearCache();
|
||||||
|
return Result.success("会员角色设置完成", counts);
|
||||||
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@SaCheckPermission("sys.manager.role")
|
@SaCheckPermission("sys.manager.role")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.budwk.app.base.service.BaseService;
|
|||||||
import com.budwk.app.sys.models.Sys_menu;
|
import com.budwk.app.sys.models.Sys_menu;
|
||||||
import com.budwk.app.sys.models.Sys_role;
|
import com.budwk.app.sys.models.Sys_role;
|
||||||
import com.budwk.app.sys.models.Sys_unit;
|
import com.budwk.app.sys.models.Sys_unit;
|
||||||
|
import org.nutz.lang.util.NutMap;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -128,6 +129,13 @@ public interface SysRoleService extends BaseService<Sys_role> {
|
|||||||
*/
|
*/
|
||||||
List<String> getRoleIdsByCode(List<RoleConstant> roleConstantList);
|
List<String> getRoleIdsByCode(List<RoleConstant> roleConstantList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为用户表中 member=1 的全部人员补齐启用的 MEMBER 角色,不受列表筛选影响。
|
||||||
|
*
|
||||||
|
* @return addedCount 为新增关联数,enabledCount 为恢复启用的关联数;已有启用关联不重复添加
|
||||||
|
*/
|
||||||
|
NutMap settingMemberRole();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空缓存
|
* 清空缓存
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.nutz.ioc.aop.Aop;
|
|||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Strings;
|
import org.nutz.lang.Strings;
|
||||||
|
import org.nutz.lang.util.NutMap;
|
||||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||||
import org.nutz.plugins.wkcache.annotation.CacheResult;
|
import org.nutz.plugins.wkcache.annotation.CacheResult;
|
||||||
@@ -284,4 +285,44 @@ public class SysRoleServiceImpl extends BaseServiceImpl<Sys_role> implements Sys
|
|||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量补齐会员角色。仅处理 member=1 的用户,保留其他角色及账号禁用状态。
|
||||||
|
*
|
||||||
|
* @return addedCount 为新增关联数,enabledCount 为恢复启用的关联数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
|
public NutMap settingMemberRole() {
|
||||||
|
// 锁定同一会员角色,使本接口的并发请求依次执行,避免重复插入用户角色关系。
|
||||||
|
Sql roleSql = Sqls.create("SELECT * FROM sys_role WHERE code=@code FOR UPDATE");
|
||||||
|
roleSql.setParam("code", RoleConstant.MEMBER.name());
|
||||||
|
roleSql.setEntity(dao().getEntity(Sys_role.class));
|
||||||
|
roleSql.setCallback(Sqls.callback.entities());
|
||||||
|
dao().execute(roleSql);
|
||||||
|
List<Sys_role> roles = roleSql.getList(Sys_role.class);
|
||||||
|
if (roles.isEmpty()) {
|
||||||
|
throw new BaseException("会员角色(MEMBER)不存在,请先配置会员角色");
|
||||||
|
}
|
||||||
|
Sys_role role = roles.get(0);
|
||||||
|
if (role.isDisabled()) {
|
||||||
|
throw new BaseException("会员角色(MEMBER)已禁用,请先启用会员角色");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 历史关联可能已停用或未填写 enable;恢复关联即可,无需重新插入。
|
||||||
|
Sql enableSql = Sqls.create("UPDATE sys_user_role SET enable=1 WHERE roleId=@roleId "
|
||||||
|
+ "AND (enable IS NULL OR enable<>1) "
|
||||||
|
+ "AND EXISTS (SELECT 1 FROM sys_user u WHERE u.id=sys_user_role.userId AND u.member=1)");
|
||||||
|
enableSql.setParam("roleId", role.getId());
|
||||||
|
dao().execute(enableSql);
|
||||||
|
|
||||||
|
// 按用户、角色判重,只为缺少会员关联的人员添加记录;不删除任何已有角色。
|
||||||
|
Sql insertSql = Sqls.create("INSERT INTO sys_user_role (userId,roleId,enable) "
|
||||||
|
+ "SELECT u.id,@roleId,1 FROM sys_user u WHERE u.member=1 "
|
||||||
|
+ "AND NOT EXISTS (SELECT 1 FROM sys_user_role ur WHERE ur.userId=u.id AND ur.roleId=@roleId)");
|
||||||
|
insertSql.setParam("roleId", role.getId());
|
||||||
|
dao().execute(insertSql);
|
||||||
|
return NutMap.NEW().addv("addedCount", insertSql.getUpdateCount())
|
||||||
|
.addv("enabledCount", enableSql.getUpdateCount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,14 +155,13 @@ layout("/layouts/platform.html"){
|
|||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="$refs.sortRef.onOpen()" size="medium" type="primary" icon="el-icon-sort">排序
|
<el-button @click="$refs.sortRef.onOpen()" size="medium" type="primary" icon="el-icon-sort">排序
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button v-if="$auth.hasPermission('sys.manager.role.user')" size="medium" type="primary"
|
||||||
|
icon="el-icon-user" :loading="memberRoleLoading" @click="doSettingMemberRole">
|
||||||
|
一键设置会员角色
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<!-- <div class="pull-right offscreen-right mt5 ml5">-->
|
|
||||||
<!-- <el-button size="medium" @click="doSettingMemberRole" type="primary"><i class="el-icon-s-tools"></i>-->
|
|
||||||
<!-- 一键设会员角色-->
|
|
||||||
<!-- </el-button>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="pull-right offscreen-right mt5 ml5">-->
|
<!-- <div class="pull-right offscreen-right mt5 ml5">-->
|
||||||
<!-- <el-button size="medium" @click="doPublic" type="primary">一键设置公共角色</el-button>-->
|
<!-- <el-button size="medium" @click="doPublic" type="primary">一键设置公共角色</el-button>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
@@ -516,6 +515,7 @@ layout("/layouts/platform.html"){
|
|||||||
roleDialogVisible: false,
|
roleDialogVisible: false,
|
||||||
menuDialogVisible: false,
|
menuDialogVisible: false,
|
||||||
userDialogVisible: false,
|
userDialogVisible: false,
|
||||||
|
memberRoleLoading: false,
|
||||||
treeData: {
|
treeData: {
|
||||||
label: "name",
|
label: "name",
|
||||||
children: "zones",
|
children: "zones",
|
||||||
@@ -689,18 +689,30 @@ layout("/layouts/platform.html"){
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
doSettingMemberRole() {
|
doSettingMemberRole() {
|
||||||
this.$confirm("是否确定一键设置会员角色?", "提示", {
|
if (this.memberRoleLoading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 操作面向全部会员,忽略当前列表筛选;确认期间也锁定按钮,避免重复提交。
|
||||||
|
this.$set(this, "memberRoleLoading", true)
|
||||||
|
this.$confirm("确定为全部已标记为会员的人员设置会员角色吗?已有角色将保留。", "提示", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(() => {
|
||||||
const {code, msg} = await this.$axios.post("/platform/sys/role/doSettingMemberRole")
|
return this.$axios.post("/platform/sys/role/doSettingMemberRole").then((res) => {
|
||||||
if (code === 0) {
|
if (res.code === 0) {
|
||||||
this.$message.success(msg)
|
this.$message.success("设置完成:新增 " + res.data.addedCount
|
||||||
|
+ " 条,恢复启用 " + res.data.enabledCount + " 条会员角色关联")
|
||||||
|
this.pageData()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
// 取消确认无需提示;请求异常由全局 axios 拦截器统一提示。
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.$set(this, "memberRoleLoading", false)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
formatAt(val) {
|
formatAt(val) {
|
||||||
|
|||||||
+2
-2
@@ -136,9 +136,9 @@ layout("/layouts/platform.html"){
|
|||||||
this.$set(this.formData, 'isRead', true)
|
this.$set(this.formData, 'isRead', true)
|
||||||
this.$commonUtil.previewFile({
|
this.$commonUtil.previewFile({
|
||||||
suffix: "pdf",
|
suffix: "pdf",
|
||||||
downloadPath: "/platform/sys/file/download?id=orpgde84uggjmpflbob83tadan",
|
downloadPath: "/platform/sys/file/download?id=15eblmambgh3hoj7hg20n4obsg",
|
||||||
name: "中国地质大学(武汉)教职工重大疾病互助基金管理办法.pdf",
|
name: "中国地质大学(武汉)教职工重大疾病互助基金管理办法.pdf",
|
||||||
id: "orpgde84uggjmpflbob83tadan"
|
id: "15eblmambgh3hoj7hg20n4obsg"
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
isReadChange() {
|
isReadChange() {
|
||||||
|
|||||||
Reference in New Issue
Block a user