SysLoginController.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package net.chenlin.dp.modules.sys.controller;
  2. import com.google.code.kaptcha.Constants;
  3. import com.taobao.api.ApiException;
  4. import net.chenlin.dp.common.annotation.SysLog;
  5. import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
  6. import net.chenlin.dp.common.openapi4j.service.AcceptService;
  7. import net.chenlin.dp.common.support.orm.db.DynamicDataSource;
  8. import net.chenlin.dp.common.support.properties.GlobalProperties;
  9. import net.chenlin.dp.common.utils.MD5Utils;
  10. import net.chenlin.dp.common.utils.ShiroUtils;
  11. import net.chenlin.dp.modules.api.controller.*;
  12. import net.chenlin.dp.modules.api.dao.AcceptOrderMapper;
  13. import net.chenlin.dp.modules.api.dao.CustomerMapper;
  14. import net.chenlin.dp.modules.api.dao.SaleOrderMapper;
  15. import net.chenlin.dp.modules.api.service.CustomerService;
  16. import net.chenlin.dp.modules.api.service.PayrequestService;
  17. import net.chenlin.dp.modules.api.service.PurchaseOrderService;
  18. import net.chenlin.dp.modules.api.service.SaleOrderService;
  19. import net.chenlin.dp.modules.api.vo.*;
  20. import net.chenlin.dp.modules.sys.service.SysUserService;
  21. import net.chenlin.dp.modules.sys.service.impl.SysUserServiceImpl;
  22. import org.apache.commons.lang.StringUtils;
  23. import org.apache.shiro.SecurityUtils;
  24. import org.apache.shiro.authc.*;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.stereotype.Controller;
  27. import org.springframework.ui.Model;
  28. import org.springframework.web.bind.annotation.RequestMapping;
  29. import org.springframework.web.bind.annotation.RequestMethod;
  30. import java.math.BigDecimal;
  31. import java.util.ArrayList;
  32. import java.util.HashMap;
  33. import java.util.List;
  34. import java.util.Map;
  35. /**
  36. * 用户controller
  37. * @author zcl<yczclcn@163.com>
  38. */
  39. @Controller
  40. public class SysLoginController extends AbstractController {
  41. @Autowired
  42. private SysUserService sysUserService;
  43. @Autowired
  44. private GlobalProperties globalProperties;
  45. /**
  46. * 跳转登录页面
  47. * @return
  48. */
  49. @RequestMapping(value = "/login", method = RequestMethod.GET)
  50. public String toLogin() {
  51. if (ShiroUtils.isLogin() || ShiroUtils.getUserEntity() != null) {
  52. return redirect("/");
  53. }
  54. return html("/login");
  55. }
  56. /**
  57. * 登录
  58. */
  59. @SysLog("登录")
  60. @RequestMapping(value = "/login", method = RequestMethod.POST)
  61. public String login(Model model) throws OpenAPIException, ApiException {
  62. String username = getParam("username").trim();
  63. String password = getParam("password").trim();
  64. Map<String,String>map=new HashMap<>();
  65. SaleOrderService service=new SaleOrderService();
  66. service.getToaccount();
  67. service.IKSDDKOrder();
  68. //saleOrderController.SaleOrderBJ();
  69. // try {
  70. // // 开启验证码
  71. // if (globalProperties.isKaptchaEnable()) {
  72. // String code = getParam("code").trim();
  73. // if (StringUtils.isBlank(code)) {
  74. // model.addAttribute("errorMsg", "验证码不能为空");
  75. // return html("/login");
  76. // }
  77. // String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
  78. // if (!code.equalsIgnoreCase(kaptcha)) {
  79. // model.addAttribute("errorMsg", "验证码错误");
  80. // return html("/login");
  81. // }
  82. // }
  83. // // 用户名验证
  84. // if (StringUtils.isBlank(username)) {
  85. // model.addAttribute("errorMsg", "用户名不能为空");
  86. // return html("/login");
  87. // }
  88. // // 密码验证
  89. // if (StringUtils.isBlank(password)) {
  90. // model.addAttribute("errorMsg", "密码不能为空");
  91. // return html("/login");
  92. // }
  93. // UsernamePasswordToken token = new UsernamePasswordToken(username, MD5Utils.encrypt(username, password));
  94. // ShiroUtils.getSubject().login(token);
  95. // SecurityUtils.getSubject().getSession().setAttribute("sessionFlag", true);
  96. // return redirect("/");
  97. // } catch (UnknownAccountException | IncorrectCredentialsException | LockedAccountException e) {
  98. // model.addAttribute("errorMsg", e.getMessage());
  99. // } catch (AuthenticationException e) {
  100. // model.addAttribute("errorMsg", "登录服务异常");
  101. // }
  102. return html("/login");
  103. }
  104. /**
  105. * 跳转后台控制台
  106. * @return
  107. */
  108. @RequestMapping(value = "/", method = RequestMethod.GET)
  109. public String index() {
  110. return html("/index");
  111. }
  112. /**
  113. * 退出
  114. */
  115. @SysLog("退出系统")
  116. @RequestMapping(value = "/logout", method = RequestMethod.GET)
  117. public String logout() {
  118. ShiroUtils.logout();
  119. return html("/login");
  120. }
  121. }