commit
This commit is contained in:
@@ -31,6 +31,8 @@ public interface Roles {
|
||||
*/
|
||||
String CLUB_FZR = "c17d7a777dd24d36b4b268037b959faf";
|
||||
|
||||
String CLUB_JBR_CODE = "xhjbr";
|
||||
|
||||
/**
|
||||
* 代表团团长
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
package io.v.nutz.sys.services;
|
||||
|
||||
import cn.wizzer.framework.base.service.BaseService;
|
||||
import io.v.nutz.web.controllers.platform.sys.club.ClubUserImportFeature;
|
||||
import io.v.nutz.sys.models.Sys_club_user;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface SysClubUserService extends BaseService<Sys_club_user> {
|
||||
/**
|
||||
* 批量导入协会成员。
|
||||
* 导入过程中按行校验并逐行入库,单行失败不会中断整批导入。
|
||||
*
|
||||
* @param file 导入文件
|
||||
* @return 导入结果统计及错误缓存标识
|
||||
*/
|
||||
NutMap importClubMembers(TempFile file);
|
||||
|
||||
/**
|
||||
* 根据缓存标识获取导入错误记录,用于前端下载错误信息表格。
|
||||
*
|
||||
* @param cacheKey 错误缓存标识
|
||||
* @return 错误记录列表
|
||||
*/
|
||||
List<ClubUserImportFeature.ErrorRow> getImportErrorList(String cacheKey);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,208 @@
|
||||
package io.v.nutz.sys.services.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.wizzer.framework.base.service.BaseServiceImpl;
|
||||
import io.v.nutz.base.utils.DateUtil;
|
||||
import io.v.nutz.sys.models.Sys_club;
|
||||
import io.v.nutz.sys.models.Sys_club_user;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.services.SysClubService;
|
||||
import io.v.nutz.sys.services.SysClubUserService;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.controllers.platform.sys.club.ClubUserImportFeature;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysClubUserServiceImpl extends BaseServiceImpl<Sys_club_user> implements SysClubUserService {
|
||||
|
||||
@Inject
|
||||
private SysClubService sysClubService;
|
||||
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
public SysClubUserServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap importClubMembers(TempFile file) {
|
||||
List<ClubUserImportFeature.ImportRow> importRows = ExcelImportUtil.importExcel(file.getFile(),
|
||||
ClubUserImportFeature.ImportRow.class, new cn.afterturn.easypoi.excel.entity.ImportParams());
|
||||
List<ClubUserImportFeature.ErrorRow> errorRows = new ArrayList<>();
|
||||
|
||||
if (Lang.isEmpty(importRows)) {
|
||||
return NutMap.NEW().setv("totalCount", 0)
|
||||
.setv("successCount", 0)
|
||||
.setv("errorCount", 0)
|
||||
.setv("cacheKey", "");
|
||||
}
|
||||
|
||||
List<String> clubCodes = importRows.stream()
|
||||
.map(ClubUserImportFeature.ImportRow::getClubCode)
|
||||
.filter(Strings::isNotBlank)
|
||||
.map(String::trim)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<String> loginNames = importRows.stream()
|
||||
.map(ClubUserImportFeature.ImportRow::getLoginname)
|
||||
.filter(Strings::isNotBlank)
|
||||
.map(String::trim)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<String, Sys_club> clubMap = Lang.isEmpty(clubCodes) ? Collections.emptyMap()
|
||||
: sysClubService.query(Cnd.where("code", "in", clubCodes)).stream()
|
||||
.collect(Collectors.toMap(v -> v.getCode().trim(), Function.identity(), (o1, o2) -> o1));
|
||||
Map<String, Sys_user> userMap = Lang.isEmpty(loginNames) ? Collections.emptyMap()
|
||||
: sysUserService.query(Cnd.where("loginname", "in", loginNames)).stream()
|
||||
.collect(Collectors.toMap(v -> v.getLoginname().trim(), Function.identity(), (o1, o2) -> o1));
|
||||
|
||||
List<String> clubIds = clubMap.values().stream().map(Sys_club::getId).collect(Collectors.toList());
|
||||
List<String> userIds = userMap.values().stream().map(Sys_user::getId).collect(Collectors.toList());
|
||||
Set<String> existsMemberKeys;
|
||||
if (Lang.isEmpty(clubIds) || Lang.isEmpty(userIds)) {
|
||||
existsMemberKeys = new HashSet<>();
|
||||
} else {
|
||||
existsMemberKeys = this.query(Cnd.where("clubid", "in", clubIds).and("userid", "in", userIds).and("isNormal", "=", true))
|
||||
.stream()
|
||||
.map(v -> v.getClubid() + "_" + v.getUserid())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
Set<String> importMemberKeys = new HashSet<>();
|
||||
int successCount = 0;
|
||||
for (ClubUserImportFeature.ImportRow importRow : importRows) {
|
||||
ClubUserImportFeature.ErrorRow errorRow = buildErrorRow(importRow);
|
||||
try {
|
||||
String clubCode = Strings.sNull(importRow.getClubCode()).trim();
|
||||
String loginname = Strings.sNull(importRow.getLoginname()).trim();
|
||||
String username = Strings.sNull(importRow.getUsername()).trim();
|
||||
|
||||
if (Strings.isBlank(clubCode)) {
|
||||
errorRow.setErrorMessage("协会编码不能为空");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
if (Strings.isBlank(loginname)) {
|
||||
errorRow.setErrorMessage("工号不能为空");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
if (Strings.isBlank(username)) {
|
||||
errorRow.setErrorMessage("姓名不能为空");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
|
||||
Sys_club club = clubMap.get(clubCode);
|
||||
if (club == null) {
|
||||
errorRow.setErrorMessage("未找到对应的协会编码");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
|
||||
Sys_user user = userMap.get(loginname);
|
||||
if (user == null) {
|
||||
errorRow.setErrorMessage("未找到对应的工号用户");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!username.equals(Strings.sNull(user.getUsername()).trim())) {
|
||||
errorRow.setErrorMessage("姓名与系统中的用户姓名不一致");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
|
||||
String importKey = clubCode + "_" + loginname;
|
||||
if (!importMemberKeys.add(importKey)) {
|
||||
errorRow.setErrorMessage("导入文件中存在重复的协会编码和工号");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
|
||||
String dbKey = club.getId() + "_" + user.getId();
|
||||
if (existsMemberKeys.contains(dbKey)) {
|
||||
errorRow.setErrorMessage("该用户已存在于该协会成员表中");
|
||||
errorRows.add(errorRow);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only persist the current system's membership relation fields here.
|
||||
Sys_club_user clubUser = new Sys_club_user();
|
||||
clubUser.setClubid(club.getId());
|
||||
clubUser.setUserid(user.getId());
|
||||
clubUser.setJoin_time(DateUtil.getDateTime());
|
||||
clubUser.setSf(2);
|
||||
clubUser.setStatus(5);
|
||||
clubUser.setIsNormal(true);
|
||||
this.insert(clubUser);
|
||||
existsMemberKeys.add(dbKey);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
errorRow.setErrorMessage(Strings.isBlank(e.getMessage()) ? "导入失败,请联系管理员处理" : e.getMessage());
|
||||
errorRows.add(errorRow);
|
||||
}
|
||||
}
|
||||
|
||||
String cacheKey = "";
|
||||
if (Lang.isNotEmpty(errorRows)) {
|
||||
cacheKey = R.UU32();
|
||||
redisService.setex(cacheKey, 60 * 60 * 5, Json.toJson(errorRows));
|
||||
}
|
||||
|
||||
return NutMap.NEW().setv("totalCount", importRows.size())
|
||||
.setv("successCount", successCount)
|
||||
.setv("errorCount", errorRows.size())
|
||||
.setv("cacheKey", cacheKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClubUserImportFeature.ErrorRow> getImportErrorList(String cacheKey) {
|
||||
if (Strings.isBlank(cacheKey)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String json = redisService.get(cacheKey);
|
||||
if (Strings.isBlank(json)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Json.fromJsonAsList(ClubUserImportFeature.ErrorRow.class, json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build one exportable error row from the original import row.
|
||||
*/
|
||||
private ClubUserImportFeature.ErrorRow buildErrorRow(ClubUserImportFeature.ImportRow importRow) {
|
||||
ClubUserImportFeature.ErrorRow errorRow = new ClubUserImportFeature.ErrorRow();
|
||||
errorRow.setIndex(importRow.getIndex());
|
||||
errorRow.setClubCode(importRow.getClubCode());
|
||||
errorRow.setLoginname(importRow.getLoginname());
|
||||
errorRow.setUsername(importRow.getUsername());
|
||||
return errorRow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ public class NutShiroProcessor extends AbstractProcessor {
|
||||
//不需要认证授权的url
|
||||
String[] authIgnoreUrlArr = Lang.array("/",
|
||||
"/sso/login",
|
||||
"/platform/login",
|
||||
// "/platform/login",
|
||||
"/platform/login(/doLogin|/logout|/captcha)",
|
||||
"/platform/qywechat/.*",
|
||||
"/platform/wechat/.*",
|
||||
"/platform/home/(500|403|404|UnknownAccountError|LockedAccountError)",
|
||||
"/mobile/login",
|
||||
// "/mobile/login",
|
||||
"/mobile/login/doLogin"
|
||||
);
|
||||
if (Arrays.stream(authIgnoreUrlArr).noneMatch(v -> Pattern.compile(v).matcher(requestURI).matches())) {
|
||||
@@ -218,4 +218,4 @@ public class NutShiroProcessor extends AbstractProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
package io.v.nutz.web.controllers.platform.sys.club;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.annontation.ViReturn;
|
||||
import io.v.nutz.sys.services.SysClubService;
|
||||
import io.v.nutz.sys.services.SysClubUserService;
|
||||
import io.v.nutz.util.ViTool;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
@@ -22,9 +39,50 @@ public class ClubInController {
|
||||
@Inject
|
||||
private SysClubService sysClubService;
|
||||
|
||||
@Inject
|
||||
private SysClubUserService sysClubUserService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/club/clubIn.html")
|
||||
@RequiresPermissions("sys.club.clubIn")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("sys.club.clubIn")
|
||||
public void downloadImportTemplate(HttpServletResponse response) throws IOException {
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ClubUserImportFeature.ImportRow.class, Collections.emptyList());
|
||||
ViTool.excelResponse(response, "协会成员导入模板.xlsx");
|
||||
workbook.write(response.getOutputStream());
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@RequiresPermissions("sys.club.clubIn")
|
||||
public Object doImportMember(@Param("file") TempFile file) {
|
||||
if (file == null) {
|
||||
return Result.error("请先选择导入文件");
|
||||
}
|
||||
try {
|
||||
return Result.success(sysClubUserService.importClubMembers(file));
|
||||
} catch (Exception e) {
|
||||
return Result.error(Strings.isBlank(e.getMessage()) ? "导入失败" : e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("sys.club.clubIn")
|
||||
public void exportImportErrors(HttpServletResponse response, String cacheKey) throws IOException {
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ClubUserImportFeature.ErrorRow.class,
|
||||
sysClubUserService.getImportErrorList(cacheKey));
|
||||
ViTool.excelResponse(response, "协会成员导入错误信息.xlsx");
|
||||
workbook.write(response.getOutputStream());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,12 +72,16 @@ public class SysClubCon {
|
||||
@At
|
||||
@ViReturn
|
||||
public Object updateSf(String userid, Integer sf, String clubId) {
|
||||
sysClubUserService.update(Chain.make("sf", sf), Cnd.where("userid", "=", userid));
|
||||
sysUserRoleService.clear(Cnd.where("userid", "=", userid).and("roleid", "=", Roles.CLUB_FZR));
|
||||
if (sf == 1 || sf == 3 || sf == 4 || sf == 5) {
|
||||
sysClubUserService.update(Chain.make("sf", sf), Cnd.where("userid", "=", userid).and("clubid", "=", clubId));
|
||||
clearClubManageRole(userid, clubId);
|
||||
if (sf == 1 || sf == 3 || sf == 4 || sf == 5 || sf == 6) {
|
||||
String roleId = sf == 6 ? getClubJbrRoleId() : Roles.CLUB_FZR;
|
||||
if (Strings.isBlank(roleId)) {
|
||||
return Result.error("未找到协会经办人角色");
|
||||
}
|
||||
Sys_user_role sys_user_role = new Sys_user_role();
|
||||
sys_user_role.setUserId(userid);
|
||||
sys_user_role.setRoleId(Roles.CLUB_FZR);
|
||||
sys_user_role.setRoleId(roleId);
|
||||
sys_user_role.setStid(clubId);
|
||||
sysUserRoleService.insert(sys_user_role);
|
||||
}
|
||||
@@ -248,7 +252,7 @@ public class SysClubCon {
|
||||
"\tLEFT JOIN sys_user u ON scu.userid = u.id\n" +
|
||||
"\tLEFT JOIN sys_unit unit ON u.unitid = unit.id\n" +
|
||||
"\tWHERE scu.clubid = @clubid and scu.status = 5\n" +
|
||||
"\tORDER BY FIELD( scu.sf, 1, 3,4,5, 2 ),scu.join_time DESC").setParam("clubid", id)));
|
||||
"\tORDER BY FIELD( scu.sf, 1, 3,4,5,6, 2 ),scu.join_time DESC").setParam("clubid", id)));
|
||||
record.set("files", baseService.dao().query("sys_file", Cnd.where("reid", "=", id)));
|
||||
return record;
|
||||
}
|
||||
@@ -284,6 +288,18 @@ public class SysClubCon {
|
||||
}
|
||||
}
|
||||
|
||||
private String getClubJbrRoleId() {
|
||||
Sys_role role = sysRoleService.fetch(Cnd.where("code", "=", Roles.CLUB_JBR_CODE));
|
||||
return role == null ? "" : role.getId();
|
||||
}
|
||||
|
||||
private void clearClubManageRole(String userId, String clubId) {
|
||||
sysUserRoleService.clear(Cnd.where("userid", "=", userId)
|
||||
.and("stid", "=", clubId)
|
||||
.and(new Static("roleid IN (SELECT id FROM sys_role WHERE id = '" + Roles.CLUB_FZR
|
||||
+ "' OR code = '" + Roles.CLUB_JBR_CODE + "')")));
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object dissolve(String id, Boolean isjs) {
|
||||
|
||||
@@ -64,7 +64,13 @@ public class SysClubUserCon {
|
||||
if (ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
|
||||
return sysClubService.query(Cnd.where("isjs", "=", false).asc("create_time"));
|
||||
}
|
||||
return sysClubService.query(Cnd.where("fzr", "=", ShiroUtil.getPrincipalProperty("id")).and("isjs", "=", false).asc("create_time"));
|
||||
return sysClubService.query(Cnd.where("isjs", "=", false)
|
||||
.and(new org.nutz.dao.util.cri.Static("(fzr = '" + ShiroUtil.getPrincipalProperty("id")
|
||||
+ "' OR id IN (SELECT stid FROM sys_user_role WHERE userid = '"
|
||||
+ ShiroUtil.getPrincipalProperty("id")
|
||||
+ "' AND roleid IN (SELECT id FROM sys_role WHERE id = '" + Roles.CLUB_FZR
|
||||
+ "' OR code = '" + Roles.CLUB_JBR_CODE + "')))"))
|
||||
.asc("create_time"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +84,7 @@ public class SysClubUserCon {
|
||||
if (Strings.isBlank(clubid)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
String orderStr = " ORDER BY FIELD( sf, 1, 3,4,5, 2 ),scu.join_time DESC";
|
||||
String orderStr = " ORDER BY FIELD( sf, 1, 3,4,5,6, 2 ),scu.join_time DESC";
|
||||
if (type == 2 && radioType == 2) {
|
||||
orderStr = " order by field(status, 1, 3, 5),scu.join_time DESC";
|
||||
} else if (type == 3 && radioType == 2) {
|
||||
@@ -133,8 +139,10 @@ public class SysClubUserCon {
|
||||
public Object delUser(String clubid, String userid) {
|
||||
sysClubUserService.clear(Cnd.where("clubid", "=", clubid).and("userid", "=", userid));
|
||||
//删除协会负责人的角色
|
||||
sysUserRoleService.clear(Cnd.NEW().and("userId", "=", ShiroUtil.getPrincipalProperty("id"))
|
||||
.and("roleId", "=", Roles.CLUB_FZR).and("stid", "=", clubid));
|
||||
sysUserRoleService.clear(Cnd.NEW().and("userId", "=", userid)
|
||||
.and("stid", "=", clubid)
|
||||
.and(new org.nutz.dao.util.cri.Static("roleId IN (SELECT id FROM sys_role WHERE id = '" + Roles.CLUB_FZR
|
||||
+ "' OR code = '" + Roles.CLUB_JBR_CODE + "')")));
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
return null;
|
||||
@@ -149,7 +157,31 @@ public class SysClubUserCon {
|
||||
"\tsys_user u\n" +
|
||||
"\tLEFT JOIN sys_unit unit ON u.unitid = unit.id\n" +
|
||||
"\tLEFT JOIN sys_union un ON unit.unionid = un.id\n" +
|
||||
"\tWHERE (u.username LIKE @query or u.loginname like @query) and u.id not in (SELECT userid from sys_club_user WHERE clubid = @clubid) LIMIT 50").setParam("query", "%" + query + "%").setParam("clubid", clubid);
|
||||
"\tWHERE (u.username LIKE @query or u.loginname like @query) and u.id not in (SELECT userid from sys_club_user WHERE clubid = @clubid and isNormal = true) LIMIT 50").setParam("query", "%" + query + "%").setParam("clubid", clubid);
|
||||
return sysClubService.list(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置理事机构时,只允许从当前协会已通过的普通成员中选择,避免把协会外人员设为理事机构。
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object queryClubMemberForManage(String clubid, String query) {
|
||||
if (Strings.isBlank(clubid)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Sql sql = Sqls.create("SELECT\n" +
|
||||
"\tu.id,u.username,unit.name as unitname,u.loginname \n" +
|
||||
"FROM\n" +
|
||||
"\tsys_club_user scu\n" +
|
||||
"\tLEFT JOIN sys_user u ON scu.userid = u.id\n" +
|
||||
"\tLEFT JOIN sys_unit unit ON u.unitid = unit.id\n" +
|
||||
"\tWHERE scu.clubid = @clubid\n" +
|
||||
"\tAND scu.isNormal = 1\n" +
|
||||
"\tAND scu.status = 5\n" +
|
||||
"\tAND scu.sf = 2\n" +
|
||||
"\tAND (u.username LIKE @query or u.loginname like @query)\n" +
|
||||
"\tLIMIT 50").setParam("query", "%" + query + "%").setParam("clubid", clubid);
|
||||
return sysClubService.list(sql);
|
||||
}
|
||||
|
||||
@@ -160,13 +192,44 @@ public class SysClubUserCon {
|
||||
//type=1协会信息管理菜单,操作为录入理事机构,此时状态直接为通过5
|
||||
//type=2社团录入菜单,操作为录入成员,此时需要校工会审核,状态为3
|
||||
//type=3校工会录入菜单,操作为录入成员,此时状态直接为通过5
|
||||
int status = type == 1 || type == 3 ? 5 : 3;
|
||||
int status = 5;
|
||||
|
||||
for (String user : users) {
|
||||
if (type != null && type == 1) {
|
||||
Sys_club_user sysClubUser = sysClubUserService.fetch(Cnd.where("clubid", "=", clubid)
|
||||
.and("userid", "=", user)
|
||||
.and("isNormal", "=", true)
|
||||
.and("status", "=", 5));
|
||||
if (sysClubUser == null) {
|
||||
return cn.wizzer.framework.base.Result.error("只能从本协会已通过成员中设置理事机构");
|
||||
}
|
||||
clearClubManageRole(user, clubid);
|
||||
if (sf != 2) {
|
||||
String roleId = sf == 6 ? getClubJbrRoleId() : Roles.CLUB_FZR;
|
||||
if (Strings.isBlank(roleId)) {
|
||||
return cn.wizzer.framework.base.Result.error("未找到协会经办人角色");
|
||||
}
|
||||
Sys_user_role sys_user_role = new Sys_user_role();
|
||||
sys_user_role.setUserId(user);
|
||||
sys_user_role.setRoleId(roleId);
|
||||
sys_user_role.setStid(clubid);
|
||||
sysUserRoleService.insert(sys_user_role);
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
}
|
||||
// 设置理事机构是调整本协会已有成员身份,不新增成员记录,避免出现重复协会成员。
|
||||
sysClubUserService.update(Chain.make("sf", sf), Cnd.where("id", "=", sysClubUser.getId()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sf != 2) {
|
||||
String roleId = sf == 6 ? getClubJbrRoleId() : Roles.CLUB_FZR;
|
||||
if (Strings.isBlank(roleId)) {
|
||||
return cn.wizzer.framework.base.Result.error("未找到协会经办人角色");
|
||||
}
|
||||
Sys_user_role sys_user_role = new Sys_user_role();
|
||||
sys_user_role.setUserId(user);
|
||||
sys_user_role.setRoleId(Roles.CLUB_FZR);
|
||||
sys_user_role.setRoleId(roleId);
|
||||
sys_user_role.setStid(clubid);
|
||||
sysUserRoleService.insert(sys_user_role);
|
||||
sysUserService.clearCache();
|
||||
@@ -180,9 +243,22 @@ public class SysClubUserCon {
|
||||
sys_club_user.setJoin_time(DateUtil.getDate());
|
||||
sys_club_user.setSf(sf);
|
||||
sys_club_user.setStatus(status);
|
||||
sys_club_user.setIsNormal(true);
|
||||
sysClubUserService.insert(sys_club_user);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getClubJbrRoleId() {
|
||||
io.v.nutz.sys.models.Sys_role role = sysRoleService.fetch(Cnd.where("code", "=", Roles.CLUB_JBR_CODE));
|
||||
return role == null ? "" : role.getId();
|
||||
}
|
||||
|
||||
private void clearClubManageRole(String userid, String clubid) {
|
||||
sysUserRoleService.clear(Cnd.NEW().and("userId", "=", userid)
|
||||
.and("stid", "=", clubid)
|
||||
.and(new org.nutz.dao.util.cri.Static("roleId IN (SELECT id FROM sys_role WHERE id = '" + Roles.CLUB_FZR
|
||||
+ "' OR code = '" + Roles.CLUB_JBR_CODE + "')")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,13 +121,11 @@ public class SysClubUserShCon {
|
||||
|
||||
cnd.and("sf", "=", 2);
|
||||
cnd.and("isNormal", "=", true);
|
||||
cnd.andEX("scu.clubid", "=", clubid);
|
||||
cnd.andEX("scu.clubid", "=", clubid);
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
|
||||
if (ShiroUtil.hasAnyRoles("club01, club02, club03, club04, H02")) {
|
||||
cnd.and(new Static("""
|
||||
scu.clubid IN ( SELECT stid FROM sys_user_role WHERE roleid = '%s' AND userid = '%s' AND stid IS NOT NULL )
|
||||
""".formatted(Roles.CLUB_FZR, ShiroUtil.getPrincipalProperty("id"))));
|
||||
if (ShiroUtil.hasAnyRoles("club01, club02, club03, club04, H02, xhjbr")) {
|
||||
cnd.and(new Static(getClubAuditRoleCnd("scu.clubid")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +203,7 @@ public class SysClubUserShCon {
|
||||
cnd.and("isjs", "=", false);
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
|
||||
cnd.and("club.fzr", "=", ShiroUtil.getPrincipalProperty("id"));
|
||||
cnd.and(new Static("(club.fzr = '" + ShiroUtil.getPrincipalProperty("id") + "' OR " + getClubAuditRoleCnd("club.id") + ")"));
|
||||
}
|
||||
if (StrUtil.isNotBlank(clubType)) {
|
||||
cnd.and("club.type", "=", clubType);
|
||||
@@ -263,10 +261,8 @@ public class SysClubUserShCon {
|
||||
cnd.andEX("scu.clubid", "=", id);
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
|
||||
if (ShiroUtil.hasRole("H02")) {
|
||||
cnd.and(new Static("""
|
||||
scu.clubid IN ( SELECT stid FROM sys_user_role WHERE roleid = '%s' AND userid = '%s' AND stid IS NOT NULL )
|
||||
""".formatted(Roles.CLUB_FZR, ShiroUtil.getPrincipalProperty("id"))));
|
||||
if (ShiroUtil.hasAnyRoles("H02, xhjbr, club01, club02, club03, club04")) {
|
||||
cnd.and(new Static(getClubAuditRoleCnd("scu.clubid")));
|
||||
}
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
@@ -289,4 +285,11 @@ public class SysClubUserShCon {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String getClubAuditRoleCnd(String clubIdColumn) {
|
||||
return clubIdColumn + " IN ( SELECT stid FROM sys_user_role WHERE userid = '"
|
||||
+ ShiroUtil.getPrincipalProperty("id")
|
||||
+ "' AND stid IS NOT NULL AND roleid IN (SELECT id FROM sys_role WHERE id = '"
|
||||
+ Roles.CLUB_FZR + "' OR code = '" + Roles.CLUB_JBR_CODE + "') )";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,9 @@ layout("/layouts/platform.html"){
|
||||
<el-button icon="el-icon-plus" @click="openAdd">创建协会</el-button>
|
||||
<!–#}#–>
|
||||
</div>-->
|
||||
<div class="pull-right offscreen-right mt5">
|
||||
<el-button type="primary" icon="el-icon-upload2" @click="openImport">导入成员</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-row class="el-table-container">
|
||||
@@ -646,6 +649,57 @@ layout("/layouts/platform.html"){
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
title="导入成员"
|
||||
:visible.sync="importDialogVisible" :close-on-click-modal="false" width="40%">
|
||||
<el-timeline>
|
||||
<el-timeline-item placement="top" timestamp="下载模板">
|
||||
<el-card>
|
||||
<el-button
|
||||
@click="downloadImportTemplate"
|
||||
icon="el-icon-download" size="medium"
|
||||
style="width: 200px"
|
||||
type="">下载模板
|
||||
</el-button>
|
||||
</el-card>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item placement="top" timestamp="上传文件">
|
||||
<el-card>
|
||||
<el-upload
|
||||
:auto-upload="false"
|
||||
:file-list="importData.fileList"
|
||||
:limit="1"
|
||||
:on-change="importFileChange"
|
||||
:on-remove="importFileRemove"
|
||||
name="file"
|
||||
ref="importUpload">
|
||||
<el-button icon="el-icon-upload" size="medium" style="width: 200px" type="">
|
||||
选择文件
|
||||
</el-button>
|
||||
<div class="el-upload__tip" slot="tip" style="color: #F56C6C">
|
||||
只能上传 xls/xlsx 文件
|
||||
</div>
|
||||
</el-upload>
|
||||
</el-card>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item placement="top" timestamp="导入结果" v-if="importResult.totalCount > 0">
|
||||
<el-card>
|
||||
<div>
|
||||
本次导入共 {{importResult.totalCount}} 条,成功 {{importResult.successCount}} 条,失败 {{importResult.errorCount}} 条
|
||||
</div>
|
||||
<div style="margin-top: 15px" v-if="importResult.errorCount > 0 && importResult.cacheKey">
|
||||
<el-button icon="el-icon-download" @click="downloadImportErrors">下载错误信息表格</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button :disabled="importLoading" @click="importDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="importLoading" @click="doImportMember">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
var E = window.wangEditor
|
||||
@@ -690,7 +744,7 @@ layout("/layouts/platform.html"){
|
||||
userLoading: false,
|
||||
fileList: [],
|
||||
delFiles: [],
|
||||
checkNode: {level: 2},
|
||||
checkNode: {level: 1},
|
||||
checkData: {},
|
||||
//################################
|
||||
userFormRules: {
|
||||
@@ -713,6 +767,17 @@ layout("/layouts/platform.html"){
|
||||
userTabKey: "",
|
||||
addDialogVisible: false,
|
||||
clubOptions: [],
|
||||
importDialogVisible: false,
|
||||
importLoading: false,
|
||||
importData: {
|
||||
fileList: []
|
||||
},
|
||||
importResult: {
|
||||
totalCount: 0,
|
||||
successCount: 0,
|
||||
errorCount: 0,
|
||||
cacheKey: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@@ -826,6 +891,88 @@ layout("/layouts/platform.html"){
|
||||
})
|
||||
|
||||
},
|
||||
openImport() {
|
||||
this.$set(this, 'importResult', {
|
||||
totalCount: 0,
|
||||
successCount: 0,
|
||||
errorCount: 0,
|
||||
cacheKey: ''
|
||||
})
|
||||
this.$set(this, 'importData', {
|
||||
fileList: []
|
||||
})
|
||||
this.importDialogVisible = true
|
||||
},
|
||||
downloadImportTemplate() {
|
||||
window.location.href = base + '/platform/sys/club/clubIn/downloadImportTemplate'
|
||||
},
|
||||
importFileChange(file, fileList) {
|
||||
var fileName = file.name ? file.name : file.raw.name
|
||||
var suffix = fileName.indexOf('.') > -1 ? fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase() : ''
|
||||
if (['xls', 'xlsx'].indexOf(suffix) === -1) {
|
||||
this.$message({
|
||||
message: '只能上传 xls、xlsx 文件',
|
||||
type: 'warning'
|
||||
})
|
||||
this.$set(this.importData, 'fileList', [])
|
||||
return
|
||||
}
|
||||
this.$set(this.importData, 'fileList', fileList.slice(fileList.length - 1))
|
||||
},
|
||||
importFileRemove(file, fileList) {
|
||||
this.$set(this.importData, 'fileList', fileList)
|
||||
},
|
||||
doImportMember() {
|
||||
if (!this.importData.fileList.length) {
|
||||
this.$message({
|
||||
message: '请先选择导入文件',
|
||||
type: 'warning'
|
||||
})
|
||||
return
|
||||
}
|
||||
var formdata = new FormData();
|
||||
this.importData.fileList.forEach(function (val) {
|
||||
formdata.append('file', val.raw, val.raw.name)
|
||||
})
|
||||
this.importLoading = true
|
||||
$.ajax({
|
||||
url: base + "/platform/sys/club/clubIn/doImportMember",
|
||||
type: "post",
|
||||
data: formdata,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: (resp) => {
|
||||
this.importLoading = false
|
||||
if (resp.code === 0) {
|
||||
this.$set(this, 'importResult', resp.data)
|
||||
this.$message({
|
||||
message: '导入完成,成功 ' + resp.data.successCount + ' 条,失败 ' + resp.data.errorCount + ' 条',
|
||||
type: resp.data.errorCount > 0 ? 'warning' : 'success'
|
||||
})
|
||||
this.pageData()
|
||||
this.loadTree()
|
||||
} else {
|
||||
this.$message({
|
||||
message: resp.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
},
|
||||
error: (resp) => {
|
||||
this.importLoading = false
|
||||
this.$message({
|
||||
message: resp.msg ? resp.msg : '导入失败',
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
downloadImportErrors() {
|
||||
if (!this.importResult.cacheKey) {
|
||||
return
|
||||
}
|
||||
window.location.href = base + '/platform/sys/club/clubIn/exportImportErrors?cacheKey=' + this.importResult.cacheKey
|
||||
},
|
||||
doUserSearch() {
|
||||
this.userTabKey = new Date().getTime()
|
||||
this.userPageForm.pageNumber = 1
|
||||
@@ -1246,7 +1393,7 @@ layout("/layouts/platform.html"){
|
||||
this.treeLoading = false
|
||||
if (code == 0) {
|
||||
this.treeData = data
|
||||
this.checkData = data[0].child[0]
|
||||
this.checkData = data[0]
|
||||
} else {
|
||||
this.$message({
|
||||
message: data.msg,
|
||||
@@ -1258,12 +1405,10 @@ layout("/layouts/platform.html"){
|
||||
async created() {
|
||||
await this.loadTree()
|
||||
this.typeOptions = await getClubType()
|
||||
this.userPageForm.clubid = this.checkData.id
|
||||
this.userPageData();
|
||||
this.pageData();
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
#-->
|
||||
|
||||
@@ -292,6 +292,7 @@ layout("/layouts/platform.html"){
|
||||
<el-lable v-if="scope.row.sf==3">副会长</el-lable>
|
||||
<el-lable v-if="scope.row.sf==4">秘书长</el-lable>
|
||||
<el-lable v-if="scope.row.sf==5">副秘书长</el-lable>
|
||||
<el-lable v-if="scope.row.sf==6">协会经办人</el-lable>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -325,6 +326,10 @@ layout("/layouts/platform.html"){
|
||||
@click.native="updateSf(row,5)"
|
||||
class="text-primary">设置副秘书长
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="row.sf!==6"
|
||||
@click.native="updateSf(row,6)"
|
||||
class="text-primary">设置协会经办人
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click.native="userDropdownCommand(row)">删除
|
||||
</el-dropdown-item>
|
||||
@@ -567,6 +572,7 @@ layout("/layouts/platform.html"){
|
||||
<el-lable v-if="scope.row.sf==3">副会长</el-lable>
|
||||
<el-lable v-if="scope.row.sf==4">秘书长</el-lable>
|
||||
<el-lable v-if="scope.row.sf==5">副秘书长</el-lable>
|
||||
<el-lable v-if="scope.row.sf==6">协会经办人</el-lable>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工号" width="150px" prop="loginname" header-align="center"
|
||||
@@ -627,6 +633,7 @@ layout("/layouts/platform.html"){
|
||||
<el-radio-button :label="3">副会长</el-radio-button>
|
||||
<el-radio-button :label="4">秘书长</el-radio-button>
|
||||
<el-radio-button :label="5">副秘书长</el-radio-button>
|
||||
<el-radio-button :label="6">协会经办人</el-radio-button>
|
||||
<!--<el-radio-button :label="2">成员</el-radio-button>-->
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
@@ -791,7 +798,7 @@ layout("/layouts/platform.html"){
|
||||
});
|
||||
},
|
||||
async userQueryUser(clubid, query) {
|
||||
const {data} = await $.get("/platform/sys/club/users/queryUser", {clubid, query})
|
||||
const {data} = await $.get("/platform/sys/club/users/queryClubMemberForManage", {clubid, query})
|
||||
return data
|
||||
},
|
||||
async userUserRemoteMethod(query) {
|
||||
@@ -1258,4 +1265,4 @@ layout("/layouts/platform.html"){
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
#-->
|
||||
|
||||
Reference in New Issue
Block a user