源码获取:俺的博客首页 "资源" 里下载!
一、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
用户相关的controller控制层:
/**
* 用户相关的controller
*/
@Controller
public class UserController {
/**
* 转向登录页面
*/
@RequestMapping(value = "/login")
public String login(){
return "/login";
}
/**
* 判断用户登录是否成功
*/
@RequestMapping(value = "/toLogin")
@ResponseBody
public Object toLogin(String username,String password){
if(username==null||password==null){
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";
}
}
药品相关的controller:
/**
* 药品相关的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<Druginfo> 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<Druginfo> druginfoList = druginfoService.queryDruginfoList();
return ResultMapUtil.getHashMapList(druginfoList);
}
/**
* 转向药品保质期检查页面
*/
@RequestMapping(value = "/warranty")
public String warranty(){
return "/warranty";
}
}
供应商相关的controller:
/**
* 供应商相关的controller
*/
@Controller
@RequestMapping(value = "/supplier")
public class SupplierController {
@Autowired
private ISupplierService supplierService;
/**
* 转向供应商页面
*/
@RequestMapping
public String supplier(){
return "/supplier";
}
/**
* 分页查询供应商列表
*/
@RequestMapping(value = "/supplierQueryPage")
@ResponseBody
public Object supplierQueryPage(String param, @RequestParam(defaultValue = "1")int pageNum,@RequestParam(defaultValue = "10")int pageSize){
try{
IPage<Supplier> iPage = supplierService.selectSupplierPage(pageNum,pageSize,param);
return ResultMapUtil.getHashMapMysqlPage(iPage);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
/**
* 转向供应商新增页面
*/
@RequestMapping(value = "/supplierPage")
public String supplierPage(){
return "/supplierPage";
}
/**
* 添加一个供应商
*/
@RequestMapping(value = "/supplierAdd")
@ResponseBody
public Object supplierAdd(Supplier supplier){
try{
supplier.setCreatetime(new Date());
int i = supplierService.addSupplier(supplier);
return ResultMapUtil.getHashMapSave(i);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
/**
* 转向供应商编辑页面
*/
@RequestMapping(value = "/supplierQueryById")
public String supplierQueryById(@RequestParam(name = "id",required = true)Integer id, Model model){
Supplier supplier = supplierService.querySupplierById(id);
model.addAttribute("obj",supplier);
return "/supplierPage";
}
/**
* 修改一个供应商
*/
@RequestMapping(value = "/supplierEdit")
@ResponseBody
public Object supplierEdit(Supplier supplier){
try{
int i = supplierService.editSupplier(supplier);
return ResultMapUtil.getHashMapSave(i);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
/**
* 删除一个供应商
*/
@RequestMapping(value = "/supplierDelById")
@ResponseBody
public Object supplierDelById(Integer id){
try{
int i = supplierService.delSupplierById(id);
return ResultMapUtil.getHashMapDel(i);
} catch (Exception e){
return ResultMapUtil.getHashMapException(e);
}
}
/**
* 获取所有供应商
*/
@RequestMapping(value = "/supplierList")
@ResponseBody
public Object supplierList(){
List<Supplier> supplierList = supplierService.querySupplierList();
return ResultMapUtil.getHashMapList(supplierList);
}
}
源码获取:俺的博客首页 "资源" 里下载!