/** * . * * * * */ package io.renren.modules.sys.controller; import com.google.code.kaptcha.Constants; import com.google.code.kaptcha.Producer; import io.renren.common.utils.R; import io.renren.modules.sys.shiro.ShiroUtils; import org.apache.shiro.authc.*; import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.imageio.ImageIO; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.IOException; /** * 登录相关 * * @author Mark s.com */ @Controller public class SysLoginController { @Autowired private Producer producer; @RequestMapping("captcha.jpg") public void captcha(HttpServletResponse response)throws IOException { response.setHeader("Cache-Control", "no-store, no-cache"); response.setContentType("image/jpeg"); //生成文字验证码 String text = producer.createText(); //生成图片验证码 BufferedImage image = producer.createImage(text); //保存到shiro session ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); ServletOutputStream out = response.getOutputStream(); ImageIO.write(image, "jpg", out); } /** * 登录 */ @ResponseBody @RequestMapping(value = "/sys/login", method = RequestMethod.POST) public R login(String username, String password, String captcha) { String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); if(!captcha.equalsIgnoreCase(kaptcha)){ return R.error("验证码不正确"); } try{ Subject subject = ShiroUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(username, password);//md5+Jiayan subject.login(token); }catch (UnknownAccountException e) { return R.error(e.getMessage()); }catch (IncorrectCredentialsException e) { return R.error("账号或密码不正确"); }catch (LockedAccountException e) { return R.error("账号已被锁定,请联系管理员"); }catch (AuthenticationException e) { return R.error("账户验证失败"); } return R.ok(); } /** * 退出 */ @RequestMapping(value = "logout", method = RequestMethod.GET) public String logout() { ShiroUtils.logout(); return "redirect:login.html"; } }
package io.renren.modules.sys.controller; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; import io.renren.modules.sys.entity.MatterApply; import io.renren.modules.sys.service.MatterApplyService; import io.renren.modules.sys.service.impl.MatterApplyServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Arrays; import java.util.Date; import java.util.Map; @RestController @RequestMapping("/sys/matterApply") public class MatterApplyController extends AbstractController { @Autowired private MatterApplyService MatterApplyService; @Autowired MatterApplyServiceImpl MatterApplyServiceImpe; @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params){ PageUtils page = MatterApplyService.queryPage(params); return R.ok().put("page", page); } @RequestMapping("/AuditList") public R AuditList(@RequestParam Map<String, Object> params){ params.put("applyStu","未审核"); PageUtils page = MatterApplyService.queryPage(params); return R.ok().put("page", page); } @RequestMapping("/listByUser") public R listByUser(@RequestParam Map<String, Object> params){ params.put("applyUserId",String.valueOf(getUserId())); PageUtils page = MatterApplyService.queryPage(params); return R.ok().put("page", page); } @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ MatterApply matterApply = MatterApplyService.getById(id); return R.ok().put("matterApply", matterApply); } @RequestMapping("/save") public R save(@RequestBody MatterApply matterApply){ matterApply.setApplyTime(new Date()); matterApply.setApplyUserId(getUserId()); matterApply.setApplyStu("未审核"); MatterApplyService.save(matterApply); return R.ok(); } @RequestMapping("/update") public R update(@RequestBody MatterApply matterApply){ MatterApplyService.updateById(matterApply); return R.ok(); } @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ MatterApplyService.removeByIds(Arrays.asList(ids)); return R.ok(); } }
CREATE TABLE `NewTable` ( `user_id` bigint(20) NOT NULL AUTO_INCREMENT , `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名' , `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码' , `salt` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '盐' , `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱' , `mobile` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号' , `status` tinyint(4) NULL DEFAULT NULL COMMENT '状态 0:禁用 1:正常' , `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '部门ID' , `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间' , PRIMARY KEY (`user_id`), UNIQUE INDEX `username` (`username`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='系统用户' AUTO_INCREMENT=3 ROW_FORMAT=COMPACT ;
点击查看更多java精品毕业设计+现成产品项目 >>>