feat: 东区缴费分支初始化

This commit is contained in:
2025-05-15 15:08:15 +08:00
parent 39f3acc15f
commit bafd4aa3ab
261 changed files with 3751 additions and 9416 deletions
@@ -86,10 +86,6 @@
* 针对org.apache.commons.codec.binary.Base64
* 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本)
* 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi
* <p>
* 针对org.apache.commons.codec.binary.Base64
* 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本)
* 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi
*/
// ------------------------------------------------------------------------
@@ -153,11 +149,11 @@ public class WXBizMsgCrypt {
}
public static void main(String[] args) {
// WXBizMsgCrypt wxcpt = new WXBizMsgCrypt("yta6ad", "n0KuvcacrFw761RqgNTsN3UwHFw3KYptFij2XWrWW4s", "wxfc7961cd4039bc6d");
// wxcpt.DecryptMsg("dd57e9c2b26b073d5777497e8dd43f940d90d8e2", "1635322300", "203081013", "<xml>\n" +
// " <ToUserName><![CDATA[gh_d688014af56d]]></ToUserName>\n" +
// " <Encrypt><![CDATA[hY3vFoh9E1Dtb8e6MbAwmLwlul0MEWRk0idIsJvI5iavXpnuGJneYFIfysSTqAx/ZOc8yCo8XKd8dNeYExxOmtJ2i39yvLgXXHx3GOeWAo5t2q0lGgt1B31snJSIvp9XALaNXBcYmQYF0XgInaQmc1yW1HXxVL5Q/2OXkmdup7e+O2st4MMUvfowyOoHoxBWhN8GHJmetvyt7hb+Ize6yyruOvoZRX7E8jQlF2BFX+M46mUlXwD9a6XQo3t/AjX7ebJBWeHbVILeeBOHe4TynPlrhAXuEMOxIttM6KpTmC+PX+pbV3xJUkKs78T+HPBsrLkWXOfCyyN3pBIIorAUdTtFwWcteUP6Xa4Kj6Dhn+RutMieIYBGMGS8LczxxxeKSjbgEEDIkXhe3OkF53MTwOttiN6CyoJ9bGYD3ksvLkMi6frJWAHAWj9sRGYOzKKo6yEMxp6b7cHkjiqjl6Bf3KtGEBVrV0N5Rq+uv1Yvev+NUfLN2rYnPQNWxZZen+kEeZod8VC3MPLetID9kpHNE6XtIZ7ZgNtvC0GrC5h9zswtGjDIq1aSNlt5XivKuAu4BIYnt7xAb5O7CtQgUv3G0VnxncQjeO8fw/zIeqT2nJhd17nfz0KMCZZkN5fO/cbD]]></Encrypt>\n" +
// "</xml>");
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt("yta6ad", "n0KuvcacrFw761RqgNTsN3UwHFw3KYptFij2XWrWW4s", "wxfc7961cd4039bc6d");
wxcpt.DecryptMsg("dd57e9c2b26b073d5777497e8dd43f940d90d8e2", "1635322300", "203081013", "<xml>\n" +
" <ToUserName><![CDATA[gh_d688014af56d]]></ToUserName>\n" +
" <Encrypt><![CDATA[hY3vFoh9E1Dtb8e6MbAwmLwlul0MEWRk0idIsJvI5iavXpnuGJneYFIfysSTqAx/ZOc8yCo8XKd8dNeYExxOmtJ2i39yvLgXXHx3GOeWAo5t2q0lGgt1B31snJSIvp9XALaNXBcYmQYF0XgInaQmc1yW1HXxVL5Q/2OXkmdup7e+O2st4MMUvfowyOoHoxBWhN8GHJmetvyt7hb+Ize6yyruOvoZRX7E8jQlF2BFX+M46mUlXwD9a6XQo3t/AjX7ebJBWeHbVILeeBOHe4TynPlrhAXuEMOxIttM6KpTmC+PX+pbV3xJUkKs78T+HPBsrLkWXOfCyyN3pBIIorAUdTtFwWcteUP6Xa4Kj6Dhn+RutMieIYBGMGS8LczxxxeKSjbgEEDIkXhe3OkF53MTwOttiN6CyoJ9bGYD3ksvLkMi6frJWAHAWj9sRGYOzKKo6yEMxp6b7cHkjiqjl6Bf3KtGEBVrV0N5Rq+uv1Yvev+NUfLN2rYnPQNWxZZen+kEeZod8VC3MPLetID9kpHNE6XtIZ7ZgNtvC0GrC5h9zswtGjDIq1aSNlt5XivKuAu4BIYnt7xAb5O7CtQgUv3G0VnxncQjeO8fw/zIeqT2nJhd17nfz0KMCZZkN5fO/cbD]]></Encrypt>\n" +
"</xml>");
}
// 生成4个字节的网络字节序
@@ -239,10 +235,6 @@ public class WXBizMsgCrypt {
}
}
String decrypt(String text) throws AesException {
return decrypt(text, true);
}
/**
* 对密文进行解密.
* 应用消息回调时receiveid应该为corpid,应对比receiveid与corpid是否一致
@@ -256,7 +248,7 @@ public class WXBizMsgCrypt {
* @return 解密得到的明文
* @throws AesException aes解密失败
*/
String decrypt(String text, boolean flag) throws AesException {
String decrypt(String text) throws AesException {
byte[] original;
try {
// 设置解密模式为AES的CBC模式
@@ -292,14 +284,12 @@ public class WXBizMsgCrypt {
e.printStackTrace();
throw new AesException(AesException.IllegalBuffer);
}
log.info("解密后的密文, encrypt: {}", xmlContent);
log.info("解密后的from_receiveid: {}", from_receiveid);
// 判断是否对比receiveid
if (flag) {
// receiveid不相同的情况
if (!from_receiveid.equals(receiveid)) {
throw new AesException(AesException.ValidateCorpidError);
}
// receiveid不相同的情况
if (!from_receiveid.equals(receiveid) && !xmlContent.contains("SuiteId")) {
throw new AesException(AesException.ValidateCorpidError);
}
return xmlContent;
@@ -337,12 +327,7 @@ public class WXBizMsgCrypt {
return result;
}
public String DecryptMsg(String msgSignature, String timeStamp, String nonce, String postData) {
return DecryptMsg(msgSignature, timeStamp, nonce, postData, true);
}
/**
* 服务商待开发应用回调验证
* 检验消息的真实性,并且获取解密后的明文.
* <ol>
* <li>利用收到的密文生成安全签名,进行签名验证</li>
@@ -358,7 +343,7 @@ public class WXBizMsgCrypt {
* @return 解密后的原文
* @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息
*/
public String DecryptMsg(String msgSignature, String timeStamp, String nonce, String postData, boolean flag)
public String DecryptMsg(String msgSignature, String timeStamp, String nonce, String postData)
throws AesException {
// 密钥,公众账号的app secret
@@ -376,16 +361,11 @@ public class WXBizMsgCrypt {
}
// 解密
return decrypt(encrypt[1].toString(), flag);
}
public String VerifyURL(String msgSignature, String timeStamp, String nonce, String echoStr)
throws AesException {
return VerifyURL(msgSignature, timeStamp, nonce, echoStr, true);
String result = decrypt(encrypt[1].toString());
return result;
}
/**
* 服务商待开发应用回调验证
* 验证URL
* @param msgSignature 签名串,对应URL参数的msg_signature
* @param timeStamp 时间戳,对应URL参数的timestamp
@@ -395,7 +375,7 @@ public class WXBizMsgCrypt {
* @return 解密之后的echostr
* @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息
*/
public String VerifyURL(String msgSignature, String timeStamp, String nonce, String echoStr, boolean flag)
public String VerifyURL(String msgSignature, String timeStamp, String nonce, String echoStr)
throws AesException {
String signature = SHA1.getSHA1(token, timeStamp, nonce, echoStr);
@@ -403,7 +383,8 @@ public class WXBizMsgCrypt {
throw new AesException(AesException.ValidateSignatureError);
}
return decrypt(echoStr, flag);
String result = decrypt(echoStr);
return result;
}
}
@@ -1,21 +1,9 @@
package com.yida.data.system.configure;
import cc.mrbird.febs.common.redis.service.RedisService;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
import com.yida.data.common.core.entity.constant.QywxServiceProviderConstant;
import com.yida.data.common.core.entity.system.Dept;
import com.yida.data.common.core.entity.system.EduQywxServiceProvider;
import com.yida.data.common.core.entity.system.EduQywxServiceProviderSchool;
import com.yida.data.common.core.utils.WxServiceProviderUtil;
import com.yida.data.common.service.CommonService;
import com.yida.data.system.service.EduQywxServiceProviderSchoolService;
import com.yida.data.system.service.EduQywxServiceProviderService;
import com.yida.data.system.service.IDeptService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
@@ -24,7 +12,10 @@ import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import cc.mrbird.febs.common.redis.service.RedisService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor
@Component
@@ -33,14 +24,10 @@ import java.util.Objects;
public class InitializeRunner implements ApplicationRunner {
private final RedisService redisService;
private final WxServiceProviderUtil wxServiceProviderUtil;
private final IDeptService deptService;
private final EduQywxServiceProviderService eduQywxServiceProviderService;
private final EduQywxServiceProviderSchoolService eduQywxServiceProviderSchoolService;
@Override
public void run(ApplicationArguments args) {
public void run(ApplicationArguments args) throws Exception {
log.info("初始化部门缓存");
List<Dept> allDept = deptService.list();
Map<Object, Object> items = new HashMap<>();
@@ -49,54 +36,5 @@ public class InitializeRunner implements ApplicationRunner {
items.put(dept.getDeptId().toString(), dept);
}
redisService.hmset(CachePrefixConstant.SYS_DEPT_DATA, items);
// initProviderSchool();
}
/**
* 初始化服务商对应学校加密corpId
*
* @author ZYJ
* @date 2022/11/10 9:13
*/
// public void initProviderSchool() {
// // 查询所有服务商
// List<EduQywxServiceProvider> providerList = eduQywxServiceProviderService.list();
// // 查询所有企业微信学校
// List<Dept> deptList = deptService.list(Wrappers.lambdaQuery(new Dept()).eq(Dept::getSchoolType, Dept.TYPE_QYWX));
// // 加密key缓存map
// Map<Object, Object> items = new HashMap<>(16);
// // 原始key缓存map
// Map<Object, Object> originalItems = new HashMap<>(16);
//
// // 处理关联数据
// for (EduQywxServiceProvider provider : providerList) {
// for (Dept dept : deptList) {
// // 查询是否有关联数据
// EduQywxServiceProviderSchool providerSchool = eduQywxServiceProviderSchoolService
// .getOne(Wrappers.lambdaQuery(new EduQywxServiceProviderSchool())
// .eq(EduQywxServiceProviderSchool::getProviderCorpId, provider.getCorpId())
// .eq(EduQywxServiceProviderSchool::getDeptOriginalCorpId, dept.getCorpId()));
// if (Objects.isNull(providerSchool)) {
// continue;
// }
// if (StringUtils.isNotBlank(providerSchool.getDeptEncryptionCorpId())) {
// providerSchool = new EduQywxServiceProviderSchool();
// providerSchool.setProviderCorpId(provider.getCorpId());
// providerSchool.setDeptOriginalCorpId(dept.getCorpId());
// // 转换corpId
// String providerToken = wxServiceProviderUtil
// .getProviderToken(provider.getCorpId(), provider.getServiceProviderSecret());
// String convertCorpId = wxServiceProviderUtil.convertCorpId(providerToken, dept.getCorpId());
// providerSchool.setDeptEncryptionCorpId(convertCorpId);
// eduQywxServiceProviderSchoolService.save(providerSchool);
// }
// items.put(provider.getCorpId() + "." + providerSchool.getDeptEncryptionCorpId(), providerSchool);
// originalItems.put(provider.getCorpId() + "." + providerSchool.getDeptOriginalCorpId(), providerSchool);
// }
// }
// if (CollUtil.isNotEmpty(items)) {
// redisService.hmset(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_DATA, items);
// redisService.hmset(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_ORIGINAL_DATA, originalItems);
// }
// }
}
@@ -9,9 +9,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
@Configuration
public class RabbitConfig {
@@ -40,7 +37,7 @@ public class RabbitConfig {
*/
@Bean
public Binding agentReceiveMsgBinding(@Qualifier("agentReceiveMsgQueue") Queue queue,
@Qualifier("wxPublicQrExchange") DirectExchange exchange) {
@Qualifier("wxPublicQrExchange") DirectExchange exchange) {
return BindingBuilder.bind(queue).to(exchange).with(RabbitConstant.AGENT_RECEIVE_MSG_KEY);
}
@@ -59,26 +56,7 @@ public class RabbitConfig {
*/
@Bean
public Binding visitorInviteCodeBinding(@Qualifier("visitorInviteCodeQueue") Queue queue,
@Qualifier("wxPublicQrExchange") DirectExchange exchange) {
@Qualifier("wxPublicQrExchange") DirectExchange exchange) {
return BindingBuilder.bind(queue).to(exchange).with(RabbitConstant.VISITOR_INVITE_CODE_KEY);
}
@Bean
public DirectExchange qywxHandleExchange() {
return new DirectExchange(RabbitConstant.QYWX_HANDLE_EXCHANGE);
}
@Bean
public Queue qywxHandleQueue() {
Map<String, Object> args = new HashMap<>();
// 设置同时只能一个消费者进行消费
args.put("x-single-active-consumer", true);
return new Queue(RabbitConstant.QYWX_HANDLE_QUEUE, true, false, false, args);
}
@Bean
public Binding qywxHandleBinding(@Qualifier("qywxHandleQueue") Queue queue,
@Qualifier("qywxHandleExchange") DirectExchange exchange) {
return BindingBuilder.bind(queue).to(exchange).with(RabbitConstant.QYWX_HANDLE_KEY);
}
}
@@ -23,6 +23,10 @@ public class SysRabbitReceiver {
/**
* 区域后台消息接收者
*
* @param wxPublicQr
* @param channel
* @param message
*/
@RabbitListener(bindings = @QueueBinding(
value = @Queue(RabbitConstant.AGENT_RECEIVE_MSG_QUEUE),
@@ -6,14 +6,15 @@ import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.EduSysFile;
import com.yida.data.common.core.exception.FebsException;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.school.vo.smart.WxConfigVO;
import com.yida.data.system.service.CommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@Api(tags = "通用接口")
@@ -42,20 +43,4 @@ public class CommonController {
}
return ResultBean.buildSuccess(stringBuilder.toString());
}
@GetMapping("/getWxJsConfig")
@ApiOperation("获取企业微信JS-SDK配置")
ResultBean<WxConfigVO> getWxJsConfig(
@RequestParam @ApiParam(value = "部门id", required = true) Long deptId,
@RequestParam @ApiParam(value = "当前网页的URL,不包含#及其后面部分", required = true) String url) {
return ResultBean.buildSuccess(commonService.getWxJsConfig(deptId, url));
}
@GetMapping("/getWxPublicJsConfig")
@ApiOperation("获取微信JS-SDK配置")
ResultBean<WxConfigVO> getWxPublicJsConfig(
@RequestParam @ApiParam(value = "部门id", required = true) Long deptId,
@RequestParam @ApiParam(value = "当前网页的URL,不包含#及其后面部分", required = true) String url) {
return ResultBean.buildSuccess(commonService.getWxPublicJsConfig(deptId, url));
}
}
@@ -57,45 +57,52 @@ public class DeptController {
*/
@ApiOperation("查询父级部门")
@GetMapping("/getParent")
@OperationLog(module = ModuleName.SYSTEM, methods = "查询父级部门")
public ResultBean<Dept> getParent(@ApiParam("部门id") Long deptId) {
return ResultBean.buildSuccess(deptService.getById(deptService.getById(deptId).getParentId()));
}
@ApiOperation("向上查询父级部门")
@GetMapping("/findParentUp")
@OperationLog(module = ModuleName.SYSTEM, methods = "向上查询父级部门")
public ResultBean<AllDeptInfoVO> findParentUp(@ApiParam("部门id") Long deptId,
@ApiParam("最上级部门类型,0表示学校,1表示班级,2表示年级,3表示学段,4表示校区,5公司,6" +
"学校部门") Integer type) {
@ApiParam("最上级部门类型,0表示学校,1表示班级,2表示年级,3表示学段,4表示校区,5公司,6" +
"学校部门") Integer type) {
return ResultBean.buildSuccess(deptService.findParentUp(deptId, type));
}
@GetMapping("/findListByParent")
@ApiOperation("查询所有子节点")
@OperationLog(module = ModuleName.SYSTEM, methods = "查询所有子节点")
public ResultBean<List<Dept>> findListByParent(Long deptId) {
return ResultBean.buildSuccess(deptService.findListByParent(Arrays.asList(deptId), 0));
}
@ApiOperation("查询直接子节点")
@GetMapping("/findChildByParent")
@OperationLog(module = ModuleName.SYSTEM, methods = "查询子节点")
public ResultBean findChildByParent(@ApiParam("父节点id,不能为空") @RequestParam Long deptId,
@ApiParam("子节点类型,0表示学校,5公司,6部门,7教育局,默认所有直接子节点") Integer type) {
@ApiParam("子节点类型,0表示学校,5公司,6部门,7教育局,默认所有直接子节点") Integer type) {
return ResultBean.buildSuccess(deptService.findChildByParent(deptId, type));
}
@ApiOperation("向下查询到要查询的部门类别的子部门(可查询非直接子部门)")
@GetMapping("/findChildByParentAndType")
@OperationLog(module = ModuleName.SYSTEM, methods = "向下查询到要查询的部门类别的子部门")
public ResultBean<List<Dept>> findChildByParentAndType(@ApiParam("父节点id,不能为空") Long parentId,
@ApiParam("子节点类型,0表示学校,5公司,6部门,7教育局,默认所有直接子节点") Integer type) {
@ApiParam("子节点类型,0表示学校,5公司,6部门,7教育局,默认所有直接子节点") Integer type) {
return ResultBean.buildSuccess(deptService.findChildByParentAndType(Arrays.asList(parentId), type));
}
@ApiOperation("根据部门id查询所属学校")
@GetMapping("findSchoolByDept")
@OperationLog(module = ModuleName.SYSTEM, methods = "根据部门id查询所属学校")
public ResultBean<Dept> findSchoolByDept(Long deptId) {
return ResultBean.buildSuccess(deptService.findSchooleByDept(deptId));
}
@GetMapping
@OperationLog(module = ModuleName.SYSTEM, methods = "查询部门")
public FebsResponse deptList(QueryRequest request, Dept dept) {
Map<String, Object> depts = this.deptService.findDepts(request, dept);
return new FebsResponse().data(depts);
@@ -103,14 +110,14 @@ public class DeptController {
@PostMapping
@PreAuthorize("hasAuthority('dept:add')")
@OperationLog(module = ModuleName.DEPT, methods = "新增部门", type = OperationLogTypeEnum.INSERT)
@OperationLog(module = ModuleName.SYSTEM, methods = "新增部门", type = OperationLogTypeEnum.INSERT)
public void addDept(@Valid Dept dept) {
this.deptService.createDept(dept);
}
@DeleteMapping("/{deptIds}")
@PreAuthorize("hasAuthority('dept:delete')")
@OperationLog(module = ModuleName.DEPT, methods = "删除部门", type = OperationLogTypeEnum.DELETE)
@OperationLog(module = ModuleName.SYSTEM, methods = "删除部门", type = OperationLogTypeEnum.DELETE)
public void deleteDepts(@NotBlank(message = "{required}") @PathVariable String deptIds) {
String[] ids = deptIds.split(StringConstant.COMMA);
this.deptService.deleteDepts(ids);
@@ -118,13 +125,14 @@ public class DeptController {
@PutMapping
@PreAuthorize("hasAuthority('dept:update')")
@OperationLog(module = ModuleName.DEPT, methods = "修改部门", type = OperationLogTypeEnum.UPDATE)
@OperationLog(module = ModuleName.SYSTEM, methods = "修改部门", type = OperationLogTypeEnum.UPDATE)
public void updateDept(@Valid Dept dept) {
this.deptService.updateDept(dept);
}
@PostMapping("excel")
@PreAuthorize("hasAuthority('dept:export')")
@ControllerLog(operation = "导出部门数据", exceptionMessage = "导出Excel失败")
public void export(Dept dept, QueryRequest request, HttpServletResponse response) {
List<Dept> depts = this.deptService.findDepts(dept, request);
//ExcelKit.$Export(Dept.class, response).downXlsx(depts, false);
@@ -138,17 +146,19 @@ public class DeptController {
@ApiOperation("根据区域查询学校列表")
@GetMapping("/getSchoolByArea")
@OperationLog(module = ModuleName.SYSTEM, methods = "根据区域查询学校列表")
public ResultBean<List<Dept>> getSchoolByArea(@ApiParam("区域id") @RequestParam(required = false) Long areaId,
@ApiParam("搜索关键词 学校名") @RequestParam(required = false) String schoolName) throws NoSuchMethodException {
@ApiParam("搜索关键词 学校名") @RequestParam(required = false) String schoolName) throws NoSuchMethodException {
return ResultBean.buildSuccess(deptService.getSchoolByArea(areaId, schoolName));
}
@ApiOperation("分页查询学校列表")
@GetMapping("/getPageSchoolByArea")
@OperationLog(module = ModuleName.SYSTEM, methods = "分页查询学校列表")
public ResultBean<IPage<Dept>> getPageSchoolByArea(@ApiParam("类型") @RequestParam(required = false) Long areaId,
@ApiParam("搜索关键词 学校名") @RequestParam(required = false) String schoolName,
@ApiParam("当前页码") @RequestParam(defaultValue = "1") Integer pageNum,
@ApiParam("页面大小") @RequestParam(defaultValue = "10") Integer pageSize) {
@ApiParam("搜索关键词 学校名") @RequestParam(required = false) String schoolName,
@ApiParam("当前页码") @RequestParam(defaultValue = "1") Integer pageNum,
@ApiParam("页面大小") @RequestParam(defaultValue = "10") Integer pageSize) {
Page<Dept> page = new Page<>();
page.setSize(pageSize);
page.setCurrent(pageNum);
@@ -157,9 +167,10 @@ public class DeptController {
@ApiOperation("部门树")
@GetMapping("/getDeptTree")
@OperationLog(module = ModuleName.SYSTEM, methods = "部门树")
public ResultBean<List> getDeptTree(@ApiParam("根节点Id") Long deptId,
@ApiParam("0-包含学校的企业部门(后勤部等)与学校部门(校区学段等),1-仅学校部门,2-仅企业部门,默认0") @RequestParam(defaultValue =
"0") Integer type) {
@ApiParam("0-包含学校的企业部门(后勤部等)与学校部门(校区学段等),1-仅学校部门,2-仅企业部门,默认0") @RequestParam(defaultValue =
"0") Integer type) {
if (deptId == null) {
deptId = FebsUtil.getCurrentUser().getDeptId();
}
@@ -174,6 +185,7 @@ public class DeptController {
@ApiOperation("查询部门区域")
@GetMapping("/findAreaById")
@OperationLog(module = ModuleName.SYSTEM, methods = "查询部门区域")
public ResultBean<AreaVO> findAreaById(@RequestParam Long id) {
Long byId = deptService.getById(id).getAreaId();
return ResultBean.buildSuccess(eduAreaMapper.findAreaById(byId));
@@ -183,15 +195,14 @@ public class DeptController {
* 查询代理商管理的学校列表数据
*
* @param agentSchoolSelectPageDTO 查询代理商管理的学校列表数据请求类
* @return com.yida.data.common.core.common.ResultBean<com.baomidou.mybatisplus.core.metadata.IPage <
* com.yida.data.system.vo.AgentSchoolVO>>
* @return com.yida.data.common.core.common.ResultBean<com.baomidou.mybatisplus.core.metadata.IPage < com.yida.data.system.vo.AgentSchoolVO>>
* @author ZYJ
* @date 2021/9/27 17:03
*/
@GetMapping(value = "/listAgentSchoolPage")
@ApiOperation(value = "查询代理商管理的学校列表数据", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResultBean<IPage<AgentSchoolSelectPageVO>> listAgentSchoolPage(
@Valid AgentSchoolSelectPageDTO agentSchoolSelectPageDTO) {
@Valid AgentSchoolSelectPageDTO agentSchoolSelectPageDTO) {
return this.deptService.listAgentSchoolPage(agentSchoolSelectPageDTO);
}
@@ -207,7 +218,7 @@ public class DeptController {
@PostMapping(value = "/saveAgentSchool", consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "代理商保存学校数据", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResultBean<String> saveAgentSchool(
@Valid @RequestBody AgentSchoolSaveDTO agentSchoolSaveDTO) {
@Valid @RequestBody AgentSchoolSaveDTO agentSchoolSaveDTO) {
return this.deptService.saveAgentSchool(agentSchoolSaveDTO);
}
@@ -223,7 +234,7 @@ public class DeptController {
@PostMapping(value = "/getAgentSchoolInfo")
@ApiOperation(value = "查询学校信息", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResultBean<AgentSchoolDetailVO> getAgentSchoolInfo(
@ApiParam(value = "学校id", required = true) @RequestParam Long schoolId) {
@ApiParam(value = "学校id", required = true) @RequestParam Long schoolId) {
return this.deptService.getAgentSchoolInfo(schoolId);
}
@@ -239,10 +250,9 @@ public class DeptController {
// @PreAuthorize("hasRole('role:agent:admin')")
@PostMapping(value = "/updateEnableStatus")
@ApiOperation(value = "启用或停用学校", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@OperationLog(module = ModuleName.DEPT, methods = "启用或停用学校", type = OperationLogTypeEnum.UPDATE)
public ResultBean<String> updateEnableStatus(
@ApiParam(value = "学校id", required = true) @RequestParam Long schoolId,
@ApiParam(value = "需要设置的启用或停用状态. 启用: 1, 停用: 0", required = true) @RequestParam Integer enableStatus) {
@ApiParam(value = "学校id", required = true) @RequestParam Long schoolId,
@ApiParam(value = "需要设置的启用或停用状态. 启用: 1, 停用: 0", required = true) @RequestParam Integer enableStatus) {
return this.deptService.updateEnableStatus(schoolId, enableStatus);
}
@@ -252,15 +262,14 @@ public class DeptController {
* 代理商查询学校管理员账号列表数据
*
* @param schoolAdminAccountSelectPageDTO 代理商查询学校管理员账号列表数据请求类
* @return com.yida.data.common.core.common.ResultBean<com.baomidou.mybatisplus.core.metadata.IPage <
* com.yida.data.system.vo.SchoolAdminAccountSelectPageVO>>
* @return com.yida.data.common.core.common.ResultBean<com.baomidou.mybatisplus.core.metadata.IPage < com.yida.data.system.vo.SchoolAdminAccountSelectPageVO>>
* @author ZYJ
* @date 2021/9/29 17:34
*/
@PostMapping(value = "/listSchoolAdminAccountPage")
@ApiOperation(value = "查询学校管理员账号列表数据", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResultBean<IPage<SchoolAdminAccountSelectPageVO>> listSchoolAdminAccountPage(
@Valid SchoolAdminAccountSelectPageDTO schoolAdminAccountSelectPageDTO) {
@Valid SchoolAdminAccountSelectPageDTO schoolAdminAccountSelectPageDTO) {
return ResultBean.buildSuccess(this.userService.listSchoolAdminAccountPage(schoolAdminAccountSelectPageDTO));
}
@@ -275,9 +284,8 @@ public class DeptController {
// @PreAuthorize("hasRole('role:agent:admin')")
@PostMapping(value = "/saveSchoolAdminAccount", consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "保存学校负责人账号", consumes = MediaType.APPLICATION_JSON_VALUE)
@OperationLog(module = ModuleName.DEPT, methods = "保存学校负责人账号", type = OperationLogTypeEnum.UPDATE)
public ResultBean<String> saveSchoolAdminAccount(
@Valid @RequestBody SchoolAdminAccountSaveDTO schoolAdminAccountSaveDTO) {
@Valid @RequestBody SchoolAdminAccountSaveDTO schoolAdminAccountSaveDTO) {
return this.userService.saveSchoolAdminAccount(schoolAdminAccountSaveDTO);
}
}
@@ -1,6 +1,5 @@
package com.yida.data.system.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ModuleName;
@@ -46,8 +45,8 @@ public class DictController {
@ApiOperation("分页查询字典类型")
@GetMapping("/listDictTypePage")
public ResultBean<IPage<DictTypePageVO>> listDictGroup(@RequestParam(required = false) String typeName,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize) {
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize) {
return ResultBean.buildSuccess(dictService.listDictTypePage(typeName, pageNum, pageSize));
}
@@ -56,7 +55,7 @@ public class DictController {
@OperationLog(module = ModuleName.SYSTEM, methods = "查询字典")
public ResultBean<List<Dict>> selectDict(@ApiParam("类型") @RequestParam String type) {
return ResultBean.buildSuccess(dictService.list(Wrappers.lambdaQuery(new Dict())
.eq(Dict::getType, type).orderByAsc(Dict::getSort)));
.eq(Dict::getType, type).orderByAsc(Dict::getSort)));
}
@PostMapping("/insertDict")
@@ -77,22 +76,7 @@ public class DictController {
@GetMapping("/delDictByType")
public ResultBean delDictByType(String type) {
dictService.remove(Wrappers.<Dict>lambdaQuery()
.eq(Dict::getType, type));
return ResultBean.buildSuccess();
}
@GetMapping("/getDictByTypeAndValueOrLabel")
public ResultBean getDictCode(String type, String value, String Label) {
if (ObjectUtil.isNotNull(value)) {
return ResultBean
.buildSuccess(
dictService.getOne(Wrappers.lambdaQuery(new Dict()).eq(Dict::getType, type).eq(Dict::getValue, value)));
}
if (ObjectUtil.isNotNull(Label)) {
return ResultBean
.buildSuccess(
dictService.getOne(Wrappers.lambdaQuery(new Dict()).eq(Dict::getType, type).eq(Dict::getLabel, Label)));
}
.eq(Dict::getType, type));
return ResultBean.buildSuccess();
}
@@ -3,13 +3,10 @@ package com.yida.data.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.common.ResultMsgType;
import com.yida.data.common.core.entity.instructions.EduInstructionsContent;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.system.service.EduInstructionsContentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -40,15 +37,15 @@ public class EduInstructionsContentController {
@ApiOperation("分页获取系统指南内容LIST")
@GetMapping("/findPageList")
@ControllerLog(operation = "分页获取系统指南内容LIST")
public ResultBean<IPage<EduInstructionsContent>> findPageList(
@ApiParam("指南类型") @RequestParam(required = false) String typeCode,
@ApiParam("指南标题") @RequestParam(required = false) String title,
@ApiParam("当前页码,默认1") @RequestParam(defaultValue = "1") Integer pageNum,
@ApiParam("分页大小,默认10") @RequestParam(defaultValue = "10") Integer pageSize
@ApiParam("指南类型") @RequestParam(required = false) String typeCode,
@ApiParam("指南标题") @RequestParam(required = false) String title,
@ApiParam("当前页码,默认1") @RequestParam(defaultValue = "1") Integer pageNum,
@ApiParam("分页大小,默认10") @RequestParam(defaultValue = "10") Integer pageSize
) {
try {
return ResultBean.buildSuccess(
eduInstructionsContentService.listPageEduInstructionsContent(new Page(pageNum, pageSize), typeCode, title));
return ResultBean.buildSuccess(eduInstructionsContentService.listPageEduInstructionsContent(new Page(pageNum, pageSize), typeCode, title));
} catch (Exception e) {
log.error("分页获取系统指南内容LIST失败: {}", e.getMessage(), e);
return ResultBean.buildError(ResultMsgType.QUERY_FAIL.getValue());
@@ -57,8 +54,9 @@ public class EduInstructionsContentController {
@ApiOperation("根据typeCode或者Id获取单条指南内容")
@PostMapping("/getOneEduInstructionsContent")
@ControllerLog(operation = "根据typeCode或者Id获取单条指南内容")
public ResultBean<EduInstructionsContent> getOneEduInstructionsContent(@RequestParam(required = false) String typeCode,
@RequestParam(required = false) Integer id
@RequestParam(required = false) Integer id
) {
try {
return ResultBean.buildSuccess(eduInstructionsContentService.getOneEduInstructionsContent(typeCode, id));
@@ -71,7 +69,7 @@ public class EduInstructionsContentController {
@ApiOperation("新增或修改系统指南内容")
@PostMapping("/saveOrUpdateInstructions")
@OperationLog(module = ModuleName.INSTRUCTION, methods = "新增或修改系统指南内容", type = OperationLogTypeEnum.SAVE)
@ControllerLog(operation = "新增或修改系统指南内容")
public ResultBean saveOrUpdateInstructions(@RequestBody EduInstructionsContent eduInstructionsContent) {
try {
boolean b = eduInstructionsContentService.saveInstructionsContent(eduInstructionsContent, FebsUtil.getCurrentUser());
@@ -89,7 +87,7 @@ public class EduInstructionsContentController {
@ApiOperation("删除系统指南内容")
@PostMapping("/removeBatch")
@OperationLog(module = ModuleName.INSTRUCTION, methods = "删除系统指南内容", type = OperationLogTypeEnum.DELETE)
@ControllerLog(operation = "删除系统指南内容")
public ResultBean selectProduct(@ApiParam("系统指南内容id") @RequestBody List<Integer> ids) {
try {
eduInstructionsContentService.deleteByIds(ids);
@@ -1,13 +1,10 @@
package com.yida.data.system.controller;
import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.common.ResultMsgType;
import com.yida.data.common.core.entity.instructions.EduInstructionsType;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.system.service.EduInstructionsTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -38,6 +35,7 @@ public class EduInstructionsTypeController {
@ApiOperation("系统指南类型列表")
@GetMapping("/findList")
@ControllerLog(operation = "系统指南类型列表")
public ResultBean<List<EduInstructionsType>> selectInstructionsList() {
try {
return ResultBean.buildSuccess(eduInstructionsTypeService.selectInstructionsTypeList());
@@ -50,7 +48,7 @@ public class EduInstructionsTypeController {
@ApiOperation("新增或修改系统指南类型")
@PostMapping("/save")
@OperationLog(module = ModuleName.INSTRUCTION, methods = "新增或修改系统指南类型", type = OperationLogTypeEnum.SAVE)
@ControllerLog(operation = "新增或修改系统指南类型")
public ResultBean insertInstructionsList(@RequestBody EduInstructionsType eduInstructionsType) {
try {
eduInstructionsTypeService.saveData(eduInstructionsType, FebsUtil.getCurrentUser());
@@ -64,7 +62,7 @@ public class EduInstructionsTypeController {
@ApiOperation("删除系统指南类型")
@PostMapping("/removeBatch")
@OperationLog(module = ModuleName.INSTRUCTION, methods = "删除系统指南类型", type = OperationLogTypeEnum.DELETE)
@ControllerLog(operation = "删除系统指南类型")
public ResultBean removeBatch(@ApiParam("系统指南类型id") @RequestBody List<Integer> ids) {
try {
eduInstructionsTypeService.removeByIds(ids);
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
import com.yida.data.common.core.entity.system.Dept;
import com.yida.data.common.core.entity.system.EduDeptWxPublic;
import com.yida.data.common.core.entity.system.EduHotWord;
@@ -20,6 +21,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -67,7 +69,7 @@ public class InDeptController {
@GetMapping("/getSchoolByName")
public ResultBean<Dept> getSchoolByName(String schoolName) {
return ResultBean.buildSuccess(deptService
.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getDeptName, schoolName)));
.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getDeptName, schoolName).eq(Dept::getDeptType, 0)));
}
/**
@@ -97,15 +99,7 @@ public class InDeptController {
@GetMapping("/syncQywxDept")
public ResultBean syncQywxDept() {
log.info("进入同步企业微信");
deptService.syncQywxDept(null);
return ResultBean.buildSuccess();
}
@ApiOperation("同步指定学校企业微信部门")
@GetMapping("/syncSchoolDept")
public ResultBean<String> syncSchoolDept(@RequestParam Long schoolId) {
log.info("同步企业微信部门数据: schoolId: [{}]", schoolId);
deptService.syncQywxDept(schoolId);
deptService.syncQywxDept();
return ResultBean.buildSuccess();
}
@@ -183,12 +177,29 @@ public class InDeptController {
@ApiOperation("根据名称和类型查询教育局学校列表")
@PostMapping("/listSchoolPage")
// @Cacheable(value = CachePrefixConstant.SCHOOL_LIST_SEARCH, key = "#dto.deptId + '-' + #dto.schoolName")
public ResultBean<IPage<SchoolInformationDTO>> listSchoolPage(@RequestBody SchoolPageDTO dto) {
IPage<SchoolInformationDTO> page = deptService.listSchoolPage(dto);
return ResultBean.buildSuccess(page);
}
@ApiOperation("根据名称查询教育局缴费学校列表")
@GetMapping("/listPaySchool")
public ResultBean<List<SchoolInformationDTO>> listPaySchool(
@ApiParam(value = "教育局或代理商id", required = true) @RequestParam Long deptId,
@ApiParam(value = "学校名称") String schoolName) {
List<SchoolInformationDTO> list = deptService.listPaySchool(deptId, schoolName);
return ResultBean.buildSuccess(list);
}
@ApiOperation("查询:1幼儿园,2小学,3初中,4高中,5大学")
@PostMapping("/listSchoolPageByNature")
@Cacheable(value = CachePrefixConstant.SCHOOL_LIST_SEARCH, key = "#dto.deptId + '-' + #dto.natureType + '-' + #dto.schoolName")
public ResultBean<IPage<SchoolInformationDTO>> listSchoolPageByNature(@RequestBody SchoolPageDTO dto) {
IPage<SchoolInformationDTO> page = deptService.listSchoolPage(dto);
return ResultBean.buildSuccess(page);
}
@ApiOperation("根据住所查询对应可读学校")
@GetMapping("/findSchoolByAddress")
public ResultBean<Page<SchoolInformationDTO>> findSchoolByAddress(
@@ -246,20 +257,4 @@ public class InDeptController {
return ResultBean.buildSuccess(deptService.findHotWord(num, type, deptId));
}
@ApiOperation("查询父级部门集合")
@PostMapping("/findParentDeptByChilds")
public ResultBean<List<Dept>> findParentDeptByChilds(@RequestBody List<Long> deptIds) {
return ResultBean.buildSuccess(deptService.findParentDeptByChild(deptIds));
}
@ApiOperation("获取部门树")
@PostMapping("/getDeptTree")
public ResultBean<List> getDeptTree(@RequestBody List<Long> deptIds) {
return ResultBean.buildSuccess(deptService.getDeptTree(deptIds));
}
}
@@ -1,14 +1,9 @@
package com.yida.data.system.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.EduApp;
import com.yida.data.common.core.entity.system.EduAppTemplate;
import com.yida.data.common.core.entity.system.EduQywxServiceProvider;
import com.yida.data.system.service.EduAppService;
import com.yida.data.system.service.EduAppTemplateService;
import com.yida.data.system.service.EduQywxServiceProviderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -22,26 +17,9 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class InEduAppController {
private final EduAppService eduAppService;
private final EduAppTemplateService eduAppTemplateService;
private final EduQywxServiceProviderService eduQywxServiceProviderService;
@GetMapping("/getAppBySchoolOrCorpIdAndCode")
public ResultBean<EduApp> getAppBySchoolOrCorpIdAndCode(Long schoolId, String corpId, String code) {
return ResultBean.buildSuccess(eduAppService.getAppBySchoolOrCorpIdAndCode(schoolId, corpId, code));
}
@GetMapping("/getAppTemplateByTemplateId")
public ResultBean<EduAppTemplate> getAppTemplateByTemplateId(String templateId, String serviceCorpId) {
return ResultBean.buildSuccess(eduAppTemplateService.getOne(Wrappers.lambdaQuery(new EduAppTemplate())
.eq(EduAppTemplate::getTemplateId, templateId)
.eq(EduAppTemplate::getServiceCorpId, serviceCorpId)
));
}
@GetMapping("/getServiceProviderByServiceCorpId")
public ResultBean<EduQywxServiceProvider> getServiceProviderByServiceCorpId(String serviceCorpId) {
return ResultBean.buildSuccess(eduQywxServiceProviderService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProvider())
.eq(EduQywxServiceProvider::getCorpId, serviceCorpId)
));
}
}
@@ -1,17 +1,19 @@
package com.yida.data.system.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.EduQywxServiceProviderSchool;
import com.yida.data.system.service.EduQywxServiceProviderSchoolService;
import com.yida.data.system.service.QywxCallbackService;
import com.yida.data.system.service.QywxServiceProviderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@Slf4j
@Api(tags = "企业微信同步")
@RestController
@RequiredArgsConstructor
@@ -19,8 +21,6 @@ import org.springframework.web.bind.annotation.*;
public class InQywxController {
private final QywxCallbackService qywxCallbackService;
private final QywxServiceProviderService qywxServiceProviderService;
private final EduQywxServiceProviderSchoolService eduQywxServiceProviderSchoolService;
@GetMapping("/callback/{corpId}")
public String get(@PathVariable String corpId,
@@ -33,124 +33,13 @@ public class InQywxController {
}
@PostMapping("/callback/{corpId}")
public String post(@PathVariable String corpId,
public Object post(@PathVariable String corpId,
@RequestParam("msg_signature") String msgSignature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestBody String body) {
return qywxCallbackService.post(corpId, msgSignature, timestamp, nonce, body);
}
/**
* 服务商代开发应用模板验证URL回调
*/
@GetMapping("/normal/callback/{corpId}")
public String getNormal(@PathVariable String corpId,
@RequestParam("msg_signature") String msgSignature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("echostr") String echostr) {
return qywxCallbackService.getNormal(corpId, msgSignature, timestamp, nonce, echostr);
}
/**
* 服务商代开发应用模板接口回调
*/
@PostMapping("/normal/callback/{corpId}")
public String postNormal(@PathVariable String corpId,
@RequestParam("msg_signature") String msgSignature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestBody String body) {
return qywxCallbackService.postNormal(corpId, msgSignature, timestamp, nonce, body);
}
/**
* 服务商代开发应用客户验证URL回调
*/
@GetMapping("/normal/customer/callback/{providerCorpId}/{corpId}")
public String getNormalCustomer(@PathVariable String providerCorpId,
@PathVariable String corpId,
@RequestParam("msg_signature") String msgSignature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("echostr") String echostr) {
return qywxCallbackService.getNormalCustomer(providerCorpId, corpId, msgSignature, timestamp, nonce, echostr);
}
/**
* 服务商代开发应用客户接口回调
* 此回调暂不做任何处理
*/
@PostMapping("/normal/customer/callback/{providerCorpId}/{corpId}")
public String postNormalCustomer(
@PathVariable String providerCorpId,
@PathVariable String corpId,
@RequestParam("msg_signature") String msgSignature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestBody String body) {
return qywxCallbackService.postNormalCustomer(providerCorpId, corpId, msgSignature, timestamp, nonce, body);
}
/**
* 服务商代开发应用验证URL回调
*/
@GetMapping("/event/callback/{providerCorpId}/{corpId}")
public String getEvent(@PathVariable String providerCorpId,
@PathVariable String corpId,
@RequestParam("msg_signature") String msgSignature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("echostr") String echostr) {
return qywxCallbackService.getEvent(providerCorpId, corpId, msgSignature, timestamp, nonce, echostr);
}
/**
* 服务商代开发应用回调
*/
@PostMapping("/event/callback/{providerCorpId}/{corpId}")
public String postEvent(
@PathVariable String providerCorpId,
@PathVariable String corpId,
@RequestParam("msg_signature") String msgSignature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestBody String body) {
return qywxCallbackService.postEvent(providerCorpId, corpId, msgSignature, timestamp, nonce, body);
}
/**
* 加密对应服务商的学校corpId
*/
@GetMapping("/changeCorpId/{providerCorpId}/{corpId}")
public ResultBean<String> changeCorpId(@PathVariable String providerCorpId, @PathVariable String corpId) {
qywxServiceProviderService.changeCorpId(providerCorpId, corpId);
qywxCallbackService.post(corpId, msgSignature, timestamp, nonce, body);
return ResultBean.buildSuccess();
}
/**
* 服务商对应学校加密corpId数据(原始值为key)
*/
@GetMapping("/getCorpByOriginalData")
public ResultBean<EduQywxServiceProviderSchool> getCorpByOriginalData(@RequestParam String providerCorpId,
@RequestParam String deptOriginalCorpId) {
EduQywxServiceProviderSchool providerSchool = eduQywxServiceProviderSchoolService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProviderSchool())
.eq(EduQywxServiceProviderSchool::getProviderCorpId, providerCorpId)
.eq(EduQywxServiceProviderSchool::getDeptOriginalCorpId, deptOriginalCorpId));
return ResultBean.buildSuccess(providerSchool);
}
/**
* 服务商对应学校加密corpId数据(加密值为key)
*/
@GetMapping("/getCorpByEncryptionData")
public ResultBean<EduQywxServiceProviderSchool> getCorpByEncryptionData(@RequestParam String providerCorpId,
@RequestParam String deptEncryptionCorpId) {
EduQywxServiceProviderSchool providerSchool = eduQywxServiceProviderSchoolService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProviderSchool())
.eq(EduQywxServiceProviderSchool::getProviderCorpId, providerCorpId)
.eq(EduQywxServiceProviderSchool::getDeptEncryptionCorpId, deptEncryptionCorpId));
return ResultBean.buildSuccess(providerSchool);
}
}
@@ -6,12 +6,16 @@ import com.yida.data.system.service.IUserRoleService;
import com.yida.data.system.service.IUserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Validated
@@ -64,12 +68,4 @@ public class InUserController {
userService.updateUserRoleByRoleName(userId, roleNames);
return ResultBean.buildSuccess();
}
@ApiOperation("获取企业微信用户授权后创建职工用户信息")
@GetMapping("createStaff")
public ResultBean<String> createStaff(@ApiParam("学校Id") Long schoolId,
@ApiParam("通过成员授权获取到的code") String code) {
userService.createStaff(schoolId, code);
return ResultBean.buildSuccess();
}
}
@@ -1,14 +1,11 @@
package com.yida.data.system.controller;
import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.entity.FebsResponse;
import com.yida.data.common.core.entity.QueryRequest;
import com.yida.data.common.core.entity.constant.StringConstant;
import com.yida.data.common.core.entity.system.LoginLog;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.system.service.ILoginLogService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -54,7 +51,7 @@ public class LoginLogController {
@DeleteMapping("{ids}")
@PreAuthorize("hasAuthority('loginlog:delete')")
@OperationLog(module = ModuleName.SYSTEM, methods = "删除登录日志", type = OperationLogTypeEnum.DELETE)
@ControllerLog(operation = "删除登录日志", exceptionMessage = "删除登录日志失败")
public void deleteLogs(@NotBlank(message = "{required}") @PathVariable String ids) {
String[] loginLogIds = ids.split(StringConstant.COMMA);
this.loginLogService.deleteLoginLogs(loginLogIds);
@@ -62,6 +59,7 @@ public class LoginLogController {
@PostMapping("excel")
@PreAuthorize("hasAuthority('loginlog:export')")
@ControllerLog(operation = "导出登录日志数据", exceptionMessage = "导出Excel失败")
public void export(QueryRequest request, LoginLog loginLog, HttpServletResponse response) {
List<LoginLog> loginLogs = this.loginLogService.findLoginLogs(loginLog, request).getRecords();
//ExcelKit.$Export(LoginLog.class, response).downXlsx(loginLogs, false);
@@ -1,14 +1,11 @@
package com.yida.data.system.controller;
import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.entity.FebsResponse;
import com.yida.data.common.core.entity.constant.StringConstant;
import com.yida.data.common.core.entity.router.VueRouter;
import com.yida.data.common.core.entity.system.Menu;
import com.yida.data.common.core.entity.system.Role;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.system.service.IMenuService;
import com.yida.data.system.service.IRoleService;
import io.swagger.annotations.ApiOperation;
@@ -42,7 +39,6 @@ public class MenuController {
private final IMenuService menuService;
private final IRoleService roleService;
@GetMapping("/{username}")
public FebsResponse getUserRouters(@NotBlank(message = "{required}") @PathVariable String username) {
Map<String, Object> result = new HashMap<>(4);
@@ -60,9 +56,9 @@ public class MenuController {
String[] roleArray = new String[0];
if (!CollectionUtils.isEmpty(userRoleList)) {
String userRoles = userRoleList.stream()
.filter(role -> Objects.nonNull(role) && StringUtils.isNotBlank(role.getRolePerms()))
.map(Role::getRolePerms)
.collect(Collectors.joining(StringConstant.COMMA));
.filter(role -> Objects.nonNull(role) && StringUtils.isNotBlank(role.getRolePerms()))
.map(Role::getRolePerms)
.collect(Collectors.joining(StringConstant.COMMA));
if (StringUtils.isNoneBlank(userPermissions)) {
roleArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(userRoles, StringConstant.COMMA);
}
@@ -71,9 +67,9 @@ public class MenuController {
String[] mainRoleArray = new String[0];
if (!CollectionUtils.isEmpty(mainRoleList)) {
String mainRoles = mainRoleList.stream()
.filter(role -> Objects.nonNull(role) && StringUtils.isNotBlank(role.getRolePerms()))
.map(Role::getRolePerms)
.collect(Collectors.joining(StringConstant.COMMA));
.filter(role -> Objects.nonNull(role) && StringUtils.isNotBlank(role.getRolePerms()))
.map(Role::getRolePerms)
.collect(Collectors.joining(StringConstant.COMMA));
if (StringUtils.isNoneBlank(mainRoles)) {
mainRoleArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(mainRoles, StringConstant.COMMA);
}
@@ -99,14 +95,14 @@ public class MenuController {
@PostMapping
@PreAuthorize("hasAuthority('menu:add')")
@OperationLog(module = ModuleName.SYSTEM, methods = "新增菜单/按钮", type = OperationLogTypeEnum.INSERT)
@ControllerLog(operation = "新增菜单/按钮", exceptionMessage = "新增菜单/按钮失败")
public void addMenu(@Valid Menu menu) {
this.menuService.createMenu(menu);
}
@DeleteMapping("/{menuIds}")
@PreAuthorize("hasAuthority('menu:delete')")
@OperationLog(module = ModuleName.SYSTEM, methods = "删除菜单/按钮", type = OperationLogTypeEnum.DELETE)
@ControllerLog(operation = "删除菜单/按钮", exceptionMessage = "删除菜单/按钮失败")
public void deleteMenus(@NotBlank(message = "{required}") @PathVariable String menuIds) {
String[] ids = menuIds.split(StringConstant.COMMA);
this.menuService.deleteMeuns(ids);
@@ -114,13 +110,14 @@ public class MenuController {
@PutMapping
@PreAuthorize("hasAuthority('menu:update')")
@OperationLog(module = ModuleName.SYSTEM, methods = "修改菜单/按钮", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(operation = "修改菜单/按钮", exceptionMessage = "修改菜单/按钮失败")
public void updateMenu(@Valid Menu menu) {
this.menuService.updateMenu(menu);
}
@PostMapping("excel")
@PreAuthorize("hasAuthority('menu:export')")
@ControllerLog(operation = "导出菜单数据", exceptionMessage = "导出Excel失败")
public void export(Menu menu, HttpServletResponse response) {
List<Menu> menus = this.menuService.findMenuList(menu);
//ExcelKit.$Export(Menu.class, response).downXlsx(menus, false);
@@ -4,17 +4,22 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.Dept;
import com.yida.data.common.core.entity.system.EduDeptWxPublic;
import com.yida.data.system.dto.SchoolInformationDTO;
import com.yida.data.system.mapper.EduDeptWxPublicMapper;
import com.yida.data.system.service.IDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@Validated
@Api(tags = "部门管理(无鉴权 外部使用)")
@@ -37,4 +42,13 @@ public class OutDeptController {
}
return ResultBean.buildSuccess(school);
}
@ApiOperation("根据名称查询教育局缴费学校列表")
@GetMapping("/listPaySchool")
public ResultBean<List<SchoolInformationDTO>> listPaySchool(
@ApiParam(value = "教育局或代理商id", required = true) @RequestParam Long deptId,
@ApiParam(value = "学校名称") String schoolName) {
List<SchoolInformationDTO> list = deptService.listPaySchool(deptId, schoolName);
return ResultBean.buildSuccess(list);
}
}
@@ -1,15 +1,12 @@
package com.yida.data.system.controller;
import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.FebsResponse;
import com.yida.data.common.core.entity.QueryRequest;
import com.yida.data.common.core.entity.constant.StringConstant;
import com.yida.data.common.core.entity.system.Role;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.system.service.IRoleService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -67,14 +64,14 @@ public class RoleController {
@PostMapping
@PreAuthorize("hasAuthority('role:add')")
@OperationLog(module = ModuleName.SYSTEM, methods = "新增角色", type = OperationLogTypeEnum.INSERT)
@ControllerLog(operation = "新增角色", exceptionMessage = "新增角色失败")
public void addRole(@Valid Role role) {
this.roleService.createRole(role);
}
@DeleteMapping("/{roleIds}")
@PreAuthorize("hasAuthority('role:delete')")
@OperationLog(module = ModuleName.SYSTEM, methods = "删除角色失败", type = OperationLogTypeEnum.DELETE)
@ControllerLog(operation = "删除角色", exceptionMessage = "删除角色失败")
public void deleteRoles(@NotBlank(message = "{required}") @PathVariable String roleIds) {
String[] ids = roleIds.split(StringConstant.COMMA);
this.roleService.deleteRoles(ids);
@@ -82,13 +79,14 @@ public class RoleController {
@PutMapping
@PreAuthorize("hasAuthority('role:update')")
@OperationLog(module = ModuleName.SYSTEM, methods = "修改角色", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(operation = "修改角色", exceptionMessage = "修改角色失败")
public void updateRole(@Valid Role role) {
this.roleService.updateRole(role);
}
@PostMapping("excel")
@PreAuthorize("hasAuthority('role:export')")
@ControllerLog(operation = "导出角色数据", exceptionMessage = "导出Excel失败")
public void export(QueryRequest queryRequest, Role role, HttpServletResponse response) {
List<Role> roles = this.roleService.findRoles(role, queryRequest).getRecords();
//ExcelKit.$Export(Role.class, response).downXlsx(roles, false);
@@ -1,6 +1,7 @@
package com.yida.data.system.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.FebsResponse;
@@ -11,7 +12,6 @@ import com.yida.data.common.core.entity.system.LoginLog;
import com.yida.data.common.core.entity.system.SystemUser;
import com.yida.data.common.core.entity.system.SystemUserMenu;
import com.yida.data.common.core.entity.system.UserRole;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.common.core.exception.FebsException;
import com.yida.data.common.core.utils.ExcelUtil;
import com.yida.data.common.core.utils.FebsUtil;
@@ -116,14 +116,14 @@ public class UserController {
@PostMapping
@PreAuthorize("hasAuthority('user:add')")
@OperationLog(module = ModuleName.USER, methods = "新增用户", type = OperationLogTypeEnum.INSERT)
@ControllerLog(operation = "新增用户", exceptionMessage = "新增用户失败")
public void addUser(@Valid SystemUser user) {
userService.createUser(user);
}
@PutMapping
@PreAuthorize("hasAuthority('user:update')")
@OperationLog(module = ModuleName.USER, methods = "修改用户", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(operation = "修改用户", exceptionMessage = "修改用户失败")
public void updateUser(@Valid SystemUser user) {
userService.updateUser(user);
}
@@ -137,32 +137,33 @@ public class UserController {
@DeleteMapping("/{userIds}")
@PreAuthorize("hasAuthority('user:delete')")
@OperationLog(module = ModuleName.USER, methods = "删除用户", type = OperationLogTypeEnum.DELETE)
@ControllerLog(operation = "删除用户", exceptionMessage = "删除用户失败")
public void deleteUsers(@NotBlank(message = "{required}") @PathVariable String userIds) {
String[] ids = userIds.split(StringConstant.COMMA);
userService.deleteUsers(ids);
}
@GetMapping("/updatePassword")
@OperationLog(module = ModuleName.USER, methods = "修改密码", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(operation = "修改密码", exceptionMessage = "修改密码失败")
public void updatePassword(String password, String newPassword, String repeatPassword) {
userService.updatePassword(password, newPassword, repeatPassword, FebsUtil.getCurrentUsername());
}
@GetMapping("/validatePassword")
@ControllerLog(operation = "校验密码", exceptionMessage = "密码校验失败")
public ResultBean validatePassword(String password) {
userService.validatePassword(password, FebsUtil.getCurrentUsername());
return ResultBean.buildSuccess();
}
@PutMapping("profile")
@OperationLog(module = ModuleName.USER, methods = "修改个人信息", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(exceptionMessage = "修改个人信息失败")
public void updateProfile(@Valid SystemUser user) throws FebsException {
userService.updateProfile(user);
}
@PutMapping("avatar")
@OperationLog(module = ModuleName.USER, methods = "修改头像", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(exceptionMessage = "修改头像失败")
public void updateAvatar(@NotBlank(message = "{required}") String avatar) {
userService.updateAvatar(avatar);
}
@@ -175,14 +176,14 @@ public class UserController {
}
@PutMapping("password")
@OperationLog(module = ModuleName.USER, methods = "修改密码", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(exceptionMessage = "修改密码失败")
public void updatePassword(@NotBlank(message = "{required}") String password) {
userService.updatePassword(password);
}
@PutMapping("password/reset")
@PreAuthorize("hasAuthority('user:reset')")
@OperationLog(module = ModuleName.USER, methods = "重置用户密码", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(exceptionMessage = "重置用户密码失败")
public void resetPassword(@NotBlank(message = "{required}") String usernames) {
String[] usernameArr = usernames.split(StringConstant.COMMA);
userService.resetPassword(usernameArr);
@@ -190,6 +191,8 @@ public class UserController {
@PostMapping("excel")
@PreAuthorize("hasAuthority('user:export')")
@ControllerLog(operation = "导出用户数据", exceptionMessage = "导出Excel失败")
@OperationLog(module = ModuleName.SYSTEM, methods = "导出用户数据")
public void export(QueryRequest queryRequest, SystemUser user, HttpServletResponse response) {
List<SystemUser> users = userService.findUserDetailList(user, queryRequest).getRecords();
List<ExportUserInfoVO> userInfoVOS = users.stream().map(x -> {
@@ -219,7 +222,6 @@ public class UserController {
@ApiOperation("锁定或解锁用户")
@GetMapping("/lockUser")
@OperationLog(module = ModuleName.USER, methods = "锁定或解锁用户", type = OperationLogTypeEnum.UPDATE)
public ResultBean lockUser(Long id) {
userService.lockUser(id);
return ResultBean.buildSuccess();
@@ -227,7 +229,6 @@ public class UserController {
@ApiOperation("重置密码")
@GetMapping("/resetPwd")
@OperationLog(module = ModuleName.USER, methods = "重置密码", type = OperationLogTypeEnum.UPDATE)
public ResultBean resetPwd(Long id) {
userService.resetPwd(id);
return ResultBean.buildSuccess();
@@ -235,13 +236,12 @@ public class UserController {
@ApiOperation("添加用户")
@PostMapping("/add")
@OperationLog(module = ModuleName.USER, methods = "添加用户", type = OperationLogTypeEnum.INSERT)
public ResultBean add(@RequestBody SystemUser systemUser) {
return ResultBean.buildSuccess(userService.createUser(systemUser));
}
@PostMapping("/update")
@OperationLog(module = ModuleName.USER, methods = "修改用户", type = OperationLogTypeEnum.UPDATE)
@ControllerLog(operation = "修改用户", exceptionMessage = "修改用户失败")
public ResultBean updateUserWithName(@RequestBody SystemUser user) {
userService.updateUserWithName(user);
return ResultBean.buildSuccess();
@@ -249,7 +249,6 @@ public class UserController {
@ApiOperation("批量删除用户")
@PostMapping("/delUser")
@OperationLog(module = ModuleName.USER, methods = "批量删除用户", type = OperationLogTypeEnum.DELETE)
public ResultBean delUser(@RequestBody String[] ids) {
userService.deleteUsers(ids);
return ResultBean.buildSuccess();
@@ -257,7 +256,6 @@ public class UserController {
@ApiOperation("添加用户角色")
@PostMapping("/addUserRole")
@OperationLog(module = ModuleName.USER, methods = "添加用户角色", type = OperationLogTypeEnum.UPDATE)
public ResultBean addUserRole(@RequestBody UserRole[] userRole) {
userRoleService.bindRoleByRoleName(userRole);
return ResultBean.buildSuccess();
@@ -276,7 +274,6 @@ public class UserController {
@ApiOperation("新增用户对应菜单")
@PostMapping("/saveUserMenu")
@OperationLog(module = ModuleName.USER, methods = "新增用户对应菜单", type = OperationLogTypeEnum.UPDATE)
public ResultBean saveUserMenu(@RequestBody MenuForUserDTO menuForUserDTO) {
systemUserMenuService.saveUserMenu(menuForUserDTO);
return ResultBean.buildSuccess();
@@ -284,7 +281,6 @@ public class UserController {
@ApiOperation("修改用户对应菜单")
@PostMapping("/updateUserMenu")
@OperationLog(module = ModuleName.USER, methods = "修改用户对应菜单", type = OperationLogTypeEnum.UPDATE)
public ResultBean updateUserMenu(@RequestBody MenuForUserDTO menuForUserDTO) {
systemUserMenuService.updateUserMenu(menuForUserDTO);
return ResultBean.buildSuccess();
@@ -292,7 +288,6 @@ public class UserController {
@ApiOperation("删除用户对应菜单")
@GetMapping("/removeUserMenu")
@OperationLog(module = ModuleName.USER, methods = "删除用户对应菜单", type = OperationLogTypeEnum.UPDATE)
public ResultBean removeUserMenu(@ApiParam("用户id") @RequestParam Long userId) {
systemUserMenuService.remove(Wrappers.lambdaQuery(new SystemUserMenu())
.eq(SystemUserMenu::getUserId, userId));
@@ -313,7 +308,6 @@ public class UserController {
@ApiOperation("保存logo")
@PostMapping("/saveLogo")
@OperationLog(module = ModuleName.USER, methods = "保存logo", type = OperationLogTypeEnum.INSERT)
public ResultBean saveLogo(@RequestBody EduUserLogo logo) {
eduUserLogoService.saveOrUpdate(logo);
return ResultBean.buildSuccess();
@@ -18,12 +18,13 @@ public interface DeptSchoolInformationMapper extends BaseMapper<DeptSchoolInform
/**
* 分页查询学校
* @param deptId 教育局或代理商id
*
* @param deptId 教育局或代理商id
* @param schoolName 学校名称
* @param schoolType 学校类型
* @param natureType 学校性质
* @param areaId 区域id
* @param tag 标签
* @param areaId 区域id
* @param tag 标签
* @return
*/
Page<SchoolInformationDTO> findSchoolListByDeptId(@Param("deptId") Long deptId, @Param("schoolName") String schoolName,
@@ -41,4 +42,16 @@ public interface DeptSchoolInformationMapper extends BaseMapper<DeptSchoolInform
List<Long> findDeptSchoolId(@Param("tags") String[] tags);
IPage<SchoolInformationDTO> listSchoolPage(Page<Dept> page, @Param("dto") SchoolPageDTO dto);
/**
* 根据名称查询教育局缴费学校列表
*
* @param deptId 教育局或代理商id
* @param schoolName 学校名称
* @return java.util.List<com.yida.data.system.dto.SchoolInformationDTO>
* @author ZYJ
* @date 2023/8/30 14:23
*/
List<SchoolInformationDTO> listPaySchool(@Param("deptId") Long deptId,
@Param("schoolName") String schoolName);
}
@@ -28,15 +28,4 @@ public interface MenuMapper extends BaseMapper<Menu> {
*/
List<Menu> findUserRealMenus(@Param("username") String username,
@Param("selectType") Integer selectType);
/**
* 查询用户绑定权限数据
*
* @param username 用户名
* @param selectType 查询类型 0菜单,1按钮,空查询所有
* @return 用户菜单
*/
List<Menu> findUserMenus(@Param("username") String username,
@Param("selectType") Integer selectType);
}
@@ -38,8 +38,6 @@ public interface UserMapper extends BaseMapper<SystemUser> {
SystemUser findUserByUsername(String username);
SystemUser findUserByMobile(String mobile);
/**
* 获取代理商管理员账号详情
*
@@ -1,7 +1,6 @@
package com.yida.data.system.service;
import com.yida.data.common.core.entity.system.EduSysFile;
import com.yida.data.school.vo.smart.WxConfigVO;
import org.springframework.web.multipart.MultipartFile;
public interface CommonService {
@@ -11,24 +10,4 @@ public interface CommonService {
String uploadImg(String code);
void saveReceiveMsg();
/**
* 获取企业微信配置唤起扫码功能
*
* @param deptId 部门id
* @param url 当前网页的URL,不包含#及其后面部分
* @return com.yida.data.school.vo.smart.WxConfigVO
* @author ZYJ
* @date 2023/6/5 14:24
*/
WxConfigVO getWxJsConfig(Long deptId, String url);
/**
* 获取微信配置唤起扫码功能
*
* @param deptId
* @param url
* @return
*/
WxConfigVO getWxPublicJsConfig(Long deptId, String url);
}
@@ -108,8 +108,6 @@ public interface IDeptService extends IService<Dept> {
List getDeptTree(Long deptId, Integer type);
List getDeptTree(List<Long> deptIds);
Dept getParentById(Long deptId);
List<Long> listClassByDept(List<Long> ids);
@@ -143,7 +141,7 @@ public interface IDeptService extends IService<Dept> {
* 同步企业微信部门
*/
@Async(FebsConstant.ASYNC_POOL)
void syncQywxDept(Long schoolId);
void syncQywxDept();
/**
* 处理挂在学校下的部门
@@ -155,7 +153,7 @@ public interface IDeptService extends IService<Dept> {
*
* @param agentSchoolSelectPageDTO 查询代理商管理的学校列表数据请求类
* @return com.yida.data.common.core.common.ResultBean<com.baomidou.mybatisplus.core.metadata.IPage <
* com.yida.data.system.vo.AgentSchoolVO>>
* com.yida.data.system.vo.AgentSchoolVO>>
* @author ZYJ
* @date 2021/9/27 17:05
*/
@@ -195,10 +193,9 @@ public interface IDeptService extends IService<Dept> {
void saveOrUpdateDeptSchool(SchoolInformationDTO information);
Page<SchoolInformationDTO> findSchoolListByDeptId(Long deptId, String schoolName, Integer schoolType,
Integer natureType, String address, String tag, Page<SchoolInformationDTO> page, Integer schoolOwnership);
Integer natureType, String address, String tag, Page<SchoolInformationDTO> page, Integer schoolOwnership);
Page<SchoolInformationDTO> findSchoolPageList(String schoolName, List<Integer> schoolType, List<Integer> natureType,
Page<SchoolInformationDTO> page, String tag, Long deptId, List<Integer> schoolOwnership);
Page<SchoolInformationDTO> findSchoolPageList(String schoolName, List<Integer> schoolType, List<Integer> natureType, Page<SchoolInformationDTO> page, String tag, Long deptId, List<Integer> schoolOwnership);
Page<SchoolInformationDTO> findSchoolByAddress(Page<SchoolInformationDTO> page, String address, Long deptId);
@@ -220,12 +217,14 @@ public interface IDeptService extends IService<Dept> {
*/
IPage<SchoolInformationDTO> listSchoolPage(SchoolPageDTO dto);
/**
* 根据子部门查询父级IDList
* 根据名称查询教育局缴费学校列表
*
* @param deptIds
* @return
* @param deptId 教育局或代理商id
* @param schoolName 学校名称
* @return java.util.List<com.yida.data.system.dto.SchoolInformationDTO>
* @author ZYJ
* @date 2023/8/30 14:21
*/
List<Dept> findParentDeptByChild(List<Long> deptIds);
List<SchoolInformationDTO> listPaySchool(Long deptId, String schoolName);
}
@@ -75,7 +75,8 @@ public interface IMenuService extends IService<Menu> {
void deleteMeuns(String[] menuIds);
/**
* 根据登录账号查询菜单数 角色相关菜单数据
* 根据登录账号查询菜单数
* 角色相关菜单数据
*
* @param username 登录账号
* @return java.util.Map<java.lang.String, java.lang.Object>
@@ -25,14 +25,6 @@ public interface IUserService extends IService<SystemUser> {
*/
SystemUser findByName(String username);
/**
* 通过手机号查找用户
*
* @param mobile 手机号
* @return 用户
*/
SystemUser findByMobile(String mobile);
/**
* 查找用户详细信息
*
@@ -147,9 +139,4 @@ public interface IUserService extends IService<SystemUser> {
* 更新用户的角色
*/
void updateUserRoleByRoleName(Long userId, List<String> roleNames);
/**
* 获取企业微信用户授权后创建职工用户信息
*/
void createStaff(Long schoolId, String code);
}
@@ -5,7 +5,6 @@ import com.yida.data.system.dto.ListLogDTO;
import com.yida.data.system.repository.LogEsRepository;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
@@ -65,9 +64,8 @@ public class LogService {
Pageable pageable = PageRequest.of(dto.getPageNum() - 1, dto.getPageSize());
//封装查询条件
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
.withPageable(pageable)
.withSort(SortBuilders.fieldSort("createDate").order(SortOrder.DESC));
.withPageable(pageable)
.withSort(SortBuilders.fieldSort("createDate").order(SortOrder.DESC));
//日志类型
String logType = dto.getLogType();
if (StringUtils.isNotBlank(logType)) {
@@ -83,24 +81,19 @@ public class LogService {
if (StringUtils.isNotBlank(method)) {
queryBuilder.withQuery(QueryBuilders.matchQuery("method", method));
}
//操作参数
String operateParams = dto.getOperateParams();
if (StringUtils.isNotBlank(operateParams)) {
queryBuilder.withQuery(QueryBuilders.matchQuery("operateParams", operateParams));
}
//操作开始时间
LocalDateTime startTime = dto.getStartTime();
//操作结束时间
LocalDateTime endTime = dto.getEndTime();
if (Optional.ofNullable(startTime).isPresent()) {
queryBuilder.withQuery(QueryBuilders.rangeQuery("createDate").gte(startTime.toInstant(
ZoneOffset.of("+8")
ZoneOffset.of("+8")
).toEpochMilli()).lte(endTime.toInstant(
ZoneOffset.of("+8")
ZoneOffset.of("+8")
).toEpochMilli()));
}
//查询列表数据
return logEsRepository.search(queryBuilder.build());
Page<Log> page = logEsRepository.search(queryBuilder.build().getQuery(), pageable);
return page;
}
}
@@ -8,17 +8,6 @@ public interface QywxCallbackService {
String get(String corpId, String msgSignature, String timestamp, String nonce, String echostr);
String post(String corpId, String msgSignature, String timestamp, String nonce, String body);
String getNormal(String corpId, String msgSignature, String timestamp, String nonce, String echostr);
String postNormal(String corpId, String msgSignature, String timestamp, String nonce, String body);
String getNormalCustomer(String providerCorpId, String corpId, String msgSignature, String timestamp, String nonce, String echostr);
String postNormalCustomer(String providerCorpId, String corpId, String msgSignature, String timestamp, String nonce, String body);
String getEvent(String providerCorpId, String corpId, String msgSignature, String timestamp, String nonce, String echostr);
String postEvent(String providerCorpId, String corpId, String msgSignature, String timestamp, String nonce, String body);
@Async(PoolConstant.QYWX_CALL_POOL)
void post(String corpId, String msgSignature, String timestamp, String nonce, String body);
}
@@ -4,7 +4,6 @@ import com.yida.data.common.core.entity.CurrentUser;
import com.yida.data.common.core.entity.constant.FebsConstant;
import com.yida.data.common.core.entity.system.Dept;
import com.yida.data.common.core.entity.system.EduApp;
import org.springframework.scheduling.annotation.Async;
public interface QywxService {
@@ -42,7 +41,6 @@ public interface QywxService {
* @param deptId
* @param school
*/
// @Async(FebsConstant.ASYNC_POOL)
void createSchoolDept(String corpId, String accessToken, Long deptId, Dept school);
/**
@@ -52,7 +50,6 @@ public interface QywxService {
* @param deptId
* @param school
*/
// @Async(FebsConstant.ASYNC_POOL)
void updateSchoolDept(String accessToken, Long deptId, Dept school);
/**
@@ -72,7 +69,6 @@ public interface QywxService {
* @param order
* @param school
*/
// @Async(FebsConstant.ASYNC_POOL)
void createDept(String deptId, String deptName, String parentId, String order, Dept school);
/**
@@ -83,7 +79,6 @@ public interface QywxService {
* @param parentId
* @param schoolId
*/
// @Async(FebsConstant.ASYNC_POOL)
void updateDept(String deptId, String deptName, String parentId, Long schoolId);
/**
@@ -176,9 +171,4 @@ public interface QywxService {
* 家长关注事件
*/
void sendParentSubscribeMessage(String parentId, Long schoolId);
/**
* 修改职工部门信息
*/
void updateUserInfo(String userId, Dept school, EduApp app);
}
@@ -1,45 +1,27 @@
package com.yida.data.system.service.impl;
import cc.mrbird.febs.common.redis.service.RedisService;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.base.Joiner;
import com.yida.data.common.core.entity.ReceiveMsg;
import com.yida.data.common.core.entity.constant.AppConstant;
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
import com.yida.data.common.core.entity.system.*;
import com.yida.data.common.core.exception.FebsException;
import com.yida.data.common.core.entity.system.EduSysFile;
import com.yida.data.common.core.utils.FileUtil;
import com.yida.data.common.core.utils.WxPublicUtil;
import com.yida.data.common.core.utils.WxUtil;
import com.yida.data.school.vo.smart.WxConfigVO;
import com.yida.data.system.mapper.EduSysFileMapper;
import com.yida.data.system.repository.ReceiveMsgRepository;
import com.yida.data.system.service.CommonService;
import com.yida.data.system.service.IDeptService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.TreeMap;
@Service
@RefreshScope
@@ -47,14 +29,8 @@ import java.util.TreeMap;
@RequiredArgsConstructor
public class CommonServiceImpl implements CommonService {
private final IDeptService deptService;
private final EduSysFileMapper eduSysFileMapper;
private final ReceiveMsgRepository receiveMsgRepository;
private final com.yida.data.common.service.CommonService commonService;
private final WxUtil wxUtil;
private final WxPublicUtil wxPublicUtil;
private final RedisService redisService;
@Value("${febs.uploadUrl}")
@@ -147,69 +123,4 @@ public class CommonServiceImpl implements CommonService {
log.info("保存{}条接收数据", saveSize);
}
}
@Override
public WxConfigVO getWxJsConfig(Long deptId, String url) {
Dept dept = deptService.getById(deptId);
if (Objects.isNull(dept)) {
throw new FebsException("当前学校配置信息错误!");
}
// 获取应用信息
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT_SELECT, null, deptId);
String jsApiTicket = wxUtil.getJsApiTicket(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()), deptId);
// 时间戳
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 随机字符串
String nonceStr = RandomUtil.randomString(32);
// 请求参数
JSONObject jsonObject = JSONUtil.createObj()
.set("jsapi_ticket", jsApiTicket)
.set("timestamp", timestamp)
.set("noncestr", nonceStr)
.set("url", url);
TreeMap<String, Object> paramMap = MapUtil.sort(jsonObject);
// 处理请求参数
String paramsStr = Joiner.on("&").withKeyValueSeparator("=").join(paramMap);
// 签名
String signature = SecureUtil.sha1(paramsStr);
return WxConfigVO.builder()
.appId(dept.getCorpId())
.timestamp(timestamp)
.nonceStr(nonceStr)
.signature(signature)
.build();
}
@Override
public WxConfigVO getWxPublicJsConfig(Long deptId, String url) {
Dept dept = deptService.getById(deptId);
if (Objects.isNull(dept)) {
throw new FebsException("当前学校配置信息错误!");
}
String jsApiTicket = wxPublicUtil.getJsApiTicket(dept.getWxPublicAppId(), dept.getWxPublicSecret());
// 时间戳
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 随机字符串
String nonceStr = RandomUtil.randomString(32);
// 请求参数
JSONObject jsonObject = JSONUtil.createObj()
.set("jsapi_ticket", jsApiTicket)
.set("timestamp", timestamp)
.set("noncestr", nonceStr)
.set("url", url);
TreeMap<String, Object> paramMap = MapUtil.sort(jsonObject);
// 处理请求参数
String paramsStr = Joiner.on("&").withKeyValueSeparator("=").join(paramMap);
// 签名
String signature = SecureUtil.sha1(paramsStr);
return WxConfigVO.builder()
.appId(dept.getWxPublicAppId())
.timestamp(timestamp)
.nonceStr(nonceStr)
.signature(signature)
.build();
}
}
@@ -29,18 +29,20 @@ import java.util.List;
@RequiredArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class DeptSchoolInformationServiceImpl extends ServiceImpl<DeptSchoolInformationMapper, DeptSchoolInformation>
implements DeptSchoolInformationService {
implements DeptSchoolInformationService {
private final DeptSchoolLabelService labelService;
private final CommonService commonService;
@Override
public Page<SchoolInformationDTO> findSchoolListByDeptId(Long deptId, String schoolName, Integer schoolType,
Integer natureType, String address, String tag, Page<SchoolInformationDTO> page,
Integer schoolOwnership) {
Page<SchoolInformationDTO> schoolListByDeptId = baseMapper.findSchoolListByDeptId(deptId, schoolName, schoolType, natureType, address, tag, page, schoolOwnership);
Integer natureType, String address, String tag, Page<SchoolInformationDTO> page,
Integer schoolOwnership) {
Page<SchoolInformationDTO> schoolListByDeptId = baseMapper
.findSchoolListByDeptId(deptId, schoolName, schoolType, natureType, address, tag, page, schoolOwnership);
for (SchoolInformationDTO record : schoolListByDeptId.getRecords()) {
List<DeptSchoolLabel> list = labelService.list(Wrappers.query(new DeptSchoolLabel()).lambda().eq(DeptSchoolLabel::getDeptSchoolId, record.getId()));
List<DeptSchoolLabel> list = labelService
.list(Wrappers.query(new DeptSchoolLabel()).lambda().eq(DeptSchoolLabel::getDeptSchoolId, record.getId()));
List<String> tagList = new ArrayList<>();
for (DeptSchoolLabel deptSchoolLabel : list) {
tagList.add(deptSchoolLabel.getLabel());
@@ -51,8 +53,9 @@ public class DeptSchoolInformationServiceImpl extends ServiceImpl<DeptSchoolInfo
}
@Override
public Page<SchoolInformationDTO> findSchoolPageList(String schoolName, List<Integer> schoolType, List<Integer> natureType, Page<SchoolInformationDTO> page,
String[] tags, Long deptId, List<Integer> schoolOwnership) {
public Page<SchoolInformationDTO> findSchoolPageList(String schoolName, List<Integer> schoolType, List<Integer> natureType,
Page<SchoolInformationDTO> page,
String[] tags, Long deptId, List<Integer> schoolOwnership) {
List<Long> deptSchoolId = new ArrayList<>();
if (tags != null && tags.length > 0) {
deptSchoolId = baseMapper.findDeptSchoolId(tags);
@@ -65,7 +68,6 @@ public class DeptSchoolInformationServiceImpl extends ServiceImpl<DeptSchoolInfo
@Override
public Page<SchoolInformationDTO> findSchoolByAddress(Page<SchoolInformationDTO> page, String address, Long deptId) {
return baseMapper.findSchoolByAddress(page, address, deptId);
}
@@ -24,7 +24,6 @@ import com.yida.data.common.core.entity.system.*;
import com.yida.data.common.core.entity.system.enums.DeptTypeEnum;
import com.yida.data.common.core.entity.system.enums.RoleEnum;
import com.yida.data.common.core.entity.system.enums.UserStatusEnum;
import com.yida.data.common.core.entity.user.enums.DeptVisibleTypeEnum;
import com.yida.data.common.core.enums.EnableStatusEnum;
import com.yida.data.common.core.exception.FebsException;
import com.yida.data.common.core.utils.*;
@@ -34,6 +33,7 @@ import com.yida.data.system.dto.AgentSchoolSelectPageDTO;
import com.yida.data.system.dto.SchoolInformationDTO;
import com.yida.data.system.dto.SchoolPageDTO;
import com.yida.data.system.mapper.DeptMapper;
import com.yida.data.system.mapper.DeptSchoolInformationMapper;
import com.yida.data.system.mapper.DeptSchoolRelateMapper;
import com.yida.data.system.mapper.EduAppMapper;
import com.yida.data.system.service.*;
@@ -70,7 +70,6 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
private final EduAppAccountService eduAppAccountService;
private final CommonService commonService;
private final EduPayWxConfigService eduPayWxConfigService;
private final EduAgentSchoolRelateService eduAgentSchoolRelateService;
private final IUserService userService;
private final RedisService redisService;
private final DeptSchoolRelateMapper deptSchoolRelateMapper;
@@ -82,13 +81,15 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
private final DeptSchoolInformationService schoolInformationService;
private final DeptSchoolInformationNatureService natureService;
private final DeptSchoolInformationMapper deptSchoolInformationMapper;
@Override
public Dept getSchoolDeptByDeptAndWx(List<Long> deptId, Long wxId) {
Dept exist = getOne(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId).eq(Dept::getWxId,
wxId).ne(Dept::getDeptType, 6));
wxId).ne(Dept::getDeptType, 6));
if (exist == null) {
List<Dept> deptList =
list(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId).ne(Dept::getDeptType, 6));
list(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId).ne(Dept::getDeptType, 6));
if (CollUtil.isNotEmpty(deptList)) {
List<Long> deptIds = deptList.stream().map(x -> x.getDeptId()).collect(Collectors.toList());
exist = getSchoolDeptByDeptAndWx(deptIds, wxId);
@@ -100,13 +101,12 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
@Override
public Dept getSysDeptByDeptAndWx(List<Long> deptId, Long wxId) {
Dept exist = getOne(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId).eq(Dept::getWxId,
wxId).eq(Dept::getDeptType, DeptTypeEnum.DEPARTMENT_TYPE.getValue()));
wxId).eq(Dept::getDeptType, 6));
if (exist == null) {
List<Dept> deptList =
list(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId)
.eq(Dept::getDeptType, DeptTypeEnum.DEPARTMENT_TYPE.getValue()));
list(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId).eq(Dept::getDeptType, 6));
if (CollUtil.isNotEmpty(deptList)) {
List<Long> deptIds = deptList.stream().map(Dept::getDeptId).collect(Collectors.toList());
List<Long> deptIds = deptList.stream().map(x -> x.getDeptId()).collect(Collectors.toList());
exist = getSysDeptByDeptAndWx(deptIds, wxId);
}
}
@@ -135,9 +135,9 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
} else {
// 查询下级部门信息
List<Long> childIdList = findListByParent(Collections.singletonList(currentUser.getDeptId()), 0)
.stream().map(Dept::getDeptId).collect(Collectors.toList());
.stream().map(Dept::getDeptId).collect(Collectors.toList());
if (RoleEnum.ROLE_EDUCATION_PRINCIPAL.equals(roleEnum) ||
RoleEnum.ROLE_AGENT_ADMIN.equals(roleEnum)) {
RoleEnum.ROLE_AGENT_ADMIN.equals(roleEnum)) {
childIdList.add(currentUser.getDeptId());
}
// 具有创建账号的数据 自己创建的账号+当前登陆账号部门以下的账号
@@ -155,7 +155,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
List<Dept> res = new ArrayList<>();
// 查询直接子部门
LambdaQueryWrapper<Dept> condition = Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId)
.orderByDesc(Dept::getOrderNum);
.orderByDesc(Dept::getOrderNum);
// if (type != null) {
// if (type == 1) {
// condition.ne(Dept::getDeptType, 6);
@@ -187,12 +187,12 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
@Override
public List<Dept> findChildByParentAndType(List<Long> deptId, Integer type) {
List<Dept> res = list(Wrappers.<Dept>lambdaQuery().in(Dept::getParentId, deptId).eq(Dept::getDeptType, type)
.orderByDesc(Dept::getOrderNum));
.orderByDesc(Dept::getOrderNum));
if (CollUtil.isEmpty(res)) {
List<Dept> child = list(Wrappers.<Dept>lambdaQuery().in(Dept::getParentId, deptId));
if (CollUtil.isNotEmpty(child)) {
res = findChildByParentAndType(child.stream().map(x -> x.getDeptId()).collect(Collectors.toList()),
type);
type);
}
}
return res;
@@ -220,8 +220,8 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
private Dept findSchoolOrEducationByDept(Long deptId) {
Dept now = this.baseMapper.selectById(deptId);
if (now != null &&
(DeptTypeEnum.SCHOOL_TYPE.getValue().equals(now.getDeptType())
|| DeptTypeEnum.EDUCATION_DEPT_TYPE.getValue().equals(now.getDeptType()))) {
(DeptTypeEnum.SCHOOL_TYPE.getValue().equals(now.getDeptType())
|| DeptTypeEnum.EDUCATION_DEPT_TYPE.getValue().equals(now.getDeptType()))) {
return now;
} else if (now != null) {
return findSchoolOrEducationByDept(now.getParentId());
@@ -275,10 +275,10 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
deptList.forEach(x -> {
// 教育局、代理商查询对应的关联学校信息
if (DeptTypeEnum.EDUCATION_DEPT_TYPE.getValue().equals(x.getDeptType()) ||
DeptTypeEnum.AGENT_TYPE.getValue().equals(x.getDeptType())) {
DeptTypeEnum.AGENT_TYPE.getValue().equals(x.getDeptType())) {
x.setRelationSchoolList(this.deptSchoolRelateMapper.selectList(Wrappers.lambdaQuery(new DeptSchoolRelate())
.eq(DeptSchoolRelate::getDeptId, x.getDeptId())).stream().map(DeptSchoolRelate::getSchoolId)
.collect(Collectors.toList()));
.eq(DeptSchoolRelate::getDeptId, x.getDeptId())).stream().map(DeptSchoolRelate::getSchoolId)
.collect(Collectors.toList()));
}
});
return deptList;
@@ -322,11 +322,13 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
Dept parent = findSchoolOrEducationByDept(dept.getParentId());
// 挂在学校的部门需要同步企业微信
if (parent != null && DeptTypeEnum.SCHOOL_TYPE.getValue().equals(parent.getDeptType())
&& parent.getSchoolType().contains(Dept.TYPE_QYWX)
&& dept.getWxId() == null) {
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT, null, parent.getDeptId());
&& parent.getSchoolType().contains(Dept.TYPE_QYWX)
&& dept.getWxId() == null) {
EduApp app = eduAppMapper.selectOne(Wrappers.lambdaQuery(new EduApp()).eq(EduApp::getDeptId,
parent.getDeptId()).eq(EduApp::getName, AppConstant.CONTACT));
if (app != null) {
Long wxId = wxUtil.createDept(commonService.getAddressListToken(app.getDeptId()), dept);
Long wxId = wxUtil.createDept(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()),
dept);
dept.setWxId(wxId);
}
}
@@ -339,19 +341,19 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
dept.setYidaAppColId(colId);
}
} else if (DeptTypeEnum.EDUCATION_DEPT_TYPE.getValue().equals(dept.getDeptType()) &&
StrUtil.isNotBlank(dept.getSchoolType()) && dept.getSchoolType().contains(Dept.TYPE_YIDA_APP)) {
StrUtil.isNotBlank(dept.getSchoolType()) && dept.getSchoolType().contains(Dept.TYPE_YIDA_APP)) {
dept.setYidaAppColId(yidaApp.getAppColId());
}
this.save(dept);
// 创建绑定易达的学校
if (DeptTypeEnum.SCHOOL_TYPE.getValue().equals(dept.getDeptType())
&& StrUtil.isNotBlank(dept.getSchoolType())
&& dept.getSchoolType().contains(Dept.TYPE_YIDA_APP)) {
&& StrUtil.isNotBlank(dept.getSchoolType())
&& dept.getSchoolType().contains(Dept.TYPE_YIDA_APP)) {
// 保存学校栏目到区域位下
List<Dept> list = list(Wrappers.lambdaQuery(new Dept())
.eq(Dept::getDeptType, 0)
.eq(Dept::getYidaAppId, yidaApp.getId())
.like(Dept::getSchoolType, Dept.TYPE_YIDA_APP));
.eq(Dept::getDeptType, 0)
.eq(Dept::getYidaAppId, yidaApp.getId())
.like(Dept::getSchoolType, Dept.TYPE_YIDA_APP));
if (CollUtil.isNotEmpty(list)) {
JSONArray content = new JSONArray();
for (Dept col : list) {
@@ -363,8 +365,8 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
}});
}
String regionId = AppUtil.regionUpdate(yidaApp.getAppSchoolRegionId(), "热门学校", 0,
yidaApp.getAppColId(),
AppUtil.REGION_TYPE_HOT, content, yidaApp);
yidaApp.getAppColId(),
AppUtil.REGION_TYPE_HOT, content, yidaApp);
if (StrUtil.isBlank(yidaApp.getAppSchoolRegionId())) {
yidaApp.setAppSchoolRegionId(regionId);
eduYidaAppService.updateById(yidaApp);
@@ -382,22 +384,20 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
eduAppAccountService.save(appAccount);
}
} else if (DeptTypeEnum.EDUCATION_DEPT_TYPE.getValue().equals(dept.getDeptType()) ||
DeptTypeEnum.AGENT_TYPE.getValue().equals(dept.getDeptType())) {
DeptTypeEnum.AGENT_TYPE.getValue().equals(dept.getDeptType())) {
CurrentUser currentUser = FebsUtil.getCurrentUser();
if (CollUtil.isNotEmpty(dept.getRelationSchoolList())) {
// 处理关联学校数据
dept.getRelationSchoolList().forEach(schoolId -> {
DeptSchoolRelate deptSchoolRelate = DeptSchoolRelate.builder()
.deptId(dept.getDeptId())
.createDeptId(currentUser.getDeptId())
.createId(currentUser.getUserId())
.createDate(LocalDateTime.now())
.schoolId(schoolId)
.build();
.deptId(dept.getDeptId())
.createDeptId(currentUser.getDeptId())
.createId(currentUser.getUserId())
.createDate(LocalDateTime.now())
.schoolId(schoolId)
.build();
this.deptSchoolRelateMapper.insert(deptSchoolRelate);
List<DeptSchoolInformation> list = schoolInformationService.list(
Wrappers.query(new DeptSchoolInformation()).lambda()
.eq(DeptSchoolInformation::getSchoolId, deptSchoolRelate.getSchoolId()));
List<DeptSchoolInformation> list = schoolInformationService.list(Wrappers.query(new DeptSchoolInformation()).lambda().eq(DeptSchoolInformation::getSchoolId, deptSchoolRelate.getSchoolId()));
if (CollectionUtil.isEmpty(list)) {
DeptSchoolInformation deptSchoolInformation = new DeptSchoolInformation();
@@ -457,9 +457,9 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
dept.setYidaAppColId(colId);
// 保存栏目到订阅号下
List<Dept> list = list(Wrappers.lambdaQuery(new Dept())
.eq(Dept::getDeptType, 0)
.like(Dept::getSchoolType, Dept.TYPE_YIDA_APP)
.eq(Dept::getYidaAppId, original.getYidaAppId()));
.eq(Dept::getDeptType, 0)
.like(Dept::getSchoolType, Dept.TYPE_YIDA_APP)
.eq(Dept::getYidaAppId, original.getYidaAppId()));
if (CollUtil.isNotEmpty(list)) {
JSONArray content = new JSONArray();
for (Dept col : list) {
@@ -471,8 +471,8 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
}});
}
String regionId = AppUtil.regionUpdate(yidaApp.getAppSchoolRegionId(), "热门学校", 0,
yidaApp.getAppColId(),
AppUtil.REGION_TYPE_HOT, content, yidaApp);
yidaApp.getAppColId(),
AppUtil.REGION_TYPE_HOT, content, yidaApp);
if (StrUtil.isBlank(yidaApp.getAppSchoolRegionId())) {
yidaApp.setAppSchoolRegionId(regionId);
@@ -492,9 +492,9 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
// }
for (int i = 0; i < 2; i++) {
EduYidaAppAccount appAccount = eduAppAccountService
.getOne(Wrappers.lambdaQuery(new EduYidaAppAccount())
.eq(EduYidaAppAccount::getSchoolId, dept.getDeptId())
.eq(EduYidaAppAccount::getType, i));
.getOne(Wrappers.lambdaQuery(new EduYidaAppAccount())
.eq(EduYidaAppAccount::getSchoolId, dept.getDeptId())
.eq(EduYidaAppAccount::getType, i));
if (appAccount == null) {
appAccount = new EduYidaAppAccount();
}
@@ -512,23 +512,24 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
Dept parent = findSchoolOrEducationByDept(dept.getParentId());
// 挂在学校的部门需要同步企业微信
if (Objects.nonNull(parent) && DeptTypeEnum.SCHOOL_TYPE.getValue().equals(parent.getDeptType())
&& parent.getSchoolType().contains(Dept.TYPE_QYWX)) {
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT, null, parent.getDeptId());
&& parent.getSchoolType().contains(Dept.TYPE_QYWX)) {
EduApp app = eduAppMapper.selectOne(Wrappers.lambdaQuery(new EduApp()).eq(EduApp::getDeptId,
parent.getDeptId()).eq(EduApp::getName, AppConstant.CONTACT));
if (app != null) {
dept.setWxId(original.getWxId());
wxUtil.updateDept(commonService.getAddressListToken(app.getDeptId()), dept);
wxUtil.updateDept(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()), dept);
}
}
} else if (DeptTypeEnum.EDUCATION_DEPT_TYPE.getValue().equals(dept.getDeptType()) ||
DeptTypeEnum.AGENT_TYPE.getValue().equals(dept.getDeptType())) {
DeptTypeEnum.AGENT_TYPE.getValue().equals(dept.getDeptType())) {
// 教育局、代理商
if (DeptTypeEnum.AGENT_TYPE.getValue().equals(dept.getDeptType()) &&
CollectionUtils.isEmpty(dept.getRelationSchoolList())) {
CollectionUtils.isEmpty(dept.getRelationSchoolList())) {
throw new FebsException("请选择关联的学校");
}
// 删除关联学校数据
this.deptSchoolRelateMapper.delete(Wrappers.lambdaQuery(new DeptSchoolRelate())
.eq(DeptSchoolRelate::getDeptId, dept.getDeptId()));
.eq(DeptSchoolRelate::getDeptId, dept.getDeptId()));
// 绑定了易达app
if (StrUtil.isNotBlank(dept.getSchoolType()) && dept.getSchoolType().contains(Dept.TYPE_YIDA_APP)) {
// 设置教育局栏目id
@@ -539,17 +540,15 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
// 处理关联学校数据
dept.getRelationSchoolList().forEach(schoolId -> {
DeptSchoolRelate deptSchoolRelate = DeptSchoolRelate.builder()
.deptId(original.getDeptId())
.createDeptId(currentUser.getDeptId())
.createId(currentUser.getUserId())
.createDate(LocalDateTime.now())
.schoolId(schoolId)
.build();
.deptId(original.getDeptId())
.createDeptId(currentUser.getDeptId())
.createId(currentUser.getUserId())
.createDate(LocalDateTime.now())
.schoolId(schoolId)
.build();
this.deptSchoolRelateMapper.insert(deptSchoolRelate);
//关联关系表学校放入学校信息表
List<DeptSchoolInformation> list = schoolInformationService.list(
Wrappers.query(new DeptSchoolInformation()).lambda()
.eq(DeptSchoolInformation::getSchoolId, deptSchoolRelate.getSchoolId()));
List<DeptSchoolInformation> list = schoolInformationService.list(Wrappers.query(new DeptSchoolInformation()).lambda().eq(DeptSchoolInformation::getSchoolId, deptSchoolRelate.getSchoolId()));
if (CollectionUtil.isEmpty(list)) {
DeptSchoolInformation deptSchoolInformation = new DeptSchoolInformation();
deptSchoolInformation.setSchoolName(getById(schoolId).getDeptName());
@@ -569,60 +568,60 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
public void deleteDepts(String[] deptIds) {
// 删除企业微信部门信息
List<Dept> deptList =
list(Wrappers.lambdaQuery(new Dept()).in(Dept::getDeptId, deptIds).notIn(Dept::getDeptType
, 0, 5));
list(Wrappers.lambdaQuery(new Dept()).in(Dept::getDeptId, deptIds).notIn(Dept::getDeptType
, 0, 5));
for (Dept dept : deptList) {
Dept school = findSchooleByDept(dept.getDeptId());
// 绑定了微信
if (Objects.nonNull(school) && school.getSchoolType().contains(Dept.TYPE_QYWX)) {
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT, null,
school.getDeptId());
EduApp app = commonService.getAppByCodeAndSchool(dept.getDeptType() == 6 ? "通讯录" : "家校沟通", null,
school.getDeptId());
// 同步删除企业微信部门
if (dept.getDeptType() == 6) {
wxUtil.deleteDept(commonService.getAddressListToken(school.getDeptId()), dept.getWxId());
wxUtil.deleteDept(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()), dept.getWxId());
}
}
// 绑定了大华
if (Objects.nonNull(school) && school.getSchoolType().contains(Dept.TYPE_DAHUA)) {
DaHuaUtil.delDept(Collections.singletonList(dept.getDahuaId()));
DaHuaUtil.delDept(Arrays.asList(dept.getDahuaId()));
}
// 教育局、代理商
if (DeptTypeEnum.EDUCATION_DEPT_TYPE.getValue().equals(dept.getDeptType()) ||
DeptTypeEnum.AGENT_TYPE.getValue().equals(dept.getDeptType())) {
DeptTypeEnum.AGENT_TYPE.getValue().equals(dept.getDeptType())) {
// 删除关联学校数据
this.deptSchoolRelateMapper.delete(Wrappers.lambdaQuery(new DeptSchoolRelate())
.eq(DeptSchoolRelate::getDeptId, dept.getDeptId()));
.eq(DeptSchoolRelate::getDeptId, dept.getDeptId()));
}
}
List<Dept> delYidaSchool =
list(Wrappers.<Dept>lambdaQuery().in(Dept::getDeptId, deptIds).eq(Dept::getDeptType, 0)
.like(Dept::getSchoolType, "1"));
list(Wrappers.<Dept>lambdaQuery().in(Dept::getDeptId, deptIds).eq(Dept::getDeptType, 0)
.like(Dept::getSchoolType, "1"));
this.delete(Arrays.asList(deptIds));
// 更新学校列表
if (CollUtil.isNotEmpty(delYidaSchool)) {
List<Long> yidaAppIds =
delYidaSchool.stream().map(Dept::getYidaAppId).distinct().collect(Collectors.toList());
delYidaSchool.stream().map(x -> x.getYidaAppId()).distinct().collect(Collectors.toList());
for (Long yidaAppId : yidaAppIds) {
EduYidaApp yidaApp = eduYidaAppService.getById(yidaAppId);
List<Dept> schoolList = list(Wrappers.<Dept>lambdaQuery()
.eq(Dept::getYidaAppId, yidaAppId)
.eq(Dept::getDeptType, 0)
.like(Dept::getSchoolType, "1"));
.eq(Dept::getYidaAppId, yidaAppId)
.eq(Dept::getDeptType, 0)
.like(Dept::getSchoolType, "1"));
AppUtil.regionUpdate(yidaApp.getAppSchoolRegionId(), "热门学校", 0, yidaApp.getAppColId(),
AppUtil.REGION_TYPE_HOT,
new JSONArray() {{
for (Dept dept : schoolList) {
add(
new JSONObject() {{
set("id", dept.getYidaAppColId());
if (StrUtil.isNotBlank(dept.getIcon())) {
set("img", dept.getIcon());
}
}});
}
}}
, yidaApp);
AppUtil.REGION_TYPE_HOT,
new JSONArray() {{
for (Dept dept : schoolList) {
add(
new JSONObject() {{
set("id", dept.getYidaAppColId());
if (StrUtil.isNotBlank(dept.getIcon())) {
set("img", dept.getIcon());
}
}});
}
}}
, yidaApp);
}
}
@@ -645,7 +644,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
removeByIds(deptId);
// 删除部门缓存
redisService
.hdel(CachePrefixConstant.SYS_DEPT_DATA, deptId.stream().map(x -> x.toString()).toArray(String[]::new));
.hdel(CachePrefixConstant.SYS_DEPT_DATA, deptId.stream().map(x -> x.toString()).toArray(String[]::new));
}
private void buildTrees(List<DeptTree> trees, List<Dept> depts) {
@@ -674,7 +673,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
removeByIds(deptIds);
userDataPermissionService.deleteByDeptIds(deptIds);
this.deptSchoolRelateMapper.delete(Wrappers.lambdaQuery(new DeptSchoolRelate())
.in(DeptSchoolRelate::getSchoolId, deptIds));
.in(DeptSchoolRelate::getSchoolId, deptIds));
LambdaQueryWrapper<Dept> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(Dept::getParentId, deptIds);
List<Dept> depts = baseMapper.selectList(queryWrapper);
@@ -710,41 +709,15 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
return deptTree;
}
@Override
public List getDeptTree(List<Long> deptIds) {
List<Dept> allDepts = new ArrayList<>();
List<Long> rootIdList = new ArrayList<>();
if (CollUtil.isNotEmpty(deptIds)) {
for (Long deptId : deptIds) {
// 添加根节点
Dept root = getById(deptId);
if (ObjectUtil.isNotNull(root)) {
if (root.getParentId() != null) {
root.setParentId(null);
root.setParentWxId(null);
}
allDepts.add(root);
rootIdList.add(deptId);
}
}
}
// 循环查询子节点
allDepts.addAll(findListByParent(rootIdList, 2));
List<DeptTree> trees = new ArrayList<>();
buildTrees(trees, allDepts);
List<? extends Tree<?>> deptTree = TreeUtil.build(trees);
return deptTree;
}
@Override
public List<Long> listClassByDept(List<Long> ids) {
List<Long> res = new ArrayList<>();
if (CollUtil.isNotEmpty(ids)) {
List<Dept> child = list(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, ids));
res.addAll(
child.stream().filter(x -> x.getDeptType() == 1).map(x -> x.getDeptId()).collect(Collectors.toList()));
child.stream().filter(x -> x.getDeptType() == 1).map(x -> x.getDeptId()).collect(Collectors.toList()));
res.addAll(listClassByDept(
child.stream().filter(x -> x.getDeptType() != 1).map(x -> x.getDeptId()).collect(Collectors.toList())));
child.stream().filter(x -> x.getDeptType() != 1).map(x -> x.getDeptId()).collect(Collectors.toList())));
}
return res;
}
@@ -752,12 +725,12 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
@Override
public Dept getDeptBySchoolAndName(List<Long> deptId, String deptName) {
List<Dept> deptList = list(Wrappers.lambdaQuery(new Dept()).eq(Dept::getDeptName, deptName).in(Dept
::getParentId, deptId).eq(Dept::getDeptType, 6));
::getParentId, deptId).eq(Dept::getDeptType, 6));
if (CollUtil.isEmpty(deptList)) {
List<Dept> child = list(Wrappers.lambdaQuery(new Dept()).in(Dept::getParentId, deptId));
if (CollUtil.isNotEmpty(child)) {
return getDeptBySchoolAndName(child.stream().map(x -> x.getDeptId()).collect(Collectors.toList()),
deptName);
deptName);
}
return null;
} else {
@@ -851,67 +824,56 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
public Dept getClassBySchoolAndWx(Long schoolId, Long classWxId) {
// 查询到学校年级层
List<Dept> campusList = list(
Wrappers.<Dept>lambdaQuery().eq(Dept::getParentId, schoolId).eq(Dept::getDeptType, 4));
Wrappers.<Dept>lambdaQuery().eq(Dept::getParentId, schoolId).eq(Dept::getDeptType, 4));
List<Dept> sectionList =
list(Wrappers.<Dept>lambdaQuery()
.in(Dept::getParentId, campusList.stream().map(x -> x.getDeptId()).collect(Collectors.toList()))
.eq(Dept::getDeptType, 3));
list(Wrappers.<Dept>lambdaQuery()
.in(Dept::getParentId, campusList.stream().map(x -> x.getDeptId()).collect(Collectors.toList()))
.eq(Dept::getDeptType, 3));
List<Dept> gradeList =
list(Wrappers.<Dept>lambdaQuery()
.in(Dept::getParentId, sectionList.stream().map(x -> x.getDeptId()).collect(Collectors.toList()))
.eq(Dept::getDeptType, 2));
list(Wrappers.<Dept>lambdaQuery()
.in(Dept::getParentId, sectionList.stream().map(x -> x.getDeptId()).collect(Collectors.toList()))
.eq(Dept::getDeptType, 2));
return getOne(Wrappers.<Dept>lambdaQuery()
.in(Dept::getParentId, gradeList.stream().map(x -> x.getDeptId()).collect(Collectors.toList()))
.eq(Dept::getWxId,
classWxId));
.in(Dept::getParentId, gradeList.stream().map(x -> x.getDeptId()).collect(Collectors.toList()))
.eq(Dept::getWxId,
classWxId));
}
@Override
public void syncQywxDept(Long schoolId) {
// 查询所有和企业微信关联的学校信息
List<Dept> schoolList = new ArrayList<>();
if (Objects.isNull(schoolId)) {
// 查询所有绑定了企业微信的学校信息
schoolList = list(Wrappers.<Dept>lambdaQuery()
.eq(Dept::getDeptType, DeptTypeEnum.SCHOOL_TYPE.getValue())
public void syncQywxDept() {
// 绑定了企业微信的学校
log.info("开始同步企业微信部门");
List<Dept> schoolList = list(Wrappers.<Dept>lambdaQuery()
.eq(Dept::getDeptType, 0)
.like(Dept::getSchoolType, Dept.TYPE_QYWX));
} else {
Dept school = getById(schoolId);
schoolList.add(school);
}
if (CollUtil.isNotEmpty(schoolList)) {
for (Dept school : schoolList) {
EduApp contactApp = commonService.getAppContactUsedBySelect(school.getDeptId());
EduApp contactApp = commonService.getAppByCodeAndSchool(AppConstant.CONTACT, null, school.getDeptId());
// 获取办公部门
log.info("[{}]开始同步办公部门", school.getDeptName());
List<Map> deptList = wxUtil
.listSimpleDept(wxUtil.getAccessToken(contactApp.getWxCorpId(), contactApp.getWxSecret()),
school.getWxId());
.listDept(wxUtil.getAccessToken(contactApp.getWxCorpId(), contactApp.getWxSecret()),
school.getWxId());
// 保存办公部门
Map<Long, Long> idCache = new HashMap<>();
idCache.put(1L, school.getDeptId());
for (Map map : deptList) {
Long wxId = Long.valueOf(map.get("id").toString());
Long parentWxId = Long.valueOf(map.get("parentid").toString());
// String deptName = map.get("name").toString();
String deptName = map.get("name").toString();
Integer order = Integer.valueOf(map.get("order").toString());
Long parentId = idCache.get(parentWxId);
if (wxId == 1) {
continue;
}
// 获取单个部门详情
JSONObject deptInfo = wxUtil.getDeptInfo(
wxUtil.getAccessToken(contactApp.getWxCorpId(), contactApp.getWxSecret()), String.valueOf(wxId));
String deptName = deptInfo.get("name").toString();
Dept exist = getOne(Wrappers.<Dept>lambdaQuery().eq(Dept::getParentId, parentId)
.eq(Dept::getWxId, wxId).eq(Dept::getDeptType, 6));
.eq(Dept::getWxId, wxId).eq(Dept::getDeptType, 6));
if (exist == null) {
exist = new Dept();
}
exist.setParentId(parentId);
exist.setDeptName(deptName);
exist.setDeptType(DeptTypeEnum.DEPARTMENT_TYPE.getValue());
exist.setDeptType(6);
exist.setAreaId(school.getAreaId());
exist.setWxId(wxId);
exist.setParentWxId(parentWxId);
@@ -927,22 +889,23 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
@Override
public void dealNoParentDept() {
List<Dept> schools = list(Wrappers.lambdaQuery(new Dept())
.eq(Dept::getDeptType, DeptTypeEnum.SCHOOL_TYPE.getValue()));
.eq(Dept::getDeptType, 0));
if (CollUtil.isNotEmpty(schools)) {
List<Long> schoolIds = schools.stream().map(Dept::getDeptId).collect(Collectors.toList());
schoolIds.forEach(schoolId -> {
List<Dept> depts = list(Wrappers.lambdaQuery(new Dept())
.eq(Dept::getVisible, DeptVisibleTypeEnum.INVISIBLE_TYPE.getValue())
.eq(Dept::getParentId, schoolId)
.ne(Dept::getDeptType, DeptTypeEnum.COMPANY_TYPE.getValue()));
.eq(Dept::getVisible, 1)
.eq(Dept::getParentId, schoolId)
.ne(Dept::getDeptType, 4)
.ne(Dept::getDeptType, 5));
for (Dept dept : depts) {
if (StrUtil.isNotBlank(dept.getCorpId())) {
Dept parent = getOne(Wrappers.lambdaQuery(new Dept())
.eq(Dept::getCorpId, dept.getCorpId())
.eq(Dept::getWxId, dept.getParentWxId()));
.eq(Dept::getCorpId, dept.getCorpId())
.eq(Dept::getWxId, dept.getParentWxId()));
if (parent != null) {
dept.setParentId(parent.getDeptId());
dept.setVisible(DeptVisibleTypeEnum.VISIBLE_TYPE.getValue());
dept.setVisible(0);
updateById(dept);
}
}
@@ -972,25 +935,25 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
*
* @param agentSchoolSelectPageDTO 查询代理商管理的学校列表数据请求类
* @return com.yida.data.common.core.common.ResultBean<com.baomidou.mybatisplus.core.metadata.IPage <
* com.yida.data.system.vo.AgentSchoolVO>>
* com.yida.data.system.vo.AgentSchoolVO>>
* @author ZYJ
* @date 2021/9/27 17:05
*/
@Override
public ResultBean<IPage<AgentSchoolSelectPageVO>> listAgentSchoolPage(
AgentSchoolSelectPageDTO agentSchoolSelectPageDTO) {
AgentSchoolSelectPageDTO agentSchoolSelectPageDTO) {
CurrentUser currentUser = FebsUtil.getCurrentUser();
// 查询下级部门信息
List<Long> childIdList = findListByParent(Collections.singletonList(currentUser.getDeptId()), 0)
.stream().map(Dept::getDeptId).collect(Collectors.toList());
.stream().map(Dept::getDeptId).collect(Collectors.toList());
// 代理商管理员查询当前代理商所有数据
if (RoleEnum.ROLE_AGENT_ADMIN.equals(RoleUtil.getMaxRole(currentUser))) {
childIdList.add(currentUser.getDeptId());
}
// 具有创建学校列表的数据 自己创建的学校+当前登陆账号部门以下的学校
IPage<AgentSchoolSelectPageVO> iPage = this.baseMapper
.listAgentSchoolPage(agentSchoolSelectPageDTO.toPage(), agentSchoolSelectPageDTO,
childIdList, currentUser);
.listAgentSchoolPage(agentSchoolSelectPageDTO.toPage(), agentSchoolSelectPageDTO,
childIdList, currentUser);
return ResultBean.buildSuccess(iPage);
}
@@ -1027,7 +990,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
}
// 查询学校已有微信支付配置信息
EduPayWxConfig payWxConfig = this.eduPayWxConfigService.getOne(Wrappers.lambdaQuery(new EduPayWxConfig())
.eq(EduPayWxConfig::getSchoolId, dept.getDeptId()));
.eq(EduPayWxConfig::getSchoolId, dept.getDeptId()));
if (Objects.isNull(payWxConfig)) {
payWxConfig = new EduPayWxConfig();
}
@@ -1055,7 +1018,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
BeanUtils.copyProperties(dept, agentSchoolDetailVO);
// 查询支付配置信息
EduPayWxConfig payWxConfig = this.eduPayWxConfigService.getOne(Wrappers.lambdaQuery(new EduPayWxConfig())
.eq(EduPayWxConfig::getSchoolId, dept.getDeptId()));
.eq(EduPayWxConfig::getSchoolId, dept.getDeptId()));
if (Objects.nonNull(payWxConfig)) {
// 配置支付数据
agentSchoolDetailVO.setWxPublicId(payWxConfig.getWxPublicId());
@@ -1087,7 +1050,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
// 修改学校状态
this.deptSchoolRelateMapper.update(deptSchoolRelate,
Wrappers.lambdaUpdate(new DeptSchoolRelate()).eq(DeptSchoolRelate::getSchoolId, schoolId));
Wrappers.lambdaUpdate(new DeptSchoolRelate()).eq(DeptSchoolRelate::getSchoolId, schoolId));
// 修改相关登陆账号信息
SystemUser systemUser = new SystemUser();
systemUser.setUpdateDate(LocalDateTime.now());
@@ -1100,7 +1063,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
}
// 修改学校相关账号状态
this.userService.update(systemUser,
Wrappers.lambdaUpdate(new SystemUser()).eq(SystemUser::getDeptId, schoolId));
Wrappers.lambdaUpdate(new SystemUser()).eq(SystemUser::getDeptId, schoolId));
return ResultBean.buildSuccess();
}
@@ -1171,8 +1134,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
deptSchoolInformationNature.setNature(integer);
list.add(deptSchoolInformationNature);
}
natureService.remove(Wrappers.query(new DeptSchoolInformationNature()).lambda()
.eq(DeptSchoolInformationNature::getInformationId, deptSchoolInformation.getId()));
natureService.remove(Wrappers.query(new DeptSchoolInformationNature()).lambda().eq(DeptSchoolInformationNature::getInformationId, deptSchoolInformation.getId()));
natureService.saveBatch(list);
}
@@ -1184,11 +1146,11 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
schoolLabel.setDeptSchoolId(deptSchoolInformation.getId());
schoolLabelList.add(schoolLabel);
}
schoolLabelService.remove(Wrappers.query(new DeptSchoolLabel()).lambda()
.eq(DeptSchoolLabel::getDeptSchoolId, deptSchoolInformation.getId()));
schoolLabelService.remove(Wrappers.query(new DeptSchoolLabel()).lambda().eq(DeptSchoolLabel::getDeptSchoolId, deptSchoolInformation.getId()));
schoolLabelService.saveBatch(schoolLabelList);
}
String studentRange = information.getStudentRange();
List<DeptSchoolStudentRange> list = new ArrayList<>();
//分割招生范围
@@ -1205,8 +1167,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
range.setDeptSchoolId(deptSchoolInformation.getId());
list.add(range);
}
rangeService.remove(Wrappers.query(new DeptSchoolStudentRange()).lambda()
.eq(DeptSchoolStudentRange::getDeptSchoolId, deptSchoolInformation.getId()));
rangeService.remove(Wrappers.query(new DeptSchoolStudentRange()).lambda().eq(DeptSchoolStudentRange::getDeptSchoolId, deptSchoolInformation.getId()));
rangeService.saveBatch(list);
}
@@ -1214,16 +1175,15 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
@Override
public Page<SchoolInformationDTO> findSchoolListByDeptId(Long deptId, String schoolName, Integer schoolType,
Integer natureType, String address, String tag, Page<SchoolInformationDTO> page,
Integer schoolOwnership) {
Integer natureType, String address, String tag, Page<SchoolInformationDTO> page,
Integer schoolOwnership) {
return informationService
.findSchoolListByDeptId(deptId, schoolName, schoolType, natureType, address, tag, page, schoolOwnership);
return informationService.findSchoolListByDeptId(deptId, schoolName, schoolType, natureType, address, tag, page, schoolOwnership);
}
@Override
public Page<SchoolInformationDTO> findSchoolPageList(String schoolName, List<Integer> schoolType, List<Integer> natureType,
Page<SchoolInformationDTO> page, String tag, Long deptId, List<Integer> schoolOwnership) {
public Page<SchoolInformationDTO> findSchoolPageList(String schoolName, List<Integer> schoolType, List<Integer> natureType, Page<SchoolInformationDTO> page, String tag, Long deptId, List<Integer> schoolOwnership) {
String[] tags = null;
if (ObjectUtil.isNotEmpty(tag)) {
@@ -1285,23 +1245,17 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
}
@Override
public List<Dept> findParentDeptByChild(List<Long> deptIds) {
List<Dept> childList = list(Wrappers.lambdaQuery(new Dept()).in(Dept::getDeptId, deptIds));
List<Dept> allDeptList = list();
List<Dept> parentDeptList = new ArrayList<>();
return getParentDeptList(allDeptList, childList, parentDeptList);
}
private List<Dept> getParentDeptList(List<Dept> depts, List<Dept> childrenDeptList, List<Dept> parentDeptList) {
if (CollectionUtils.isEmpty(childrenDeptList)) {
return parentDeptList;
}
parentDeptList.addAll(childrenDeptList);
List<Long> parentIds = childrenDeptList.stream().map(Dept::getParentId).filter(Objects::nonNull)
.collect(Collectors.toList());
//查询父级部门
List<Dept> parentDepts = depts.stream().filter(x -> parentIds.contains(x.getDeptId())).collect(Collectors.toList());
return getParentDeptList(depts, parentDepts, parentDeptList);
public List<SchoolInformationDTO> listPaySchool(Long deptId, String schoolName) {
List<SchoolInformationDTO> list = deptSchoolInformationMapper.listPaySchool(deptId, schoolName);
// // 返回数据
// List<SchoolInformationDTO> returnList = new ArrayList<>();
// // 判断是否包含缴费信息
// list.forEach(schoolInformationDTO -> {
// EduDeptPayType deptPayType = commonService.getDeptPayWay(schoolInformationDTO.getSchoolId());
// if (Objects.nonNull(deptPayType)) {
// returnList.add(schoolInformationDTO);
// }
// });
return list;
}
}
@@ -54,25 +54,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
@Override
public List<Menu> findUserRealMenus(String username, Integer selectType) {
checkUser(username);
List<Menu> permissions = baseMapper.findUserPermissions(username);
List<Menu> userRealMenus = baseMapper.findUserMenus(username, selectType);
permissions.addAll(userRealMenus.stream().filter(x -> x.getUserMenuType() == 0).collect(Collectors.toList()));
Iterator<Menu> iterator = permissions.iterator();
while (iterator.hasNext()) {
Menu next = iterator.next();
for (Menu realMenu : userRealMenus) {
if (realMenu.getUserMenuType() == 1 && realMenu.getMenuId().equals(next.getMenuId())) {
iterator.remove();
}
}
}
if (Objects.nonNull(selectType)) {
permissions = permissions.stream().filter(x -> x.getType().equals(selectType.toString()))
.peek(x->x.setUserMenuType(null))
.distinct()
.collect(Collectors.toList());
}
return permissions;
return this.baseMapper.findUserRealMenus(username, selectType);
}
@Override
@@ -1,68 +1,67 @@
package com.yida.data.system.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.entity.constant.AppConstant;
import com.yida.data.common.core.entity.constant.QywxConstant;
import com.yida.data.common.core.entity.system.Dept;
import com.yida.data.common.core.entity.system.EduQywxServiceProvider;
import com.yida.data.common.core.entity.system.EduQywxServiceProviderSchool;
import com.yida.data.common.core.entity.system.enums.DeptTypeEnum;
import com.yida.data.common.core.enums.QywxCallbackTypeEnum;
import com.yida.data.rabbit.constant.RabbitConstant;
import com.yida.data.rabbit.util.RabbitUtil;
import com.yida.data.common.core.entity.system.EduApp;
import com.yida.data.common.core.utils.WxUtil;
import com.yida.data.common.service.CommonService;
import com.yida.data.system.aes.WXBizMsgCrypt;
import com.yida.data.system.dto.QywxCallbackHandleDTO;
import com.yida.data.system.service.*;
import com.yida.data.system.service.IDeptService;
import com.yida.data.system.service.IUserService;
import com.yida.data.system.service.QywxCallbackService;
import com.yida.data.system.service.QywxService;
import com.yida.data.user.feign.RemoteStudentService;
import com.yida.data.user.feign.RemoteTeacherService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.StringReader;
/**
* 企业微信回调类
*
* @author ZYJ
* @date 2023/10/27 17:15
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class QywxCallbackServiceImpl implements QywxCallbackService {
private final IDeptService deptService;
private final EduQywxServiceProviderService eduQywxServiceProviderService;
private final EduQywxServiceProviderSchoolService eduQywxServiceProviderSchoolService;
private final IUserService userService;
private final QywxService qywxService;
private final RabbitUtil rabbitUtil;
private final WxUtil wxUtil;
private final CommonService commonService;
private final RemoteTeacherService remoteTeacherService;
private final RemoteStudentService remoteStudentService;
@Override
public String get(String corpId, String msgSignature, String timestamp, String nonce, String echostr) {
Dept school =
deptService.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getCorpId, corpId).eq(Dept::getDeptType, DeptTypeEnum.SCHOOL_TYPE.getValue()));
log.info("部门验证url回调params:{},{},{},{},{}", corpId, msgSignature, timestamp, nonce, echostr);
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
deptService.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getCorpId, corpId).eq(Dept::getDeptType, 0));
log.info("params:{},{},{},{},{}", corpId, msgSignature, timestamp, nonce, echostr);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
school.getCorpId());
String result = wxCpt.VerifyURL(msgSignature, timestamp, nonce, echostr);
log.info("部门验证url回调call valid result:{}", result);
String result = wxcpt.VerifyURL(msgSignature, timestamp, nonce, echostr);
log.info("call valid result:{}", result);
return result;
}
@Override
@GlobalTransactional
public String post(String corpId, String msgSignature, String timestamp, String nonce, String body) {
Dept school = deptService.getOne(Wrappers.lambdaQuery(new Dept())
.eq(Dept::getCorpId, corpId)
.eq(Dept::getDeptType, DeptTypeEnum.SCHOOL_TYPE.getValue())
);
log.info("部门回调params:{},{},{},{},{}", corpId, msgSignature, timestamp, nonce, body);
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
public void post(String corpId, String msgSignature, String timestamp, String nonce, String body) {
Dept school =
deptService.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getCorpId, corpId).eq(Dept::getDeptType, 0));
log.info("params:{},{},{},{},{}", corpId, msgSignature, timestamp, nonce, body);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
school.getCorpId());
String msg = wxCpt.DecryptMsg(msgSignature, timestamp, nonce, body);
String msg = wxcpt.DecryptMsg(msgSignature, timestamp, nonce, body);
log.info("msg:{}", msg);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
StringReader sr = new StringReader(msg);
@@ -74,155 +73,135 @@ public class QywxCallbackServiceImpl implements QywxCallbackService {
document = db.parse(is);
} catch (Exception e) {
log.error("解析微信回调信息失败,msg:{}", e.getMessage());
return "fail";
}
// 发送消息给rabbitmq
rabbitUtil.convertAndSendMsg(RabbitConstant.QYWX_HANDLE_EXCHANGE, RabbitConstant.QYWX_HANDLE_KEY,
QywxCallbackHandleDTO.builder()
.root(document.getDocumentElement())
.corpId(corpId)
.school(school)
.qywxCallbackTypeEnum(QywxCallbackTypeEnum.POST)
.build()
);
return "success";
}
@Override
public String getNormal(String corpId, String msgSignature, String timestamp, String nonce, String echostr) {
EduQywxServiceProvider serviceProvider =
eduQywxServiceProviderService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProvider())
.eq(EduQywxServiceProvider::getCorpId, corpId));
log.info("服务商验证url回调params:{},{},{},{},{}", corpId, msgSignature, timestamp, nonce, echostr);
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(serviceProvider.getWxCallToken(), serviceProvider.getWxAesKey(),
serviceProvider.getCorpId());
String result = wxCpt.VerifyURL(msgSignature, timestamp, nonce, echostr, false);
log.info("服务商验证url回调call valid result:{}", result);
return result;
}
@Override
public String postNormal(String corpId, String msgSignature, String timestamp, String nonce, String body) {
EduQywxServiceProvider serviceProvider =
eduQywxServiceProviderService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProvider())
.eq(EduQywxServiceProvider::getCorpId, corpId));
log.info("服务商代开发应用模板接口回调params:{},{},{},{},{}", corpId, msgSignature, timestamp, nonce, body);
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(serviceProvider.getWxCallToken(), serviceProvider.getWxAesKey(),
serviceProvider.getCorpId());
String msg = wxCpt.DecryptMsg(msgSignature, timestamp, nonce, body, false);
log.info("msg:{}", msg);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
StringReader sr = new StringReader(msg);
InputSource is = new InputSource(sr);
DocumentBuilder db = null;
Document document = null;
try {
db = dbf.newDocumentBuilder();
document = db.parse(is);
} catch (Exception e) {
log.error("服务商代开发应用模板接口回调信息失败,msg:{}", e.getMessage());
return "fail";
}
// 发送消息给rabbitmq
rabbitUtil.convertAndSendMsg(RabbitConstant.QYWX_HANDLE_EXCHANGE, RabbitConstant.QYWX_HANDLE_KEY,
QywxCallbackHandleDTO.builder()
.root(document.getDocumentElement())
.eduQywxServiceProvider(serviceProvider)
.qywxCallbackTypeEnum(QywxCallbackTypeEnum.POST_NORMAL)
.build()
);
return "success";
}
@Override
public String getNormalCustomer(String providerCorpId, String corpId, String msgSignature, String timestamp,
String nonce, String echostr) {
Dept school = deptService.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getCorpId, corpId).eq(Dept::getDeptType, 0));
log.info("服务商代开发应用客户验证url回调params:{},{},{},{},{},{}", providerCorpId, corpId, msgSignature, timestamp, nonce, echostr);
EduQywxServiceProviderSchool providerSchool = eduQywxServiceProviderSchoolService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProviderSchool())
.eq(EduQywxServiceProviderSchool::getProviderCorpId, providerCorpId)
.eq(EduQywxServiceProviderSchool::getDeptOriginalCorpId, corpId));
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
providerSchool.getDeptEncryptionCorpId());
String result = wxCpt.VerifyURL(msgSignature, timestamp, nonce, echostr);
log.info("服务商代开发应用客户验证url回调call valid result:{}", result);
return result;
}
@Override
public String postNormalCustomer(String providerCorpId, String corpId, String msgSignature, String timestamp, String nonce, String body) {
Dept school =
deptService.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getCorpId, corpId).eq(Dept::getDeptType, DeptTypeEnum.SCHOOL_TYPE.getValue()));
log.info("服务商代开发应用客户接口回调params: {},{},{},{},{},{}", providerCorpId, corpId, msgSignature, timestamp, nonce, body);
EduQywxServiceProviderSchool providerSchool = eduQywxServiceProviderSchoolService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProviderSchool())
.eq(EduQywxServiceProviderSchool::getProviderCorpId, providerCorpId)
.eq(EduQywxServiceProviderSchool::getDeptOriginalCorpId, corpId));
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
providerSchool.getDeptEncryptionCorpId());
String msg = wxCpt.DecryptMsg(msgSignature, timestamp, nonce, body);
log.info("msg:{}", msg);
return "success";
}
@Override
public String getEvent(String providerCorpId, String corpId, String msgSignature, String timestamp, String nonce, String echostr) {
Dept school = deptService.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getCorpId, corpId).eq(Dept::getDeptType, DeptTypeEnum.SCHOOL_TYPE.getValue()));
log.info("服务商代开发家校沟通验证url回调params:{},{},{},{},{},{}", providerCorpId, corpId, msgSignature, timestamp, nonce, echostr);
EduQywxServiceProviderSchool providerSchool = eduQywxServiceProviderSchoolService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProviderSchool())
.eq(EduQywxServiceProviderSchool::getProviderCorpId, providerCorpId)
.eq(EduQywxServiceProviderSchool::getDeptOriginalCorpId, corpId));
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
providerSchool.getDeptEncryptionCorpId());
String result = wxCpt.VerifyURL(msgSignature, timestamp, nonce, echostr);
log.info("服务商代开发应用家校沟通验证url回调call valid result:{}", result);
return result;
}
@Override
public String postEvent(String providerCorpId, String corpId, String msgSignature, String timestamp, String nonce, String body) {
Dept school = deptService.getOne(Wrappers.lambdaQuery(new Dept()).eq(Dept::getCorpId, corpId).eq(Dept::getDeptType, DeptTypeEnum.SCHOOL_TYPE.getValue()));
log.info("服务商代开发家校沟通回调params: {},{},{},{},{},{}", providerCorpId, corpId, msgSignature, timestamp, nonce, body);
EduQywxServiceProviderSchool providerSchool = eduQywxServiceProviderSchoolService.getOne(Wrappers.lambdaQuery(new EduQywxServiceProviderSchool())
.eq(EduQywxServiceProviderSchool::getProviderCorpId, providerCorpId)
.eq(EduQywxServiceProviderSchool::getDeptOriginalCorpId, corpId));
WXBizMsgCrypt wxCpt = new WXBizMsgCrypt(school.getWxCallToken(), school.getWxAesKey(),
providerSchool.getDeptEncryptionCorpId());
String msg = wxCpt.DecryptMsg(msgSignature, timestamp, nonce, body);
log.info("msg:{}", msg);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
StringReader sr = new StringReader(msg);
InputSource is = new InputSource(sr);
DocumentBuilder db = null;
Document document = null;
try {
db = dbf.newDocumentBuilder();
document = db.parse(is);
} catch (Exception e) {
log.error("解析服务商代开发家校沟通回调信息失败,msg:{}", e.getMessage());
return "false";
}
Element root = document.getDocumentElement();
if (root.getElementsByTagName("Event").getLength() == 0) {
log.info("暂不处理当前回调数据");
return "success";
NodeList nodelist1 = root.getElementsByTagName("ChangeType");
String changeType = nodelist1.item(0).getTextContent();
NodeList nodelist2 = root.getElementsByTagName("Event");
String event = nodelist2.item(0).getTextContent();
if (QywxConstant.SCHOOL_CONTACT_EVENT.equals(event)) {
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT_SCHOOL, null, school.getDeptId());
String id = root.getElementsByTagName("Id").item(0).getTextContent();
switch (changeType) {
case QywxConstant.SCHOOL_DEPT_CREATE_TYPE:
qywxService.createSchoolDept(corpId, wxUtil.getAccessToken(app.getWxCorpId(),
app.getWxSecret()), Long.valueOf(id), school);
break;
case QywxConstant.SCHOOL_DEPT_UPDATE_TYPE:
qywxService.updateSchoolDept(wxUtil.getAccessToken(app.getWxCorpId(),
app.getWxSecret()), Long.valueOf(id), school);
break;
case QywxConstant.SCHOOL_DEPT_DELETE_TYPE:
qywxService.deleteSchoolDept(Long.valueOf(id), school);
break;
case QywxConstant.STUDENT_CREATE_TYPE:
case QywxConstant.STUDENT_UPDATE_TYPE:
qywxService.changeStudent(wxUtil.getAccessToken(app.getWxCorpId(),
app.getWxSecret()), id, school);
break;
case QywxConstant.STUDENT_DELETE_TYPE:
qywxService.deleteStudent(id, school.getDeptId());
break;
case QywxConstant.PARENT_CREATE_TYPE:
// 新增家长可能是创建学生时创建,等待2s确保学生创建完成
try {
Thread.sleep(2000);
} catch (Exception e) {
}
case QywxConstant.PARENT_UPDATE_TYPE:
qywxService.updateParent(wxUtil.getAccessToken(app.getWxCorpId(),
app.getWxSecret()), id, school.getDeptId());
break;
case QywxConstant.PARENT_DELETE_TYPE:
qywxService.deleteParent(id, school.getDeptId());
break;
case QywxConstant.PARENT_SUBSCRIBE_TYPE:
log.info("进入家长关注事件回调");
// 调用家长关注发送通知方法
qywxService.sendParentSubscribeMessage(id, school.getDeptId());
break;
case QywxConstant.PARENT_UNSUBSCRIBE_TYPE:
log.info("进入家长取消关注事件回调");
break;
default:
break;
}
}
if (QywxConstant.CONTACT_EVENT.equals(event)) {
String userid = null, phone = null, name = null, gender = null, avatar = null, department = null,
isLeader = null, mainDepartment = null, email = null;
if (root.getElementsByTagName("UserID").getLength() != 0) {
userid = root.getElementsByTagName("UserID").item(0).getTextContent();
}
if (root.getElementsByTagName("Mobile").getLength() != 0) {
phone = root.getElementsByTagName("Mobile").item(0).getTextContent();
}
if (root.getElementsByTagName("Name").getLength() != 0) {
name = root.getElementsByTagName("Name").item(0).getTextContent();
}
if (root.getElementsByTagName("Gender").getLength() != 0) {
gender = root.getElementsByTagName("Gender").item(0).getTextContent();
}
if (root.getElementsByTagName("Avatar").getLength() != 0) {
avatar = root.getElementsByTagName("Avatar").item(0).getTextContent();
}
if (root.getElementsByTagName("Department").getLength() != 0) {
department = root.getElementsByTagName("Department").item(0).getTextContent();
}
if (root.getElementsByTagName("IsLeaderInDept").getLength() != 0) {
isLeader = root.getElementsByTagName("IsLeaderInDept").item(0).getTextContent();
}
if (root.getElementsByTagName("MainDepartment").getLength() != 0) {
mainDepartment = root.getElementsByTagName("MainDepartment").item(0).getTextContent();
}
if (root.getElementsByTagName("Email").getLength() != 0) {
email = root.getElementsByTagName("Email").item(0).getTextContent();
}
String deptId = null, deptName = null, deptParentId = null, order = null;
if (root.getElementsByTagName("Id").getLength() != 0) {
deptId = root.getElementsByTagName("Id").item(0).getTextContent();
}
if (root.getElementsByTagName("Name").getLength() != 0) {
deptName = root.getElementsByTagName("Name").item(0).getTextContent();
}
if (root.getElementsByTagName("ParentId").getLength() != 0) {
deptParentId = root.getElementsByTagName("ParentId").item(0).getTextContent();
}
if (root.getElementsByTagName("Order").getLength() != 0) {
order = root.getElementsByTagName("Order").item(0).getTextContent();
}
switch (changeType) {
case QywxConstant.USER_CREATE_TYPE:
qywxService.createUser(name, userid, phone, email, gender, avatar, department, isLeader,
mainDepartment, school);
break;
case QywxConstant.USER_UPDATE_TYPE:
qywxService.updateUser(name, userid, phone, email, gender, avatar, department, isLeader,
mainDepartment, school);
break;
case QywxConstant.USER_DELETE_TYPE:
qywxService.deleteUser(userid, school.getDeptId());
break;
case QywxConstant.DEPT_CREATE_TYPE:
qywxService.createDept(deptId, deptName, deptParentId, order, school);
break;
case QywxConstant.DEPT_UPDATE_TYPE:
qywxService.updateDept(deptId, deptName, deptParentId, school.getDeptId());
break;
case QywxConstant.DEPT_DELETE_TYPE:
qywxService.deleteDept(deptId, school.getDeptId());
break;
}
}
// 发送消息给rabbitmq
rabbitUtil.convertAndSendMsg(RabbitConstant.QYWX_HANDLE_EXCHANGE, RabbitConstant.QYWX_HANDLE_KEY,
QywxCallbackHandleDTO.builder()
.root(root)
.school(school)
.providerSchool(providerSchool)
.qywxCallbackTypeEnum(QywxCallbackTypeEnum.POST_EVENT)
.build()
);
return "success";
}
}
@@ -95,7 +95,7 @@ public class QywxServiceImpl implements QywxService {
}
EduApp app = eduAppMapper.selectOne(Wrappers.lambdaQuery(new EduApp()).eq(EduApp::getDeptId,
schoolId).eq(EduApp::getCode, AppConstant.CONTACT_SCHOOL));
schoolId).eq(EduApp::getName, AppConstant.CONTACT_SCHOOL));
List<Map> deptList = wxUtil.listSchoolDept(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()), null);
List<EduUserDept> camps = new ArrayList<>();
List<EduUserDept> section = new ArrayList<>();
@@ -113,7 +113,7 @@ public class QywxServiceImpl implements QywxService {
dept.setDeptType(Integer.valueOf(map.get("type").toString()));
dept.setDeptName(map.get("name").toString());
dept.setSchoolId(schoolId);
dept.setParentId(-schoolId);
dept.setParentId(schoolId);
switch (dept.getDeptType()) {
case 1:
// 班级
@@ -164,8 +164,7 @@ public class QywxServiceImpl implements QywxService {
wxIdAndDaHuaId.put(dept.getWxId(), dept.getDaHuaId());
}
if (CollUtil.isNotEmpty(teacherList.get(dept.getWxId()))) {
remoteTeacherService.dealWxTeacherChange(schoolId, dept.getDeptId(), null, null, null,
teacherList.get(dept.getWxId()), dept.getWxId());
remoteTeacherService.dealWxTeacherChange(schoolId, dept.getDeptId(), null, null, null, teacherList.get(dept.getWxId()));
}
}
for (EduUserDept dept : section) {
@@ -182,8 +181,7 @@ public class QywxServiceImpl implements QywxService {
for (EduUserDept dept : section) {
wxIdAndId.put(dept.getWxId(), dept.getDeptId());
if (CollUtil.isNotEmpty(teacherList.get(dept.getWxId()))) {
remoteTeacherService.dealWxTeacherChange(schoolId, dept.getParentId(), dept.getDeptId(), null, null,
teacherList.get(dept.getWxId()), dept.getWxId());
remoteTeacherService.dealWxTeacherChange(schoolId, dept.getParentId(), dept.getDeptId(), null, null, teacherList.get(dept.getWxId()));
}
}
for (EduUserDept dept : grade) {
@@ -206,7 +204,7 @@ public class QywxServiceImpl implements QywxService {
dept.getParentId(),
dept.getDeptId(),
null,
teacherList.get(dept.getWxId()), dept.getWxId());
teacherList.get(dept.getWxId()));
}
}
for (EduUserDept dept : clazz) {
@@ -226,7 +224,7 @@ public class QywxServiceImpl implements QywxService {
deptParent.get(dept.getParentId()),
dept.getParentId(),
dept.getDeptId(),
teacherList.get(dept.getWxId()), dept.getWxId());
teacherList.get(dept.getWxId()));
}
}
}
@@ -356,7 +354,7 @@ public class QywxServiceImpl implements QywxService {
public void initUser(Long schoolId, CurrentUser currentUser) {
Dept school = deptService.getById(schoolId);
EduApp app = eduAppMapper.selectOne(Wrappers.lambdaQuery(new EduApp()).eq(EduApp::getDeptId,
schoolId).eq(EduApp::getCode, AppConstant.CONTACT_SCHOOL));
schoolId).eq(EduApp::getName, AppConstant.CONTACT_SCHOOL));
JSONArray student = wxUtil.getStudentList(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()),
1L);
int size = 2;
@@ -491,10 +489,8 @@ public class QywxServiceImpl implements QywxService {
List<EduUserDept> saveDeptList = new ArrayList<>();
List<Map> deptList = wxUtil.listSchoolDept(accessToken, deptWxId);
for (Map map : deptList) {
// 查询的家校部门数据的部门id
Long wxDeptId = Long.valueOf(map.get("id").toString());
EduUserDept dept = remoteUserDeptService.getUserDeptByDeptAndWx(
Collections.singletonList(-school.getDeptId()), wxDeptId).getData();
EduUserDept dept = remoteUserDeptService.getUserDeptByDeptAndWx(Collections.singletonList(-school.getDeptId()),
Long.valueOf(map.get("id").toString())).getData();
dept.setDeptName((String) map.get("name"));
if (ObjectUtil.isNotNull(map.get("order"))) {
dept.setOrderNum((Integer) map.get("order"));
@@ -509,7 +505,7 @@ public class QywxServiceImpl implements QywxService {
classId = dept.getDeptId();
gradeId = dept.getParentId();
// 查询学段信息
EduUserDept section = remoteUserDeptService.getParentByDeptId(gradeId).getData();
EduUserDept section = this.remoteUserDeptService.getParentByDeptId(gradeId).getData();
sectionId = section.getDeptId();
campusId = section.getParentId();
break;
@@ -517,7 +513,7 @@ public class QywxServiceImpl implements QywxService {
// 年级
gradeId = dept.getDeptId();
sectionId = dept.getParentId();
campusId = remoteUserDeptService.getByDeptId(sectionId).getData().getParentId();
campusId = this.remoteUserDeptService.getByDeptId(sectionId).getData().getParentId();
break;
case 3:
// 学段
@@ -529,18 +525,13 @@ public class QywxServiceImpl implements QywxService {
campusId = dept.getDeptId();
break;
default:
log.error("家校部门类型错误, 部门信息:{}", dept);
log.error("家校部门类型错误: {}", dept.getDeptType());
break;
}
// 仅处理当前部门负责人
if (deptWxId.equals(wxDeptId)) {
// 获取老师列表
List<Map> teacherList = (List<Map>) map.get("department_admins");
log.info("teachers:{},dept:{}", teacherList, dept);
if (CollUtil.isNotEmpty(teacherList)) {
remoteTeacherService.dealWxTeacherChange(school.getDeptId(), campusId, sectionId, gradeId, classId, teacherList, deptWxId);
}
}
// 获取老师列表
List<Map> teacherList = (List<Map>) map.get("department_admins");
log.info("teachers:{},dept:{}", teacherList, dept);
remoteTeacherService.dealWxTeacherChange(school.getDeptId(), campusId, sectionId, gradeId, classId, teacherList);
saveDeptList.add(dept);
// 更新大华部门
if (school.getSchoolType().contains(Dept.TYPE_DAHUA)) {
@@ -548,15 +539,14 @@ public class QywxServiceImpl implements QywxService {
if (UserDeptTypeEnum.CAMPUS_TYPE.getValue().equals(dept.getDeptType())) {
// 学区的上级大华id是学校大华id
parentDaHuaId = school.getDahuaId();
} else {
EduUserDept parent = remoteUserDeptService.getByDeptId(dept.getParentId()).getData();
} else {
EduUserDept parent = this.remoteUserDeptService.getByDeptId(dept.getParentId()).getData();
parentDaHuaId = parent.getDaHuaId();
}
DaHuaUtil.updateDept(dept.getDaHuaId(), parentDaHuaId, dept.getDeptName());
}
}
remoteUserDeptService.updateBatchUserDept(saveDeptList);
log.info("修改家校部门完成");
this.remoteUserDeptService.updateBatchUserDept(saveDeptList);
}
/**
@@ -569,7 +559,7 @@ public class QywxServiceImpl implements QywxService {
log.info("params:{},{},{}", deptWxId, -school.getDeptId(), userDept);
if (userDept != null) {
// 未在其他删除回调事件中被删除
remoteUserDeptService.deleteUserDeptRecur(
this.remoteUserDeptService.deleteUserDeptRecur(
DeleteUserDeptDTO.builder()
.deptIdList(Collections.singletonList(userDept.getDeptId()))
.school(school)
@@ -602,20 +592,14 @@ public class QywxServiceImpl implements QywxService {
*/
@Override
public void updateDept(String deptId, String deptName, String parentId, Long schoolId) {
Dept dept = deptService.getSysDeptByDeptAndWx(Collections.singletonList(schoolId), Long.valueOf(deptId));
Dept dept = deptService.getSysDeptByDeptAndWx(Arrays.asList(schoolId), Long.valueOf(deptId));
dept.setDeptName(deptName);
// 部门类型
dept.setDeptType(DeptTypeEnum.DEPARTMENT_TYPE.getValue());
dept.setWxId(Long.valueOf(deptId));
if (StrUtil.isNotBlank(parentId)) {
Dept parent;
Long parentWxId = Long.valueOf(parentId);
if (parentWxId == 1L) {
parent = deptService.getById(schoolId);
} else {
parent = deptService.getSysDeptByDeptAndWx(Collections.singletonList(schoolId), parentWxId);
}
dept.setParentWxId(parentWxId);
if (parentId != null) {
Dept parent = deptService.getSysDeptByDeptAndWx(Arrays.asList(schoolId), Long.valueOf(parentId));
dept.setParentWxId(Long.valueOf(parentId));
dept.setParentId(parent.getDeptId());
dept.setAreaId(parent.getAreaId());
}
@@ -685,7 +669,7 @@ public class QywxServiceImpl implements QywxService {
log.info("学生所属部门,student:{},deptId:{},wxId:{}", student, Objects.requireNonNull(dept).getDeptId(), deptWxId);
EduStudent eduStudent = new EduStudent();
// eduStudent.setType(0);
eduStudent.setType(0);
eduStudent.setStuName(student.get("name").toString());
// 班级信息
eduStudent.setClassId(dept.getDeptId());
@@ -825,88 +809,6 @@ public class QywxServiceImpl implements QywxService {
remoteTeacherService.saveStaffBySchoolAndWx(eduStaff);
}
// /**
// * 响应更新企业用户事件
// */
// @Override
// public void updateUser(String name, String wxId, String phone, String email,
// String gender, String avatar, String department, String isLeader,
// String mainDepartment, Dept school) {
// EduStaff eduStaff = new EduStaff();
// if (StrUtil.isNotBlank(phone)) {
// SystemUser user = userService.findByName(phone);
// if (user == null) {
// user = new SystemUser();
// user.setAvatar(avatar);
// user.setMobile(phone);
// user.setEmail(email);
// user.setUsername(StrUtil.isNotBlank(phone) ? phone : email);
// user.setNickname(name);
// user.setDeptId(school.getDeptId());
// user.setStatus("1");
// user.setSex("1".equals(gender) ? "0" : "2".equals(gender) ? "1" : "2");
// user.setUserOrigin(0);
// user.setTeacherWxId(wxId);
// user.setUserType(1);
// userService.createUser(user);
// eduStaff.setYidaAppUserId(user.getYidaAppUserId());
// }
// eduStaff.setSysUserId(user.getUserId());
// } else {
// SystemUser user =
// userService.getOne(Wrappers.lambdaQuery(new SystemUser()).eq(SystemUser::getTeacherWxId
// , wxId).eq(SystemUser::getDeptId, school.getDeptId()));
// if (user == null) {
// user = new SystemUser();
// user.setAvatar(avatar);
// user.setMobile(phone);
// user.setEmail(email);
// user.setUsername(StrUtil.isNotBlank(phone) ? phone : email);
// user.setNickname(name);
// user.setDeptId(school.getDeptId());
// user.setStatus("1");
// user.setSex("1".equals(gender) ? "0" : "2".equals(gender) ? "1" : "2");
// user.setUserOrigin(0);
// user.setTeacherWxId(wxId);
// user.setUserType(1);
// userService.createUser(user);
// eduStaff.setYidaAppUserId(user.getYidaAppUserId());
// }
// eduStaff.setSysUserId(user.getUserId());
// }
// eduStaff.setWxId(wxId);
// eduStaff.setMobile(phone);
// eduStaff.setName(name);
// eduStaff.setAvatar(avatar);
// eduStaff.setSchoolId(school.getDeptId());
// eduStaff.setSchoolName(school.getDeptName());
// eduStaff.setSex("1".equals(gender) ? "0" : "2".equals(gender) ? "1" : "2");
//
// // 成员部门信息
// String[] departmentList = StrUtil.split(department, ",");
// String[] isLeaderList = StrUtil.split(isLeader, ",");
// if (ArrayUtil.isNotEmpty(departmentList)) {
// List<EduStaffDept> staffDeptList = new ArrayList<>();
// for (int i = 0; i < departmentList.length; i++) {
// // 成员的每个部门信息
// EduStaffDept staffDept = new EduStaffDept();
// staffDept.setStaffName(eduStaff.getName());
// staffDept.setDeptWxId(Long.valueOf(departmentList[i]));
// Dept sysDept = ("1".equals(departmentList[i])
// ? school
// : deptService.getSysDeptByDeptAndWx(Arrays.asList(school.getDeptId()), staffDept.getDeptWxId()));
// staffDept.setDeptId(sysDept.getDeptId());
// staffDept.setDeptName(sysDept.getDeptName());
// staffDept.setIsLeader(Integer.valueOf(isLeaderList[i]));
// staffDept.setIsMain(ObjectUtil.equal(mainDepartment,
// departmentList[i]) ? 0 : 1);
// staffDeptList.add(staffDept);
// }
// eduStaff.setStaffDept(staffDeptList);
// }
// remoteTeacherService.saveStaffBySchoolAndWx(eduStaff);
// }
/**
* 响应更新企业用户事件
*/
@@ -914,12 +816,9 @@ public class QywxServiceImpl implements QywxService {
public void updateUser(String name, String wxId, String phone, String email,
String gender, String avatar, String department, String isLeader,
String mainDepartment, Dept school) {
EduStaff eduStaff = remoteStaffService.getStaffByWxOrMobileOrOpenId(wxId, null, null, school.getDeptId()).getData();
if (Objects.isNull(eduStaff)) {
eduStaff = new EduStaff();
}
EduStaff eduStaff = new EduStaff();
if (StrUtil.isNotBlank(phone)) {
SystemUser user = userService.findByMobile(phone);
SystemUser user = userService.findByName(phone);
if (user == null) {
user = new SystemUser();
user.setAvatar(avatar);
@@ -935,14 +834,12 @@ public class QywxServiceImpl implements QywxService {
user.setUserType(1);
userService.createUser(user);
eduStaff.setYidaAppUserId(user.getYidaAppUserId());
eduStaff.setSysUserId(user.getUserId());
}
eduStaff.setMobile(phone);
eduStaff.setSysUserId(user.getUserId());
} else {
SystemUser user = null;
if (Objects.nonNull(eduStaff.getId())) {
user = userService.getById(eduStaff.getSysUserId());
}
SystemUser user =
userService.getOne(Wrappers.lambdaQuery(new SystemUser()).eq(SystemUser::getTeacherWxId
, wxId).eq(SystemUser::getDeptId, school.getDeptId()));
if (user == null) {
user = new SystemUser();
user.setAvatar(avatar);
@@ -958,21 +855,16 @@ public class QywxServiceImpl implements QywxService {
user.setUserType(1);
userService.createUser(user);
eduStaff.setYidaAppUserId(user.getYidaAppUserId());
eduStaff.setSysUserId(user.getUserId());
}
eduStaff.setSysUserId(user.getUserId());
}
eduStaff.setWxId(wxId);
if (StrUtil.isNotBlank(name)) {
eduStaff.setName(name);
}
if (StrUtil.isNotBlank(avatar)) {
eduStaff.setAvatar(avatar);
}
eduStaff.setMobile(phone);
eduStaff.setName(name);
eduStaff.setAvatar(avatar);
eduStaff.setSchoolId(school.getDeptId());
eduStaff.setSchoolName(school.getDeptName());
if (StrUtil.isNotBlank(gender)) {
eduStaff.setSex("1".equals(gender) ? "0" : "2".equals(gender) ? "1" : "2");
}
eduStaff.setSex("1".equals(gender) ? "0" : "2".equals(gender) ? "1" : "2");
// 成员部门信息
String[] departmentList = StrUtil.split(department, ",");
@@ -1017,7 +909,7 @@ public class QywxServiceImpl implements QywxService {
*/
@Override
public void sendParentSubscribeMessage(String parentId, Long schoolId) {
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.INDEX_PARENT, null, schoolId);
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.SCORE_PARENT, null, schoolId);
// 创建发送通知实体类
TextSchoolNotice textSchoolNotice = new TextSchoolNotice();
// 传入被通知的家长id
@@ -1041,47 +933,4 @@ public class QywxServiceImpl implements QywxService {
log.error("家长关注发送通知方法失败, 当前学校-->{} 没有默认消息数据: ", schoolId);
}
}
@Override
public void updateUserInfo(String userId, Dept school, EduApp app) {
// 查询用户详细信息
JSONObject userDetail = wxUtil.getUserDetail(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()), userId);
// 查询职工数据
EduStaff eduStaff = remoteStaffService.getStaffByWxOrMobileOrOpenId(userId, null, null, school.getDeptId()).getData();
if (Objects.isNull(eduStaff)) {
log.error("职工信息错误, userId: {}, schoolId: {}", userId, school.getDeptId());
return;
}
String name = userDetail.getStr("name");
eduStaff.setName(name);
// 职位
eduStaff.setPosition(userDetail.getStr("position"));
// 成员部门信息
JSONArray departmentList = userDetail.getJSONArray("department");
JSONArray leaderInDept = userDetail.getJSONArray("is_leader_in_dept");
// 主部门信息
String mainDepartment = userDetail.getStr("main_department");
if (ArrayUtil.isNotEmpty(departmentList)) {
List<EduStaffDept> staffDeptList = new ArrayList<>();
for (int i = 0; i < departmentList.size(); i++) {
// 部门id
String deptId = String.valueOf(departmentList.get(i));
// 成员的每个部门信息
EduStaffDept staffDept = new EduStaffDept();
staffDept.setStaffName(eduStaff.getName());
staffDept.setDeptWxId(Long.valueOf(deptId));
Dept sysDept = ("1".equals(deptId)
? school
: deptService.getSysDeptByDeptAndWx(Collections.singletonList(school.getDeptId()), staffDept.getDeptWxId()));
staffDept.setDeptId(sysDept.getDeptId());
staffDept.setDeptName(sysDept.getDeptName());
staffDept.setIsLeader(Integer.valueOf(String.valueOf(leaderInDept.get(i))));
staffDept.setIsMain(ObjectUtil.equal(mainDepartment, deptId) ? 0 : 1);
staffDeptList.add(staffDept);
}
eduStaff.setStaffDept(staffDeptList);
}
remoteTeacherService.saveStaffBySchoolAndWx(eduStaff);
}
}
@@ -69,7 +69,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
} else {
// 查询下级部门信息
List<Long> childIdList = this.deptService.findListByParent(Collections.singletonList(currentUser.getDeptId()), 0)
.stream().map(Dept::getDeptId).collect(Collectors.toList());
.stream().map(Dept::getDeptId).collect(Collectors.toList());
// 查询自己创建的角色+当前登陆账号部门以下的角色
return this.baseMapper.findRoleCheckPage(page, role, childIdList, currentUser);
}
@@ -90,7 +90,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
if (!RoleEnum.ROLE_ADMIN.equals(roleEnum)) {
// 查询下级部门信息
List<Long> childIdList = this.deptService.findListByParent(Collections.singletonList(currentUser.getDeptId()), 0)
.stream().map(Dept::getDeptId).collect(Collectors.toList());
.stream().map(Dept::getDeptId).collect(Collectors.toList());
// 学校、教育局、代理商及以下具有创建账号的数据 自己创建的角色+当前登陆账号部门以下的角色
if (CollectionUtils.isNotEmpty(childIdList)) {
queryWrapper.in(Role::getCreateDeptId, childIdList).or();
@@ -142,9 +142,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
String[] menuIds = StringUtils.splitByWholeSeparatorPreserveAllTokens(role.getMenuIds(), StringConstant.COMMA);
setRoleMenus(role, menuIds);
}
//TODO 变更用户对应菜单权限
}
@Override
@@ -1,28 +1,21 @@
package com.yida.data.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.common.core.entity.system.Menu;
import com.yida.data.common.core.entity.system.SystemUser;
import com.yida.data.common.core.entity.system.SystemUserMenu;
import com.yida.data.common.core.enums.system.MenuShowType;
import com.yida.data.system.dto.MenuForUserDTO;
import com.yida.data.system.mapper.MenuMapper;
import com.yida.data.system.mapper.SystemUserMenuMapper;
import com.yida.data.system.mapper.UserMapper;
import com.yida.data.system.service.IMenuService;
import com.yida.data.system.service.SystemUserMenuService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @author ccl
*/
@@ -30,43 +23,18 @@ import org.springframework.transaction.annotation.Transactional;
@Service("systemUserMenuService")
@RequiredArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class SystemUserMenuServiceImpl extends ServiceImpl<SystemUserMenuMapper, SystemUserMenu> implements
SystemUserMenuService {
public class SystemUserMenuServiceImpl extends ServiceImpl<SystemUserMenuMapper, SystemUserMenu> implements SystemUserMenuService {
@Resource
private IMenuService menuService;
private final UserMapper userMapper;
private final MenuMapper menuMapper;
@Override
public void saveUserMenu(MenuForUserDTO dto) {
// 查询用户信息
SystemUser systemUser = userMapper.selectById(dto.getUserId());
// 查询用户角色权限信息
List<Menu> menuList = menuMapper.findUserPermissions(systemUser.getUsername());
// 用户角色权限id信息
List<Long> roleMenuIds = menuList.stream().map(Menu::getMenuId).collect(Collectors.toList());
Collection<Long> all = CollUtil.unionAll(roleMenuIds, dto.getMenuId());
// 需要添加的
List<Long> addMenuIds = all.stream().filter(x -> !roleMenuIds.contains(x)).collect(Collectors.toList());
// 需要删除的
List<Long> removeMenuIds = all.stream().filter(x -> !dto.getMenuId().contains(x)).collect(Collectors.toList());
// 保存数据
List<SystemUserMenu> menus = new ArrayList<>();
for (Long menuId : addMenuIds) {
for (Long menuId : dto.getMenuId()) {
SystemUserMenu systemUserMenu = new SystemUserMenu();
systemUserMenu.setMenuId(menuId);
systemUserMenu.setUserId(dto.getUserId());
systemUserMenu.setType(MenuShowType.ADD_TYPE.getType());
menus.add(systemUserMenu);
}
for (Long menuId : removeMenuIds) {
SystemUserMenu systemUserMenu = new SystemUserMenu();
systemUserMenu.setMenuId(menuId);
systemUserMenu.setUserId(dto.getUserId());
systemUserMenu.setType(MenuShowType.REMOVE_TYPE.getType());
menus.add(systemUserMenu);
}
saveBatch(menus);
@@ -75,23 +43,18 @@ public class SystemUserMenuServiceImpl extends ServiceImpl<SystemUserMenuMapper,
@Override
public void updateUserMenu(MenuForUserDTO dto) {
remove(Wrappers.lambdaQuery(new SystemUserMenu())
.eq(SystemUserMenu::getUserId, dto.getUserId()));
.eq(SystemUserMenu::getUserId, dto.getUserId()));
saveUserMenu(dto);
}
@Override
public List<Long> findUserMenu(Long userId) {
SystemUser systemUser = userMapper.selectById(userId);
List<Long> menuIds = menuMapper.findUserPermissions(systemUser.getUsername()).stream().map(Menu::getMenuId)
.collect(Collectors.toList());
List<SystemUserMenu> userMenuList = list(
Wrappers.lambdaQuery(new SystemUserMenu()).eq(SystemUserMenu::getUserId, userId));
for (Long excludeMenuId : userMenuList.stream().filter(x -> x.getType() == 1).map(SystemUserMenu::getMenuId)
.collect(Collectors.toList())) {
menuIds.remove(excludeMenuId);
List<SystemUserMenu> userMenuList = list(Wrappers.lambdaQuery(new SystemUserMenu())
.eq(SystemUserMenu::getUserId, userId));
List<Long> menuIds = new ArrayList<>();
for (SystemUserMenu systemUserMenu : userMenuList) {
menuIds.add(systemUserMenu.getMenuId());
}
menuIds.addAll(
userMenuList.stream().filter(x -> x.getType() == 0).map(SystemUserMenu::getMenuId).collect(Collectors.toList()));
return menuIds;
}
}
@@ -3,10 +3,7 @@ package com.yida.data.system.service.impl;
import cc.mrbird.febs.common.redis.service.RedisService;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -19,18 +16,14 @@ import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.common.ResultMsgType;
import com.yida.data.common.core.entity.CurrentUser;
import com.yida.data.common.core.entity.QueryRequest;
import com.yida.data.common.core.entity.constant.AppConstant;
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
import com.yida.data.common.core.entity.constant.FebsConstant;
import com.yida.data.common.core.entity.constant.StringConstant;
import com.yida.data.common.core.entity.school.EduYidaAppAccount;
import com.yida.data.common.core.entity.system.*;
import com.yida.data.common.core.entity.system.enums.RoleEnum;
import com.yida.data.common.core.entity.user.EduStaff;
import com.yida.data.common.core.entity.user.EduStaffDept;
import com.yida.data.common.core.exception.FebsException;
import com.yida.data.common.core.utils.*;
import com.yida.data.common.service.CommonService;
import com.yida.data.rabbit.util.RabbitUtil;
import com.yida.data.system.dto.MenuForUserDTO;
import com.yida.data.system.dto.SchoolAdminAccountSaveDTO;
@@ -40,8 +33,6 @@ import com.yida.data.system.mapper.RoleMapper;
import com.yida.data.system.mapper.UserMapper;
import com.yida.data.system.service.*;
import com.yida.data.system.vo.SchoolAdminAccountSelectPageVO;
import com.yida.data.user.feign.RemoteStaffService;
import com.yida.data.user.feign.RemoteTeacherService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -69,20 +60,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, SystemUser> impleme
private final IUserRoleService userRoleService;
private final IUserDataPermissionService userDataPermissionService;
private final PasswordEncoder passwordEncoder;
private final RemoteAuthService remoteAuthService;
private final IRoleService roleService;
private final RedisService redisService;
private final EduAppAccountService eduAppAccountService;
private final EduYidaAppMapper eduYidaAppMapper;
private final RemoteAuthService remoteAuthService;
private final RemoteStaffService remoteStaffService;
private final RemoteTeacherService remoteTeacherService;
private final WxUtil wxUtil;
private final RabbitUtil rabbitUtil;
private final RedisService redisService;
private final CommonService commonService;
private final static String AUTH_CLIENT_ID = "febs";
@Lazy
@Resource
@@ -93,11 +77,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, SystemUser> impleme
return this.baseMapper.findUserByUsername(username);
}
@Override
public SystemUser findByMobile(String mobile) {
return baseMapper.findUserByMobile(mobile);
}
@Override
public IPage<SystemUser> findUserDetailList(SystemUser user, QueryRequest request) {
Page<SystemUser> page = new Page<>(request.getPageNum(), request.getPageSize());
@@ -231,18 +210,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, SystemUser> impleme
if (ArrayUtil.isNotEmpty(deptIds)) {
setUserDataPermissions(user, deptIds);
}
// // 保存用户对应菜单
// String[] roles = StringUtils.splitByWholeSeparatorPreserveAllTokens(user.getRoleId(), StringConstant.COMMA);
// List<String> list = Arrays.asList(roles);
// List<Long> menuId = baseMapper.findRoleId(list);
// List<SystemUserMenu> userMenuList = new ArrayList<>();
// for (Long aLong : menuId) {
// SystemUserMenu systemUserMenu = new SystemUserMenu();
// systemUserMenu.setUserId(user.getUserId());
// systemUserMenu.setMenuId(aLong);
// userMenuList.add(systemUserMenu);
// }
// systemUserMenuService.saveBatch(userMenuList);
// 保存用户对应菜单
String[] roles = StringUtils.splitByWholeSeparatorPreserveAllTokens(user.getRoleId(), StringConstant.COMMA);
List<String> list = Arrays.asList(roles);
List<Long> menuId = baseMapper.findRoleId(list);
List<SystemUserMenu> userMenuList = new ArrayList<>();
for (Long aLong : menuId) {
SystemUserMenu systemUserMenu = new SystemUserMenu();
systemUserMenu.setUserId(user.getUserId());
systemUserMenu.setMenuId(aLong);
userMenuList.add(systemUserMenu);
}
systemUserMenuService.saveBatch(userMenuList);
return user;
}
@@ -280,16 +259,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, SystemUser> impleme
// 删除用户对应权限数据
systemUserMenuService.remove(Wrappers.lambdaQuery(new SystemUserMenu())
.in(SystemUserMenu::getUserId, user.getUserId()));
// // 保存用户对应权限数据
// List<Long> menuId = baseMapper.findRoleId(Arrays.asList(roles));
// List<SystemUserMenu> userMenuList = new ArrayList<>();
// for (Long aLong : menuId) {
// SystemUserMenu systemUserMenu = new SystemUserMenu();
// systemUserMenu.setUserId(user.getUserId());
// systemUserMenu.setMenuId(aLong);
// userMenuList.add(systemUserMenu);
// }
// systemUserMenuService.saveBatch(userMenuList);
// 保存用户对应权限数据
List<Long> menuId = baseMapper.findRoleId(Arrays.asList(roles));
List<SystemUserMenu> userMenuList = new ArrayList<>();
for (Long aLong : menuId) {
SystemUserMenu systemUserMenu = new SystemUserMenu();
systemUserMenu.setUserId(user.getUserId());
systemUserMenu.setMenuId(aLong);
userMenuList.add(systemUserMenu);
}
systemUserMenuService.saveBatch(userMenuList);
}
@Override
@@ -536,104 +515,5 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, SystemUser> impleme
userRoleService.saveBatch(saveList);
}
}
@Override
public void createStaff(Long schoolId, String code) {
// 学校信息
Dept school = deptService.getById(schoolId);
// 此处获取对应学校通讯录(人力资源)应用
EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT_SELECT, null, schoolId);
// 获取access token
String accessToken = wxUtil.getAccessToken(school.getCorpId(), app.getWxSecret());
// 获取访问用户身份
JSONObject userInfo = wxUtil.getUserInfo(accessToken, code);
// 获取访问用户敏感信息
JSONObject sensitiveInfo = wxUtil.getUserSensitiveInfo(accessToken, userInfo.getStr("user_ticket"));
String mobile = sensitiveInfo.getStr("mobile");
if (StrUtil.isEmpty(mobile)) {
throw new FebsException("请授权手机号码!");
}
// 成员UserID
String userId = sensitiveInfo.getStr("userid");
// 查询用户详细信息
JSONObject userDetail = wxUtil.getUserDetail(wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret()), userId);
String name = userDetail.getStr("name");
String avatar = sensitiveInfo.getStr("avatar");
String email = sensitiveInfo.getStr("email");
// 企业微信性别 0表示未定义,1表示男性,2表示女性
String gender = sensitiveInfo.getStr("gender");
// 主部门信息
String mainDepartment = userDetail.getStr("main_department");
// 查询是否有职工数据
// EduStaff eduStaff = remoteStaffService.getStaffByWxOrMobileOrOpenId(userId, null, null, school.getDeptId()).getData();
EduStaff eduStaff = remoteStaffService.getStaffByWxOrMobileOrOpenId(null, mobile, null, school.getDeptId()).getData();
if (Objects.isNull(eduStaff)) {
eduStaff = new EduStaff();
eduStaff.setName(name);
eduStaff.setMobile(mobile);
eduStaff.setAvatar(avatar);
eduStaff.setEmail(email);
eduStaff.setSex("1".equals(gender) ? "0" : "2".equals(gender) ? "1" : "2");
eduStaff.setWxId(userId);
eduStaff.setSchoolId(school.getDeptId());
eduStaff.setSchoolName(school.getDeptName());
eduStaff.setPosition(userDetail.getStr("position"));
} else {
// 修改不创建到企业微信的职工数据
if (eduStaff.getWxPath() == 1) {
// 修改手机号码、用户id
eduStaff.setWxId(userId);
eduStaff.setWxPath(0);
}
}
// 判断是否存在登录用户信息
SystemUser user = findUserDetail(mobile);
if (user == null) {
user = new SystemUser();
user.setAvatar(avatar);
user.setMobile(mobile);
user.setEmail(email);
user.setUsername(mobile);
user.setNickname(name);
user.setDeptId(school.getDeptId());
user.setStatus("1");
// 用户性别 0男, 1女, 2保密
user.setSex("1".equals(gender) ? "0" : "2".equals(gender) ? "1" : "2");
user.setUserOrigin(0);
user.setUserType(1);
createUser(user);
eduStaff.setYidaAppUserId(user.getYidaAppUserId());
eduStaff.setSysUserId(user.getUserId());
} else {
eduStaff.setSysUserId(user.getUserId());
}
// 成员部门信息
JSONArray departmentList = userDetail.getJSONArray("department");
JSONArray leaderInDept = userDetail.getJSONArray("is_leader_in_dept");
if (ArrayUtil.isNotEmpty(departmentList)) {
List<EduStaffDept> staffDeptList = new ArrayList<>();
for (int i = 0; i < departmentList.size(); i++) {
// 部门id
String deptId = String.valueOf(departmentList.get(i));
// 成员的每个部门信息
EduStaffDept staffDept = new EduStaffDept();
staffDept.setStaffName(eduStaff.getName());
staffDept.setDeptWxId(Long.valueOf(deptId));
Dept sysDept = ("1".equals(deptId)
? school
: deptService.getSysDeptByDeptAndWx(Collections.singletonList(school.getDeptId()), staffDept.getDeptWxId()));
staffDept.setDeptId(sysDept.getDeptId());
staffDept.setDeptName(sysDept.getDeptName());
staffDept.setIsLeader(Integer.valueOf(String.valueOf(leaderInDept.get(i))));
staffDept.setIsMain(ObjectUtil.equal(mainDepartment, deptId) ? 0 : 1);
staffDeptList.add(staffDept);
}
eduStaff.setStaffDept(staffDeptList);
}
remoteTeacherService.saveStaffBySchoolAndWx(eduStaff);
}
}
@@ -2,259 +2,277 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yida.data.system.mapper.DeptSchoolInformationMapper">
<select id="findSchoolListByDeptId" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_id,
a.school_name,
a.school_type,
a.school_profit_nature,
a.school_ownership,
a.logo_url,
a.phone,
a.introduction,
a.shunt_situation,
a.address,
a.zip_code,
a.email,
a.student_range,
GROUP_CONCAT(DISTINCT e.nature) as school_nature
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id
LEFT JOIN t_dept_school_student_range d ON a.id = d.dept_school_id
LEFT JOIN t_dept_school_label c on c.dept_school_id = a.id
LEFT JOIN t_dept_school_information_nature e on a.id = e.information_id
WHERE
b.del_flag = 0
<if test="tag !=null and tag !=''">
and c.label = #{tag}
</if>
<if test="deptId != null">
AND b.dept_id = #{deptId}
</if>
<select id="findSchoolListByDeptId" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_id,
a.school_name,
a.school_type,
a.school_profit_nature,
a.school_ownership,
a.logo_url,
a.phone,
a.introduction,
a.shunt_situation,
a.address,
a.zip_code,
a.email,
a.student_range,
GROUP_CONCAT(DISTINCT e.nature) as school_nature
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id
LEFT JOIN t_dept_school_student_range d ON a.id = d.dept_school_id
LEFT JOIN t_dept_school_label c on c.dept_school_id = a.id
LEFT JOIN t_dept_school_information_nature e on a.id = e.information_id
WHERE
b.del_flag = 0
<if test="tag !=null and tag !=''">
and c.label = #{tag}
</if>
<if test="deptId != null">
AND b.dept_id = #{deptId}
</if>
<if test="address != null and address != ''">
and a.address like concat ('%',#{address},'%')
</if>
<if test="schoolType != null">
AND a.school_type = #{schoolType}
</if>
<if test="schoolType == 1 and natureType != null">
and e.nature = #{natureType}
</if>
<if test="schoolOwnership != null">
and a.school_ownership =#{schoolOwnership}
</if>
<if test="schoolName != null and schoolName != ''">
AND a.school_name LIKE CONCAT('%',#{schoolName},'%')
</if>
GROUP BY a.id
order by a.id
<if test="address != null and address != ''">
and a.address like concat ('%',#{address},'%')
</if>
<if test="schoolType != null">
AND a.school_type = #{schoolType}
</if>
<if test="schoolType == 1 and natureType != null">
and e.nature = #{natureType}
</if>
<if test="schoolOwnership != null">
and a.school_ownership =#{schoolOwnership}
</if>
<if test="schoolName != null and schoolName != ''">
AND a.school_name LIKE CONCAT('%',#{schoolName},'%')
</if>
GROUP BY a.id
order by a.id
</select>
<select id="findSchoolPageList" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_id,
a.school_name,
a.school_type,
a.school_profit_nature,
a.school_ownership,
a.phone,
a.introduction,
a.lng,
a.lat,
a.logo_url,
a.shunt_situation,
a.address,
f.icon,
GROUP_CONCAT(DISTINCT d.address) as student_range,
GROUP_CONCAT(DISTINCT e.nature) as school_nature
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id
LEFT JOIN t_dept_school_label c ON a.id = c.dept_school_id
LEFT JOIN t_dept_school_student_range d ON a.id = d.dept_school_id
LEFT JOIN t_dept_school_information_nature e on a.id = e.information_id
LEFT JOIN t_dept f on a.school_id = f.DEPT_ID
WHERE
b.del_flag = 0
<if test="deptId !=null">
and b.dept_id = #{deptId}
</if>
<if test="deptSchoolId != null and deptSchoolId.size>0">
and c.dept_school_id in
<foreach collection="deptSchoolId" separator="," close=")" open="(" item="item">
#{item}
</foreach>
</if>
<if test="schoolType != null and schoolType.size>0">
AND a.school_type in
<foreach collection="schoolType" separator="," close=")" open="(" item="item">
#{item}
</foreach>
</if>
<if test="natureType !=null and natureType.size > 0">
AND e.nature in
<foreach collection="natureType" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="schoolOwnership !=null and schoolOwnership.size>0">
and a.school_ownership in
<foreach collection="schoolOwnership" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="findSchoolPageList" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_id,
a.school_name,
a.school_type,
a.school_profit_nature,
a.school_ownership,
a.phone,
a.introduction,
a.lng,
a.lat,
a.logo_url,
a.shunt_situation,
a.address,
f.icon,
GROUP_CONCAT(DISTINCT d.address) as student_range,
GROUP_CONCAT(DISTINCT e.nature) as school_nature
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id
LEFT JOIN t_dept_school_label c ON a.id = c.dept_school_id
LEFT JOIN t_dept_school_student_range d ON a.id = d.dept_school_id
LEFT JOIN t_dept_school_information_nature e on a.id = e.information_id
LEFT JOIN t_dept f on a.school_id = f.DEPT_ID
WHERE
b.del_flag = 0
<if test="deptId !=null">
and b.dept_id = #{deptId}
</if>
<if test="deptSchoolId != null and deptSchoolId.size>0">
and c.dept_school_id in
<foreach collection="deptSchoolId" separator="," close=")" open="(" item="item">
#{item}
</foreach>
</if>
<if test="schoolType != null and schoolType.size>0">
AND a.school_type in
<foreach collection="schoolType" separator="," close=")" open="(" item="item">
#{item}
</foreach>
</if>
<if test="natureType !=null and natureType.size > 0">
AND e.nature in
<foreach collection="natureType" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="schoolOwnership !=null and schoolOwnership.size>0">
and a.school_ownership in
<foreach collection="schoolOwnership" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="schoolName != null">
AND a.school_name LIKE CONCAT('%',#{schoolName},'%')
</if>
GROUP BY a.id
<if test="schoolName != null">
AND a.school_name LIKE CONCAT('%',#{schoolName},'%')
</if>
GROUP BY a.id
<!-- union-->
<!-- union-->
<!-- SELECT distinct-->
<!-- a.id,-->
<!-- a.school_id,-->
<!-- a.school_name,-->
<!-- a.school_type,-->
<!-- a.school_education_nature,-->
<!-- a.school_ownership,-->
<!-- a.phone,-->
<!-- a.introduction,-->
<!-- a.lng,-->
<!-- a.lat,-->
<!-- a.logo_url,-->
<!-- a.shunt_situation,-->
<!-- a.address,-->
<!-- GROUP_CONCAT(DISTINCT d.address) as student_range-->
<!-- FROM-->
<!-- `t_dept_school_information` a-->
<!-- LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id-->
<!-- LEFT JOIN t_dept_school_label c ON a.id = c.dept_school_id-->
<!-- LEFT JOIN t_dept_school_student_range d ON a.id = d.dept_school_id-->
<!-- WHERE-->
<!-- b.del_flag = 0-->
<!-- <if test="deptId !=null">-->
<!-- and b.dept_id = #{deptId}-->
<!-- </if>-->
<!-- <if test="deptSchoolId != null and deptSchoolId.size>0">-->
<!-- and c.dept_school_id in-->
<!-- <foreach collection="deptSchoolId" separator="," close=")" open="(" item="item">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="schoolType != null and schoolType.size>0">-->
<!-- AND a.school_type in-->
<!-- <foreach collection="schoolType" separator="," close=")" open="(" item="item">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- SELECT distinct-->
<!-- a.id,-->
<!-- a.school_id,-->
<!-- a.school_name,-->
<!-- a.school_type,-->
<!-- a.school_education_nature,-->
<!-- a.school_ownership,-->
<!-- a.phone,-->
<!-- a.introduction,-->
<!-- a.lng,-->
<!-- a.lat,-->
<!-- a.logo_url,-->
<!-- a.shunt_situation,-->
<!-- a.address,-->
<!-- GROUP_CONCAT(DISTINCT d.address) as student_range-->
<!-- FROM-->
<!-- `t_dept_school_information` a-->
<!-- LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id-->
<!-- LEFT JOIN t_dept_school_label c ON a.id = c.dept_school_id-->
<!-- LEFT JOIN t_dept_school_student_range d ON a.id = d.dept_school_id-->
<!-- WHERE-->
<!-- b.del_flag = 0-->
<!-- <if test="deptId !=null">-->
<!-- and b.dept_id = #{deptId}-->
<!-- </if>-->
<!-- <if test="deptSchoolId != null and deptSchoolId.size>0">-->
<!-- and c.dept_school_id in-->
<!-- <foreach collection="deptSchoolId" separator="," close=")" open="(" item="item">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="schoolType != null and schoolType.size>0">-->
<!-- AND a.school_type in-->
<!-- <foreach collection="schoolType" separator="," close=")" open="(" item="item">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="natureType !=null and natureType.size > 0">-->
<!-- AND a.school_education_nature in-->
<!-- <foreach collection="natureType" item="item" open="(" close=")" separator=",">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="natureType !=null and natureType.size > 0">-->
<!-- AND a.school_education_nature in-->
<!-- <foreach collection="natureType" item="item" open="(" close=")" separator=",">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="schoolOwnership !=null and schoolOwnership.size>0">-->
<!-- and a.school_ownership in-->
<!-- <foreach collection="schoolOwnership" item="item" open="(" close=")" separator=",">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="schoolName != null">-->
<!-- AND a.school_name LIKE CONCAT('%',#{schoolName},'%')-->
<!-- </if>-->
<!-- GROUP BY a.id-->
</select>
<select id="findSchoolByAddress" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_name,
a.school_type,
GROUP_CONCAT(DISTINCT d.nature) as school_nature,
a.school_ownership,
a.phone,
a.logo_url,
a.introduction,
a.shunt_situation,
a.address,
a.school_id
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_student_range b ON a.id = b.dept_school_id
LEFT JOIN t_dept_school_relate c ON a.school_id = c.school_id
left join t_dept_school_information_nature d on a.id = d.information_id
WHERE
1= 1
<if test="deptId != null">
and c.dept_id = #{deptId}
</if>
<!-- <if test="schoolOwnership !=null and schoolOwnership.size>0">-->
<!-- and a.school_ownership in-->
<!-- <foreach collection="schoolOwnership" item="item" open="(" close=")" separator=",">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="schoolName != null">-->
<!-- AND a.school_name LIKE CONCAT('%',#{schoolName},'%')-->
<!-- </if>-->
<!-- GROUP BY a.id-->
</select>
<select id="findSchoolByAddress" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_name,
a.school_type,
a.school_ownership,
a.phone,
a.logo_url,
a.introduction,
a.shunt_situation,
a.address,
a.school_id
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_student_range b ON a.id = b.dept_school_id
LEFT JOIN t_dept_school_relate c ON a.school_id = c.school_id
WHERE 1= 1
<if test="deptId != null">
and c.dept_id = #{deptId}
</if>
<if test="address != null and address != ''">
AND b.address LIKE CONCAT( '%', #{address}, '%' )
</if>
</select>
<select id="findDeptSchoolId" resultType="java.lang.Long">
SELECT
dept_school_id
FROM
t_dept_school_label
GROUP BY
dept_school_id
<if test="address != null and address != ''">
AND b.address LIKE CONCAT( '%', #{address}, '%' )
<if test="tags != null and tags.length>0">
HAVING
<foreach collection="tags" item="item" open="(" close=")" separator=" " index="index">
<if test="index != 0">
and
</if>
</select>
<select id="findDeptSchoolId" resultType="java.lang.Long">
SELECT
dept_school_id
FROM
t_dept_school_label
GROUP BY
dept_school_id
FIND_IN_SET(
#{item},
GROUP_CONCAT( label )
)
</foreach>
</if>
</select>
<!-- 根据名称和类型查询教育局学校列表 -->
<select id="listSchoolPage" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_id,
a.school_name,
a.school_type,
a.school_profit_nature,
a.school_ownership,
a.phone,
a.introduction,
a.lng,
a.lat,
a.logo_url,
a.shunt_situation,
a.address,
b.create_date,
f.icon
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id
LEFT JOIN t_dept_school_information_nature e on a.id = e.information_id
LEFT JOIN t_dept f on a.school_id = f.DEPT_ID
WHERE
b.del_flag = 0
and b.dept_id = #{dto.deptId}
<if test="dto.natureType != null">
AND e.nature = #{dto.natureType}
</if>
<if test="dto.schoolName != null">
AND a.school_name LIKE CONCAT('%', #{dto.schoolName}, '%')
</if>
order by
b.create_date desc
</select>
<!-- 根据名称查询教育局缴费学校列表 -->
<select id="listPaySchool" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT
s.*
FROM
(
SELECT
b.school_id,
b.school_name
FROM
t_dept_school_relate a
INNER JOIN t_dept_school_information b ON a.school_id = b.school_id
WHERE
a.del_flag = 0
AND a.dept_id = #{deptId}
<if test="schoolName != null">
AND b.school_name LIKE CONCAT('%', #{schoolName}, '%')
</if>
) s
INNER JOIN edu_dept_pay_type t ON s.school_id = t.dept_id
</select>
<if test="tags != null and tags.length>0">
HAVING
<foreach collection="tags" item="item" open="(" close=")" separator=" " index="index">
<if test="index != 0">
and
</if>
FIND_IN_SET(
#{item},
GROUP_CONCAT( label )
)
</foreach>
</if>
</select>
<!-- 根据名称和类型查询教育局学校列表 -->
<select id="listSchoolPage" resultType="com.yida.data.system.dto.SchoolInformationDTO">
SELECT distinct
a.id,
a.school_id,
a.school_name,
a.school_type,
a.school_profit_nature,
a.school_ownership,
a.phone,
a.introduction,
a.lng,
a.lat,
a.logo_url,
a.shunt_situation,
a.address,
b.create_date,
f.icon
FROM
`t_dept_school_information` a
LEFT JOIN t_dept_school_relate b ON a.school_id = b.school_id
LEFT JOIN t_dept_school_information_nature e on a.id = e.information_id
LEFT JOIN t_dept f on a.school_id = f.DEPT_ID
WHERE
b.del_flag = 0
and b.dept_id = #{dto.deptId}
<if test="dto.natureType != null">
AND e.nature = #{dto.natureType}
</if>
<if test="dto.schoolName != null">
AND a.school_name LIKE CONCAT('%', #{dto.schoolName}, '%')
</if>
order by
b.create_date desc
</select>
</mapper>
@@ -2,57 +2,57 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yida.data.system.mapper.EduSchoolInquireCommonQuestionMapper">
<select id="findQuestionPage"
resultType="com.yida.data.common.core.entity.system.EduSchoolInquireCommonQuestion">
SELECT
a.*,
GROUP_CONCAT( c.label ) AS label
FROM
`edu_school_inquire_common_question` a
LEFT JOIN edu_school_inquire_common_question_label b ON a.id = b.question_id
LEFT JOIN edu_label c ON b.label_id = c.id
WHERE
a.dept_id = #{deptId}
AND a.del_flag = 0
<if test="labelId != null">
AND b.label_id = #{labelId}
</if>
<if test="question != null and question != ''">
and a.question like concat ('%',#{question},'%')
</if>
GROUP BY
a.id
ORDER BY a.create_date DESC
</select>
<select id="findPhonePage" resultType="com.yida.data.system.vo.FindPhonePageVO">
SELECT
a.id,
a.`name`,
a.phone,
c.school_name,
GROUP_CONCAT(DISTINCT f.nature) as school_type,
GROUP_CONCAT(e.label) as label
FROM
`edu_school_inquire_phone` a
LEFT JOIN edu_school_inquire_phone_label b ON a.id = b.phone_id
LEFT JOIN edu_label e ON b.label_id = e.id
LEFT JOIN t_dept d ON a.dept_id = d.DEPT_ID
LEFT JOIN t_dept_school_information c ON d.DEPT_ID = c.school_id
left join t_dept_school_information_nature f on c.id = f.information_id
WHERE
a.dept_id = #{deptId}
AND a.del_flag = 0
<if test="labelId != null">
AND b.label_id = #{labelId}
</if>
<if test="schoolName != null and schoolName != ''">
and d.DEPT_NAME like concat ('%',#{schoolName},'%')
</if>
GROUP BY a.id,
a.`name`,
a.phone,
c.id
ORDER BY
a.create_date DESC
</select>
<select id="findQuestionPage"
resultType="com.yida.data.common.core.entity.system.EduSchoolInquireCommonQuestion">
SELECT
a.*,
GROUP_CONCAT( c.label ) AS label
FROM
`edu_school_inquire_common_question` a
LEFT JOIN edu_school_inquire_common_question_label b ON a.id = b.question_id
LEFT JOIN edu_label c ON b.label_id = c.id
WHERE
a.dept_id = #{deptId}
AND a.del_flag = 0
<if test="labelId != null">
AND b.label_id = #{labelId}
</if>
<if test="question != null and question != ''">
and a.question like concat ('%',#{question},'%')
</if>
GROUP BY
a.id
ORDER BY a.create_date DESC
</select>
<select id="findPhonePage" resultType="com.yida.data.system.vo.FindPhonePageVO">
SELECT
a.id,
a.`name`,
a.phone,
c.school_name,
GROUP_CONCAT(DISTINCT f.nature) as school_type,
GROUP_CONCAT(e.label) as label
FROM
`edu_school_inquire_phone` a
LEFT JOIN edu_school_inquire_phone_label b ON a.id = b.phone_id
LEFT JOIN edu_label e ON b.label_id = e.id
LEFT JOIN t_dept d ON a.dept_id = d.DEPT_ID
LEFT JOIN t_dept_school_information c ON a.school_id = c.school_id
left join t_dept_school_information_nature f on c.id = f.information_id
WHERE
a.dept_id = #{deptId}
AND a.del_flag = 0
<if test="labelId != null">
AND b.label_id = #{labelId}
</if>
<if test="schoolName != null and schoolName != ''">
and d.DEPT_NAME like concat ('%',#{schoolName},'%')
</if>
GROUP BY a.id,
a.`name`,
a.phone,
c.id
ORDER BY
a.create_date DESC
</select>
</mapper>
@@ -1,61 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yida.data.system.mapper.MenuMapper">
<select id="findUserPermissions" resultType="com.yida.data.common.core.entity.system.Menu">
select distinct m.*
from t_role r
left join t_user_role ur on (r.role_id = ur.role_id)
left join t_user u on (u.user_id = ur.user_id)
left join t_role_menu rm on (rm.role_id = r.role_id)
left join t_menu m on (m.menu_id = rm.menu_id)
where u.username = #{userName}
and m.menu_id is not null
order by m.order_num
</select>
<select id="findUserPermissions" resultType="com.yida.data.common.core.entity.system.Menu">
select distinct
m.*
from t_role r
left join t_user_role ur on (r.role_id = ur.role_id)
left join t_user u on (u.user_id = ur.user_id)
left join t_role_menu rm on (rm.role_id = r.role_id)
left join t_menu m on (m.menu_id = rm.menu_id)
where u.username = #{userName}
</select>
<!-- 查询用户真实权限数据 -->
<select id="findUserRealMenus" resultType="com.yida.data.common.core.entity.system.Menu">
SELECT
m.*
FROM
t_menu m
LEFT JOIN (
SELECT DISTINCT
m.menu_id
FROM
t_user_menu m
LEFT JOIN t_user t ON m.user_id = t.USER_ID
WHERE
t.USERNAME = #{username}
) a ON m.MENU_ID = a.menu_id
where
a.menu_id IS NOT NULL
<if test='selectType != null'>
and m.type = #{selectType}
</if>
order by m.order_num
</select>
<!-- 查询用户真实权限数据 -->
<select id="findUserMenus" resultType="com.yida.data.common.core.entity.system.Menu">
SELECT
m.*,
a.type as user_menu_type
FROM
t_menu m
inner JOIN (
SELECT m.menu_id,m.type
FROM
t_user_menu m
LEFT JOIN t_user t ON m.user_id = t.USER_ID
WHERE
t.USERNAME = #{username}
) a ON m.MENU_ID = a.menu_id
where
a.menu_id IS NOT NULL
<if test='selectType != null'>
and m.type = #{selectType}
</if>
order by m.order_num
</select>
<!-- 查询用户真实权限数据 -->
<select id="findUserRealMenus" resultType="com.yida.data.common.core.entity.system.Menu">
SELECT
m.*
FROM
t_menu m
LEFT JOIN (
SELECT DISTINCT
m.menu_id
FROM
t_user_menu m
LEFT JOIN t_user t ON m.user_id = t.USER_ID
WHERE
t.USERNAME = #{username}
) a ON m.MENU_ID = a.menu_id
where
a.menu_id IS NOT NULL
<if test='selectType != null'>
and m.type = #{selectType}
</if>
order by m.order_num
</select>
</mapper>
@@ -121,14 +121,6 @@
group by a.USER_ID
</select>
<select id="findUserByMobile" resultType="com.yida.data.common.core.entity.system.SystemUser">
select a.*, group_concat(b.ROLE_ID) roleId
from t_user a
left join t_user_role b on a.USER_ID = b.USER_ID
where a.MOBILE=#{mobile}
group by a.USER_ID
</select>
<!-- 获取代理商管理员账号详情 -->
<select id="getAgentAdminAccountInfo"
resultType="com.yida.data.common.core.entity.system.SystemUser">
@@ -142,7 +134,7 @@
u.agent_id = #{agentId}
AND r.ROLE_PERMS = #{rolePerm}
</select>
<!-- 代理商查询学校管理员账号列表数据 -->
<select id="listSchoolAdminAccountPage"
resultType="com.yida.data.system.vo.SchoolAdminAccountSelectPageVO">
@@ -167,16 +159,16 @@
</select>
<select id="findRoleId" resultType="java.lang.Long">
SELECT DISTINCT
MENU_ID
MENU_ID
FROM
`t_role_menu`
`t_role_menu`
WHERE
ROLE_ID IN
ROLE_ID IN
<foreach collection="roles" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="findUserPage"
resultType="com.yida.data.common.core.entity.system.SystemUser">
SELECT
@@ -249,5 +241,5 @@
u.dept_id,u.last_login_time,u.modify_time,u.description,u.avatar
order by u.CREATE_TIME desc
</select>
</mapper>