一、项目简述
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringMVC + MyBatis + html+ css + Javascript + JQuery + Ajax + layui+ maven等等
药品相关的controller:
@Controller
@RequestMapping(value = “/druginfo”)
public class DruginfoController {
@Autowired
private IDruginfoService druginfoService;
@RequestMapping
public String druginfo(){
return “/druginfo”;
}
@RequestMapping(value = “/druginfoQueryPage”)
@ResponseBody
public Object druginfoQueryPage(String param, @RequestParam(defaultValue = “1”)int pageNum,@RequestParam(defaultValue = “10”)int pageSize){
try{
IPage iPage = druginfoService.selectDruginfoPage(pageNum,pageSize,param);
return ResultMapUtil.getHashMapMysqlPage(iPage);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
@RequestMapping(value = “/druginfoPage”)
public String druginfoPage(){
return “/druginfoPage”;
}
@RequestMapping(value = “/druginfoAdd”)
@ResponseBody
public Object druginfoAdd(Druginfo druginfo){
try{
int i = druginfoService.addDruginfo(druginfo);
return ResultMapUtil.getHashMapSave(i);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
@RequestMapping(value = “/druginfoQueryById”)
public String druginfoQueryById(@RequestParam(name = “id”,required = true)Integer id, Model model){
Druginfo druginfo = druginfoService.queryDruginfoById(id);
model.addAttribute(“obj”,druginfo);
return “/druginfoPage”;
}
@RequestMapping(value = “/druginfoEdit”)
@ResponseBody
public Object druginfoEdit(Druginfo druginfo){
try{
int i = druginfoService.editDruginfo(druginfo);
return ResultMapUtil.getHashMapSave(i);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
@RequestMapping(value = “/druginfoDelById”)
@ResponseBody
public Object druginfoDelById(Integer id){
try{
int i = druginfoService.delDruginfoById(id);
return ResultMapUtil.getHashMapDel(i);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
@RequestMapping(value = “/druginfoList”)
@ResponseBody
public Object druginfoList(){
List druginfoList = druginfoService.queryDruginfoList();
return ResultMapUtil.getHashMapList(druginfoList);
}
@Controller
public class UserController {
@RequestMapping(value = “/login”)
public String login(){
return “/login”;
}
@RequestMapping(value = “/toLogin”)
@ResponseBody
public Object toLogin(String username,String password){
if(usernamenull||passwordnull){
return ResultMapUtil.getHashMapLogin(“用户名密码不能为空”,“2”);
}
Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username,password);
try{
subject.login(token);
}catch (UnknownAccountException e){
return ResultMapUtil.getHashMapLogin(“用户名不存在”,“2”);
}catch (IncorrectCredentialsException e){
return ResultMapUtil.getHashMapLogin(“密码错误”,“2”);
}
return ResultMapUtil.getHashMapLogin(“验证成功”,“1”);
}
@RequestMapping(value = “/index”)
public String index(){
return “/index”;
}
@RequestMapping(value = “/logout”)
public String logout(){
Subject subject = SecurityUtils.getSubject();
subject.logout();
return “redirect:/login”;
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)