mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-26 16:26:41 +08:00
2.1.3 大屏版本发布
This commit is contained in:
@ -22,8 +22,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
@EnableAutoConfiguration
|
||||
public class JeecgApplication {
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
//System.setProperty("spring.devtools.restart.enabled", "true");
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
//System.setProperty("spring.devtools.restart.enabled", "true");
|
||||
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
@ -34,22 +34,8 @@ public class JeecgApplication {
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
|
||||
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"swagger-ui: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* tomcat-embed-jasper引用后提示jar找不到的问题
|
||||
*/
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory tomcatFactory() {
|
||||
return new TomcatServletWebServerFactory() {
|
||||
@Override
|
||||
protected void postProcessContext(Context context) {
|
||||
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -66,6 +66,10 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put(url,"anon");
|
||||
}
|
||||
}
|
||||
//大屏请求排除
|
||||
filterChainDefinitionMap.put("/big/screen/**", "anon");
|
||||
filterChainDefinitionMap.put("/bigscreen/**", "anon");
|
||||
|
||||
//cas验证登录
|
||||
filterChainDefinitionMap.put("/cas/client/validateLogin", "anon");
|
||||
// 配置不会被拦截的链接 顺序判断
|
||||
@ -119,7 +123,7 @@ public class ShiroConfig {
|
||||
|
||||
//排除Online请求
|
||||
filterChainDefinitionMap.put("/auto/cgform/**", "anon");
|
||||
|
||||
|
||||
//websocket排除
|
||||
filterChainDefinitionMap.put("/websocket/**", "anon");
|
||||
|
||||
|
||||
@ -45,32 +45,20 @@ public class MybatisInterceptor implements Interceptor {
|
||||
return invocation.proceed();
|
||||
}
|
||||
if (SqlCommandType.INSERT == sqlCommandType) {
|
||||
LoginUser sysUser = this.getLoginUser();
|
||||
Field[] fields = oConvertUtils.getAllFields(parameter);
|
||||
for (Field field : fields) {
|
||||
log.debug("------field.name------" + field.getName());
|
||||
try {
|
||||
//update-begin--Author:scott Date:20190828 for:关于使用Quzrtz 开启线程任务, #465
|
||||
// 获取登录用户信息
|
||||
LoginUser sysUser = null;
|
||||
try{
|
||||
sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
}catch (Exception e){
|
||||
sysUser = null;
|
||||
}
|
||||
//update-end--Author:scott Date:20190828 for:关于使用Quzrtz 开启线程任务, #465
|
||||
if ("createBy".equals(field.getName())) {
|
||||
field.setAccessible(true);
|
||||
Object local_createBy = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (local_createBy == null || local_createBy.equals("")) {
|
||||
String createBy = "jeecg";
|
||||
if (sysUser != null) {
|
||||
// 登录账号
|
||||
createBy = sysUser.getUsername();
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(createBy)) {
|
||||
// 登录人账号
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, createBy);
|
||||
field.set(parameter, sysUser.getUsername());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
@ -92,15 +80,10 @@ public class MybatisInterceptor implements Interceptor {
|
||||
Object local_sysOrgCode = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (local_sysOrgCode == null || local_sysOrgCode.equals("")) {
|
||||
String sysOrgCode = "";
|
||||
// 获取登录用户信息
|
||||
if (sysUser != null) {
|
||||
// 登录账号
|
||||
sysOrgCode = sysUser.getOrgCode();
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(sysOrgCode)) {
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, sysOrgCode);
|
||||
field.set(parameter, sysUser.getOrgCode());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
@ -110,6 +93,7 @@ public class MybatisInterceptor implements Interceptor {
|
||||
}
|
||||
}
|
||||
if (SqlCommandType.UPDATE == sqlCommandType) {
|
||||
LoginUser sysUser = this.getLoginUser();
|
||||
Field[] fields = null;
|
||||
if (parameter instanceof ParamMap) {
|
||||
ParamMap<?> p = (ParamMap<?>) parameter;
|
||||
@ -137,12 +121,10 @@ public class MybatisInterceptor implements Interceptor {
|
||||
try {
|
||||
if ("updateBy".equals(field.getName())) {
|
||||
//获取登录用户信息
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if (sysUser != null) {
|
||||
// 登录账号
|
||||
String updateBy = sysUser.getUsername();
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, updateBy);
|
||||
field.set(parameter, sysUser.getUsername());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
@ -169,4 +151,17 @@ public class MybatisInterceptor implements Interceptor {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
//update-begin--Author:scott Date:20191213 for:关于使用Quzrtz 开启线程任务, #465
|
||||
private LoginUser getLoginUser() {
|
||||
LoginUser sysUser = null;
|
||||
try {
|
||||
sysUser = SecurityUtils.getSubject().getPrincipal() != null ? (LoginUser) SecurityUtils.getSubject().getPrincipal() : null;
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
sysUser = null;
|
||||
}
|
||||
return sysUser;
|
||||
}
|
||||
//update-end--Author:scott Date:20191213 for:关于使用Quzrtz 开启线程任务, #465
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
package org.jeecg.modules.demo.test.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 大屏预览入口
|
||||
* @Author: scott
|
||||
* @Date:2019-12-12
|
||||
* @Version:V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/big/screen")
|
||||
public class BigScreenController extends JeecgController<JeecgDemo, IJeecgDemoService> {
|
||||
|
||||
/**
|
||||
* @param modelAndView
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/html")
|
||||
public ModelAndView ftl(ModelAndView modelAndView) {
|
||||
modelAndView.setViewName("demo3");
|
||||
List<String> userList = new ArrayList<String>();
|
||||
userList.add("admin");
|
||||
userList.add("user1");
|
||||
userList.add("user2");
|
||||
log.info("--------------test--------------");
|
||||
modelAndView.addObject("userList", userList);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产销售监控模版
|
||||
* @param modelAndView
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/index1")
|
||||
public ModelAndView index1(ModelAndView modelAndView) {
|
||||
modelAndView.setViewName("/bigscreen/template1/index");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 智慧物流监控模版
|
||||
* @param modelAndView
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/index2")
|
||||
public ModelAndView index2(ModelAndView modelAndView) {
|
||||
modelAndView.setViewName("/bigscreen/template2/index");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,23 +4,34 @@ import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
public class EmailSendMsgHandle implements ISendMsgHandle {
|
||||
static String emailFrom;
|
||||
public static void setEmailFrom(String emailFrom) {
|
||||
EmailSendMsgHandle.emailFrom = emailFrom;
|
||||
}
|
||||
static String emailFrom;
|
||||
|
||||
@Override
|
||||
public void SendMsg(String es_receiver, String es_title, String es_content) {
|
||||
JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
SimpleMailMessage message = new SimpleMailMessage();
|
||||
// 设置发送方邮箱地址
|
||||
message.setFrom(emailFrom);
|
||||
message.setTo(es_receiver);
|
||||
message.setSubject(es_title);
|
||||
message.setText(es_content);
|
||||
mailSender.send(message);
|
||||
public static void setEmailFrom(String emailFrom) {
|
||||
EmailSendMsgHandle.emailFrom = emailFrom;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void SendMsg(String es_receiver, String es_title, String es_content) {
|
||||
JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = null;
|
||||
try {
|
||||
helper = new MimeMessageHelper(message, true);
|
||||
// 设置发送方邮箱地址
|
||||
helper.setFrom(emailFrom);
|
||||
helper.setTo(es_receiver);
|
||||
helper.setSubject(es_title);
|
||||
helper.setText(es_content, true);
|
||||
mailSender.send(message);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,10 +17,14 @@ import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/11/29 9:41
|
||||
* @Description: 此注解相当于设置访问URL
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@ServerEndpoint("/websocket/{userId}")
|
||||
//此注解相当于设置访问URL
|
||||
@ServerEndpoint("/websocket/{userId}") //此注解相当于设置访问URL
|
||||
public class WebSocket {
|
||||
|
||||
private Session session;
|
||||
@ -50,7 +54,8 @@ public class WebSocket {
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message) {
|
||||
//log.info("【websocket消息】收到客户端消息:"+message);
|
||||
//todo 现在有个定时任务刷,应该去掉
|
||||
log.debug("【websocket消息】收到客户端消息:"+message);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("cmd", "heartcheck");//业务类型
|
||||
obj.put("msgTxt", "心跳响应");//消息内容
|
||||
|
||||
@ -249,7 +249,6 @@ public class SysDepartController {
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
|
||||
|
||||
@ -151,19 +151,9 @@ public class SysRoleController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<SysRole> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
SysRole sysrole = sysRoleService.getById(id);
|
||||
if(sysrole==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
boolean ok = sysRoleService.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysRoleService.deleteRole(id);
|
||||
return Result.ok("删除角色成功");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,11 +164,11 @@ public class SysRoleController {
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysRole> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
if(oConvertUtils.isEmpty(ids)) {
|
||||
result.error500("未选中角色!");
|
||||
}else {
|
||||
this.sysRoleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
sysRoleService.deleteBatchRole(ids.split(","));
|
||||
result.success("删除角色成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
//@RequiresPermissions("user:edit")
|
||||
@RequiresPermissions("user:edit")
|
||||
public Result<SysUser> edit(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
try {
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.jeecg.modules.system.entity.SysRole;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@ -14,4 +17,21 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/12/13 16:12
|
||||
* @Description: 删除角色与用户关系
|
||||
*/
|
||||
@Delete("delete from sys_user_role where role_id = #{roleId}")
|
||||
void deleteRoleUserRelation(@Param("roleId") String roleId);
|
||||
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/12/13 16:12
|
||||
* @Description: 删除角色与权限关系
|
||||
*/
|
||||
@Delete("delete from sys_role_permission where role_id = #{roleId}")
|
||||
void deleteRolePermissionRelation(@Param("roleId") String roleId);
|
||||
|
||||
}
|
||||
|
||||
@ -83,4 +83,17 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
*/
|
||||
Integer getUserByOrgCodeTotal(@Param("orgCode") String orgCode, @Param("userParams") SysUser userParams);
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/12/13 16:10
|
||||
* @Description: 批量删除角色与用户关系
|
||||
*/
|
||||
void deleteBathRoleUserRelation(@Param("roleIdArray") String[] roleIdArray);
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/12/13 16:10
|
||||
* @Description: 批量删除角色与权限关系
|
||||
*/
|
||||
void deleteBathRolePermissionRelation(@Param("roleIdArray") String[] roleIdArray);
|
||||
}
|
||||
|
||||
@ -81,4 +81,20 @@
|
||||
SELECT COUNT(1) <include refid="getUserByOrgCodeFromSql"/>
|
||||
</select>
|
||||
|
||||
<!-- 批量删除角色的与用户关系-->
|
||||
<update id="deleteBathRoleUserRelation">
|
||||
delete from sys_user_role
|
||||
where role_id in
|
||||
<foreach item="id" collection="roleIdArray" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<!-- 批量删除角色的与权限关系-->
|
||||
<update id="deleteBathRolePermissionRelation">
|
||||
delete from sys_role_permission
|
||||
where role_id in
|
||||
<foreach item="id" collection="roleIdArray" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@ -0,0 +1,64 @@
|
||||
package org.jeecg.modules.system.rule;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.jeecg.common.handler.IFillRuleHandler;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.YouBianCodeUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
import org.jeecg.modules.system.mapper.SysCategoryMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/12/9 11:32
|
||||
* @Description: 分类字典编码生成规则
|
||||
*/
|
||||
public class CategoryCodeRule implements IFillRuleHandler {
|
||||
|
||||
public static final String ROOT_PID_VALUE = "0";
|
||||
|
||||
@Override
|
||||
public Object execute(JSONObject params, JSONObject formData) {
|
||||
|
||||
String categoryPid = ROOT_PID_VALUE;
|
||||
String categoryCode = null;
|
||||
|
||||
if (formData != null && formData.size() > 0) {
|
||||
Object obj = formData.get("pid");
|
||||
if (oConvertUtils.isNotEmpty(obj)) categoryPid = obj.toString();
|
||||
} else {
|
||||
if (params != null) {
|
||||
Object obj = params.get("pid");
|
||||
if (oConvertUtils.isNotEmpty(obj)) categoryPid = obj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 分成三种情况
|
||||
* 1.数据库无数据 调用YouBianCodeUtil.getNextYouBianCode(null);
|
||||
* 2.添加子节点,无兄弟元素 YouBianCodeUtil.getSubYouBianCode(parentCode,null);
|
||||
* 3.添加子节点有兄弟元素 YouBianCodeUtil.getNextYouBianCode(lastCode);
|
||||
* */
|
||||
//找同类 确定上一个最大的code值
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getPid, categoryPid).orderByDesc(SysCategory::getCode);
|
||||
SysCategoryMapper baseMapper = (SysCategoryMapper) SpringContextUtils.getBean("sysCategoryMapper");
|
||||
List<SysCategory> list = baseMapper.selectList(query);
|
||||
if (list == null || list.size() == 0) {
|
||||
if (ROOT_PID_VALUE.equals(categoryPid)) {
|
||||
//情况1
|
||||
categoryCode = YouBianCodeUtil.getNextYouBianCode(null);
|
||||
} else {
|
||||
//情况2
|
||||
SysCategory parent = (SysCategory) baseMapper.selectById(categoryPid);
|
||||
categoryCode = YouBianCodeUtil.getSubYouBianCode(parent.getCode(), null);
|
||||
}
|
||||
} else {
|
||||
//情况3
|
||||
categoryCode = YouBianCodeUtil.getNextYouBianCode(list.get(0).getCode());
|
||||
}
|
||||
return categoryCode;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package org.jeecg.modules.system.rule;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.jeecg.common.handler.IFillRuleHandler;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.YouBianCodeUtil;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/12/9 11:33
|
||||
* @Description: 机构编码生成规则
|
||||
*/
|
||||
public class OrgCodeRule implements IFillRuleHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(JSONObject params, JSONObject formData) {
|
||||
ISysDepartService sysDepartService = (ISysDepartService) SpringContextUtils.getBean("sysDepartServiceImpl");
|
||||
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
LambdaQueryWrapper<SysDepart> query1 = new LambdaQueryWrapper<SysDepart>();
|
||||
// 创建一个List集合,存储查询返回的所有SysDepart对象
|
||||
List<SysDepart> departList = new ArrayList<>();
|
||||
String[] strArray = new String[2];
|
||||
//定义部门类型
|
||||
String orgType = "";
|
||||
// 定义新编码字符串
|
||||
String newOrgCode = "";
|
||||
// 定义旧编码字符串
|
||||
String oldOrgCode = "";
|
||||
|
||||
String parentId = null;
|
||||
if (formData != null && formData.size() > 0) {
|
||||
Object obj = formData.get("parentId");
|
||||
if (obj != null) parentId = obj.toString();
|
||||
} else {
|
||||
if (params != null) {
|
||||
Object obj = params.get("parentId");
|
||||
if (obj != null) parentId = obj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
//如果是最高级,则查询出同级的org_code, 调用工具类生成编码并返回
|
||||
if (StringUtil.isNullOrEmpty(parentId)) {
|
||||
// 线判断数据库中的表是否为空,空则直接返回初始编码
|
||||
query1.eq(SysDepart::getParentId, "").or().isNull(SysDepart::getParentId);
|
||||
query1.orderByDesc(SysDepart::getOrgCode);
|
||||
departList = sysDepartService.list(query1);
|
||||
if (departList == null || departList.size() == 0) {
|
||||
strArray[0] = YouBianCodeUtil.getNextYouBianCode(null);
|
||||
strArray[1] = "1";
|
||||
return strArray;
|
||||
} else {
|
||||
SysDepart depart = departList.get(0);
|
||||
oldOrgCode = depart.getOrgCode();
|
||||
orgType = depart.getOrgType();
|
||||
newOrgCode = YouBianCodeUtil.getNextYouBianCode(oldOrgCode);
|
||||
}
|
||||
} else {//反之则查询出所有同级的部门,获取结果后有两种情况,有同级和没有同级
|
||||
// 封装查询同级的条件
|
||||
query.eq(SysDepart::getParentId, parentId);
|
||||
// 降序排序
|
||||
query.orderByDesc(SysDepart::getOrgCode);
|
||||
// 查询出同级部门的集合
|
||||
List<SysDepart> parentList = sysDepartService.list(query);
|
||||
// 查询出父级部门
|
||||
SysDepart depart = sysDepartService.getById(parentId);
|
||||
// 获取父级部门的Code
|
||||
String parentCode = depart.getOrgCode();
|
||||
// 根据父级部门类型算出当前部门的类型
|
||||
orgType = String.valueOf(Integer.valueOf(depart.getOrgType()) + 1);
|
||||
// 处理同级部门为null的情况
|
||||
if (parentList == null || parentList.size() == 0) {
|
||||
// 直接生成当前的部门编码并返回
|
||||
newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, null);
|
||||
} else { //处理有同级部门的情况
|
||||
// 获取同级部门的编码,利用工具类
|
||||
String subCode = parentList.get(0).getOrgCode();
|
||||
// 返回生成的当前部门编码
|
||||
newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, subCode);
|
||||
}
|
||||
}
|
||||
// 返回最终封装了部门编码和部门类型的数组
|
||||
strArray[0] = newOrgCode;
|
||||
strArray[1] = orgType;
|
||||
return strArray;
|
||||
}
|
||||
}
|
||||
@ -26,4 +26,18 @@ public interface ISysRoleService extends IService<SysRole> {
|
||||
*/
|
||||
Result importExcelCheckRoleCode(MultipartFile file, ImportParams params) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
* @param roleid
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteRole(String roleid);
|
||||
|
||||
/**
|
||||
* 批量删除角色
|
||||
* @param roleids
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteBatchRole(String[] roleids);
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -25,6 +26,8 @@ import org.jeecg.common.system.vo.SysDepartModel;
|
||||
import org.jeecg.common.util.IPUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.message.entity.SysMessageTemplate;
|
||||
import org.jeecg.modules.message.service.ISysMessageTemplateService;
|
||||
import org.jeecg.modules.message.websocket.WebSocket;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
@ -51,7 +54,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
/** 当前系统数据库类型 */
|
||||
public static String DB_TYPE = "";
|
||||
|
||||
@Autowired
|
||||
private ISysMessageTemplateService sysMessageTemplateService;
|
||||
@Resource
|
||||
private SysLogMapper sysLogMapper;
|
||||
@Autowired
|
||||
@ -182,6 +186,11 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
|
||||
@Override
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent) {
|
||||
this.sendSysAnnouncement(fromUser, toUser, title, msgContent, CommonConstant.MSG_CATEGORY_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent, String setMsgCategory) {
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(msgContent);
|
||||
@ -190,7 +199,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory(CommonConstant.MSG_CATEGORY_2);
|
||||
announcement.setMsgCategory(setMsgCategory);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
@ -216,8 +225,82 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
webSocket.sendOneMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseTemplateByCode(String templateCode,Map<String, String> map) {
|
||||
List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
|
||||
if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
|
||||
throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode);
|
||||
}
|
||||
SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
|
||||
//模板内容
|
||||
String content = sysSmsTemplate.getTemplateContent();
|
||||
if(map!=null) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
String str = "${" + entry.getKey() + "}";
|
||||
content = content.replace(str, entry.getValue());
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSysAnnouncement(String fromUser, String toUser,String title,Map<String, String> map, String templateCode) {
|
||||
List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
|
||||
if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
|
||||
throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode);
|
||||
}
|
||||
SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
|
||||
//模板标题
|
||||
title = title==null?sysSmsTemplate.getTemplateName():title;
|
||||
//模板内容
|
||||
String content = sysSmsTemplate.getTemplateContent();
|
||||
if(map!=null) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
String str = "${" + entry.getKey() + "}";
|
||||
title = title.replace(str, entry.getValue());
|
||||
content = content.replace(str, entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(content);
|
||||
announcement.setSender(fromUser);
|
||||
announcement.setPriority(CommonConstant.PRIORITY_M);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory(CommonConstant.MSG_CATEGORY_2);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
String userId = toUser;
|
||||
String[] userIds = userId.split(",");
|
||||
String anntId = announcement.getId();
|
||||
for(int i=0;i<userIds.length;i++) {
|
||||
if(oConvertUtils.isNotEmpty(userIds[i])) {
|
||||
SysUser sysUser = userMapper.getUserByName(userIds[i]);
|
||||
if(sysUser==null) {
|
||||
continue;
|
||||
}
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
announcementSend.setAnntId(anntId);
|
||||
announcementSend.setUserId(sysUser.getId());
|
||||
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
|
||||
sysAnnouncementSendMapper.insert(announcementSend);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("cmd", "user");
|
||||
obj.put("userId", sysUser.getId());
|
||||
obj.put("msgId", announcement.getId());
|
||||
obj.put("msgTxt", announcement.getTitile());
|
||||
webSocket.sendOneMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型
|
||||
* @param dataSource
|
||||
|
||||
@ -3,7 +3,9 @@ package org.jeecg.modules.system.service.impl;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.FillRuleUtil;
|
||||
import org.jeecg.common.util.YouBianCodeUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
@ -42,29 +44,11 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 分成三种情况
|
||||
* 1.数据库无数据 调用YouBianCodeUtil.getNextYouBianCode(null);
|
||||
* 2.添加子节点,无兄弟元素 YouBianCodeUtil.getSubYouBianCode(parentCode,null);
|
||||
* 3.添加子节点有兄弟元素 YouBianCodeUtil.getNextYouBianCode(lastCode);
|
||||
* */
|
||||
//找同类 确定上一个最大的code值
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>()
|
||||
.eq(SysCategory::getPid,categoryPid)
|
||||
.orderByDesc(SysCategory::getCode);
|
||||
List<SysCategory> list = baseMapper.selectList(query);
|
||||
if(list==null || list.size()==0){
|
||||
if(ISysCategoryService.ROOT_PID_VALUE.equals(categoryPid)){
|
||||
//情况1
|
||||
categoryCode = YouBianCodeUtil.getNextYouBianCode(null);
|
||||
}else{
|
||||
//情况2
|
||||
categoryCode = YouBianCodeUtil.getSubYouBianCode(parentCode,null);
|
||||
}
|
||||
}else{
|
||||
//情况3
|
||||
categoryCode = YouBianCodeUtil.getNextYouBianCode(list.get(0).getCode());
|
||||
}
|
||||
//update-begin--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("pid",categoryPid);
|
||||
categoryCode = (String) FillRuleUtil.executeRule("category_code_rule",formData);
|
||||
//update-end--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
sysCategory.setCode(categoryCode);
|
||||
sysCategory.setPid(categoryPid);
|
||||
baseMapper.insert(sysCategory);
|
||||
|
||||
@ -5,8 +5,10 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.FillRuleUtil;
|
||||
import org.jeecg.common.util.YouBianCodeUtil;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.mapper.SysDepartMapper;
|
||||
@ -76,7 +78,11 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
// 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
|
||||
// 获取父级ID
|
||||
String parentId = sysDepart.getParentId();
|
||||
String[] codeArray = generateOrgCode(parentId);
|
||||
//update-begin--Author:baihailong Date:20191209 for:部门编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("parentId",parentId);
|
||||
String[] codeArray = (String[]) FillRuleUtil.executeRule("org_num_role",formData);
|
||||
//update-end--Author:baihailong Date:20191209 for:部门编码规则生成器做成公用配置
|
||||
sysDepart.setOrgCode(codeArray[0]);
|
||||
String orgType = codeArray[1];
|
||||
sysDepart.setOrgType(String.valueOf(orgType));
|
||||
@ -88,8 +94,8 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
|
||||
/**
|
||||
* saveDepartData 的调用方法,生成部门编码和部门类型
|
||||
*
|
||||
* saveDepartData 的调用方法,生成部门编码和部门类型(作废逻辑)
|
||||
* @deprecated
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
@ -105,8 +111,8 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
// 定义旧编码字符串
|
||||
String oldOrgCode = "";
|
||||
// 定义部门类型
|
||||
String orgType = "";
|
||||
// 如果是最高级,则查询出同级的org_code, 调用工具类生成编码并返回
|
||||
String orgType = "";
|
||||
// 如果是最高级,则查询出同级的org_code, 调用工具类生成编码并返回
|
||||
if (StringUtil.isNullOrEmpty(parentId)) {
|
||||
// 线判断数据库中的表是否为空,空则直接返回初始编码
|
||||
query1.eq(SysDepart::getParentId, "").or().isNull(SysDepart::getParentId);
|
||||
|
||||
@ -6,14 +6,18 @@ import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.PmsUtil;
|
||||
import org.jeecg.modules.system.entity.SysRole;
|
||||
import org.jeecg.modules.system.mapper.SysRoleMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.jeecg.modules.system.service.ISysRoleService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -26,6 +30,10 @@ import java.util.List;
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
|
||||
@Autowired
|
||||
SysRoleMapper sysRoleMapper;
|
||||
@Autowired
|
||||
SysUserMapper sysUserMapper;
|
||||
|
||||
@Override
|
||||
public Result importExcelCheckRoleCode(MultipartFile file, ImportParams params) throws Exception {
|
||||
@ -80,4 +88,28 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
res.setMessage("文件导入成功,但有错误。");
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteRole(String roleid) {
|
||||
//1.删除角色和用户关系
|
||||
sysRoleMapper.deleteRoleUserRelation(roleid);
|
||||
//2.删除角色和权限关系
|
||||
sysRoleMapper.deleteRolePermissionRelation(roleid);
|
||||
//3.删除角色
|
||||
this.removeById(roleid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteBatchRole(String[] roleIds) {
|
||||
//1.删除角色和用户关系
|
||||
sysUserMapper.deleteBathRoleUserRelation(roleIds);
|
||||
//2.删除角色和权限关系
|
||||
sysUserMapper.deleteBathRolePermissionRelation(roleIds);
|
||||
//3.删除角色
|
||||
this.removeByIds(Arrays.asList(roleIds));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,11 +13,15 @@ public class SysUserRoleVO implements Serializable{
|
||||
private String roleId;
|
||||
/**对应的用户id集合*/
|
||||
private List<String> userIdList;
|
||||
|
||||
public SysUserRoleVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SysUserRoleVO(String roleId, List<String> userIdList) {
|
||||
super();
|
||||
this.roleId = roleId;
|
||||
this.userIdList = userIdList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user