|
| 1 | +package com.vone.mq.controller; |
| 2 | + |
| 3 | +import com.vone.mq.dto.CommonRes; |
| 4 | +import com.vone.mq.dto.PageRes; |
| 5 | +import com.vone.mq.entity.PayQrcode; |
| 6 | +import com.vone.mq.service.AdminService; |
| 7 | +import com.vone.mq.utils.ResUtil; |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; |
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | +import org.springframework.web.bind.annotation.RestController; |
| 11 | + |
| 12 | +import javax.servlet.http.HttpSession; |
| 13 | +import java.util.*; |
| 14 | + |
| 15 | +@RestController |
| 16 | +public class AdminController { |
| 17 | + @Autowired |
| 18 | + private AdminService adminService; |
| 19 | + |
| 20 | + @RequestMapping("/login") |
| 21 | + public CommonRes login(HttpSession session,String user, String pass){ |
| 22 | + if (user==null){ |
| 23 | + return ResUtil.error("请输入账号"); |
| 24 | + } |
| 25 | + if (pass==null){ |
| 26 | + return ResUtil.error("请输入密码"); |
| 27 | + } |
| 28 | + CommonRes r = adminService.login(user, pass); |
| 29 | + if (r.getCode()==1){ |
| 30 | + session.setAttribute("login","1"); |
| 31 | + } |
| 32 | + return r; |
| 33 | + } |
| 34 | + |
| 35 | + @RequestMapping("/admin/getMenu") |
| 36 | + public List<Map<String,Object>> getMenu(HttpSession session){ |
| 37 | + if (session.getAttribute("login")==null){ |
| 38 | + return null; |
| 39 | + } |
| 40 | + List<Map<String,Object>> menu = new ArrayList<>(); |
| 41 | + Map<String,Object> node = new HashMap<>(); |
| 42 | + node.put("name","系统设置"); |
| 43 | + node.put("type","url"); |
| 44 | + node.put("url","admin/setting.html?t="+new Date().getTime()); |
| 45 | + menu.add(node); |
| 46 | + |
| 47 | + node = new HashMap<>(); |
| 48 | + node.put("name","监控端设置"); |
| 49 | + node.put("type","url"); |
| 50 | + node.put("url","admin/jk.html?t="+new Date().getTime()); |
| 51 | + menu.add(node); |
| 52 | + |
| 53 | + |
| 54 | + List<Map<String,Object>> menu1 = new ArrayList<>(); |
| 55 | + |
| 56 | + node = new HashMap<>(); |
| 57 | + node.put("name","添加"); |
| 58 | + node.put("type","url"); |
| 59 | + node.put("url","admin/addwxqrcode.html?t="+new Date().getTime()); |
| 60 | + menu1.add(node); |
| 61 | + |
| 62 | + node = new HashMap<>(); |
| 63 | + node.put("name","管理"); |
| 64 | + node.put("type","url"); |
| 65 | + node.put("url","admin/wxqrcodelist.html?t="+new Date().getTime()); |
| 66 | + menu1.add(node); |
| 67 | + |
| 68 | + node = new HashMap<>(); |
| 69 | + node.put("name","微信二维码"); |
| 70 | + node.put("type","menu"); |
| 71 | + node.put("node",menu1); |
| 72 | + menu.add(node); |
| 73 | + |
| 74 | + |
| 75 | + List<Map<String,Object>> menu2 = new ArrayList<>(); |
| 76 | + |
| 77 | + node = new HashMap<>(); |
| 78 | + node.put("name","添加"); |
| 79 | + node.put("type","url"); |
| 80 | + node.put("url","admin/addzfbqrcode.html?t="+new Date().getTime()); |
| 81 | + menu2.add(node); |
| 82 | + |
| 83 | + node = new HashMap<>(); |
| 84 | + node.put("name","管理"); |
| 85 | + node.put("type","url"); |
| 86 | + node.put("url","admin/zfbqrcodelist.html?t="+new Date().getTime()); |
| 87 | + menu2.add(node); |
| 88 | + |
| 89 | + node = new HashMap<>(); |
| 90 | + node.put("name","支付宝二维码"); |
| 91 | + node.put("type","menu"); |
| 92 | + node.put("node",menu2); |
| 93 | + menu.add(node); |
| 94 | + |
| 95 | + node = new HashMap<>(); |
| 96 | + node.put("name","订单列表"); |
| 97 | + node.put("type","url"); |
| 98 | + node.put("url","admin/orderlist.html?t="+new Date().getTime()); |
| 99 | + menu.add(node); |
| 100 | + |
| 101 | + node = new HashMap<>(); |
| 102 | + node.put("name","Api说明"); |
| 103 | + node.put("type","url"); |
| 104 | + node.put("url","../api.html?t="+new Date().getTime()); |
| 105 | + menu.add(node); |
| 106 | + return menu; |
| 107 | + } |
| 108 | + @RequestMapping("/admin/saveSetting") |
| 109 | + public CommonRes saveSetting(HttpSession session,String user,String pass,String notifyUrl,String returnUrl,String key,String wxpay,String zfbpay,String close){ |
| 110 | + if (session.getAttribute("login")==null){ |
| 111 | + return ResUtil.error("未登录"); |
| 112 | + } |
| 113 | + return adminService.saveSetting(user, pass, notifyUrl, returnUrl, key, wxpay, zfbpay, close); |
| 114 | + } |
| 115 | + @RequestMapping("/admin/getSettings") |
| 116 | + public CommonRes getSettings(HttpSession session){ |
| 117 | + if (session.getAttribute("login")==null){ |
| 118 | + return ResUtil.error("未登录"); |
| 119 | + } |
| 120 | + return adminService.getSettings(); |
| 121 | + } |
| 122 | + @RequestMapping("/admin/getOrders") |
| 123 | + public PageRes getOrders(HttpSession session,Integer page, Integer limit, Integer type, Integer state){ |
| 124 | + if (session.getAttribute("login")==null){ |
| 125 | + PageRes p = new PageRes(); |
| 126 | + p.setCode(-1); |
| 127 | + p.setMsg("未登录"); |
| 128 | + return p; |
| 129 | + } |
| 130 | + return adminService.getOrders(page, limit, type,state); |
| 131 | + } |
| 132 | + @RequestMapping("/admin/setBd") |
| 133 | + public CommonRes setBd(HttpSession session,Integer id){ |
| 134 | + if (session.getAttribute("login")==null){ |
| 135 | + return ResUtil.error("未登录"); |
| 136 | + } |
| 137 | + if (id==null){ |
| 138 | + return ResUtil.error(); |
| 139 | + } |
| 140 | + return adminService.setBd(id); |
| 141 | + } |
| 142 | + @RequestMapping("/admin/getPayQrcodes") |
| 143 | + public PageRes getPayQrcodes(HttpSession session,Integer page, Integer limit, Integer type){ |
| 144 | + if (session.getAttribute("login")==null){ |
| 145 | + PageRes p = new PageRes(); |
| 146 | + p.setCode(-1); |
| 147 | + p.setMsg("未登录"); |
| 148 | + return p; |
| 149 | + } |
| 150 | + return adminService.getPayQrcodes(page, limit, type); |
| 151 | + } |
| 152 | + @RequestMapping("/admin/delPayQrcode") |
| 153 | + public CommonRes delPayQrcode(HttpSession session,Long id){ |
| 154 | + if (session.getAttribute("login")==null){ |
| 155 | + return ResUtil.error("未登录"); |
| 156 | + } |
| 157 | + |
| 158 | + return adminService.delPayQrcode(id); |
| 159 | + } |
| 160 | + @RequestMapping("/admin/addPayQrcode") |
| 161 | + public CommonRes addPayQrcode(HttpSession session,PayQrcode payQrcode){ |
| 162 | + if (session.getAttribute("login")==null){ |
| 163 | + return ResUtil.error("未登录"); |
| 164 | + } |
| 165 | + return adminService.addPayQrcode(payQrcode); |
| 166 | + } |
| 167 | + @RequestMapping("/admin/getMain") |
| 168 | + public CommonRes getMain(HttpSession session){ |
| 169 | + if (session.getAttribute("login")==null){ |
| 170 | + return ResUtil.error("未登录"); |
| 171 | + } |
| 172 | + return adminService.getMain(); |
| 173 | + } |
| 174 | + |
| 175 | +} |
0 commit comments