From b3f4a3ac181592549a464b28833ecc4c5ded23f1 Mon Sep 17 00:00:00 2001 From: Tang Cheng Date: Tue, 2 Jul 2019 21:42:37 +0800 Subject: [PATCH] =?utf8?q?=E6=95=B4=E7=90=86=E6=95=B0=E6=8D=AE=E5=AD=97?= =?utf8?q?=E5=85=B8=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../dlpay/framework/util/Dictionary.java | 3 + .../system/controller/UserController.java | 242 +++++++++--------- src/main/resources/data.sql | 29 +++ src/main/resources/static/libs/custom.js | 16 +- .../templates/system/user/account.html | 71 +++-- .../templates/system/user/index.html | 73 +++--- 6 files changed, 241 insertions(+), 193 deletions(-) diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/Dictionary.java b/src/main/java/com/supwisdom/dlpay/framework/util/Dictionary.java index af7b9e25..46377e92 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/util/Dictionary.java +++ b/src/main/java/com/supwisdom/dlpay/framework/util/Dictionary.java @@ -4,6 +4,9 @@ public class Dictionary { // dictionary 表字典 public static final String REVERSE_FLAG = "reverseflagList"; public static final String DTL_STATUS = "dtlStatusList"; + public static final String IDTYPE = "idtypeList"; + public static final String SEX = "sexList"; + public static final String ACCOUNT_STATUS = "accountStatusList"; ///////////////////////////////////// public static final String SOURCE_TYPE = "sourcetypeList"; diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/UserController.java b/src/main/java/com/supwisdom/dlpay/system/controller/UserController.java index a39aa521..31c7faef 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/UserController.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/UserController.java @@ -6,11 +6,13 @@ import com.supwisdom.dlpay.api.domain.TPerson; import com.supwisdom.dlpay.api.domain.TPersonIdentity; import com.supwisdom.dlpay.api.domain.TPointsAccount; import com.supwisdom.dlpay.framework.domain.TOperator; +import com.supwisdom.dlpay.framework.util.Dictionary; import com.supwisdom.dlpay.framework.util.PageResult; import com.supwisdom.dlpay.framework.util.StringUtil; import com.supwisdom.dlpay.framework.util.WebConstant; import com.supwisdom.dlpay.system.bean.IdTypeBean; import com.supwisdom.dlpay.system.bean.PersonParamBean; +import com.supwisdom.dlpay.system.service.DictionaryProxy; import com.supwisdom.dlpay.system.service.UserDataService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -23,142 +25,140 @@ import java.util.List; @Controller public class UserController { - @Autowired - private UserDataService userDataService; + @Autowired + private UserDataService userDataService; - @GetMapping("/user/index") - public String index() { - return "system/user/index"; - } + @Autowired + private DictionaryProxy dictionaryProxy; - @GetMapping("/user/list") - @PreAuthorize("hasPermission('/user/list','')") - @ResponseBody - public PageResult getDataList(@RequestParam("page") Integer pageNo, - @RequestParam("limit") Integer pageSize, - @RequestParam(value = "searchkey", required = false) String searchKey) { - try { - if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; - if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; - PersonParamBean searchBean = new PersonParamBean(); - searchBean.setPageNo(pageNo); - searchBean.setName(searchKey); - searchBean.setPageSize(pageSize); - return userDataService.getPersonsByKey(searchBean); - } catch (Exception e) { - e.printStackTrace(); - return new PageResult<>(99, "系统查询错误"); - } - } + @GetMapping("/user/index") + public String index() { + return "system/user/index"; + } - @GetMapping("/user/loadadd") - public String add(ModelMap map) { - List list = new ArrayList<>(); - list.add(new IdTypeBean("1", "身份证")); - list.add(new IdTypeBean("2", "护照")); - list.add(new IdTypeBean("3", "驾照")); - list.add(new IdTypeBean("4", "港澳通行证")); - list.add(new IdTypeBean("5", "学工号")); - list.add(new IdTypeBean("9", "其他")); - map.put("idtypes", list); - return "system/user/add"; + @GetMapping("/user/list") + @PreAuthorize("hasPermission('/user/list','')") + @ResponseBody + public PageResult getDataList(@RequestParam("page") Integer pageNo, + @RequestParam("limit") Integer pageSize, + @RequestParam(value = "searchkey", required = false) String searchKey) { + try { + if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; + if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; + PersonParamBean searchBean = new PersonParamBean(); + searchBean.setPageNo(pageNo); + searchBean.setName(searchKey); + searchBean.setPageSize(pageSize); + return userDataService.getPersonsByKey(searchBean); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); } + } - @PostMapping("/user/add") - @PreAuthorize("hasPermission('/user/add','')") - @ResponseBody - public JsonResult add(@RequestBody TPerson person) { - if (StringUtil.isEmpty(person.getName()) - || StringUtil.isEmpty(person.getSex()) - || StringUtil.isEmpty(person.getIdno()) - || StringUtil.isEmpty(person.getIdtype()) - || StringUtil.isEmpty(person.getMobile())) { - return JsonResult.error("参数错误"); - } - return userDataService.saveUser(person); - } + @GetMapping("/user/loadadd") + public String add(ModelMap map) { + map.put(Dictionary.IDTYPE, dictionaryProxy.getDictionaryAsList(Dictionary.IDTYPE)); + return "system/user/add"; + } - @PostMapping("/user/del") - @PreAuthorize("hasPermission('/user/del','')") - @ResponseBody - public JsonResult del(@RequestParam String userid) { - if (StringUtil.isEmpty(userid)) { - return JsonResult.error("参数错误"); - } - return userDataService.deleteUser(userid); + @PostMapping("/user/add") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult add(@RequestBody TPerson person) { + if (StringUtil.isEmpty(person.getName()) + || StringUtil.isEmpty(person.getSex()) + || StringUtil.isEmpty(person.getIdno()) + || StringUtil.isEmpty(person.getIdtype()) + || StringUtil.isEmpty(person.getMobile())) { + return JsonResult.error("参数错误"); } + return userDataService.saveUser(person); + } - @GetMapping("/user/acc") - public String acc() { - return "system/user/account"; + @PostMapping("/user/del") + @PreAuthorize("hasPermission('/user/del','')") + @ResponseBody + public JsonResult del(@RequestParam String userid) { + if (StringUtil.isEmpty(userid)) { + return JsonResult.error("参数错误"); } + return userDataService.deleteUser(userid); + } - @GetMapping("/user/account") - @PreAuthorize("hasPermission('/user/account','')") - @ResponseBody - public PageResult getDataAccountList(@RequestParam("page") Integer pageNo, - @RequestParam("limit") Integer pageSize, - @RequestParam(value = "searchkey", required = false) String searchKey) { - try { - if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; - if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; - PersonParamBean searchBean = new PersonParamBean(); - searchBean.setPageNo(pageNo); - searchBean.setName(searchKey); - searchBean.setPageSize(pageSize); - return userDataService.getAccountsByKey(searchBean); - } catch (Exception e) { - e.printStackTrace(); - return new PageResult<>(99, "系统查询错误"); - } - } + @GetMapping("/user/acc") + public String acc() { + return "system/user/account"; + } - @GetMapping("/user/point") - public String point() { - return "system/user/point"; + @GetMapping("/user/account") + @PreAuthorize("hasPermission('/user/account','')") + @ResponseBody + public PageResult getDataAccountList(@RequestParam("page") Integer pageNo, + @RequestParam("limit") Integer pageSize, + @RequestParam(value = "searchkey", required = false) String searchKey) { + try { + if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; + if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; + PersonParamBean searchBean = new PersonParamBean(); + searchBean.setPageNo(pageNo); + searchBean.setName(searchKey); + searchBean.setPageSize(pageSize); + return userDataService.getAccountsByKey(searchBean); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); } + } - @GetMapping("/user/pointlist") - @PreAuthorize("hasPermission('/user/pointlist','')") - @ResponseBody - public PageResult getDataPointList(@RequestParam("page") Integer pageNo, - @RequestParam("limit") Integer pageSize, - @RequestParam(value = "searchkey", required = false) String searchKey) { - try { - if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; - if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; - PersonParamBean searchBean = new PersonParamBean(); - searchBean.setPageNo(pageNo); - searchBean.setName(searchKey); - searchBean.setPageSize(pageSize); - return userDataService.getPointsByKey(searchBean); - } catch (Exception e) { - e.printStackTrace(); - return new PageResult<>(99, "系统查询错误"); - } - } + @GetMapping("/user/point") + public String point() { + return "system/user/point"; + } - @PostMapping("/user/delacc") - @PreAuthorize("hasPermission('/user/delacc','')") - @ResponseBody - public JsonResult delacc(@RequestParam String accno) { - if (StringUtil.isEmpty(accno)) { - return JsonResult.error("参数错误"); - } - return userDataService.closeAccount(accno); + @GetMapping("/user/pointlist") + @PreAuthorize("hasPermission('/user/pointlist','')") + @ResponseBody + public PageResult getDataPointList(@RequestParam("page") Integer pageNo, + @RequestParam("limit") Integer pageSize, + @RequestParam(value = "searchkey", required = false) String searchKey) { + try { + if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; + if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; + PersonParamBean searchBean = new PersonParamBean(); + searchBean.setPageNo(pageNo); + searchBean.setName(searchKey); + searchBean.setPageSize(pageSize); + return userDataService.getPointsByKey(searchBean); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); } - @PostMapping("/user/delpoint") - @PreAuthorize("hasPermission('/user/delpoint','')") - @ResponseBody - public JsonResult delpoint(@RequestParam String userid) { - if (StringUtil.isEmpty(userid)) { - return JsonResult.error("参数错误"); - } - return userDataService.deletePoint(userid); + } + + @PostMapping("/user/delacc") + @PreAuthorize("hasPermission('/user/delacc','')") + @ResponseBody + public JsonResult delacc(@RequestParam String accno) { + if (StringUtil.isEmpty(accno)) { + return JsonResult.error("参数错误"); } - @GetMapping("/user/pointdtl") - public String pointdtl(@RequestParam String userid,ModelMap map) { - map.put("userid",userid); - return "system/user/pointdtl"; + return userDataService.closeAccount(accno); + } + + @PostMapping("/user/delpoint") + @PreAuthorize("hasPermission('/user/delpoint','')") + @ResponseBody + public JsonResult delpoint(@RequestParam String userid) { + if (StringUtil.isEmpty(userid)) { + return JsonResult.error("参数错误"); } + return userDataService.deletePoint(userid); + } + + @GetMapping("/user/pointdtl") + public String pointdtl(@RequestParam String userid, ModelMap map) { + map.put("userid", userid); + return "system/user/pointdtl"; + } } diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 5e91f802..b16d5a47 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -506,5 +506,34 @@ VALUES ('wip', 'dtlStatusList','待支付', '流水状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") VALUES ('cancel','dtlStatusList', '交易取消', '流水状态', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('1', 'idtypeList', '身份证', '证件类型', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('2', 'idtypeList', '护照', '证件类型', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('3', 'idtypeList', '驾照', '证件类型', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('4', 'idtypeList', '港澳通行证', '证件类型', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('5', 'idtypeList', '学工号', '证件类型', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('9', 'idtypeList', '其他', '证件类型', '{tenantid}'); + + +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('male', 'sexList', '男', '性别', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('female', 'sexList', '女', '性别', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('unknown', 'sexList', '未知', '性别', '{tenantid}'); + +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('normal', 'accountStatusList', '正常', '账户状态', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('closed', 'accountStatusList', '注销', '账户状态', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('locked', 'accountStatusList', '锁定', '账户状态', '{tenantid}'); +INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") +VALUES ('unknown', 'accountStatusList', '异常', '账户状态', '{tenantid}'); ---------------------------------------------------- commit; \ No newline at end of file diff --git a/src/main/resources/static/libs/custom.js b/src/main/resources/static/libs/custom.js index e91928dd..21e96014 100644 --- a/src/main/resources/static/libs/custom.js +++ b/src/main/resources/static/libs/custom.js @@ -15,7 +15,7 @@ pool: {}, addNewDict: function (dictType) { var that = this; - console.log("正在加载<"+dictType+">"); + console.log("正在加载<" + dictType + ">"); $.ajax(that.url, { method: "GET", data: "dicttype=" + dictType, @@ -25,11 +25,11 @@ that.storage.removeItem(dictType); } else { that.storage.setItem(dictType, JSON.stringify(data)); - console.log("<"+dictType+">加载成功!"); + console.log("<" + dictType + ">加载成功!"); } }, - error: function(e){ - console.log("<"+dictType+">加载失败!"); + error: function (e) { + console.log("<" + dictType + ">加载失败!"); } } ); @@ -48,7 +48,7 @@ that.storage.removeItem(dictType); } else { that.storage.setItem(dictType, JSON.stringify(data)); - console.log("<"+dictType+">加载成功!"); + console.log("<" + dictType + ">加载成功!"); } }, error: function (e) { @@ -60,7 +60,11 @@ }, initAll: function (url) { this.url = url; - this.addNewDict("sourcetypeList").addNewDict("reverseFlagList"); + this.addNewDict("sourcetypeList") + .addNewDict("reverseFlagList") + .addNewDict("idtypeList") + .addNewDict("sexList") + .addNewDict("accountStatusList") }, getDict: function (dictType) { var dict, that = this; diff --git a/src/main/resources/templates/system/user/account.html b/src/main/resources/templates/system/user/account.html index cd9cc576..988fa72d 100644 --- a/src/main/resources/templates/system/user/account.html +++ b/src/main/resources/templates/system/user/account.html @@ -9,8 +9,10 @@
搜索: -   -
@@ -29,36 +31,53 @@ page: true, cols: [ [ - {field: 'accno', title: '账号',fixed: 'left', width: 100}, - {field: 'person', title: '名称', width: 80,fixed: 'left', sort: true, templet: function (item) { - if(item.accname!=null){ + {field: 'accno', title: '账号', fixed: 'left', width: 100}, + { + field: 'person', + title: '名称', + width: 80, + fixed: 'left', + sort: true, + templet: function (item) { + if (item.accname != null) { return item.accname; } return item.person.name; - }}, - {field: 'transStatus', title: '状态',fixed: 'left',width: 80 , templet: function (item) { - if (item.transStatus == 'normal') { - return '正常' - } else if (item.transStatus == 'closed') { - return '注销' - } else if (item.transStatus == 'locked') { - return '锁定' - } else { + } + }, + { + field: 'transStatus', + title: '状态', + fixed: 'left', + width: 80, + templet: function (item) { + let desc = getTempDictValue('accountStatusList', item.transStatus) + if (item.transStatus === 'normal') { + return '' + desc + '' + } else if (item.transStatus === 'closed') { + return '' + desc + '' + } else if (item.transStatus === 'locked') { + return '' + desc + '' + } else { return '异常' } } }, - {field: 'availbal', title: '可用余额', width: 100,fixed: 'left', sort: true}, - {field: 'balance', title: '总余额', width: 100,fixed: 'left', sort: true}, - {field: 'frozebal', title: '冻结余额', width: 100,fixed: 'left', sort: true}, - {field: 'lasttranstime', title: '最后交易日期', width: 120,fixed: 'left', sort: true}, - {field: 'opendate', title: '开户日期', width: 100,fixed: 'left', sort: true}, + {field: 'availbal', title: '可用余额', width: 100, fixed: 'left', sort: true}, + {field: 'balance', title: '总余额', width: 100, fixed: 'left', sort: true}, + {field: 'frozebal', title: '冻结余额', width: 100, fixed: 'left', sort: true}, + {field: 'lasttranstime', title: '最后交易日期', width: 120, fixed: 'left', sort: true}, + {field: 'opendate', title: '开户日期', width: 100, fixed: 'left', sort: true}, { - field: 'accno', align: 'center', title: '操作', fixed: 'right', templet: function (item) { - if (item.transStatus != 'closed') { + field: 'accno', + align: 'center', + title: '操作', + fixed: 'right', + templet: function (item) { + if (item.transStatus !== 'closed') { let html = ' 注销 '; return html; - }else { + } else { return ''; } } @@ -93,9 +112,9 @@ }, function (data) { console.log(data.code); layer.closeAll('loading'); - if (data.code == 200) { + if (data.code === 200) { layer.msg(data.msg, {icon: 1}); - } else if (data.code == 401) { + } else if (data.code === 401) { layer.msg(data.msg, {icon: 2, time: 1500}, function () { location.replace('[[@{/login}]]'); }, 1000); @@ -107,9 +126,9 @@ }, function (ret) { console.log(ret); layer.closeAll('loading'); - if(ret.transStatus==403){ + if (ret.transStatus === 403) { layer.msg('没有权限', {icon: 2}); - }else{ + } else { layer.msg('请求失败了,请稍后再试', {icon: 2}); } }); diff --git a/src/main/resources/templates/system/user/index.html b/src/main/resources/templates/system/user/index.html index dc009c7f..8e133646 100644 --- a/src/main/resources/templates/system/user/index.html +++ b/src/main/resources/templates/system/user/index.html @@ -12,7 +12,8 @@ - +
@@ -30,55 +31,47 @@ page: true, cols: [ [ - {field: 'name', title: '名称', width: 80,fixed: 'left', sort: true}, - {field: 'sex', title: '性别',fixed: 'left', width: 80, templet: function (item) { - if (item.sex === 'male') { - return '男' - } else if (item.sex === 'female') { - return '女' - } else { - return '男' - } + {field: 'name', title: '名称', width: 80, fixed: 'left', sort: true}, + { + field: 'sex', title: '性别', fixed: 'left', width: 80, + templet: function (item) { + return getTempDictValue('sexList', item.sex); } }, - {field: 'status', title: '状态',fixed: 'left',width: 80 , templet: function (item) { + { + field: 'status', title: '状态', fixed: 'left', width: 80, templet: function (item) { + let desc = getTempDictValue('accountStatusList', item.status) if (item.status === 'normal') { - return '正常' + return '' + desc + '' } else if (item.status === 'closed') { - return '注销' + return '' + desc + '' } else if (item.status === 'locked') { - return '锁定' - } else { + return '' + desc + '' + } else { return '异常' } } }, - {field: 'idtype', align: 'center',width: 100, title: '证件类型', fixed: 'left', templet: function (item) { - if (item.idtype === '1') { - return '身份证' - } else if (item.idtype === '2') { - return '护照' - } else if (item.idtype === '3') { - return '驾照' - } else if (item.idtype === '4') { - return '港澳通行证' - } else if (item.idtype === '5') { - return '学工号' - } else { - return '其他' - } + { + field: 'idtype', align: 'center', width: 100, title: '证件类型', fixed: 'left', + templet: function (item) { + return getTempDictValue('idtypeList', item.idtype); } }, - {field: 'idno', title: '证件号', width: 120,fixed: 'left', sort: true}, - {field: 'email', title: '邮箱', width: 100,fixed: 'left', sort: true}, - {field: 'mobile', title: '手机', width: 120,fixed: 'left', sort: true}, - {field: 'tel', title: '电话', width: 100,fixed: 'left', sort: true}, - {field: 'addr', title: '地址', width: 200,fixed: 'left', sort: true}, - {field: 'lastsaved', title: '最后修改时间', width: 140,fixed: 'left', sort: true}, + {field: 'idno', title: '证件号', width: 120, fixed: 'left', sort: true}, + {field: 'email', title: '邮箱', width: 100, fixed: 'left', sort: true}, + {field: 'mobile', title: '手机', width: 120, fixed: 'left', sort: true}, + {field: 'tel', title: '电话', width: 100, fixed: 'left', sort: true}, + {field: 'addr', title: '地址', width: 200, fixed: 'left', sort: true}, + {field: 'lastsaved', title: '最后修改时间', width: 140, fixed: 'left', sort: true}, { - field: 'userid', align: 'center', title: '操作', fixed: 'right', templet: function (item) { - let html = ' 编辑 '; - html +='删除'; + field: 'userid', + align: 'center', + title: '操作', + fixed: 'right', + templet: function (item) { + let html = ' 编辑 '; + html += '删除'; /*html += '交易记录 ';*/ return html; } @@ -142,9 +135,9 @@ }, function (ret) { console.log(ret); layer.closeAll('loading'); - if(ret.transStatus===403){ + if (ret.transStatus === 403) { layer.msg('没有权限', {icon: 2}); - }else{ + } else { layer.msg('请求失败了,请稍后再试', {icon: 2}); } }); -- 2.17.1