Showing
17 changed files
with
421 additions
and
39 deletions
| 1 | +package com.fedex.connect.common.dependencies.annotation; | ||
| 2 | + | ||
| 3 | +import java.lang.annotation.ElementType; | ||
| 4 | +import java.lang.annotation.Retention; | ||
| 5 | +import java.lang.annotation.RetentionPolicy; | ||
| 6 | +import java.lang.annotation.Target; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 记录操作日志的自定义注解 | ||
| 10 | + * @author EDY | ||
| 11 | + */ | ||
| 12 | +@Target(ElementType.METHOD) | ||
| 13 | +@Retention(RetentionPolicy.RUNTIME) | ||
| 14 | +public @interface OperationMethodLog { | ||
| 15 | + | ||
| 16 | + //操作描述 | ||
| 17 | + String describe(); | ||
| 18 | + | ||
| 19 | + String module() default ""; | ||
| 20 | + | ||
| 21 | + //备注类型, | ||
| 22 | + // 0-无特殊备注 | ||
| 23 | + // 1-从参数中获取备注,reamrkExt保存的是参数名,分号分隔 | ||
| 24 | + // 2-从参数中获取id查询,remarkExt保存的是查询表格 | ||
| 25 | + // 3-需要根据url特殊处理 | ||
| 26 | + int remarkType() default 0; | ||
| 27 | + | ||
| 28 | + String remarkField() default ""; | ||
| 29 | + | ||
| 30 | + String remarkTable() default ""; | ||
| 31 | + | ||
| 32 | + //日志是否展示, 0-不展示, 1-展示 | ||
| 33 | + long status() default 0; | ||
| 34 | +} |
| 1 | +package com.fedex.connect.common.dependencies.aspect; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.annotation.OperationMethodLog; | ||
| 4 | +import com.fedex.connect.common.dependencies.contants.AnnotationConstants; | ||
| 5 | +import com.fedex.connect.common.dependencies.date.vo.ResponseVo; | ||
| 6 | +import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; | ||
| 7 | +import com.fedex.connect.common.dependencies.repository.repo.log.IOperationRepository; | ||
| 8 | +import com.fedex.connect.common.dependencies.util.CurrentUserInfo; | ||
| 9 | +import com.fedex.connect.common.dependencies.util.JsonUtils; | ||
| 10 | +import com.fedex.connect.common.model.log.Operation; | ||
| 11 | +import com.fedex.connect.common.model.sys.User; | ||
| 12 | +import org.aspectj.lang.JoinPoint; | ||
| 13 | +import org.aspectj.lang.ProceedingJoinPoint; | ||
| 14 | +import org.aspectj.lang.annotation.*; | ||
| 15 | +import org.slf4j.Logger; | ||
| 16 | +import org.slf4j.LoggerFactory; | ||
| 17 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 18 | +import org.springframework.stereotype.Component; | ||
| 19 | +import org.springframework.util.StringUtils; | ||
| 20 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 21 | +import org.springframework.web.context.request.RequestAttributes; | ||
| 22 | +import org.springframework.web.context.request.RequestContextHolder; | ||
| 23 | +import org.springframework.web.context.request.ServletRequestAttributes; | ||
| 24 | +import org.springframework.web.multipart.MultipartFile; | ||
| 25 | + | ||
| 26 | +import javax.annotation.Resource; | ||
| 27 | +import javax.servlet.http.HttpServletRequest; | ||
| 28 | +import javax.servlet.http.HttpServletResponse; | ||
| 29 | +import java.util.*; | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * 定义切面。用于处理定义的切点。 | ||
| 33 | + * 用于自定义注解。记录操作日志 | ||
| 34 | + */ | ||
| 35 | +@Aspect | ||
| 36 | +@Component | ||
| 37 | +public class OperationLogAspect { | ||
| 38 | + | ||
| 39 | + private Logger logger = LoggerFactory.getLogger(OperationLogAspect.class); | ||
| 40 | + | ||
| 41 | + @Resource | ||
| 42 | + protected LocaleMessageUtil localeMessageUtil; | ||
| 43 | + | ||
| 44 | + @Autowired | ||
| 45 | + protected IOperationRepository operationRepository; | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 定义切点 | ||
| 49 | + * 在OperationMethodLog注解位置做切面 | ||
| 50 | + * @throws Exception | ||
| 51 | + */ | ||
| 52 | + @Pointcut("@annotation(com.fedex.connect.common.dependencies.annotation.OperationMethodLog)") | ||
| 53 | + public void OperationMethodLog() throws Exception{ | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 在切点方法之前执行 | ||
| 58 | + * @param joinPoint 连接点对象,获取当前切入的方法的参数、代理类等信息 | ||
| 59 | + * @throws Exception | ||
| 60 | + */ | ||
| 61 | + @Before("OperationMethodLog()") | ||
| 62 | + public void doBefore(JoinPoint joinPoint) throws Exception{ | ||
| 63 | + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes() ; | ||
| 64 | + HttpServletRequest request =((ServletRequestAttributes)requestAttributes).getRequest(); | ||
| 65 | + //options过滤出去 | ||
| 66 | + if ("OPTIONS".equals(request.getMethod())){ | ||
| 67 | + return; | ||
| 68 | + } | ||
| 69 | + logger.info("【收到请求】" + request.getRequestURL() + request.getMethod()); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 切点方法返回后执行 | ||
| 74 | + * @param joinPoint 连接点对象,获取当前切入的方法的参数、代理类等信息 | ||
| 75 | + * @param e | ||
| 76 | + */ | ||
| 77 | + @AfterThrowing(pointcut = "OperationMethodLog()", throwing = "e") | ||
| 78 | + public void doAfterThrowing(JoinPoint joinPoint, Throwable e){ | ||
| 79 | + logger.error("【日志切面异常】" + e.getMessage()); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 围绕着切点或方法上的注解执行. | ||
| 84 | + * @param pjp | ||
| 85 | + * @param operationMethodLog 在JoinPoint的基础上暴露出 proceed 这个方法. | ||
| 86 | + * @return | ||
| 87 | + * @throws Throwable | ||
| 88 | + */ | ||
| 89 | + @Around("OperationMethodLog() && @annotation(operationMethodLog)") | ||
| 90 | + public Object doAfterReturning(ProceedingJoinPoint pjp, OperationMethodLog operationMethodLog) throws Throwable{ | ||
| 91 | + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes() ; | ||
| 92 | + HttpServletRequest request =((ServletRequestAttributes)requestAttributes).getRequest(); | ||
| 93 | + | ||
| 94 | + //参数中,HttpServletRequest和HttpServletResponse无法转成json,过滤掉 | ||
| 95 | + //如果是MultipartFile类型,只记录文件的名称 | ||
| 96 | + Object[] param = pjp.getArgs(); | ||
| 97 | + param = Arrays.stream(pjp.getArgs()) | ||
| 98 | + .filter(o -> !( o instanceof HttpServletResponse)) | ||
| 99 | + .filter(o -> !( o instanceof HttpServletRequest)) | ||
| 100 | + .map(o -> { | ||
| 101 | + if (o instanceof MultipartFile){ | ||
| 102 | + return ((MultipartFile) o).getOriginalFilename(); | ||
| 103 | + } | ||
| 104 | + return o; | ||
| 105 | + }) | ||
| 106 | + .toArray(); | ||
| 107 | + //获取请求的参数进行处理 | ||
| 108 | + String requestParameters = JsonUtils.obj2jsonIgnoreNull(param); | ||
| 109 | + String url = request.getServletPath(); | ||
| 110 | + String describe = localeMessageUtil.getMessage(operationMethodLog.describe()); | ||
| 111 | + String method = request.getMethod(); | ||
| 112 | + | ||
| 113 | + Operation log = new Operation(); | ||
| 114 | + log.setRequestParameters(requestParameters); | ||
| 115 | + log.setUrl(url); | ||
| 116 | + log.setDescribe(describe); | ||
| 117 | + log.setStatus(operationMethodLog.status()); | ||
| 118 | + log.setRemark(method + ":" +getRemark(operationMethodLog.remarkType(), operationMethodLog.remarkTable(), operationMethodLog.remarkField(), describe, url, param)); | ||
| 119 | + | ||
| 120 | + //获取用户信息。 login,logout,oss登录特殊处理 | ||
| 121 | + User user = CurrentUserInfo.getUser(); | ||
| 122 | + log.setUserId(user.getId()); | ||
| 123 | + log.setUserName(user.getUserName()); | ||
| 124 | + | ||
| 125 | + Object res = pjp.proceed(); | ||
| 126 | + if (Objects.isNull(log.getUserId())){ | ||
| 127 | + //没获取到用户信息,直接return | ||
| 128 | + return res; | ||
| 129 | + } | ||
| 130 | + log.setCreateTime(new Date()); | ||
| 131 | + //模块描述可以写在类的RequestMapping 的 name中,或者写在OperationMethodLog 的module中,OperationMethodLog的级别更高 | ||
| 132 | + String module = Objects.isNull(pjp.getTarget().getClass().getAnnotation(RequestMapping.class)) ? | ||
| 133 | + "" : | ||
| 134 | + pjp.getTarget().getClass().getAnnotation(RequestMapping.class).name(); | ||
| 135 | + if (StringUtils.isEmpty(module) || !StringUtils.isEmpty(operationMethodLog.module())){ | ||
| 136 | + module = operationMethodLog.module(); | ||
| 137 | + } | ||
| 138 | + log.setModule(module); | ||
| 139 | + | ||
| 140 | + //返回的结果可能不是Result类型,比如void响应流,不存 | ||
| 141 | + if (res instanceof ResponseVo) { | ||
| 142 | + ResponseVo result = (ResponseVo)res; | ||
| 143 | + String resultJson = JsonUtils.obj2jsonIgnoreNull(result); | ||
| 144 | + logger.info("【请求结果】" + resultJson); | ||
| 145 | + //太长存不进数据库。把data去掉 | ||
| 146 | + if (resultJson.length() > 255){ | ||
| 147 | + Map<String, Object> r = JsonUtils.json2map(resultJson); | ||
| 148 | + r.remove("data"); | ||
| 149 | + resultJson = JsonUtils.objectToJson(r); | ||
| 150 | + if (resultJson.length() > 255){ | ||
| 151 | + r.put("msg", localeMessageUtil.getMessage("config_aspect_length_error")); | ||
| 152 | + resultJson = JsonUtils.objectToJson(r); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + log.setResult(resultJson); | ||
| 157 | + } | ||
| 158 | + // 日志插入数据库 | ||
| 159 | + logger.info("插入日志:" + JsonUtils.objectToJson(log)); | ||
| 160 | + operationRepository.insert(log); | ||
| 161 | + return res; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + //自定义的解析方法,根据自身情况调整。 | ||
| 165 | + public String getRemark(int remarkType, String remarkTable, String remarkField, String describe, String url, Object[] paramArray){ | ||
| 166 | + Map<String, Object> param = new HashMap<>(); | ||
| 167 | + if (paramArray != null && paramArray.length > 0){ | ||
| 168 | + Object po = paramArray[0]; | ||
| 169 | + if (po instanceof Map){ | ||
| 170 | + param = (Map<String, Object>) po; | ||
| 171 | + } else if (po.getClass().isArray()){ | ||
| 172 | + param.put("list", Arrays.asList((Object[]) po)); | ||
| 173 | + } else if (po instanceof List){ | ||
| 174 | + param.put("list", (List) po); | ||
| 175 | + } else { | ||
| 176 | + param = JsonUtils.pojo2Map(po); | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + String remark = ""; | ||
| 181 | + //remark += getOperation(describe, param); | ||
| 182 | + | ||
| 183 | + if (AnnotationConstants.LOG_REMARK_TYPE_REQUEST == remarkType){ | ||
| 184 | + remark += getRemarkFromRequest(remarkField, param); | ||
| 185 | + } | ||
| 186 | + if (AnnotationConstants.LOG_REMARK_TYPE_TABLE == remarkType){ | ||
| 187 | + remark += getRemarkFromTable(remarkTable, remarkField, param); | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + if (AnnotationConstants.LOG_REMARK_TYPE_SPECIAL == remarkType){ | ||
| 191 | + } | ||
| 192 | + return remark; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + public String getRemarkFromRequest(String remarkField, Map<String, Object> param){ | ||
| 196 | + if (StringUtils.isEmpty(remarkField)){ | ||
| 197 | + return param.get("list").toString(); | ||
| 198 | + } | ||
| 199 | + String remark = "\n"; | ||
| 200 | + //从参数中获取备注,reamrkExt保存的是参数名,分号分隔 | ||
| 201 | + String[] split = remarkField.split(";"); | ||
| 202 | + for (String key : split){ | ||
| 203 | + if (Objects.nonNull(param.get(key)) && !StringUtils.isEmpty(param.get(key))) { | ||
| 204 | + remark += param.get(key) + " "; | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + return remark; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + public String getRemarkFromTable(String remarkTable, String remarkField, Map<String, Object> param){ | ||
| 211 | + return "" + remarkTable; | ||
| 212 | + | ||
| 213 | + /*Map<String , Object> searchTable = new HashMap<>(); | ||
| 214 | + List<Long> idArray = new ArrayList<>(); | ||
| 215 | + searchTable.put("tableName", remarkTable); | ||
| 216 | + if (param.containsKey("id")){ | ||
| 217 | + idArray.add(Long.parseLong(param.get("id").toString())); | ||
| 218 | + }else if (param.containsKey("ids")){ | ||
| 219 | + idArray = (List<Long>) param.get("ids"); | ||
| 220 | + }else if (param.containsKey("updateIds")){ | ||
| 221 | + idArray = (List<Long>) param.get("updateIds"); | ||
| 222 | + }else { | ||
| 223 | + idArray = (List<Long>) param.get("list"); | ||
| 224 | + } | ||
| 225 | + searchTable.put("id", idArray); | ||
| 226 | + List<Map<String, Object>> resList = systemOperationLogMapperExt.searchTable(searchTable); | ||
| 227 | + String[] split = remarkField.split(";"); | ||
| 228 | + | ||
| 229 | + for (Map item : resList){ | ||
| 230 | + remark += "\n"; | ||
| 231 | + for (String key : split){ | ||
| 232 | + if (Objects.nonNull(item.get(key))) { | ||
| 233 | + remark += item.get(key) + " "; | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + return remark;*/ | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | +} |
| 1 | +package com.fedex.connect.common.dependencies.contants; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 定义操作日志使用的常量 | ||
| 5 | + * @author EDY | ||
| 6 | + */ | ||
| 7 | +public class AnnotationConstants { | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * 日志是否展示, 0-不展示, 1-展示 | ||
| 11 | + */ | ||
| 12 | + public static final long LOG_STATUS_SHOW = 1; | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + // 0-无特殊备注 | ||
| 17 | + // 1-从参数中获取备注,reamrkExt保存的是参数名,分号分隔 | ||
| 18 | + // 2-从参数中获取id查询,remarkExt保存的是查询表格 | ||
| 19 | + // 3-需要根据url特殊处理 | ||
| 20 | + public static final int LOG_REMARK_TYPE_REQUEST = 1; | ||
| 21 | + public static final int LOG_REMARK_TYPE_TABLE = 2; | ||
| 22 | + public static final int LOG_REMARK_TYPE_SPECIAL = 3; | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +} |
| 1 | package com.fedex.connect.common.dependencies.repository.base; | 1 | package com.fedex.connect.common.dependencies.repository.base; |
| 2 | 2 | ||
| 3 | import com.fedex.connect.common.dao.bi.DictionaryEntriesMapper; | 3 | import com.fedex.connect.common.dao.bi.DictionaryEntriesMapper; |
| 4 | +import com.fedex.connect.common.dao.log.OperationMapper; | ||
| 4 | import com.fedex.connect.common.dao.sys.RedisSlabMapper; | 5 | import com.fedex.connect.common.dao.sys.RedisSlabMapper; |
| 5 | import com.fedex.connect.common.dependencies.repository.dao.UserMapperExt; | 6 | import com.fedex.connect.common.dependencies.repository.dao.UserMapperExt; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -12,4 +13,6 @@ public class BaseDao { | ... | @@ -12,4 +13,6 @@ public class BaseDao { |
| 12 | public RedisSlabMapper redisSlabMapper; | 13 | public RedisSlabMapper redisSlabMapper; |
| 13 | @Autowired | 14 | @Autowired |
| 14 | public DictionaryEntriesMapper dictionaryEntriesMapper; | 15 | public DictionaryEntriesMapper dictionaryEntriesMapper; |
| 16 | + @Autowired | ||
| 17 | + public OperationMapper operationMapper; | ||
| 15 | } | 18 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -6,5 +6,5 @@ import com.fedex.connect.common.model.bi.DictionaryEntriesExample; | ... | @@ -6,5 +6,5 @@ import com.fedex.connect.common.model.bi.DictionaryEntriesExample; |
| 6 | import java.util.List; | 6 | import java.util.List; |
| 7 | 7 | ||
| 8 | public interface IDictionaryEntriesRepository { | 8 | public interface IDictionaryEntriesRepository { |
| 9 | - List<DictionaryEntries> selectByExample(DictionaryEntriesExample example); | 9 | + List<DictionaryEntries> findAll(DictionaryEntriesExample example); |
| 10 | } | 10 | } | ... | ... |
| ... | @@ -13,7 +13,7 @@ import java.util.List; | ... | @@ -13,7 +13,7 @@ import java.util.List; |
| 13 | public class DictionaryEntriesImpl extends BaseDao implements IDictionaryEntriesRepository { | 13 | public class DictionaryEntriesImpl extends BaseDao implements IDictionaryEntriesRepository { |
| 14 | 14 | ||
| 15 | @Override | 15 | @Override |
| 16 | - public List<DictionaryEntries> selectByExample(DictionaryEntriesExample example) { | 16 | + public List<DictionaryEntries> findAll(DictionaryEntriesExample example) { |
| 17 | DictionaryEntriesExample.Criteria criteria = example.createCriteria(); | 17 | DictionaryEntriesExample.Criteria criteria = example.createCriteria(); |
| 18 | criteria.andStatusEqualTo(DatabaseConstants.GLOBAL_STATUS_VALID); | 18 | criteria.andStatusEqualTo(DatabaseConstants.GLOBAL_STATUS_VALID); |
| 19 | example.setOrderByClause("CREATE_TIME DESC"); | 19 | example.setOrderByClause("CREATE_TIME DESC"); | ... | ... |
| 1 | +package com.fedex.connect.common.dependencies.repository.repo.log.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.repository.base.BaseDao; | ||
| 4 | +import com.fedex.connect.common.dependencies.repository.repo.log.IOperationRepository; | ||
| 5 | +import com.fedex.connect.common.model.log.Operation; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @Author mt | ||
| 9 | + * @Description 操作日志 | ||
| 10 | + * @Date 2024/11/6 | ||
| 11 | + */ | ||
| 12 | +public class OperationRepositoryImpl extends BaseDao implements IOperationRepository { | ||
| 13 | + public void insert(Operation record){ | ||
| 14 | + operationMapper.insert(record); | ||
| 15 | + } | ||
| 16 | +} |
| ... | @@ -19,7 +19,7 @@ public class DictionaryEntriesServiceImpl extends BaseService implements IDictio | ... | @@ -19,7 +19,7 @@ public class DictionaryEntriesServiceImpl extends BaseService implements IDictio |
| 19 | public List<DictionaryEntries> findAll() { | 19 | public List<DictionaryEntries> findAll() { |
| 20 | try{ | 20 | try{ |
| 21 | DictionaryEntriesExample example = new DictionaryEntriesExample(); | 21 | DictionaryEntriesExample example = new DictionaryEntriesExample(); |
| 22 | - return dictionaryEntriesRepository.selectByExample(example); | 22 | + return dictionaryEntriesRepository.findAll(example); |
| 23 | } catch (Exception e){ | 23 | } catch (Exception e){ |
| 24 | log.error(LogShowModel.showException("Exception",e)); | 24 | log.error(LogShowModel.showException("Exception",e)); |
| 25 | return null; | 25 | return null; | ... | ... |
| ... | @@ -3,6 +3,7 @@ package com.fedex.connect.manager.controller.base; | ... | @@ -3,6 +3,7 @@ package com.fedex.connect.manager.controller.base; |
| 3 | 3 | ||
| 4 | import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; | 4 | import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; |
| 5 | import com.fedex.connect.manager.config.PropertiesConfig; | 5 | import com.fedex.connect.manager.config.PropertiesConfig; |
| 6 | +import com.fedex.connect.manager.service.bi.IDicEntriesService; | ||
| 6 | import com.fedex.connect.manager.service.log.ILogLoginService; | 7 | import com.fedex.connect.manager.service.log.ILogLoginService; |
| 7 | import com.fedex.connect.manager.service.sys.ISysAuthService; | 8 | import com.fedex.connect.manager.service.sys.ISysAuthService; |
| 8 | import com.fedex.connect.manager.service.sys.ISysUserService; | 9 | import com.fedex.connect.manager.service.sys.ISysUserService; |
| ... | @@ -24,4 +25,6 @@ public class BaseController { | ... | @@ -24,4 +25,6 @@ public class BaseController { |
| 24 | protected ISysAuthService sysAuthService; | 25 | protected ISysAuthService sysAuthService; |
| 25 | @Autowired | 26 | @Autowired |
| 26 | protected ILogLoginService logLoginService; | 27 | protected ILogLoginService logLoginService; |
| 28 | + @Autowired | ||
| 29 | + protected IDicEntriesService dicEntriesService; | ||
| 27 | } | 30 | } | ... | ... |
| 1 | package com.fedex.connect.manager.controller.bi.impl; | 1 | package com.fedex.connect.manager.controller.bi.impl; |
| 2 | 2 | ||
| 3 | import com.fedex.connect.common.dependencies.date.vo.ResponseVo; | 3 | import com.fedex.connect.common.dependencies.date.vo.ResponseVo; |
| 4 | +import com.fedex.connect.common.model.bi.DictionaryEntries; | ||
| 5 | +import com.fedex.connect.manager.controller.base.BaseController; | ||
| 6 | +import com.fedex.connect.manager.controller.bi.IDicEntriesController; | ||
| 4 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| 5 | import io.swagger.annotations.ApiOperation; | 8 | import io.swagger.annotations.ApiOperation; |
| 6 | -import org.springframework.web.bind.annotation.PostMapping; | 9 | +import org.springframework.web.bind.annotation.GetMapping; |
| 7 | import org.springframework.web.bind.annotation.RequestMapping; | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
| 8 | import org.springframework.web.bind.annotation.RestController; | 11 | import org.springframework.web.bind.annotation.RestController; |
| 9 | 12 | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 10 | @RestController | 15 | @RestController |
| 11 | @RequestMapping(value = "/dicEntries", name = "字典相关操作") | 16 | @RequestMapping(value = "/dicEntries", name = "字典相关操作") |
| 12 | @Api(value="DicEntriesController",tags={"字典相关操作"}) | 17 | @Api(value="DicEntriesController",tags={"字典相关操作"}) |
| 13 | -public class DicEntriesController { | 18 | +public class DicEntriesController extends BaseController implements IDicEntriesController { |
| 14 | 19 | ||
| 15 | - @PostMapping("/init") | 20 | + @GetMapping("/getCountryAll") |
| 16 | - @ApiOperation(value = "初始化进入首页获取FCL登录地址") | 21 | + @ApiOperation(value = "获取所有国家字典信息") |
| 17 | - public ResponseVo init(){ | 22 | + public ResponseVo getCountryAll(){ |
| 18 | - return ResponseVo.succ(fclIndexLoginUrl); | 23 | + List<DictionaryEntries> countryList = dicEntriesService.getCountryAll(); |
| 24 | + return ResponseVo.succ(countryList); | ||
| 19 | } | 25 | } |
| 20 | } | 26 | } | ... | ... |
| 1 | +package com.fedex.connect.manager.repository.repo.bi.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.cache.CacheSystem; | ||
| 4 | +import com.fedex.connect.common.dependencies.contants.DictionaryConstants; | ||
| 5 | +import com.fedex.connect.common.model.bi.DictionaryEntries; | ||
| 6 | +import com.fedex.connect.manager.repository.base.BaseDao; | ||
| 7 | +import com.fedex.connect.manager.repository.repo.bi.IDicEntriesRepository; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.stereotype.Repository; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * @Author mt | ||
| 15 | + * @Description 字典查询repository | ||
| 16 | + * @Date 2024/11/6 | ||
| 17 | + */ | ||
| 18 | +@Repository | ||
| 19 | +public class DicEntriesRepositoryImpl extends BaseDao implements IDicEntriesRepository { | ||
| 20 | + @Autowired | ||
| 21 | + CacheSystem cacheSystem; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * @Author mt | ||
| 25 | + * @Description 获取所有国家字典 | ||
| 26 | + * @Date 2024/11/6 | ||
| 27 | + * @param | ||
| 28 | + * @return java.util.List<com.fedex.connect.common.model.bi.DictionaryEntries> | ||
| 29 | + */ | ||
| 30 | + public List<DictionaryEntries> getCountryAll(){ | ||
| 31 | + return cacheSystem.getDictionarysByDicCode(DictionaryConstants.COUNTRY); | ||
| 32 | + } | ||
| 33 | +} |
| ... | @@ -6,6 +6,7 @@ import com.fedex.connect.common.dao.sys.RoleMapper; | ... | @@ -6,6 +6,7 @@ import com.fedex.connect.common.dao.sys.RoleMapper; |
| 6 | import com.fedex.connect.common.dao.sys.UserMapper; | 6 | import com.fedex.connect.common.dao.sys.UserMapper; |
| 7 | import com.fedex.connect.common.dao.sys.UserRoleMapper; | 7 | import com.fedex.connect.common.dao.sys.UserRoleMapper; |
| 8 | import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; | 8 | import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; |
| 9 | +import com.fedex.connect.manager.repository.repo.bi.IDicEntriesRepository; | ||
| 9 | import com.fedex.connect.manager.repository.repo.log.IUserLoginLogRepository; | 10 | import com.fedex.connect.manager.repository.repo.log.IUserLoginLogRepository; |
| 10 | import com.fedex.connect.manager.repository.repo.sys.*; | 11 | import com.fedex.connect.manager.repository.repo.sys.*; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -31,25 +32,5 @@ public class BaseService { | ... | @@ -31,25 +32,5 @@ public class BaseService { |
| 31 | @Autowired | 32 | @Autowired |
| 32 | public IUserRepository userRepository; | 33 | public IUserRepository userRepository; |
| 33 | @Autowired | 34 | @Autowired |
| 34 | - public IDictionaryEntriesRepository dictionaryEntriesRepository; | 35 | + public IDicEntriesRepository dicEntriesRepository; |
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * Mapper--------------------------------------------- | ||
| 38 | - */ | ||
| 39 | - @Autowired | ||
| 40 | - protected UserMapper userMapper; | ||
| 41 | - | ||
| 42 | - @Autowired | ||
| 43 | - protected UserRoleMapper userRoleMapper; | ||
| 44 | - | ||
| 45 | - @Autowired | ||
| 46 | - protected RoleMapper roleMapper; | ||
| 47 | - | ||
| 48 | - @Autowired | ||
| 49 | - protected UserLoginInfoMapper userLoginInfoMapper; | ||
| 50 | - | ||
| 51 | - /** | ||
| 52 | - * MapperExt--------------------------------------------- | ||
| 53 | - */ | ||
| 54 | - | ||
| 55 | } | 36 | } | ... | ... |
| 1 | +package com.fedex.connect.manager.service.bi.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.model.bi.DictionaryEntries; | ||
| 4 | +import com.fedex.connect.manager.service.base.BaseService; | ||
| 5 | +import com.fedex.connect.manager.service.bi.IDicEntriesService; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Service | ||
| 11 | +public class DicEntriesServiceImpl extends BaseService implements IDicEntriesService { | ||
| 12 | + | ||
| 13 | + @Override | ||
| 14 | + public List<DictionaryEntries> getCountryAll() { | ||
| 15 | + return dicEntriesRepository.getCountryAll(); | ||
| 16 | + } | ||
| 17 | +} |
| ... | @@ -4,6 +4,7 @@ import com.fedex.connect.manager.data.dto.LogLoginDto; | ... | @@ -4,6 +4,7 @@ import com.fedex.connect.manager.data.dto.LogLoginDto; |
| 4 | import com.fedex.connect.manager.data.model.LogShowModel; | 4 | import com.fedex.connect.manager.data.model.LogShowModel; |
| 5 | import com.fedex.connect.manager.service.base.BaseService; | 5 | import com.fedex.connect.manager.service.base.BaseService; |
| 6 | import com.fedex.connect.manager.service.log.ILogLoginService; | 6 | import com.fedex.connect.manager.service.log.ILogLoginService; |
| 7 | +import lombok.extern.slf4j.Slf4j; | ||
| 7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| ... | @@ -13,12 +14,10 @@ import org.springframework.transaction.annotation.Transactional; | ... | @@ -13,12 +14,10 @@ import org.springframework.transaction.annotation.Transactional; |
| 13 | * 日志相关service | 14 | * 日志相关service |
| 14 | * @author EDY | 15 | * @author EDY |
| 15 | */ | 16 | */ |
| 17 | +@Slf4j | ||
| 16 | @Service | 18 | @Service |
| 17 | public class LogLoginServiceImpl extends BaseService implements ILogLoginService { | 19 | public class LogLoginServiceImpl extends BaseService implements ILogLoginService { |
| 18 | 20 | ||
| 19 | - private Logger logger = LoggerFactory.getLogger(LogLoginServiceImpl.class); | ||
| 20 | - | ||
| 21 | - | ||
| 22 | /** | 21 | /** |
| 23 | * 保存登录日志 | 22 | * 保存登录日志 |
| 24 | * @param dto | 23 | * @param dto |
| ... | @@ -26,11 +25,6 @@ public class LogLoginServiceImpl extends BaseService implements ILogLoginService | ... | @@ -26,11 +25,6 @@ public class LogLoginServiceImpl extends BaseService implements ILogLoginService |
| 26 | */ | 25 | */ |
| 27 | @Transactional(rollbackFor = Exception.class) | 26 | @Transactional(rollbackFor = Exception.class) |
| 28 | public int saveLoginLog(LogLoginDto dto){ | 27 | public int saveLoginLog(LogLoginDto dto){ |
| 29 | - try{ | 28 | + return userLoginLogRepository.insert(LogLoginDto.dtoToDao(dto)); |
| 30 | - return userLoginLogRepository.insert(LogLoginDto.dtoToDao(dto)); | ||
| 31 | - } catch (Exception e){ | ||
| 32 | - logger.error(LogShowModel.showException("Exception",e)); | ||
| 33 | - throw e; | ||
| 34 | - } | ||
| 35 | } | 29 | } |
| 36 | } | 30 | } | ... | ... |
-
Please register or login to post a comment