123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- package com.caimei365.user.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.aliyuncs.exceptions.ClientException;
- import com.caimei365.user.components.WeChatService;
- import com.caimei365.user.idempotent.IpSave;
- import com.caimei365.user.model.ResponseJson;
- import com.caimei365.user.model.dto.MobileDto;
- import com.caimei365.user.model.dto.PasswordDto;
- import com.caimei365.user.model.po.CmUser;
- import com.caimei365.user.model.po.SysDict;
- import com.caimei365.user.model.vo.SysDictVO;
- import com.caimei365.user.service.BaseService;
- import com.caimei365.user.service.SysDictService;
- import com.caimei365.user.utils.RequestUtil;
- import io.swagger.annotations.*;
- import lombok.RequiredArgsConstructor;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.*;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * 用户公共API
- *
- * @author : Charles
- * @date : 2021/3/4
- */
- @Api(tags = "用户公共API")
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/user")
- public class BaseApi {
- private final BaseService baseService;
- private final WeChatService weChatService;
- private final SysDictService sysDictService;
- @Value(value = "${swagger.enabled}")
- private Boolean swaggerEnabled;
- @GetMapping("")
- public String welcome() {
- if (swaggerEnabled) {
- return "欢迎使用!<br><a href='http://47.119.112.46:18011/doc.html'>doc接口文档入口(beta)</a><br><a href='http://47.119.112.46:18011/swagger-ui/index.html'>swagger接口文档入口(beta)</a>";
- }
- return "欢迎使用!";
- }
- /**
- * Token失效
- */
- @GetMapping("/unauthorized")
- public ResponseJson<Void> unauthorized() {
- return ResponseJson.error(-99, "Token失效请重新登录!", null);
- }
- /**
- * 获取图片验证码
- * <p>
- * spi旧接口:/user/getImgVerifyCode
- *
- * @param platformType 0:www,1:crm/h5,2:小程序
- */
- @ApiOperation("获取图片验证码")
- @ApiImplicitParam(required = true, name = "platformType", value = "0:www,1:crm/h5,2:小程序")
- @IpSave(saveName = "获取图片验证码", saveParams = false)
- @GetMapping("/captcha")
- public ResponseJson<Map<String, Object>> getCaptchaImage(Integer platformType) {
- return baseService.getCaptchaImage(platformType);
- }
- /**
- * 获取短信验证码
- * <p>
- * spi旧接口:/user/activateCodeByReg
- *
- * @param mobile 手机号
- * @param activateCodeType 1:找回密码,2:注册机构,3:供应商注册,4:修改手机号-旧手机验证码,5:修改手机号-新手机验证码,6.发布二手验证码
- * @param platformType 0:www,1:crm/h5,2:小程序
- * @param isCheckCaptcha 是否检查图片验证码,0:检查,1:不检查
- * @param imgCode 图片验证码
- * @param token 图片验证码token
- */
- @ApiOperation("获取短信验证码")
- @ApiImplicitParams({
- @ApiImplicitParam(required = true, name = "mobile", value = "手机号"),
- @ApiImplicitParam(required = true, name = "activateCodeType", value = "1:找回密码,2:注册机构,3:供应商注册,4:更换联系人手机号-旧手机验证码,5:更换联系人手机号-新手机验证码"),
- @ApiImplicitParam(required = false, name = "platformType", value = "0:www,1:crm/h5,2:小程序"),
- @ApiImplicitParam(required = false, name = "isCheckCaptcha", value = "是否检查图片验证码,0:检查,1:不检查"),
- @ApiImplicitParam(required = false, name = "imgCode", value = "图片验证码"),
- @ApiImplicitParam(required = false, name = "token", value = "图片token")
- })
- @IpSave(saveName = "获取短信验证码", saveParams = true)
- @GetMapping("/sms/code")
- public ResponseJson getSmsCode(String mobile, Integer activateCodeType, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
- return baseService.getSmsCode(mobile, activateCodeType, platformType, isCheckCaptcha, imgCode, token);
- }
- /**
- * 绑定账号,发送短信验证
- * <p>
- * spi旧接口:/user/note
- *
- * @param mobile 运营人员手机号
- * @param bindMobile 机构手机号
- * @param userId 机构Id
- * @param platformType 0:www,1:crm/h5,2:小程序
- * @param isCheckCaptcha 是否检查图片验证码,0:检查,1:不检查
- * @param imgCode 图片验证码
- * @param token 图片验证码token
- */
- @ApiOperation("绑定账号,发送短信验证")
- @ApiImplicitParams({
- @ApiImplicitParam(required = true, name = "mobile", value = "运营人员手机号"),
- @ApiImplicitParam(required = false, name = "bindMobile", value = "机构手机号"),
- @ApiImplicitParam(required = false, name = "userId", value = "机构Id"),
- @ApiImplicitParam(required = false, name = "platformType", value = "0:www,1:crm/h5,2:小程序"),
- @ApiImplicitParam(required = false, name = "isCheckCaptcha", value = "是否检查图片验证码,0:检查,1:不检查"),
- @ApiImplicitParam(required = false, name = "imgCode", value = "图片验证码"),
- @ApiImplicitParam(required = false, name = "token", value = "图片token")
- })
- @IpSave(saveName = "绑定账号,发送短信验证", saveParams = true)
- @GetMapping("/sms/bind")
- public ResponseJson getBindSmsCode(String mobile, String bindMobile, Integer userId, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
- return baseService.getBindSmsCode(mobile, bindMobile, userId, platformType, isCheckCaptcha, imgCode, token);
- }
- /**
- * 获取邮箱验证码
- *
- * @param email 邮箱
- * @param status 1:绑定邮箱,2邮箱注册,3邮箱找回秘密
- */
- @ApiOperation("获取邮箱验证码(旧:/user/mailbox)")
- @ApiImplicitParams({
- @ApiImplicitParam(required = true, name = "email", value = "邮箱"),
- @ApiImplicitParam(required = true, name = "status", value = "1:绑定邮箱,2邮箱注册,3邮箱找回秘密")
- })
- @GetMapping("/mail/code")
- public ResponseJson sendMail(String email, Integer status) {
- return baseService.getEmailCode(email, status);
- }
- /**
- * 获取登录验证码
- * @param mobile 输入手机号
- * @return
- */
- @ApiOperation("获取登录验证码")
- @GetMapping("/login/code")
- public ResponseJson loginSmsCode(String mobile) { return baseService.getLoginCode(mobile);}
- /**
- * 获取绑定运营人员验证码
- * @param mobile 输入手机号
- * @return
- */
- @ApiOperation("获取绑定运营人员验证码")
- @GetMapping("/operate/code")
- public ResponseJson operateSmsCode(String mobile) { return baseService.operateSmsCode(mobile);}
- /**
- * 修改密码(找回密码)
- *
- * @param passwordDto {
- * mobileOrEmail 手机号或邮箱
- * smsCode 短信验证码(旧:activationCode)
- * password 密码
- * confirmPwd 确认密码
- * status 1:手机号找回,2:邮箱找回
- * }
- */
- @ApiOperation("修改密码(旧:/user/findCompanyPwd)")
- @IpSave(saveName = "修改密码", saveParams = true)
- @PostMapping("/update/password")
- public ResponseJson updatePassword(PasswordDto passwordDto) {
- return baseService.updatePassword(passwordDto);
- }
- /**
- * 修改密码(找回密码)-- 组织
- *
- * @param passwordDto {
- * mobileOrEmail 手机号或邮箱
- * smsCode 短信验证码(旧:activationCode)
- * password 密码
- * confirmPwd 确认密码
- * status 1:手机号找回,2:邮箱找回
- * }
- */
- @ApiOperation("修改密码--组织")
- @PostMapping("/updateOrganize/password")
- public ResponseJson updateOrganizePassword(PasswordDto passwordDto) {
- return baseService.updateOrganizePassword(passwordDto);
- }
- /**
- * 更换联系人手机号
- *
- * @param mobileDto {
- * mobile 旧手机号(contractMobile)
- * smsCode 旧手机短信验证码(mobileCode)
- * newMobile 新手机号(contractMobile2)
- * newSmsCode 新手机短信验证码(mobileCode)
- * userId 用户Id
- * }
- */
- @ApiOperation("更换联系人手机号(旧:/club/changeMobile)")
- @PostMapping("/update/mobile")
- public ResponseJson changeMobile(MobileDto mobileDto) {
- return baseService.updateMobile(mobileDto);
- }
- @ApiOperation("超级会员购买记录接口")
- @GetMapping("/super/history")
- public ResponseJson findVipHistory(Integer userId,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- if (null == userId) {
- return ResponseJson.error("参数异常:用户Id不能为空!", null);
- }
- return baseService.findVipHistory(userId, pageNum, pageSize);
- }
- @ApiOperation("超级会员会员中心")
- @IpSave(saveName = "超级会员中心", saveParams = true)
- @GetMapping("/super/center")
- public ResponseJson<Map<String, Object>> superCenter(Integer userId, Integer source) {
- if (null == userId) {
- return ResponseJson.error("参数异常:用户Id不能为空!", null);
- }
- return baseService.superCenter(userId, source);
- }
- @ApiOperation("超级会员套餐详情")
- @IpSave(saveName = "超级会员套餐详情", saveParams = false)
- @GetMapping("/super/package")
- public ResponseJson findPackage() {
- return baseService.findPackage();
- }
- @ApiOperation("获取阿里云token")
- @GetMapping("/oss/token")
- public ResponseJson<HashMap<String, String>> ossTokenGet() throws ClientException {
- return baseService.ossTokenGet();
- }
- @ApiOperation("获取微信跳转url")
- @GetMapping("/wechat/link")
- public ResponseJson getWechatLink(String path, String query, String env) {
- return weChatService.getOpenLink(path, query, env);
- }
- @ApiOperation("获取微信跳转url 联合丽格")
- @GetMapping("/wechat/link/mcare")
- public ResponseJson getWechatLinkMcare(String path, String query, String env) {
- return weChatService.getOpenLinkMcare(path, query, env);
- }
- @ApiOperation("获取Dict")
- @GetMapping("/getDict")
- public ResponseJson getDict(String type) {
- if (null == type) {
- return ResponseJson.error("参数异常:type不能为空!", null);
- }
- return ResponseJson.success(sysDictService.getSysDictList(new SysDict().setType(type)));
- }
- @ApiOperation("获取userId")
- @GetMapping("/getFindUserId")
- public ResponseJson getFindUserId(Integer userType, Integer id) {
- return baseService.getByUserId(userType, id);
- }
- @ApiOperation("获取Mobile")
- @GetMapping("/getByDistributionClubMobile")
- public ResponseJson getByMobile(Integer userId) {
- return ResponseJson.success(baseService.getByMobile(8, userId));
- }
- @ApiOperation("获取user数量")
- @GetMapping("/getByUserCount")
- public Integer getByUserCount(CmUser user) {
- return baseService.getByUserCount(user);
- }
- }
|