| | |
| | | package cn.huge.module.ctuser.controller; |
| | | package cn.huge.module.ctuser.controller.web; |
| | | |
| | | import cn.huge.base.common.bo.ReturnBO; |
| | | import cn.huge.base.common.utils.ReturnFailUtils; |
| | | import cn.huge.base.common.utils.ReturnSucUtils; |
| | | import cn.huge.base.config.CurrentUser; |
| | | import cn.huge.module.constant.BaseConsts; |
| | | import cn.huge.module.ctuser.domain.po.CtAccount; |
| | | import cn.huge.module.ctuser.domain.po.CtUnit; |
| | | import cn.huge.module.ctuser.dto.CtAccountLoginDTO; |
| | | import cn.huge.module.ctuser.dto.CtCipherDTO; |
| | | import cn.huge.module.ctuser.service.CtAccountService; |
| | | import cn.huge.module.sys.dto.GridTokenBaseDTO; |
| | | import cn.huge.module.utils.JwtUtils; |
| | | import com.google.common.collect.Maps; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * @title: 客户用户账号表接口api |
| | | * @description: 客户用户账号表接口api |
| | | * @title: 客户用户账号表接口api-web端-web端 |
| | | * @description: 客户用户账号表接口api-web端-web端 |
| | | * @company: hugeinfo |
| | | * @author: liyj |
| | | * @time: 2024-08-19 20:04:18 |
| | |
| | | private CtAccountService service; |
| | | |
| | | /** |
| | | * 获取请求URL参数 |
| | | * @return Map<String, Object> |
| | | */ |
| | | private Map<String, Object> getParameter(){ |
| | | Map<String, Object> terms = Maps.newHashMap(); |
| | | // 账号编号 |
| | | String id = request.getParameter("id"); |
| | | if (StringUtils.isNotBlank(id)){ |
| | | terms.put("id", id); |
| | | * web端-工作人员-用户登录 |
| | | * @url {ctx}/api/web/ctAccount/login |
| | | * @param ctAccountLoginDTO 登录对象 |
| | | * @return Object |
| | | */ |
| | | @PostMapping(value = "login") |
| | | public Object login(@RequestBody CtAccountLoginDTO ctAccountLoginDTO) { |
| | | try { |
| | | ReturnBO returnBO = service.webLogin(ctAccountLoginDTO); |
| | | return returnBO; |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(e.getMessage()); |
| | | } |
| | | // 用户编号 |
| | | String userId = request.getParameter("userId"); |
| | | if (StringUtils.isNotBlank(userId)){ |
| | | terms.put("userId", userId); |
| | | } |
| | | // 帐号类型,1:平台web端,2:平台小程序 |
| | | String accType = request.getParameter("accType"); |
| | | if (StringUtils.isNotBlank(accType)){ |
| | | terms.put("accType", accType); |
| | | } |
| | | // 身份唯一标识(存储唯一标识,比如账号、邮箱、手机号、第三方获取的唯一标识等) |
| | | String acc = request.getParameter("acc"); |
| | | if (StringUtils.isNotBlank(acc)){ |
| | | terms.put("acc", acc); |
| | | } |
| | | // 授权凭证(比如密码 第三方登录的token等) |
| | | String cipher = request.getParameter("cipher"); |
| | | if (StringUtils.isNotBlank(cipher)){ |
| | | terms.put("cipher", cipher); |
| | | } |
| | | // 授权凭证明文 |
| | | String cipherOpen = request.getParameter("cipherOpen"); |
| | | if (StringUtils.isNotBlank(cipherOpen)){ |
| | | terms.put("cipherOpen", cipherOpen); |
| | | } |
| | | // 密码最新更新时间 |
| | | String cipherTime = request.getParameter("cipherTime"); |
| | | if (StringUtils.isNotBlank(cipherTime)){ |
| | | terms.put("cipherTime", cipherTime); |
| | | } |
| | | // 最新登录时间 |
| | | String loginTime = request.getParameter("loginTime"); |
| | | if (StringUtils.isNotBlank(loginTime)){ |
| | | terms.put("loginTime", loginTime); |
| | | } |
| | | // 限制登录时间(密码错误次数超过限制,默认30分钟) |
| | | String limitTime = request.getParameter("limitTime"); |
| | | if (StringUtils.isNotBlank(limitTime)){ |
| | | terms.put("limitTime", limitTime); |
| | | } |
| | | // 删除状态,0:已删除,1:未删除 |
| | | String deleteStatus = request.getParameter("deleteStatus"); |
| | | if (StringUtils.isNotBlank(deleteStatus)){ |
| | | terms.put("deleteStatus", deleteStatus); |
| | | } |
| | | // 顾客编号 |
| | | String custId = request.getParameter("custId"); |
| | | if (StringUtils.isNotBlank(custId)){ |
| | | terms.put("custId", custId); |
| | | } |
| | | // 创建时间区间 |
| | | String createStart = request.getParameter("createStart"); |
| | | String createEnd = request.getParameter("createEnd"); |
| | | if(StringUtils.isNotBlank(createStart) && StringUtils.isNotBlank(createEnd)) { |
| | | terms.put("createStart", createStart); |
| | | terms.put("createEnd", createEnd); |
| | | } |
| | | // 更新时间区间 |
| | | String updateStart = request.getParameter("updateStart"); |
| | | String updateEnd = request.getParameter("updateEnd"); |
| | | if(StringUtils.isNotBlank(updateStart) && StringUtils.isNotBlank(updateEnd)) { |
| | | terms.put("updateStart", updateStart); |
| | | terms.put("updateEnd", updateEnd); |
| | | } |
| | | return terms; |
| | | } |
| | | |
| | | /** |
| | | * 条件查询多个 |
| | | * @url {ctx}/api/web/ctAccount/listQuery |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/listQuery") |
| | | public Object listQuery() { |
| | | * web端-工作人员-用户选择/切换角色 |
| | | * @url {ctx}/api/web/ctAccount/switchRole |
| | | * @return Object |
| | | */ |
| | | @GetMapping(value = "switchRole") |
| | | public Object switchRole(@RequestParam(value = "roleCode") String roleCode, @CurrentUser String userId) { |
| | | try { |
| | | Map<String, Object> terms = getParameter(); |
| | | return ReturnSucUtils.getRepInfo(service.listTerms(terms)); |
| | | StringBuffer result = new StringBuffer(); |
| | | if (userId.indexOf(BaseConsts.AND) != -1){ |
| | | String[] userIds = userId.split(BaseConsts.AND); |
| | | result.append(userIds[0]).append(BaseConsts.AND).append(roleCode); |
| | | }else { |
| | | result.append(userId).append(BaseConsts.AND).append(roleCode); |
| | | } |
| | | return ReturnSucUtils.getRepInfo(JwtUtils.buildJWT(result.toString())); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 条件分页查询 |
| | | * @url {ctx}/api/web/ctAccount/pageQuery |
| | | * @param page 页码 |
| | | * @param size 每页数量 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/pageQuery") |
| | | public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) { |
| | | * web端-工作人员-修改密码 |
| | | * @url {ctx}/api/web/ctAccount/changeCipher |
| | | * @param ctCipherDTO 修改密码对象 |
| | | * @return Object |
| | | */ |
| | | @PostMapping(value = "changeCipher") |
| | | public Object changeCipher(@CurrentUser String userId, @RequestBody CtCipherDTO ctCipherDTO) { |
| | | try { |
| | | Map<String, Object> terms = getParameter(); |
| | | Sort sort = Sort.by(Sort.Direction.DESC, "create_time"); |
| | | PageRequest pageRequest = PageRequest.of(page-1, size, sort); |
| | | Page<CtAccount> ctAccountPage = service.pageQuery(pageRequest, terms); |
| | | return ReturnSucUtils.getRepInfo( "处理成功", ctAccountPage); |
| | | return service.webChangeCipher(userId, ctCipherDTO); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据编号查询单个 |
| | | * @url {ctx}/api/web/ctAccount/getById |
| | | * @param id 主键编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getById") |
| | | public Object getById(@RequestParam(value = "id") String id) { |
| | | * web端-网格系统单点登录 |
| | | * @url {ctx}/api/web/ctAccount/gridLogin |
| | | * @param gridTokenBaseDTO 网格系统token |
| | | * @return Object |
| | | */ |
| | | @PostMapping(value = "gridLogin") |
| | | public Object gridLogin(@RequestBody GridTokenBaseDTO gridTokenBaseDTO) { |
| | | try { |
| | | return ReturnSucUtils.getRepInfo(service.getById(id)); |
| | | ReturnBO returnBO = service.webGridLogin(gridTokenBaseDTO); |
| | | return returnBO; |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据主键单个 |
| | | * @url {ctx}/api/web/ctAccount/deleteById |
| | | * @param id 主键编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/deleteById") |
| | | public Object deleteById(@RequestParam(value = "id") String id) { |
| | | try { |
| | | service.removeById(id); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增或更新对象 |
| | | * @url {ctx}/api/web/ctAccount/saveCtAccount |
| | | * @param ctAccount 实体对象 |
| | | * @return Object |
| | | */ |
| | | @PostMapping("/saveCtAccount") |
| | | public Object saveCtAccount(@RequestBody CtAccount ctAccount) { |
| | | try { |
| | | service.saveCtAccount(ctAccount); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | return ReturnFailUtils.getRepInfo(e.getMessage()); |
| | | } |
| | | } |
| | | |