emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/dto/req/demoReqDTO.java
对比新文件 @@ -0,0 +1,4 @@ package com.gkhy.safePlatform.emergency.dto.req; public class demoReqDTO { } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/dto/resp/demoRespDTO.java
对比新文件 @@ -0,0 +1,4 @@ package com.gkhy.safePlatform.emergency.dto.resp; public class demoRespDTO { } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/entity/DemoInfo.java
对比新文件 @@ -0,0 +1,13 @@ package com.gkhy.safePlatform.emergency.entity; import com.baomidou.mybatisplus.annotation.TableName; import java.util.Date; @TableName("demo") public class DemoInfo { private String name; private Date gmtCreate; } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/entity/DemoInfoDo.java
对比新文件 @@ -0,0 +1,8 @@ package com.gkhy.safePlatform.emergency.entity; public class DemoInfoDo { private String name; private Byte status; } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/DemoInfoRepository.java
对比新文件 @@ -0,0 +1,4 @@ package com.gkhy.safePlatform.emergency.repository; public class DemoInfoRepository { } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/DemoService.java
对比新文件 @@ -0,0 +1,10 @@ package com.gkhy.safePlatform.emergency.service; import org.springframework.beans.factory.annotation.Autowired; public interface DemoService { } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/DemoInfoService.java
对比新文件 @@ -0,0 +1,6 @@ package com.gkhy.safePlatform.emergency.service.baseService; public interface DemoInfoService { // DO } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/DemoServiceImpl.java
对比新文件 @@ -0,0 +1,17 @@ package com.gkhy.safePlatform.emergency.service.impl; import com.gkhy.safePlatform.emergency.service.DemoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service("demoService") public class DemoServiceImpl implements DemoService { @Autowired private DemoService demoService; // 1 //2 //返回的都是dto 到controller } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/LoginController.java
@@ -2,7 +2,8 @@ import com.alibaba.fastjson.JSONObject; import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService; import com.gkhy.safePlatform.account.rpc.apimodel.model.UserLoginRespDTO; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.MenuRPCRespDTO; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.UserLoginRPCRespDTO; import com.gkhy.safePlatform.commons.vo.ResultVO; import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; @@ -10,6 +11,9 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.security.Principal; import java.util.List; @RestController @RequestMapping("/auth") @@ -19,9 +23,15 @@ private UserAccountService userAccountService; @RequestMapping("/login") public ResultVO<UserLoginRespDTO> authLogin(@RequestBody JSONObject loginForm){ public ResultVO<UserLoginRPCRespDTO> authLogin(@RequestBody JSONObject loginForm){ String username = loginForm.getString("username"); String password = loginForm.getString("password"); return userAccountService.authLogin(username, password); } @RequestMapping("/menu") public ResultVO<List<MenuRPCRespDTO>> getMenu(Principal principal, Long projectId){ String userId = principal.getName(); return userAccountService.getMenu(Long.valueOf(userId), projectId); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/MenuController.java
对比新文件 @@ -0,0 +1,43 @@ package com.gkhy.safePlatform.accountController; import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService; import com.gkhy.safePlatform.account.rpc.apimodel.model.req.MenuAddRPCReqDTO; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.MenuModRPCReqDTO; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.vo.ResultVO; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.security.Principal; @RestController @RequestMapping("/menu") public class MenuController { @DubboReference(check = false) private UserAccountService userAccountService; /** * @Description: 新增菜单 */ @RequestMapping(value = "/add",method = RequestMethod.POST) public ResultVO<String> addMenu(Principal principal, @RequestBody MenuAddRPCReqDTO menuAddDto) { String userId = principal.getName(); return userAccountService.addMenu(Long.valueOf(userId), menuAddDto); } /** * @Description: 新增菜单 */ @RequestMapping(value = "/mod",method = RequestMethod.POST) public ResultVO<String> addMenu(Principal principal, @RequestBody MenuModRPCReqDTO menuModDto) { String userId = principal.getName(); return userAccountService.modMenu(Long.valueOf(userId), menuModDto); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java
对比新文件 @@ -0,0 +1,51 @@ package com.gkhy.safePlatform.config.exception; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.AusinessException; import com.gkhy.safePlatform.commons.exception.BusinessException; import com.gkhy.safePlatform.commons.vo.ResultVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; @ControllerAdvice public class GlobalExceptionHandler { private final Logger logger = LoggerFactory.getLogger(this.getClass()); /** * 自定义异常 */ @ResponseBody @ExceptionHandler(value = AusinessException.class) public ResultVO AHandler(AusinessException e) { logger.warn(e.getMessage()); return new ResultVO(e.getCode(),e.getMessage()); } /** * 通用异常 */ @ResponseBody @ExceptionHandler(value = BusinessException.class) public ResultVO AHandler(BusinessException e) { logger.warn(e.getMessage()); return new ResultVO(e.getError()); } /** * 系统错误异常 */ @ResponseBody @ExceptionHandler(value = Exception.class) public ResultVO errorHandler(Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return new ResultVO(ResultCodes.SERVER_ERROR); } }