|
@@ -0,0 +1,271 @@
|
|
|
+package com.gree.mall.manager.controller.admin;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.gree.mall.manager.annotation.ApiNotAuth;
|
|
|
+import com.gree.mall.manager.bean.ExcelData;
|
|
|
+import com.gree.mall.manager.bean.SVerification;
|
|
|
+import com.gree.mall.manager.bean.admin.*;
|
|
|
+import com.gree.mall.manager.bean.admin.reqDto.AdminCompanyWechatReqBean;
|
|
|
+import com.gree.mall.manager.bean.admin.reqDto.AdminUserAddReqBean;
|
|
|
+import com.gree.mall.manager.bean.admin.respDto.AdminCompanyWechatRespPageBean;
|
|
|
+import com.gree.mall.manager.constant.Constant;
|
|
|
+import com.gree.mall.manager.logic.admin.AdminCompanyWechatLogic;
|
|
|
+import com.gree.mall.manager.logic.admin.AdminUserLogic;
|
|
|
+import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
+import com.gree.mall.manager.helper.ResponseHelper;
|
|
|
+import com.gree.mall.manager.plus.entity.AdminCompanyWechat;
|
|
|
+import com.gree.mall.manager.plus.entity.AdminUser;
|
|
|
+import com.gree.mall.manager.utils.excel.ExcelUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.integration.redis.util.RedisLockRegistry;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.locks.Lock;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@Api(value = "系统用户管理", tags ={"后台用户相关API"} )
|
|
|
+@RequestMapping(value = "/admin/user", produces = "application/json; charset=utf-8")
|
|
|
+public class AdminUserController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AdminUserLogic adminUserLogic;
|
|
|
+ @Autowired
|
|
|
+ AdminCompanyWechatLogic adminCompanyWechatLogic;
|
|
|
+ @Autowired
|
|
|
+ RedisLockRegistry redisLockRegistry;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiNotAuth
|
|
|
+ @PostMapping("/login")
|
|
|
+ @ApiOperation(value = "登录")
|
|
|
+ public ResponseHelper<AdminUserCom> login(
|
|
|
+ @ApiParam(value = "帐号",required = true) @RequestParam(required = true) String userName,
|
|
|
+ @ApiParam(value = "密码",required = false) @RequestParam(required = false) String password,
|
|
|
+ @ApiParam(value = "验证码code",required = false) @RequestParam(required = false) String code,
|
|
|
+ @ApiParam(value = "验证码值",required = false) @RequestParam(required = false) String codeValue
|
|
|
+
|
|
|
+ ) throws RemoteServiceException, InterruptedException {
|
|
|
+ Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_LOGIN + userName);
|
|
|
+ if(!obtain.tryLock(10, TimeUnit.SECONDS)){
|
|
|
+ throw new RemoteServiceException("系统繁忙请稍后再试");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ AdminUserCom adminUserCom = adminUserLogic.login(userName, password, code, codeValue);
|
|
|
+ return ResponseHelper.success(adminUserCom);
|
|
|
+ }finally {
|
|
|
+ obtain.unlock();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/password/update")
|
|
|
+ @ApiOperation(value = "修改密码")
|
|
|
+ public ResponseHelper<AdminUserBean> login(
|
|
|
+ @ApiParam(value = "帐号",required = true) @RequestParam(required = true) String userName,
|
|
|
+ @ApiParam(value = "密码",required = true) @RequestParam(required = true) String password,
|
|
|
+ @ApiParam(value = "新密码",required = true) @RequestParam(required = true) String newPassword
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminUserLogic.updatePassword(userName, password,newPassword);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/status/update")
|
|
|
+ @ApiOperation("修改帐号状态(冻结/正常)")
|
|
|
+ public ResponseHelper updateStatus(
|
|
|
+ @ApiParam(value = "帐号名称",required = true) @RequestParam(required = true) String adminUserId,
|
|
|
+ @ApiParam(value = "true:正常 false:冻结",required = true) @RequestParam(required = true) Boolean status
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminUserLogic.updateStatus(adminUserId,status);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiNotAuth
|
|
|
+ @PostMapping("/addCompanyWechat")
|
|
|
+ @ApiOperation("新增商户")
|
|
|
+ public ResponseHelper addCompanyWechat(
|
|
|
+ @ApiParam(value = "帐号",required = true) @RequestBody AdminCompanyWechatReqBean adminUserBean,
|
|
|
+ HttpServletRequest request
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminCompanyWechatLogic.addCompanyWechat(adminUserBean);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ @ApiOperation("新增帐号")
|
|
|
+ public ResponseHelper add(
|
|
|
+ @ApiParam(value = "帐号",required = true) @RequestBody AdminUserAddReqBean adminUserBean
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminUserLogic.add(adminUserBean,false, false);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/user/updateCompanyWechat")
|
|
|
+ @ApiOperation(value = "修改商户信息")
|
|
|
+ public ResponseHelper updateCompanyWechat(
|
|
|
+ @ApiParam(value = "商户信息", required = true) @RequestBody AdminCompanyWechat adminCompanyWechat
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminCompanyWechatLogic.updateCompanyWechat(adminCompanyWechat);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/user/update")
|
|
|
+ @ApiOperation(value = "修改帐号")
|
|
|
+ public ResponseHelper updateUser(
|
|
|
+ HttpServletRequest request,
|
|
|
+ @ApiParam(value = "帐号", required = true) @RequestBody AdminUserAddReqBean adminUserBean
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminUserLogic.update(request, adminUserBean);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/password/reset")
|
|
|
+ @ApiOperation("重置密码")
|
|
|
+ public ResponseHelper resetPwd (
|
|
|
+ @ApiParam(value = "用户id",required = true) @RequestParam(required = true) String adminUserId,
|
|
|
+ @ApiParam(value = "密码",required = true) @RequestParam(required = true) String password,
|
|
|
+ HttpServletRequest request
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminUserLogic.resetPassword(adminUserId,password,request);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperation(value = "帐号列表")
|
|
|
+ public ResponseHelper<IPage<AdminUser>> list(
|
|
|
+ @ApiParam(value = "商户id",required = false) @RequestParam(required = false) String companyWechatId,
|
|
|
+ @ApiParam(value = "商户名称",required = false) @RequestParam(required = false) String companyWechatName,
|
|
|
+ @ApiParam(value = "角色id",required = false) @RequestParam(required = false) String roleId,
|
|
|
+ @ApiParam(value = "状态 true:正常 false:冻结",required = false) @RequestParam(required = false) Boolean status,
|
|
|
+ @ApiParam(value = "用户名",required = false) @RequestParam(required = false) String userName,
|
|
|
+ @ApiParam(value = "网点id",required = false) @RequestParam(required = false) String websitId,
|
|
|
+ @ApiParam(value = "页号",required = true) @RequestParam(required = true) Integer pageNum,
|
|
|
+ @ApiParam(value = "页大小",required = true) @RequestParam(required = true) Integer pageSize,
|
|
|
+ HttpServletRequest request
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ IPage<AdminUser> page = adminUserLogic.list(companyWechatId,companyWechatName,roleId,status,userName,pageNum, pageSize,websitId);
|
|
|
+ return ResponseHelper.success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/mch/list")
|
|
|
+ @ApiOperation(value = "商户账号列表")
|
|
|
+ public ResponseHelper<IPage<AdminCompanyWechatRespPageBean>> list(
|
|
|
+ @ApiParam(value = "会员帐号",required = false) @RequestParam(required = false) String userName,
|
|
|
+ @ApiParam(value = "用户昵称",required = false) @RequestParam(required = false) String nickName,
|
|
|
+ @ApiParam(value = "联系电话",required = false) @RequestParam(required = false) String linkPhone,
|
|
|
+ @ApiParam(value = "电子邮箱",required = false) @RequestParam(required = false) String email,
|
|
|
+ @ApiParam(value = "状态 true:正常 false:冻结",required = false) @RequestParam(required = false) Boolean status,
|
|
|
+ @ApiParam(value = "页号",required = true) @RequestParam(required = true) Integer pageNum,
|
|
|
+ @ApiParam(value = "页大小",required = true) @RequestParam(required = true) Integer pageSize
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ IPage<AdminCompanyWechatRespPageBean> page = adminCompanyWechatLogic.list(userName,nickName,linkPhone,email,status,pageNum, pageSize);
|
|
|
+ return ResponseHelper.success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/mch/export")
|
|
|
+ @ApiOperation(value = "商户列表导出")
|
|
|
+ public void exportMch(
|
|
|
+ @ApiParam(value = "会员帐号",required = false) @RequestParam(required = false) String userName,
|
|
|
+ @ApiParam(value = "用户昵称",required = false) @RequestParam(required = false) String nickName,
|
|
|
+ @ApiParam(value = "联系电话",required = false) @RequestParam(required = false) String linkPhone,
|
|
|
+ @ApiParam(value = "电子邮箱",required = false) @RequestParam(required = false) String email,
|
|
|
+ @ApiParam(value = "状态 true:正常 false:冻结",required = false) @RequestParam(required = false) Boolean status,
|
|
|
+ HttpServletRequest request,
|
|
|
+ HttpServletResponse response
|
|
|
+ ) throws Exception {
|
|
|
+ IPage<AdminCompanyWechatRespPageBean> page = adminCompanyWechatLogic.list(userName,nickName,linkPhone,email,status,1, -1);
|
|
|
+ ExcelData excelData = adminUserLogic.exportMch(page.getRecords());
|
|
|
+ ExcelUtils.exportExcel(request,response,"mch.xlsx",excelData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/module/list")
|
|
|
+ @ApiOperation(value = "功能菜单权限列表")
|
|
|
+ public ResponseHelper<List<AdminModuleTree>> moduleList(
|
|
|
+ @ApiParam(value = "用户id",required = true) @RequestParam(required = true) String adminUserId,
|
|
|
+ @ApiParam(value = "父级角色id") @RequestParam(required = false) String parentAdminRoleId
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ List<AdminModuleTree> adminModuleTrees = adminUserLogic.queryAdminModule(adminUserId, parentAdminRoleId);
|
|
|
+ return ResponseHelper.success(adminModuleTrees);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/module/id/checked")
|
|
|
+ @ApiOperation("查询选中的功能模块ids")
|
|
|
+ public ResponseHelper<List<String>> queryModuleIdChecked(
|
|
|
+ @ApiParam(value = "角色id",required = true) @RequestParam(required = true) String adminRoleId
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ List<String> moduleIds = adminUserLogic.queryModuleIdChecked(adminRoleId);
|
|
|
+ return ResponseHelper.success(moduleIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/module/all")
|
|
|
+ @ApiOperation(value = "全部功能菜单权限列表")
|
|
|
+ public ResponseHelper<List<AdminModuleTree>> allModuleList(
|
|
|
+ @ApiParam(value = "角色",required = true) @RequestParam(required = true) String adminRoleId,
|
|
|
+ HttpServletRequest request
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ List<AdminModuleTree> adminModuleTrees = adminUserLogic.queryAllAdminModuleTree(adminRoleId,request);
|
|
|
+ return ResponseHelper.success(adminModuleTrees);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/module/grant")
|
|
|
+ @ApiOperation(value = "授权动能菜单权限")
|
|
|
+ public ResponseHelper grant(
|
|
|
+ @RequestBody AdminWebsitGrantBean adminWebsitGrantBean
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ adminUserLogic.grantModules(adminWebsitGrantBean);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperation(value = "详情")
|
|
|
+ public ResponseHelper<AdminUserBean> detail(
|
|
|
+ @ApiParam(value = "帐号id",required = true) @RequestParam(required = true) String adminUserId
|
|
|
+ ) throws RemoteServiceException {
|
|
|
+ AdminUserBean detail = adminUserLogic.detail(adminUserId);
|
|
|
+ return ResponseHelper.success(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/logout")
|
|
|
+ @ApiOperation("退出登录")
|
|
|
+ public ResponseHelper logout(HttpServletRequest request){
|
|
|
+ adminUserLogic.logout(request);
|
|
|
+ return ResponseHelper.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiNotAuth
|
|
|
+ @GetMapping("/imageVerification")
|
|
|
+ @ApiOperation(value = "获取图片验证码")
|
|
|
+ public ResponseHelper<SVerification> defaultKaptcha()
|
|
|
+ throws Exception {
|
|
|
+ SVerification sVerification = adminUserLogic.defaultKaptcha();
|
|
|
+ return ResponseHelper.success(sVerification);
|
|
|
+ }
|
|
|
+
|
|
|
+// @ApiNotAuth
|
|
|
+// @PostMapping("/check-or-login/account")
|
|
|
+// @ApiOperation(value = "检查账号")
|
|
|
+// public ResponseHelper<ExternalMapBean> checkOrLoginAccount(
|
|
|
+// @ApiParam(value = "账号",required = true) @RequestParam String account,
|
|
|
+// @ApiParam(value = "密码",required = true) @RequestParam String password,
|
|
|
+// @ApiParam(value = "是否检查",required = true) @RequestParam Boolean isCheck,
|
|
|
+// @ApiParam(value = "时间戳",required = true) @RequestParam String timestamp,
|
|
|
+// @ApiParam(value = "签名",required = true) @RequestParam String sign
|
|
|
+// ) throws Exception {
|
|
|
+// ExternalMapBean bean = adminUserLogic.checkOrLoginAccount(account, password, isCheck, timestamp, sign);
|
|
|
+// return ResponseHelper.success(bean);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+}
|