| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse; |
| | | 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.dingTalk.DingTalk; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | |
| | | 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.dto.DingLoginDTO; |
| | | import com.doumee.dao.system.model.SystemJob; |
| | | import com.doumee.dao.vo.WebLoginUserVO; |
| | | import com.doumee.service.business.CategoryService; |
| | | import com.sun.deploy.net.HttpUtils; |
| | | import com.doumee.service.business.MemberService; |
| | | import com.taobao.api.ApiException; |
| | | 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.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | |
| | | * @date 2025/07/09 12:00 |
| | | */ |
| | | @Api(tags = "web登录相关接口") |
| | | @Trace(exclude = true) |
| | | @RestController |
| | | @RequestMapping("/web") |
| | | @RequestMapping("/web/login") |
| | | @Slf4j |
| | | public class LoginController extends BaseController { |
| | | public class LoginController extends ApiController { |
| | | |
| | | @Autowired |
| | | private CategoryService categoryService; |
| | | |
| | | @Autowired |
| | | private JwtTokenUtil jwtTokenUtil; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private MemberService memberService; |
| | | |
| | | @Autowired |
| | | private DingTalk dingTalk; |
| | | |
| | | |
| | | @ApiOperation("UK单点登录") |
| | | @RequestMapping("/ukLogin") |
| | | @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 { |
| | | /* try { |
| | | log.error("请求参数TICK最原始===========:" + tick); |
| | | JSONObject urlParams = new JSONObject(); |
| | | log.info("请求参数:" + JSON.toJSONString(urlParams)); |
| | |
| | | log.error("ticket接口请求错误:" + e.getMessage()); |
| | | response.sendRedirect(errorUrl + "?title=" + enCode("登陆错误") + "&msg=" + enCode("系统繁忙,请稍后重试~")); |
| | | return; |
| | | } |
| | | }*/ |
| | | requestParam.setRediUrl("http://localhost:10087/#/login"); |
| | | String token = UUID.randomUUID().toString()+"_doumee"; |
| | | WebLoginUserVO loginUserVO = new WebLoginUserVO(); |
| | | loginUserVO.setId("123"); |
| | | loginUserVO.setRoleType("admin"); |
| | | loginUserVO.setZhanqu("1"); |
| | | String token = jwtTokenUtil.generateToken(loginUserVO); |
| | | response.sendRedirect(requestParam.getRediUrl()+"?token="+token); |
| | | } |
| | | |
| | | @ApiOperation("钉钉登录") |
| | | @PostMapping("/ddLogin") |
| | | public ApiResponse<WebLoginUserVO> ddLogin(@Validated @RequestBody DingLoginDTO dingLoginDTO) throws ApiException { |
| | | WebLoginUserVO loginUserVO = new WebLoginUserVO(); |
| | | OapiV2UserGetuserinfoResponse.UserGetByCodeResponse response = dingTalk.getDDUserByCode(dingLoginDTO); |
| | | if(Objects.nonNull(response)){ |
| | | loginUserVO.setId(response.getUserid()); |
| | | loginUserVO.setRoleType(Constants.DD_USER_TYPE); |
| | | } |
| | | loginUserVO.setToken(jwtTokenUtil.generateToken(loginUserVO)); |
| | | return ApiResponse.success(loginUserVO); |
| | | } |
| | | |
| | | |
| | | private String enCode(String string) { |
| | | // TODO Auto-generated method stub |
| | | String str = ""; |
| | |
| | | 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()); |
| | | PageData<Member> pageData = memberService.findPage(pageWrap); |
| | | if(CollectionUtils.isNotEmpty(pageData.getRecords())){ |
| | | String roleConfig = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.ROLE_CONFIG).getCode(); |
| | | if(StringUtils.isBlank(roleConfig)||StringUtils.isBlank(pageWrap.getModel().getQueryUserRole()) |
| | | || ! (roleConfig.contains(pageWrap.getModel().getQueryUserRole()) || pageWrap.getModel().getQueryUserRole().equals(Constants.DD_USER_TYPE) )){ |
| | | pageData.getRecords().forEach(i->{ |
| | | i.setFee(null); |
| | | }); |
| | | } |
| | | } |
| | | return ApiResponse.success(pageData); |
| | | } |
| | | |
| | | |
| | | |
| | | @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)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |