screen-manage
完成sysarea模块查询
拦截器逻辑代码完成
修改organization和accountBug
8 files added
36 files modified
| | |
| | | // 全局配置 |
| | | GlobalConfig gc = new GlobalConfig(); |
| | | //String projectPath = System.getProperty("user.dir"); |
| | | String projectPath="D:\\tools\\moral\\screen-api\\"; |
| | | String projectPath="C:\\Users\\cdl\\Desktop\\comProject\\newProject\\moral\\screen-manage\\"; |
| | | gc.setOutputDir(projectPath + "/src/main/java"); |
| | | gc.setAuthor("moral"); |
| | | gc.setOpen(false); |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(encrypt("123456","AD42F7787B035B7580000EF93BE20BAD")); |
| | | System.out.println(encrypt("chenkaiyu111","AD42F7787B035B7580000EF93BE20BAD")); |
| | | System.out.println(decrypt("KoWjfDMZQhJMLlG1crBPqQ==","AD42F7787B035B7580000EF93BE20BAD")); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.moral.util; |
| | | |
| | | import org.mockito.internal.util.StringUtil; |
| | | |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | package com.moral.util; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | * @Version TODO |
| | | **/ |
| | | @Component |
| | | @Slf4j |
| | | public class TokenEncryptUtils { |
| | | |
| | | private static String key; |
| | |
| | | try { |
| | | hexStr = hexStrToStr(str); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("token解密失败"+e.getMessage()); |
| | | } |
| | | if (hexStr != null) { |
| | | hexStr = encodedString(hexStr, key); |
| | |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | } |
| | | |
| | | //token有效期 单位:秒 |
| | | private static final int validity_time = 60*30; |
| | | private static final int validity_time = 60 * 30; |
| | | |
| | | //判断user_token里有没有用户的token |
| | | public static boolean hHasKey(String uid){ |
| | | return redisTemplate.opsForHash().hasKey("user_token",uid); |
| | | public static boolean hHasKey(String uid) { |
| | | return redisTemplate.opsForHash().hasKey("user_token", uid); |
| | | } |
| | | |
| | | //根据用户id获取token |
| | | public static Object hget(String uid){ |
| | | return redisTemplate.opsForHash().get("user_token",uid); |
| | | public static Object hget(String uid) { |
| | | return redisTemplate.opsForHash().get("user_token", uid); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 生成token,并且将用户信息存入缓存 |
| | | * @Description: 生成token, 并且将用户信息存入缓存 |
| | | * @Param: [uid] type: 后台取值:manage 前台取值:api |
| | | * @return: java.lang.String |
| | | * @Author: 陈凯裕 |
| | |
| | | redisTemplate.delete(oldToken); |
| | | //新token写入到value中 |
| | | redisTemplate.opsForValue().set(token, userInfo); |
| | | redisTemplate.expire(token, validity_time, TimeUnit.SECONDS); |
| | | //redisTemplate.expire(token, validity_time, TimeUnit.SECONDS); |
| | | //新token写入到Hash中 |
| | | redisTemplate.opsForHash().put("user_token", uid, token); |
| | | return token; |
| | | } catch (Exception e) { |
| | | log.error("token生成异常:"+e.getMessage()); |
| | | log.error("token生成异常:" + e.getMessage()); |
| | | throw new TokenException(ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode(), |
| | | ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg()); |
| | | } |
| | |
| | | /** |
| | | * @Description: 校验token |
| | | * @Param: [type, token] type: 后台取值:manage 前台取值:api |
| | | * @return: java.util.Map<java.lang.String , java.lang.Object> |
| | | * @return: java.util.Map<java.lang.String , java.lang.Object> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/10 |
| | | */ |
| | |
| | | ResponseCodeEnum.TOKEN_INVALID.getMsg()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("token工具类校验token异常" + e.getMessage()); |
| | | throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(), |
| | | ResponseCodeEnum.TOKEN_INVALID.getMsg()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 通过token获取用户信息 前台使用 |
| | | * @Description: 通过token获取用户信息 |
| | | * @Param: [token] |
| | | * @return: java.util.Map<java.lang.String , java.lang.Object> |
| | | * @return: java.util.Map<java.lang.String , java.lang.Object> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/11 |
| | | */ |
| | | public static Object getUserInfoByToken(String token) { |
| | | Object userInfo = redisTemplate.opsForValue().get(token); |
| | | if(userInfo==null) |
| | | if (userInfo == null) |
| | | throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(), |
| | | ResponseCodeEnum.TOKEN_INVALID.getMsg()); |
| | | return userInfo; |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 销毁token |
| | | * @Param: [token] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/1 |
| | | */ |
| | | public static void destoryToken(String token) { |
| | | destoryToken(getUidByToken(token), token); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 根据TOKEN获取Id |
| | | * @Param: [token] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/1 |
| | | */ |
| | | public static String getUidByToken(String token) { |
| | | String[] string = TokenEncryptUtils.decoded(token).split("/"); |
| | | return string[0]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: token延长 |
| | | * @Param: [token] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/11 |
| | | */ |
| | | public static void extendTokenTime(String token) { |
| | | public static void extendTokenTime(String token) { |
| | | redisTemplate.expire(token, validity_time, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | |
| | | package com.moral.util; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import java.util.Enumeration; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | | |
| | | import javax.servlet.ServletRequest; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | @Slf4j |
| | | public class WebUtils extends org.springframework.web.util.WebUtils { |
| | |
| | | package com.moral.api.aop.log; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.api.entity.ManageLog; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.mapper.ManageLogMapper; |
| | | import com.moral.api.mapper.OrganizationMapper; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.pojo.form.organization.OrganizationDeleteForm; |
| | | import com.moral.api.pojo.form.organization.OrganizationInsertForm; |
| | | import com.moral.api.pojo.form.organization.OrganizationUpdateForm; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | import lombok.Data; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.AfterReturning; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.lang.reflect.Method; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName OperationLogAspect |
| | |
| | | **/ |
| | | @Aspect |
| | | @Component |
| | | @ConfigurationProperties(prefix = "log-aspect") |
| | | @Data |
| | | public class OperationLogAspect { |
| | | |
| | | @Autowired |
| | | ManageLogMapper manageLogMapper; |
| | | |
| | | @Autowired |
| | | OrganizationMapper organizationMapper; |
| | | |
| | | Map<String,String> organizationFormMap; |
| | | |
| | | |
| | | /** |
| | | * @Description: 设置切入点为OperationLogAnno注解使用的地方 |
| | |
| | | * @Date: 2021/3/31 |
| | | */ |
| | | @AfterReturning(returning = "result", value = "pointCut()") |
| | | @Transactional |
| | | public void saveOperLog(JoinPoint joinPoint, Object result) throws Throwable { |
| | | //判断操作是否成功,失败不计入日志 |
| | | Map resultMap = JSONObject.parseObject(JSONObject.toJSONString(result), Map.class); |
| | | if (!ResponseCodeEnum.SUCCESS.getCode().equals(resultMap.get("code"))) |
| | | return; |
| | | //获取请求参数 |
| | | RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); |
| | | Object parameters = request.getAttribute("parameters"); |
| | | String token = request.getHeader("token"); |
| | | //获取module和type |
| | | MethodSignature signature = (MethodSignature) joinPoint.getSignature();//获取切入点方法信号 |
| | | Method method = signature.getMethod();//获取切入点的方法 |
| | | OperationLogAnno anno = method.getAnnotation(OperationLogAnno.class);//获取方法的注解 |
| | | String module = anno.module();//获取操作的模块 |
| | | String type = anno.type();//获取操作的类型 |
| | | saveLog(request,parameters, module, type); |
| | | //获取操作用户id ip 名称 |
| | | Integer id = Integer.parseInt(TokenUtils.getUidByToken(token)); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | AccountInfoDTO account = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); |
| | | String accountName = account.getAccount().getUserName(); |
| | | //获取content |
| | | String content = getContent(type,module,parameters); |
| | | content = content+"操作人员:"+accountName+";"; |
| | | //存入数据库 |
| | | ManageLog manageLog = new ManageLog(); |
| | | manageLog.setContent(content); |
| | | manageLog.setIp(ip); |
| | | manageLog.setAccountId(id); |
| | | manageLogMapper.insert(manageLog); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 判断模块 |
| | | * @Param: [paramters, module, type] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/31 |
| | | */ |
| | | public void saveLog(HttpServletRequest request,Object paramters, String module, String type) { |
| | | public String getContent(String type, String module,Object parameters) { |
| | | String content = ""; |
| | | if (module.equals(Constants.ORGANIZATION_MODULE_NAME)) { |
| | | saveOrganizationLog(request,paramters, module, type); |
| | | content = getOrganizationContent(type,parameters); |
| | | } |
| | | |
| | | return content; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 处理组织日志 |
| | | * @Param: [paramters, module, type] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/31 |
| | | */ |
| | | @Transactional |
| | | public void saveOrganizationLog(HttpServletRequest request,Object paramters, String module, String type) { |
| | | * @Description: 获取组织模块操作描述 |
| | | * @Param: [type, parameters] |
| | | * @return: java.lang.String |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/1 |
| | | */ |
| | | public String getOrganizationContent(String type,Object parameters) { |
| | | StringBuilder content = new StringBuilder(); |
| | | if (type.equals(Constants.INSERT_OPERATE_TYPE)) {//处理组织添加日志插入 |
| | | OrganizationInsertForm form = JSON.parseObject(JSON.toJSONString(paramters), OrganizationInsertForm.class); |
| | | Integer accountId = 1;//固定 尚未更改 |
| | | String accountName = "测试人员"; |
| | | OrganizationInsertForm form = JSON.parseObject(JSON.toJSONString(parameters), OrganizationInsertForm.class); |
| | | String organizationName = form.getName(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | String content = accountName+"添加了新组织:"+organizationName; |
| | | |
| | | ManageLog manageLog = new ManageLog(); |
| | | manageLog.setContent(content); |
| | | manageLog.setIp(ip); |
| | | manageLog.setAccountId(accountId); |
| | | manageLog.setModule(module); |
| | | manageLog.setType(type); |
| | | manageLogMapper.insert(manageLog); |
| | | content.append("添加了组织:").append(organizationName).append(";"); |
| | | } else if (type.equals(Constants.DELETE_OPERATE_TYPE)) { //处理组织删除日志 |
| | | |
| | | OrganizationDeleteForm form = JSON.parseObject(JSON.toJSONString(parameters), OrganizationDeleteForm.class); |
| | | Organization organization = organizationMapper.selectById(form.getOrganizationId()); |
| | | String organizationName = organization.getName(); |
| | | content.append("删除了组织:").append(organizationName).append(";"); |
| | | } else if (type.equals(Constants.UPDATE_OPERATE_TYPE)) { //处理组织更新日志 |
| | | |
| | | OrganizationUpdateForm form = JSON.parseObject(JSON.toJSONString(parameters), OrganizationUpdateForm.class); |
| | | Map<String,Object> formMap = JSON.parseObject(JSON.toJSONString(parameters), Map.class); |
| | | Organization organization = organizationMapper.selectById(form.getOrganizationId()); |
| | | String organizationName = organization.getName(); |
| | | content.append("更新了组织:").append(organizationName).append(";"); |
| | | //将formMap中的Key全部替换为中文写入日志 |
| | | formMap.forEach((k,v)->{ |
| | | String key = organizationFormMap.get(k); |
| | | if(key!=null) |
| | | content.append(key).append("->").append(v).append(";"); |
| | | }); |
| | | } |
| | | |
| | | return content.toString(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | @Slf4j |
| | | @Api(tags = {"后台账户管理"}) |
| | | @RestController |
| | | @CrossOrigin(origins = "*", maxAge = 3600) |
| | | @RequestMapping("/account") |
| | | public class AccountController { |
| | | @Autowired |
| | |
| | | import com.moral.api.pojo.vo.organization.OrganizationQueryVO; |
| | | import com.moral.api.pojo.vo.organization.OrganizationUpdateVO; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | |
| | | **/ |
| | | @Slf4j |
| | | @Api(tags = {"用户组织控制器"}) |
| | | @CrossOrigin(origins = "*", maxAge = 3600) |
| | | @RestController |
| | | @RequestMapping("/organization") |
| | | @RequestMapping("/organization") |
| | | public class OrganizationController { |
| | | @Autowired |
| | | OrganizationService organizationService; |
| | | |
| | | @PostMapping("insert") |
| | | @OperationLogAnno(module = Constants.ORGANIZATION_MODULE_NAME,type = Constants.INSERT_OPERATE_TYPE) |
| | | public ResultMessage insert(@RequestBody OrganizationInsertForm form, HttpServletRequest request) { |
| | | //请求参数存入request中 |
| | | request.setAttribute("parameters",form); |
| | | |
| | | //判断是否缺少参数 |
| | | if (!form.valid()) |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | |
| | | //转换前端需要的参数 |
| | | OrganizationInsertVO vo = OrganizationInsertVO.convert(dto); |
| | | |
| | | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); |
| | | } |
| | | |
| | | @PostMapping("update") |
| | | public ResultMessage update(@RequestBody OrganizationUpdateForm form){ |
| | | public ResultMessage update(@RequestBody OrganizationUpdateForm form, HttpServletRequest request) { |
| | | |
| | | //判断是否缺少参数 |
| | | if (!form.valid()) |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | |
| | | //转换前端需要的参数 |
| | | OrganizationUpdateVO vo = OrganizationUpdateVO.convert(dto); |
| | | |
| | | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); |
| | | } |
| | | |
| | | @PostMapping("delete") |
| | | public ResultMessage delete(@RequestBody OrganizationDeleteForm form){ |
| | | public ResultMessage delete(@RequestBody OrganizationDeleteForm form,HttpServletRequest request) { |
| | | //判断是否缺少参数 |
| | | if (!form.valid()) |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | |
| | | //转换前端需要的参数 |
| | | OrganizationDeleteVO vo = OrganizationDeleteVO.convert(dto); |
| | | |
| | | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); |
| | | } |
| | | |
| | | @GetMapping("query") |
| | | public ResultMessage query(OrganizationQueryForm form){ |
| | | public ResultMessage query(OrganizationQueryForm form) { |
| | | //判断是否缺少参数 |
| | | if (!form.valid()) |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | |
| | | //转换前端需要参数 |
| | | OrganizationQueryVO vo = OrganizationQueryVO.convert(dto); |
| | | |
| | | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.moral.api.entity.SysArea; |
| | | import com.moral.api.service.SysAreaService; |
| | | import com.moral.constant.ResultMessage; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName SystemController |
| | | * @Description TODO |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/4/7 13:17 |
| | | * @Version TODO |
| | | **/ |
| | | @Slf4j |
| | | @Api(tags = {"用户组织控制器"}) |
| | | @CrossOrigin(origins = "*", maxAge = 3600) |
| | | @RestController |
| | | @RequestMapping("/system") |
| | | public class SystemController { |
| | | |
| | | @Autowired |
| | | SysAreaService sysAreaService; |
| | | |
| | | @GetMapping("area/query") |
| | | public ResultMessage query(){ |
| | | List<SysArea> sysAreas = sysAreaService.querySysArea(); |
| | | return ResultMessage.ok(sysAreas); |
| | | } |
| | | } |
| | |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.redis.RedisUtil; |
| | | import com.moral.util.PageResult; |
| | | import com.moral.util.TokenEncryptUtils; |
| | | import com.moral.util.TokenUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.kafka.core.KafkaTemplate; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | |
| | | |
| | | @Slf4j |
| | |
| | | kafkaTemplate.send("test_topic","test111111111111111"); |
| | | } |
| | | |
| | | @GetMapping("testToken") |
| | | public void testToken(){ |
| | | String decoded = TokenEncryptUtils.decoded("5b53480d4e570b54565f555775"); |
| | | String decoded2 = TokenEncryptUtils.decoded("584f560a49510f5453515453"); |
| | | System.out.println(decoded); |
| | | System.out.println(decoded2); |
| | | } |
| | | |
| | | public static void main(String[] args) throws IOException { |
| | | String path = "C:\\Users\\cdl\\Desktop\\province.txt"; |
| | | BufferedReader fis = new BufferedReader(new FileReader(path)); |
| | | BufferedWriter writer = new BufferedWriter(new FileWriter("C:\\Users\\cdl\\Desktop\\provin1ce.txt")); |
| | | String line = ""; |
| | | while((line = fis.readLine())!=null){ |
| | | //获取code |
| | | StringBuilder str = new StringBuilder(line); |
| | | String code = str.substring(31, 37); |
| | | |
| | | //获取名称 |
| | | char[] chars = line.toCharArray(); |
| | | int i = 0; |
| | | StringBuilder buffered = new StringBuilder(); |
| | | for (char aChar : chars) { |
| | | if(aChar=='\'') |
| | | i ++; |
| | | if(i==1){ |
| | | buffered.append(aChar); |
| | | } |
| | | } |
| | | buffered.append('\''); |
| | | String name = buffered.toString(); |
| | | |
| | | //获取父级code |
| | | line.trim(); |
| | | char[] chars1 = line.toCharArray(); |
| | | int j = 0; |
| | | StringBuilder buffered2 = new StringBuilder(); |
| | | for (char c : chars1) { |
| | | if(j==6){ |
| | | buffered2.append(c); |
| | | } |
| | | if(c==',') |
| | | j++; |
| | | } |
| | | StringBuilder parentCode = buffered2.deleteCharAt(buffered2.length() - 1); |
| | | //写入 |
| | | writer.write("INSERT INTO `sys_area` VALUES ("+code+","+name+","+parentCode+");"); |
| | | writer.newLine(); |
| | | } |
| | | |
| | | writer.close(); |
| | | fis.close(); |
| | | } |
| | | } |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-31 |
| | | * @since 2021-04-02 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 操作类型 |
| | | * 操作人员id |
| | | */ |
| | | private String type; |
| | | private Integer accountId; |
| | | |
| | | /** |
| | | * 操作模块 |
| | | * 操作人员 |
| | | */ |
| | | private String module; |
| | | private String userName; |
| | | |
| | | /** |
| | | * 操作描述 |
| | | */ |
| | | private String content; |
| | | |
| | | /** |
| | | * 操作人员id |
| | | */ |
| | | private Integer accountId; |
| | | |
| | | /** |
| | | * Ip地址 |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-09 |
| | | * @since 2021-04-06 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | |
| | | private Integer provinceCode; |
| | | |
| | | /** |
| | | * 省份名称 |
| | | */ |
| | | private String provinceName; |
| | | |
| | | /** |
| | | * 城市代码 |
| | | */ |
| | | private Integer cityCode; |
| | | |
| | | /** |
| | | * 县代码 |
| | | * 城市名称 |
| | | */ |
| | | private String cityName; |
| | | |
| | | /** |
| | | * 区代码 |
| | | */ |
| | | private Integer areaCode; |
| | | |
| | | /** |
| | | * 镇代码 |
| | | * 区名称 |
| | | */ |
| | | private Long townCode; |
| | | private String areaName; |
| | | |
| | | /** |
| | | * 街道代码 |
| | | * 地图定位级别码 |
| | | */ |
| | | private Long villageCode; |
| | | private Integer locationLevelCode; |
| | | |
| | | /** |
| | | * 地图定位级别 provincd_code city_code ...... |
| | | * 地图定位级别名称 |
| | | */ |
| | | private String locationLevel; |
| | | private String locationLevelName; |
| | | |
| | | /** |
| | | * 地址 |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * 系统区域表 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-04-07 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SysArea extends Model<SysArea> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 区域代码 |
| | | */ |
| | | private Integer areaCode; |
| | | |
| | | /** |
| | | * 区域名称 |
| | | */ |
| | | private String areaName; |
| | | |
| | | /** |
| | | * 父级代码 |
| | | */ |
| | | private Integer parentCode; |
| | | |
| | | /* |
| | | * 子级地区 |
| | | * */ |
| | | @TableField(exist = false) |
| | | private List<SysArea> children; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.areaCode; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.moral.api.interceptor; |
| | | |
| | | import com.moral.util.TokenUtils; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | |
| | | public class ManageInterceptor implements HandlerInterceptor { |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | return false; |
| | | String token = request.getHeader("token"); |
| | | TokenUtils.checkToken(token); |
| | | //TokenUtils.extendTokenTime(token); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-31 |
| | | * @since 2021-04-02 |
| | | */ |
| | | public interface ManageLogMapper extends BaseMapper<ManageLog> { |
| | | |
| | |
| | | * @since 2021-03-09 |
| | | */ |
| | | public interface ManageMenuMapper extends BaseMapper<ManageMenu> { |
| | | /** |
| | | * @Description: 根据角色获取所有的根菜单 |
| | | * @Param: [roles] |
| | | * @return: java.util.List<com.moral.api.entity.ManageMenu> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/10 |
| | | */ |
| | | List<ManageMenu> getParentMenuByRoles(List<ManageRole> roles); |
| | | |
| | | /** |
| | | * @Description: 根据根菜单获取对应的子菜单 |
| | | * @Param: |
| | | * @return: |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/10 |
| | | */ |
| | | List<ManageMenu> getChildrenByParentId(Integer parentId); |
| | | |
| | | List<ManageMenu> getParentChildrenMenusByRoles(List<ManageRole> roles); |
| | | List<ManageMenu> getAllMenusByRoles(List<ManageRole> roles); |
| | | |
| | | ManageMenu getManageMenuByName(String name); |
| | | |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-09 |
| | | * @since 2021-04-06 |
| | | */ |
| | | public interface OrganizationMapper extends BaseMapper<Organization> { |
| | | |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import com.moral.api.entity.SysArea; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 系统区域表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-04-07 |
| | | */ |
| | | public interface SysAreaMapper extends BaseMapper<SysArea> { |
| | | /** |
| | | * @Description: 获取所有地区 |
| | | * @Param: [] |
| | | * @return: com.moral.api.entity.SysArea |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/7 |
| | | */ |
| | | List<SysArea> querySysArea(); |
| | | } |
| | |
| | | |
| | | private String wechat; |
| | | |
| | | |
| | | private String createTime; |
| | | |
| | | |
| | | private String updateTime; |
| | | |
| | | |
| | | private List<String> roleIds; |
| | | |
| | | public boolean valid() { |
| | | if ( |
| | | ObjectUtils.isEmpty(account) || |
| | | ObjectUtils.isEmpty(password) || |
| | | ObjectUtils.isEmpty(email) || |
| | | ObjectUtils.isEmpty(mobile) || |
| | | ObjectUtils.isEmpty(userName) |
| | | ) |
| | | return false; |
| | |
| | | |
| | | private Integer organizationId; |
| | | |
| | | private Integer deleteChildren; |
| | | private Integer deleteChildren;//1:删除对应子组织 0:不删除对应自组织 |
| | | |
| | | public boolean valid() { |
| | | if (organizationId == null || organizationId == 0|| ObjectUtils.isEmpty(deleteChildren)) { |
| | |
| | | * @Version TODO |
| | | **/ |
| | | @Data |
| | | public class OrganizationInsertForm { |
| | | public class OrganizationInsertForm { |
| | | |
| | | private Integer parentId; |
| | | |
| | |
| | | |
| | | private Integer provinceCode; |
| | | |
| | | private String provinceName; |
| | | |
| | | private Integer cityCode; |
| | | |
| | | private String cityName; |
| | | |
| | | private Integer areaCode; |
| | | |
| | | private Long townCode; |
| | | private String areaName; |
| | | |
| | | private Long villageCode; |
| | | private Integer locationLevelCode; |
| | | |
| | | private String locationLevel; |
| | | private String locationLevelName; |
| | | |
| | | private String address; |
| | | |
| | |
| | | if ( |
| | | ObjectUtils.isEmpty(name) || |
| | | ObjectUtils.isEmpty(provinceCode) || |
| | | ObjectUtils.isEmpty(cityCode) || |
| | | ObjectUtils.isEmpty(areaCode) || |
| | | ObjectUtils.isEmpty(locationLevel) || |
| | | ObjectUtils.isEmpty(provinceName) || |
| | | ObjectUtils.isEmpty(locationLevelCode) || |
| | | ObjectUtils.isEmpty(locationLevelName)|| |
| | | ObjectUtils.isEmpty(address) || |
| | | ObjectUtils.isEmpty(expireTime) |
| | | ) |
| | |
| | | organization.setParentId(parentId); |
| | | organization.setName(name); |
| | | organization.setProvinceCode(provinceCode); |
| | | organization.setProvinceName(provinceName); |
| | | organization.setCityCode(cityCode); |
| | | organization.setCityName(cityName); |
| | | organization.setAreaCode(areaCode); |
| | | organization.setTownCode(townCode); |
| | | organization.setVillageCode(villageCode); |
| | | organization.setLocationLevel(locationLevel); |
| | | organization.setAreaName(areaName); |
| | | organization.setLocationLevelCode(locationLevelCode); |
| | | organization.setLocationLevelName(locationLevelName); |
| | | organization.setAddress(address); |
| | | organization.setPhone(phone); |
| | | organization.setEmail(email); |
| | |
| | | |
| | | private Integer areaCode; |
| | | |
| | | private Long townCode; |
| | | |
| | | private Long villageCode; |
| | | |
| | | private String phone; |
| | | |
| | | private String email; |
| | |
| | | |
| | | private Integer provinceCode; |
| | | |
| | | private String provinceName; |
| | | |
| | | private Integer cityCode; |
| | | |
| | | private String cityName; |
| | | |
| | | private Integer areaCode; |
| | | |
| | | private Long townCode; |
| | | private String areaName; |
| | | |
| | | private Long villageCode; |
| | | private Integer locationLevelCode; |
| | | |
| | | private String locationLevel; |
| | | private String locationLevelName; |
| | | |
| | | private String address; |
| | | |
| | |
| | | ObjectUtils.isEmpty(provinceCode) && |
| | | ObjectUtils.isEmpty(cityCode) && |
| | | ObjectUtils.isEmpty(areaCode) && |
| | | ObjectUtils.isEmpty(townCode) && |
| | | ObjectUtils.isEmpty(villageCode) && |
| | | ObjectUtils.isEmpty(locationLevel) && |
| | | ObjectUtils.isEmpty(locationLevelCode) && |
| | | ObjectUtils.isEmpty(address) && |
| | | ObjectUtils.isEmpty(phone) && |
| | | ObjectUtils.isEmpty(email) && |
| | |
| | | organization.setParentId(parentId); |
| | | organization.setName(name); |
| | | organization.setProvinceCode(provinceCode); |
| | | organization.setProvinceName(provinceName); |
| | | organization.setCityCode(cityCode); |
| | | organization.setCityName(cityName); |
| | | organization.setAreaCode(areaCode); |
| | | organization.setTownCode(townCode); |
| | | organization.setVillageCode(villageCode); |
| | | organization.setLocationLevel(locationLevel); |
| | | organization.setAreaName(areaName); |
| | | organization.setLocationLevelCode(locationLevelCode); |
| | | organization.setLocationLevelName(locationLevelName); |
| | | organization.setAddress(address); |
| | | organization.setPhone(phone); |
| | | organization.setEmail(email); |
| | |
| | | vo.setRoleNames(roleNames); |
| | | //Date转换String |
| | | Date createTime = account.getCreateTime(); |
| | | Date updateTime = account.getUpdateTime(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String createTimeStr = sdf.format(createTime); |
| | | String updateTimeStr = sdf.format(updateTime); |
| | | vo.setCreateTime(createTimeStr); |
| | | vo.setUpdateTime(updateTimeStr); |
| | | return vo; |
| | | } |
| | | } |
| | |
| | | /*过滤menu无用属性*/ |
| | | if (!ObjectUtils.isEmpty(menus)) { |
| | | for (ManageMenu menu : menus) { |
| | | menu.setCreateTime(null); |
| | | menu.setIsDelete(null); |
| | | menu.setUpdateTime(null); |
| | | menu.setParentId(null); |
| | | List<ManageMenu> children = menu.getChildren(); |
| | | for (ManageMenu child : children) { |
| | | child.setCreateTime(null); |
| | | child.setIsDelete(null); |
| | | child.setUpdateTime(null); |
| | | child.setParentId(null); |
| | | } |
| | | removeAttribute(menu); |
| | | } |
| | | } |
| | | vo.setAccountId(account.getId()); |
| | |
| | | return vo; |
| | | } |
| | | |
| | | public static void removeAttribute(ManageMenu menu) { |
| | | menu.setCreateTime(null); |
| | | menu.setIsDelete(null); |
| | | menu.setUpdateTime(null); |
| | | menu.setParentId(null); |
| | | if (ObjectUtils.isEmpty(menu.getChildren())) |
| | | return; |
| | | List<ManageMenu> children = menu.getChildren(); |
| | | for (ManageMenu child : children) { |
| | | removeAttribute(child); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | String createTimeStr = DateUtils.dateToDateString(createTime, "yyyy-MM-dd"); |
| | | String exipreTimeStr = DateUtils.dateToDateString(expireTime, "yyyy-MM-dd"); |
| | | |
| | | |
| | | vo.setId(organization.getId()); |
| | | vo.setName(organization.getName()); |
| | | if (!ObjectUtils.isEmpty(parentOrganization)) |
| | | vo.setParentName(parentOrganization.getName()); |
| | |
| | | vo.setAddress(organization.getAddress()); |
| | | vo.setCreateTime(createTimeStr); |
| | | vo.setExpireTime(exipreTimeStr); |
| | | vo.setLocationLevelCode(organization.getLocationLevelCode()); |
| | | vo.setLocationLevelName(organization.getLocationLevelName()); |
| | | return vo; |
| | | } |
| | | } |
| | |
| | | |
| | | private Long villageCode; |
| | | |
| | | private String locationLevel; |
| | | private Integer locationLevelCode; |
| | | |
| | | private String locationLevelName; |
| | | |
| | | private String address; |
| | | |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-31 |
| | | * @since 2021-04-02 |
| | | */ |
| | | public interface ManageLogService extends IService<ManageLog> { |
| | | |
| | |
| | | |
| | | import com.moral.api.entity.ManageMenu; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.ManageRole; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | @Transactional |
| | | List<ManageMenu> getManageMenuByNameFuzzy(Map map); |
| | | |
| | | List<ManageMenu> getParentChildrenMenusByRoles(List<ManageRole> roles); |
| | | } |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-09 |
| | | * @since 2021-04-06 |
| | | */ |
| | | public interface OrganizationService extends IService<Organization> { |
| | | |
| | | /** |
| | | * @Description: 添加客户组织 |
| | | * @Param: [organizationInsertForm] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/22 |
| | | */ |
| | | /** |
| | | * @Description: 添加客户组织 |
| | | * @Param: [organizationInsertForm] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/22 |
| | | */ |
| | | OrganizationDTO insertOrganization(OrganizationInsertForm organizationInsertForm); |
| | | |
| | | /** |
| | | * @Description: 更新客户组织 |
| | | * @Param: [organizationUpdateForm] |
| | | * @return: com.moral.api.pojo.dto.organization.OrganizationDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/24 |
| | | */ |
| | | * @Description: 更新客户组织 |
| | | * @Param: [organizationUpdateForm] |
| | | * @return: com.moral.api.pojo.dto.organization.OrganizationDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/24 |
| | | */ |
| | | OrganizationDTO updateOrganization(OrganizationUpdateForm organizationUpdateForm); |
| | | |
| | | /** |
| | | * @Description: 删除客户组织 |
| | | * @Param: [organizationDeleteForm] |
| | | * @return: com.moral.api.pojo.dto.organization.OrganizationDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/25 |
| | | */ |
| | | * @Description: 删除客户组织 |
| | | * @Param: [organizationDeleteForm] |
| | | * @return: com.moral.api.pojo.dto.organization.OrganizationDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/25 |
| | | */ |
| | | OrganizationDTO deleteOrganization(OrganizationDeleteForm organizationDeleteForm); |
| | | |
| | | /** |
| | | * @Description: 查询客户组织 |
| | | * @Param: [organizationQueryForm] |
| | | * @return: com.moral.api.pojo.dto.organization.OrganizationQueryDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/25 |
| | | */ |
| | | * @Description: 查询客户组织 |
| | | * @Param: [organizationQueryForm] |
| | | * @return: com.moral.api.pojo.dto.organization.OrganizationQueryDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/25 |
| | | */ |
| | | OrganizationQueryDTO queryOrganization(OrganizationQueryForm organizationQueryForm); |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.moral.api.entity.SysArea; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 系统区域表 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-04-07 |
| | | */ |
| | | public interface SysAreaService extends IService<SysArea> { |
| | | |
| | | /** |
| | | * @Description: 从缓存中查询所有的地区 |
| | | * @Param: [] |
| | | * @return: com.moral.api.entity.SysArea |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/7 |
| | | */ |
| | | List<SysArea> querySysArea(); |
| | | |
| | | |
| | | } |
| | |
| | | import com.moral.api.service.ManageAccountService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.config.mybatis.wrapper.NullFilterWrapper; |
| | | import com.moral.api.service.ManageMenuService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.util.*; |
| | |
| | | @Autowired |
| | | ManageRoleMapper manageRoleMapper; |
| | | @Autowired |
| | | ManageMenuMapper manageMenuMapper; |
| | | ManageMenuService manageMenuService; |
| | | @Autowired |
| | | ManageAccountRoleMapper manageAccountRoleMapper; |
| | | |
| | |
| | | //查询菜单 |
| | | List<ManageMenu> menus = null; |
| | | if (!ObjectUtils.isEmpty(roles)) { |
| | | menus = manageMenuMapper.getParentChildrenMenusByRoles(roles); |
| | | menus = manageMenuService.getParentChildrenMenusByRoles(roles); |
| | | } |
| | | |
| | | //封装用户信息 |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-31 |
| | | * @since 2021-04-02 |
| | | */ |
| | | @Service |
| | | public class ManageLogServiceImpl extends ServiceImpl<ManageLogMapper, ManageLog> implements ManageLogService { |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.ManageMenu; |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.mapper.ManageMenuMapper; |
| | | import com.moral.api.mapper.ManageRoleMenuMapper; |
| | | import com.moral.api.service.ManageMenuService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Predicate; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Map<String,Object> insertManageMenu(ManageMenu manageMenu) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (manageMenu.getName()==null){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | public Map<String, Object> insertManageMenu(ManageMenu manageMenu) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | if (manageMenu.getName() == null) { |
| | | resultMap.put("code", ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageMenuMapper.getManageMenuByName(manageMenu.getName()) != null){ |
| | | resultMap.put("code",ResponseCodeEnum.MENU_IS_EXPIRE.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MENU_IS_EXPIRE.getMsg()); |
| | | }else { |
| | | if (manageMenuMapper.getManageMenuByName(manageMenu.getName()) != null) { |
| | | resultMap.put("code", ResponseCodeEnum.MENU_IS_EXPIRE.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.MENU_IS_EXPIRE.getMsg()); |
| | | } else { |
| | | manageMenuMapper.insertOne(manageMenu); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Map<String,Object> updateManageMenu(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | public Map<String, Object> updateManageMenu(Map map) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")) { |
| | | resultMap.put("code", ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null){ |
| | | resultMap.put("code",ResponseCodeEnum.MENU_IS_NULL.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MENU_IS_NULL.getMsg()); |
| | | }else { |
| | | if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null) { |
| | | resultMap.put("code", ResponseCodeEnum.MENU_IS_NULL.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.MENU_IS_NULL.getMsg()); |
| | | } else { |
| | | manageMenuMapper.updateManageMenuById(map); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |
| | |
| | | @Override |
| | | @Transactional |
| | | public Map<String, Object> deleteManageMenu(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")) { |
| | | resultMap.put("code", ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null){ |
| | | resultMap.put("code",ResponseCodeEnum.MENU_IS_NULL.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MENU_IS_NULL.getMsg()); |
| | | }else { |
| | | if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null) { |
| | | resultMap.put("code", ResponseCodeEnum.MENU_IS_NULL.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.MENU_IS_NULL.getMsg()); |
| | | } else { |
| | | Map deleteMap = new HashMap(); |
| | | int id = Integer.parseInt(map.get("id").toString()); |
| | | deleteMap.put("id",id); |
| | | deleteMap.put("is_delete",1); |
| | | deleteMap.put("id", id); |
| | | deleteMap.put("is_delete", 1); |
| | | manageMenuMapper.updateManageMenuById(deleteMap); |
| | | Map role_menuDeleteMap = new HashMap(); |
| | | role_menuDeleteMap.put("menu_id",id); |
| | | role_menuDeleteMap.put("menu_id", id); |
| | | manageRoleMenuMapper.updateDeleteStateByMenu_id(role_menuDeleteMap); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |
| | |
| | | @Override |
| | | public List<ManageMenu> getAllWithPagingQuery(Map map) { |
| | | Map limitMap = new HashMap(); |
| | | limitMap.put("start",(Integer.parseInt(map.get("current").toString())-1)*Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("number",Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("start", (Integer.parseInt(map.get("current").toString()) - 1) * Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("number", Integer.parseInt(map.get("size").toString())); |
| | | List<ManageMenu> manageMenus = manageMenuMapper.getDataWithPage(limitMap); |
| | | System.out.println(manageMenus); |
| | | return manageMenus; |
| | |
| | | @Override |
| | | public List<ManageMenu> getManageMenuByNameFuzzy(Map map) { |
| | | Map limitMap = new HashMap(); |
| | | limitMap.put("name",map.get("name")); |
| | | limitMap.put("start",(Integer.parseInt(map.get("current").toString())-1)*Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("number",Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("name", map.get("name")); |
| | | limitMap.put("start", (Integer.parseInt(map.get("current").toString()) - 1) * Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("number", Integer.parseInt(map.get("size").toString())); |
| | | List<ManageMenu> manageMenus = manageMenuMapper.getManageRoleByNameFuzzy(limitMap); |
| | | return manageMenus; |
| | | } |
| | | |
| | | @Override |
| | | public List<ManageMenu> getParentChildrenMenusByRoles(List<ManageRole> roles) { |
| | | List<ManageMenu> allMenus = manageMenuMapper.getAllMenusByRoles(roles); |
| | | Map<Integer, ManageMenu> menusMap = new HashMap<>(); |
| | | for (ManageMenu menu : allMenus) { |
| | | menu.setChildren(new ArrayList<>());//初始化 |
| | | menusMap.put(menu.getId(), menu); |
| | | } |
| | | for (ManageMenu menu : allMenus) { |
| | | combinationParentChildrenMenus(menusMap, menu); |
| | | } |
| | | //已经封装好父子菜单,去除parentId不是0的菜单,去除重复 |
| | | allMenus.removeIf(new Predicate<ManageMenu>() { |
| | | @Override |
| | | public boolean test(ManageMenu manageMenu) { |
| | | if(manageMenu.getParentId().equals(0)) |
| | | return false; |
| | | return true; |
| | | } |
| | | }); |
| | | return allMenus; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 组合多级菜单 |
| | | * @Param: [menuMap, menu]menuMap:key为menuid,value为menu |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/7 |
| | | */ |
| | | private void combinationParentChildrenMenus(Map<Integer, ManageMenu> menuMap, ManageMenu menu) { |
| | | Integer parentId = menu.getParentId(); |
| | | ManageMenu parentMenu = menuMap.get(parentId); |
| | | if (!ObjectUtils.isEmpty(parentMenu)) { |
| | | parentMenu.getChildren().add(menu); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.moral.api.pojo.form.organization.OrganizationUpdateForm; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.util.ConvertUtils; |
| | | import com.moral.util.DateUtils; |
| | | import lombok.Data; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-03-09 |
| | | * @since 2021-04-06 |
| | | */ |
| | | @Service |
| | | @ConfigurationProperties(prefix = "log-aspect") |
| | | public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization> implements OrganizationService { |
| | | |
| | | @Autowired |
| | | OrganizationMapper organizationMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | Map<String, String> organizationFormMap; |
| | | |
| | | public void setOrganizationFormMap(Map<String, String> organizationFormMap) { |
| | | this.organizationFormMap = organizationFormMap; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 添加客户组织 |
| | |
| | | } |
| | | //插入组织 |
| | | organizationMapper.insert(organization); |
| | | |
| | | //封装DTO信息 |
| | | organizationDTO.setParentOrganization(parentOrganization); |
| | | organizationDTO.setOrganization(organization); |
| | | organizationDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | organizationDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了组织:").append(organization.getName()); |
| | | logUtils.saveOperationForManage(request, content.toString()); |
| | | return organizationDTO; |
| | | } |
| | | |
| | |
| | | //更新组织 |
| | | organizationMapper.updateById(organization); |
| | | |
| | | //获取更新后的组合 |
| | | //获取更新后的组织 |
| | | organization = organizationMapper.selectById(organization.getId()); |
| | | |
| | | //封装DTO信息 |
| | |
| | | organizationDTO.setOrganization(organization); |
| | | organizationDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | organizationDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("更新了组织:").append(organization.getName()).append(";"); |
| | | //更新对象转为Map |
| | | Map<String, Object> newParameters = JSONObject.parseObject(JSON.toJSONString(organizationUpdateForm), Map.class); |
| | | Map<String, Object> oldParameters = JSONObject.parseObject(JSON.toJSONString(existOrganization), Map.class); |
| | | Set<String> keys = organizationFormMap.keySet(); |
| | | for (String key : keys) { |
| | | String value = organizationFormMap.get(key); |
| | | if ("parentName".equals(key)) {//更新父组织特殊处理 |
| | | if (organizationUpdateForm.getParentId() != null) {//判断父组织是否进行了更新 |
| | | String oldParentName = "空"; |
| | | String newParentName = "空"; |
| | | if (!existOrganization.getParentId().equals(0)) { |
| | | oldParentName = organizationMapper.selectById(existOrganization.getParentId()).getName(); |
| | | } |
| | | if (!organization.getParentId().equals(0)) { |
| | | newParentName = organizationMapper.selectById(organization.getParentId()).getName(); |
| | | } |
| | | content.append(value + ":" + oldParentName + "->" + newParentName + ";"); |
| | | } |
| | | } else if ("expireTime".equals(key)) {//expireTime时间格式特殊处理 |
| | | if (organizationUpdateForm.getExpireTime() != null) { |
| | | Date oldExpireTime = existOrganization.getExpireTime(); |
| | | Date newExpireTime = organization.getExpireTime(); |
| | | String oldExpireTimeStr = DateUtils.dateToDateString(oldExpireTime, "yyyy-MM-dd"); |
| | | String newExpireTimeStr = DateUtils.dateToDateString(newExpireTime, "yyyy-MM-dd"); |
| | | content.append(value + ":" + oldExpireTimeStr + "->" + newExpireTimeStr + ";"); |
| | | } |
| | | } else {//处理其他属性 |
| | | if (newParameters.get(key) != null) { |
| | | String newValue = "空"; |
| | | String oldValue = "空"; |
| | | if (newParameters.get(key) != null && !newParameters.get(key).equals(" ")) { |
| | | newValue = String.valueOf(newParameters.get(key)); |
| | | } |
| | | if (oldParameters.get(key) != null && !oldParameters.get(key).equals(" ")) { |
| | | oldValue = String.valueOf(oldParameters.get(key)); |
| | | } |
| | | content.append(value + ":" + oldValue + "->" + newValue + ";"); |
| | | } |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(request, content.toString()); |
| | | |
| | | return organizationDTO; |
| | | } |
| | | |
| | |
| | | organizationMapper.update(null, updateChildrenWrapper); |
| | | } |
| | | |
| | | //封装返回结果 |
| | | dto.setOrganization(existOrganization); |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了组织:").append(existOrganization.getName()); |
| | | if(form.getDeleteChildren().equals(Constants.DELETE_CHILDREN_ORG)) |
| | | content.append("以及所有子组织"); |
| | | logUtils.saveOperationForManage(request, content.toString()); |
| | | |
| | | return dto; |
| | | } |
| | | |
| | |
| | | Integer provinceCode = organizationQueryForm.getProvinceCode(); |
| | | Integer cityCode = organizationQueryForm.getCityCode(); |
| | | Integer areaCode = organizationQueryForm.getAreaCode(); |
| | | Long townCode = organizationQueryForm.getTownCode(); |
| | | Long villageCode = organizationQueryForm.getVillageCode(); |
| | | String phone = organizationQueryForm.getPhone(); |
| | | String email = organizationQueryForm.getEmail(); |
| | | String wechat = organizationQueryForm.getWechat(); |
| | |
| | | queryWrapper.eq("province_code", provinceCode); |
| | | queryWrapper.eq("city_code", cityCode); |
| | | queryWrapper.eq("area_code", areaCode); |
| | | queryWrapper.eq("town_code", townCode); |
| | | queryWrapper.eq("village_code", villageCode); |
| | | queryWrapper.like("phone", phone); |
| | | queryWrapper.like("email", email); |
| | | queryWrapper.like("wechat", wechat); |
| | |
| | | Page<Organization> resultPage = organizationMapper.selectPage(page, queryWrapper); |
| | | List<Organization> organizations = resultPage.getRecords(); |
| | | List<OrganizationDTO> organizationDTOS = new ArrayList<>(); |
| | | //查找所有组织的父组织 |
| | | //查找所有组织的父组织并且封装organization到DTO中 |
| | | for (Organization child : organizations) { |
| | | OrganizationDTO resultDto = new OrganizationDTO(); |
| | | Organization parent = organizationMapper.selectById(child.getParentId()); |
| | | Organization parent = organizationMapper.selectById(child.getParentId());//查找父组织 |
| | | //拼接地址字符串 |
| | | changeAddressByOrganization(child); |
| | | resultDto.setOrganization(child); |
| | | resultDto.setParentOrganization(parent); |
| | | organizationDTOS.add(resultDto); |
| | |
| | | return dto; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 将organization的address字段与provinceName cityName areaName进行拼接 |
| | | * @Param: [organization] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/2 |
| | | */ |
| | | public void changeAddressByOrganization(Organization organization) { |
| | | String provinceName = organization.getProvinceName(); |
| | | String cityName = organization.getCityName(); |
| | | String areaName = organization.getAreaName(); |
| | | String address = organization.getAddress(); |
| | | |
| | | StringBuilder newAddress = new StringBuilder(); |
| | | if (provinceName != null) |
| | | newAddress.append(provinceName); |
| | | if (cityName != null) |
| | | newAddress.append(cityName); |
| | | if (areaName != null) |
| | | newAddress.append(areaName); |
| | | if (address != null) |
| | | newAddress.append(address); |
| | | |
| | | organization.setAddress(newAddress.toString()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.api.entity.SysArea; |
| | | import com.moral.api.mapper.SysAreaMapper; |
| | | import com.moral.api.service.SysAreaService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Predicate; |
| | | |
| | | /** |
| | | * <p> |
| | | * 系统区域表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-04-07 |
| | | */ |
| | | @Service |
| | | public class SysAreaServiceImpl extends ServiceImpl<SysAreaMapper, SysArea> implements SysAreaService { |
| | | |
| | | @Autowired |
| | | SysAreaMapper sysAreaMapper; |
| | | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | | public List<SysArea> querySysArea() { |
| | | List<SysArea> sysAreas = redisTemplate.opsForList().range("sysArea", 0, -1); |
| | | if (ObjectUtils.isEmpty(sysAreas)) { |
| | | sysAreas = querySysAreaFromDB(); |
| | | } |
| | | return sysAreas; |
| | | } |
| | | |
| | | |
| | | private List<SysArea> querySysAreaFromDB() { |
| | | //取出所有地区 |
| | | List<SysArea> sysAreas = sysAreaMapper.selectList(null); |
| | | //创建Map key为地区码 value为地区对象 供组装使用 |
| | | Map<Integer, SysArea> areaMap = new HashMap<>(); |
| | | for (SysArea sysArea : sysAreas) { |
| | | areaMap.put(sysArea.getAreaCode(), sysArea); |
| | | sysArea.setChildren(new ArrayList<>());//初始化children集合 |
| | | } |
| | | //遍历所有城市,判断是否有父城市,如果有则添加到父城市中。 |
| | | for (SysArea sysArea : sysAreas) { |
| | | Integer parentCode = sysArea.getParentCode(); |
| | | if (!parentCode.equals(0)) { |
| | | SysArea parentArea = areaMap.get(parentCode); |
| | | parentArea.getChildren().add(sysArea); |
| | | } |
| | | } |
| | | //移除集合中非父顶级城市 |
| | | sysAreas.removeIf(new Predicate<SysArea>() { |
| | | @Override |
| | | public boolean test(SysArea sysArea) { |
| | | if (sysArea.getParentCode().equals(0)) |
| | | return false; |
| | | return true; |
| | | } |
| | | }); |
| | | //存入缓存 |
| | | redisTemplate.opsForList().rightPushAll("sysArea",sysAreas); |
| | | |
| | | return sysAreas; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.util; |
| | | |
| | | import com.moral.api.entity.ManageAccount; |
| | | import com.moral.api.entity.ManageLog; |
| | | import com.moral.api.mapper.ManageLogMapper; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * @ClassName LogUtils |
| | | * @Description TODO |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/4/2 8:45 |
| | | * @Version TODO |
| | | **/ |
| | | @Component |
| | | public class LogUtils { |
| | | |
| | | @Autowired |
| | | public ManageLogMapper manageLogMapper; |
| | | |
| | | @Transactional |
| | | public void saveOperationForManage(HttpServletRequest request, String content) { |
| | | String token = request.getHeader("token"); |
| | | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); |
| | | ManageAccount account = accountInfoDTO.getAccount(); |
| | | Integer id = account.getId(); |
| | | String userName = account.getUserName(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | |
| | | ManageLog log = new ManageLog(); |
| | | log.setAccountId(id); |
| | | log.setIp(ip); |
| | | log.setContent(content); |
| | | log.setUserName(userName); |
| | | manageLogMapper.insert(log); |
| | | } |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: dev |
| | | include: |
| | | moduleFormColumn |
| | | application: |
| | | name: screen-manage |
| | | redis: |
| | |
| | | - /swagger-ui.html |
| | | - /swagger-resources/** |
| | | - /webjars/** |
| | | - /logout |
| | | - /account/insert |
| | | - /account/query |
| | | - /account/update |
| | | - /account/delete |
| | | - /account/yanzhengma |
| | | - /verificationCode/get |
| | | - /verificationCode/verify |
| | | - /verificationCode/config |
| | | - /organization/insert |
| | | - /organization/update |
| | | - /organization/delete |
| | | - /organization/query |
| | | - /verificationCode/** |
| | | - /system/** |
| | | |
| | | - /role/getAllManageRole |
| | | - /role/getManageRoleByNameFuzzy |
| | | - /role/updateRoleMenu |
| | | - /menu/getAllManageMenu |
| | | - /menu/getManageMenuByNameFuzzy |
| | | - /api/** |
| | | AES: |
| | | KEY: |
| | | AD42F7787B035B7580000EF93BE20BAD |
| | |
| | | KEY: |
| | | foh3wi2ooghiCh5 |
| | | |
| | | |
New file |
| | |
| | | #接收前端数据实体中属性的含义,用于转换供日志使用。 |
| | | log-aspect: |
| | | organization-form-map: |
| | | parentName: 父组织 |
| | | name: 名称 |
| | | provinceName: 省份 |
| | | cityName: 城市 |
| | | areaName: 区域 |
| | | locationLevelName: 定位级别 |
| | | address: 地址 |
| | | phone: 电话 |
| | | email: 邮箱 |
| | | wechat: 微信 |
| | | expireTime: 过期时间 |
| | | |
| | | |
| | | |
| | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.ManageLog"> |
| | | <id column="id" property="id" /> |
| | | <result column="type" property="type" /> |
| | | <result column="module" property="module" /> |
| | | <result column="content" property="content" /> |
| | | <result column="account_id" property="accountId" /> |
| | | <result column="user_name" property="userName" /> |
| | | <result column="content" property="content" /> |
| | | <result column="ip" property="ip" /> |
| | | <result column="create_time" property="createTime" /> |
| | | </resultMap> |
| | |
| | | <result column="is_delete" property="isDelete"/> |
| | | </resultMap> |
| | | |
| | | <!--父子结构查询映射结果--> |
| | | <resultMap id="ParentChildrenResultMap" type="com.moral.api.entity.ManageMenu"> |
| | | <id column="id" property="id"/> |
| | | <result column="name" property="name"/> |
| | | <result column="url" property="url"/> |
| | | <result column="icon" property="icon"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="order" property="order"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="is_delete" property="isDelete"/> |
| | | <collection property="children" ofType="com.moral.api.entity.ManageMenu" column="id" select="getChildrenByParentId"></collection> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | mm.id,mm.name,mm.url,mm.icon,mm.parent_id,mm.order,mm.create_time,mm.update_time,mm.is_delete |
| | | </sql> |
| | | |
| | | <!--根据角色集合查询所有的父菜单--> |
| | | <select id="getParentMenuByRoles" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"></include> |
| | | from |
| | | manage_menu mm |
| | | join |
| | | manage_role_menu mrm |
| | | on |
| | | mm.`id` = mrm.`menu_id` and mm.`is_delete`=0 |
| | | join |
| | | manage_role mr |
| | | on |
| | | mr.`id` = mrm.`role_id` and mr.`id` IN |
| | | <foreach collection="list" separator="," open="(" close=")" item="role"> |
| | | #{role.id} |
| | | </foreach> |
| | | where |
| | | mm.`is_delete`=0 |
| | | AND |
| | | mm.`parent_id`=0; |
| | | </select> |
| | | |
| | | <!--根据父菜单Id查询所有的子菜单--> |
| | | <select id="getChildrenByParentId" parameterType="Integer" resultMap="BaseResultMap"> |
| | | SELECT |
| | | <include refid="Base_Column_List"></include> |
| | | FROM |
| | | manage_menu mm |
| | | WHERE |
| | | mm.parent_id = #{value} |
| | | </select> |
| | | |
| | | <!--根据角色查询父子结构的菜单--> |
| | | <select id="getParentChildrenMenusByRoles" resultMap="ParentChildrenResultMap"> |
| | | <select id="getAllMenusByRoles" resultMap="BaseResultMap"> |
| | | select |
| | | DISTINCT |
| | | <include refid="Base_Column_List"></include> |
| | |
| | | </foreach> |
| | | where |
| | | mm.`is_delete`=0 |
| | | AND |
| | | mm.`parent_id`=0; |
| | | </select> |
| | | |
| | | <select id="getManageMenuByName" resultMap="BaseResultMap"> |
| | |
| | | <result column="admin_user_id" property="adminUserId" /> |
| | | <result column="name" property="name" /> |
| | | <result column="province_code" property="provinceCode" /> |
| | | <result column="province_name" property="provinceName" /> |
| | | <result column="city_code" property="cityCode" /> |
| | | <result column="city_name" property="cityName" /> |
| | | <result column="area_code" property="areaCode" /> |
| | | <result column="town_code" property="townCode" /> |
| | | <result column="village_code" property="villageCode" /> |
| | | <result column="location_level" property="locationLevel" /> |
| | | <result column="area_name" property="areaName" /> |
| | | <result column="location_level_code" property="locationLevelCode" /> |
| | | <result column="location_level_name" property="locationLevelName" /> |
| | | <result column="address" property="address" /> |
| | | <result column="phone" property="phone" /> |
| | | <result column="email" property="email" /> |
New file |
| | |
| | | <?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.moral.api.mapper.SysAreaMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.SysArea"> |
| | | <id column="area_code" property="areaCode"/> |
| | | <result column="area_name" property="areaName"/> |
| | | <result column="parent_code" property="parentCode"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | area_code,area_name,parent_code |
| | | </sql> |
| | | |
| | | |
| | | |
| | | </mapper> |