好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Java实战之药品管理系统的实现

项目介绍

本项目属于前后端分离的项目,分为两个角色药品管理员和取药处人员

药品管理员:

登录、退出、药品信息录入、药厂信息录入、采购员信息录入、药品信息浏览、药厂信息浏览、采购人员信息浏览、药品信息查询入库修改删除、药厂信息入库修改删除、采购员信息入库修改删除、入库记录浏览、出库记录浏览、系统帮助

取药处人员:

登录、退出、药品信息浏览、药厂信息浏览、采购员信息浏览、药品信息查询出库、出库记录浏览、系统帮助

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。

2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;

3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可

4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;

5.数据库:MySql 5.7版本;

6.是否Maven项目:是

技术栈

1. 后端:SpringBoot

2. 前端:html+layui+jquery+bootstrap+echarts

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

4. 运行项目,后端输入localhost:8081/

效果图展示

实现核心代码

用户相关的controller控制层

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

/**

  * 用户相关的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

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

/**

  * 药品相关的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

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

/**

  * 供应商相关的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);

     }

 

}

以上就是Java实战之药品管理系统的实现的详细内容,更多关于Java药品管理系统的资料请关注其它相关文章!

原文链接:https://blog.csdn.net/m0_66863468/article/details/124488010

查看更多关于Java实战之药品管理系统的实现的详细内容...

  阅读:13次