| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.annotation.LoginRequired; |
| | | import com.doumee.config.jwt.JwtTokenUtil; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.dao.business.dto.LoginRequestNewParam; |
| | | import com.doumee.dao.business.model.Category; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.system.model.SystemJob; |
| | | import com.doumee.dao.vo.WebLoginUserVO; |
| | | import com.doumee.service.business.CategoryService; |
| | | import com.doumee.service.business.MemberService; |
| | | import com.sun.deploy.net.HttpUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2025/07/09 12:00 |
| | | */ |
| | | @Api(tags = "webç»å½ç¸å
³æ¥å£") |
| | | @Trace(exclude = true) |
| | | @RestController |
| | | @RequestMapping("/web/login") |
| | | @Slf4j |
| | | public class LoginController extends ApiController { |
| | | |
| | | @Autowired |
| | | private CategoryService categoryService; |
| | | |
| | | @Autowired |
| | | private JwtTokenUtil jwtTokenUtil; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private MemberService memberService; |
| | | |
| | | |
| | | @ApiOperation("UKåç¹ç»å½") |
| | | @GetMapping("/ukLogin") |
| | | public void ukLogin(String tick, Object obj, HttpServletRequest request, HttpServletResponse response) throws Exception { |
| | | LoginRequestNewParam requestParam = new LoginRequestNewParam(); |
| | | /*// UK_ERROR_URL = "http://u.zhibang.com/sso/web/token/error"; |
| | | String errorUrl =systemDictDataBiz.queryByCode(Constants.ZBOM_PARAM,Constants.ZBOM_UK_ERROR_URL).getCode(); |
| | | try { |
| | | log.error("请æ±åæ°TICKæåå§===========ï¼" + tick); |
| | | JSONObject urlParams = new JSONObject(); |
| | | log.info("请æ±åæ°ï¼" + JSON.toJSONString(urlParams)); |
| | | //TICKET_LOGIN_TEST = "http://testsso.zhibang.com:8080/esc-idm/api/v1/getUserInfo"; |
| | | //TICKET_LOGIN = "https://sso.zbom.com/esc-idm/api/v1/getUserInfo"; |
| | | String url = systemDictDataBiz.queryByCode(Constants.ZBOM_PARAM,Constants.ZBOM_TICKET_LOGIN_URL).getCode() + "?tick=" + URLEncoder.encode(tick,Constants.UTF); |
| | | String post = HttpsUtil.get(url,true); |
| | | log.info("è¿ååæ°ï¼" + post); |
| | | JSONObject json = JSONObject.parseObject(post); |
| | | if (StringUtils.equals(json.getString("code"), "0")) { |
| | | JSONObject userInfo = json.getJSONObject("data"); |
| | | requestParam = JSONObject.toJavaObject(userInfo, LoginRequestNewParam.class); |
| | | } else { |
| | | log.error("æ¡ä¾åºç³»ç»åç¹ç»å½å¤±è´¥ é误åå è·åtick失败" + json.getString("message")); |
| | | response.sendRedirect(errorUrl + "?title=" + enCode("ç»éé误") + "&msg="+ enCode(json.getString("message"))); |
| | | return; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("ticketæ¥å£è¯·æ±é误ï¼" + e.getMessage()); |
| | | response.sendRedirect(errorUrl + "?title=" + enCode("ç»éé误") + "&msg=" + enCode("ç³»ç»ç¹å¿ï¼è¯·ç¨åéè¯~")); |
| | | return; |
| | | }*/ |
| | | requestParam.setRediUrl("http://localhost:10087/#/login"); |
| | | WebLoginUserVO loginUserVO = new WebLoginUserVO(); |
| | | loginUserVO.setId("123"); |
| | | loginUserVO.setRoleType("admin"); |
| | | loginUserVO.setZhanqu("1"); |
| | | String token = jwtTokenUtil.generateToken(loginUserVO); |
| | | response.sendRedirect(requestParam.getRediUrl()+"?token="+token); |
| | | } |
| | | |
| | | |
| | | private String enCode(String string) { |
| | | // TODO Auto-generated method stub |
| | | String str = ""; |
| | | try { |
| | | str = java.net.URLEncoder.encode(string, "utf-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("èå¸å页æ¥è¯¢") |
| | | @PostMapping("/memberPage") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse<PageData<Member>> memberPage(@RequestBody PageWrap<Member> pageWrap) { |
| | | WebLoginUserVO loginUserVO = this.getMemberResponse(); |
| | | pageWrap.getModel().setQueryUserRole(loginUserVO.getRoleType()); |
| | | pageWrap.getModel().setQueryZQCode(loginUserVO.getZhanqu()); |
| | | return ApiResponse.success(memberService.findPage(pageWrap)); |
| | | } |
| | | |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("èå¸è¯¦æ
") |
| | | @GetMapping("/memberDetail") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse<Member> memberPage(@RequestParam Integer id) { |
| | | WebLoginUserVO loginUserVO = this.getMemberResponse(); |
| | | return ApiResponse.success(memberService.findDetailById(id,loginUserVO.getRoleType())); |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("åç±»ä¿¡æ¯æ¥è¯¢") |
| | | @GetMapping("/categoryList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse<List<Category>> categoryList(@RequestParam Integer type) { |
| | | return ApiResponse.success(categoryService.getCategoryList(type)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |