| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.RequestHeader; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | public TAppUser queryAppUser1(@RequestBody Integer appUserId) { |
| | | TAppUser appUser = appUserService.getById(appUserId); |
| | | return appUser; |
| | | } |
| | | |
| | | /** |
| | | * Internal-only data source for the management sensitive-data query. The |
| | | * caller is authenticated and authorised by the management service; its |
| | | * Feign interceptor adds the header that permits the response to remain |
| | | * unmasked for that single request. |
| | | */ |
| | | @PostMapping("/internal/sensitive/app-user/{id}") |
| | | public Map<String, Object> sensitiveAppUser(@PathVariable("id") Integer id, |
| | | @RequestHeader(value = "X-Internal-Sensitive-Access", required = false) String access) { |
| | | if (!"true".equalsIgnoreCase(access)) { |
| | | throw new IllegalStateException("Sensitive data access is restricted to the management service"); |
| | | } |
| | | TAppUser user = appUserService.getById(id); |
| | | if (user == null) return null; |
| | | Map<String, Object> result = new java.util.HashMap<String, Object>(); |
| | | result.put("id", user.getId()); |
| | | result.put("name", user.getName()); |
| | | result.put("phone", user.getPhone()); |
| | | result.put("idCard", user.getIdCard()); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | |
| | | public void updateAppUser(@RequestBody TAppUser appUser) { |
| | | try { |
| | | TAppUser appUser1 = appUserService.getById(appUser.getId()); |
| | | // A management edit form may contain the displayed masked value. |
| | | // Never persist that display value over the original identifier. |
| | | if (appUser.getPhone() != null && appUser.getPhone().contains("*")) appUser.setPhone(appUser1.getPhone()); |
| | | if (appUser.getIdCard() != null && appUser.getIdCard().contains("*")) appUser.setIdCard(appUser1.getIdCard()); |
| | | appUserService.updateById(appUser); |
| | | if (appUser.getIntegral().compareTo(appUser1.getIntegral()) != 0) { |
| | | UserIntegralChanges userIntegralChanges = new UserIntegralChanges(); |