1新增小程序登录相关接口

2新增支付宝sdk
3修改用户相关接口
This commit is contained in:
fengjundan 2021-07-21 18:56:48 +08:00
parent 236f158175
commit 0ef04f3572
22 changed files with 579 additions and 81 deletions

View File

@ -38,6 +38,7 @@
<poi.version>4.1.2</poi.version> <poi.version>4.1.2</poi.version>
<common-pool.version>2.6.2</common-pool.version> <common-pool.version>2.6.2</common-pool.version>
<commons-collections.version>3.2.2</commons-collections.version> <commons-collections.version>3.2.2</commons-collections.version>
<alipay.sdk>4.15.14.ALL</alipay.sdk>
</properties> </properties>
<!-- 依赖声明 --> <!-- 依赖声明 -->
@ -236,6 +237,12 @@
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 支付宝sdk -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>${alipay.sdk}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

View File

@ -55,6 +55,7 @@ public class SysUserController extends BaseController {
@PreAuthorize(hasPermi = "system:user:list") @PreAuthorize(hasPermi = "system:user:list")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysUser user) { public TableDataInfo list(SysUser user) {
Long userId = SecurityUtils.getUserId();
startPage(); startPage();
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
return getDataTable(list); return getDataTable(list);

View File

@ -85,7 +85,10 @@
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,5 +1,10 @@
package com.xhpc.user.controller; package com.xhpc.user.controller;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableDataInfo;
@ -9,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -30,7 +36,7 @@ public class XhpcAppUserController extends BaseController {
@ApiOperation("C端用户详情") @ApiOperation("C端用户详情")
@PreAuthorize(hasPermi = "app:user:info") @PreAuthorize(hasPermi = "app:user:info")
@GetMapping("/info") @GetMapping("/info")
public AjaxResult info(@RequestBody Long appUserId) { public AjaxResult info(@RequestParam Long appUserId) {
return AjaxResult.success(iXhpcAppUserUserService.info(appUserId)); return AjaxResult.success(iXhpcAppUserUserService.info(appUserId));
} }
@ -51,8 +57,80 @@ public class XhpcAppUserController extends BaseController {
@ApiOperation("禁用/启用C端用户") @ApiOperation("禁用/启用C端用户")
@PreAuthorize(hasPermi = "app:user:status") @PreAuthorize(hasPermi = "app:user:status")
@PostMapping("/status") @PostMapping("/status")
public AjaxResult status(@RequestBody Long appUserId) { public AjaxResult status(@RequestParam Long appUserId) {
iXhpcAppUserUserService.status(appUserId); iXhpcAppUserUserService.status(appUserId);
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 以下为小程序接口
*/
/**
* C端用户注册
*/
@ApiOperation("注册")
@PostMapping("/register")
public R<?> register(@RequestBody Map<String, Object> map) {
return iXhpcAppUserUserService.register(map);
}
/**
* C端用户登录
*/
@ApiOperation("登录")
@PostMapping("/login")
public R<?> login(@RequestBody Map<String, Object> map) {
return iXhpcAppUserUserService.login(map);
}
/**
* 小程序用户详情
*/
@ApiOperation("小程序用户详情")
@GetMapping("/appInfo")
public AjaxResult appInfo(@RequestBody Long appUserId) {
return AjaxResult.success(iXhpcAppUserUserService.info(appUserId));
}
/**
* 小程序用户退出
*/
@ApiOperation("小程序用户退出")
@PostMapping("/loginOut")
public R<?> loginOut(HttpServletRequest request, @RequestParam String type) {
return iXhpcAppUserUserService.loginOut(request, type);
}
/**
* C端用户自动登录
*/
@ApiOperation("C端用户自动登录")
@PostMapping("/voluntaryLogin")
public R<?> voluntaryLogin(@RequestBody Map<String, Object> map) {
return iXhpcAppUserUserService.voluntaryLogin(map);
}
/**
* 支付宝授权
*/
@ApiOperation("支付宝授权")
@PostMapping("/alipayEmpower")
public AjaxResult alipayEmpower(@RequestParam String code) throws Exception {
String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjHDksTgZTpf0wh7oeTVRp0h3SqzTM2smjEJnx9jF1+q3WSXLRB4OzSzq7VsJ/szcyK10ZGO5PxeQ4u9GAG/U+7xhs7ei1cJB/Er55Sg9SbjfkTpwlDv181UJCRJJ/IAcqyqezwTpB8e2trYmHKovUdt0KR9/tVkGa7hsNd5GfxTOUaAFc3zADqRVM+wGimtG0NYfOF2f8tkmBEAiMMLKq5pbAnHU723a1cm/nfVp7gvXfsnO0k2GvRuHzb8mxIhWLiAnwdK9gEu5za/jWxo/xIvf2sdJPYdWj+yfyzA2e1fJkx4uRUzX31CXxZvP2/tfEcnTdI0gxN+OH2eAMiPVswIDAQAB";
String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCw3YH8KMvE7yH6C/rgnbXjml5NMvCcRNl+tbR9QEjl/9AdDIZaYvlQ72oKiOIk7GmDh3sB0YmiFnTcCj7cmKpZd2wLEP0nwwxTGTbBXi1bo/wQUI1a/mNA8rYZfwxfQZ07E28M2kMB+PE29clu+xo8TtjgiX7jofzEyQfES1uZMMDNLA+1cAYc0ZYo0NCJYEFpXm5SJHauC5+biQnOte49EbmzoXuYRap2RBf6suHEflAEgovk9L+hfPelXKG88lQNtg4w6jzNYRcuBa3IZlTJbLPGxH35eCMu0UGpa5EyH/nK+QrycESvEOfJ60urIU5FmOB2ikly2bgLLXZ43oedAgMBAAECggEBAKWt2qYsUTYaDOn/bvQayNh9Mvl+TocUt+lKrdjm72MFUB7mLLVfIc3/eIaF09Ji5DSiJUh+0T9VagL2VgyvtmQ4yq1TLNKilFkDtZdOcY72/pkJ3GDxDGk68/rOWPiirnc4rT6M91hRqySg+iFMeDcmZWNxabwzcmWlK/Fl5liJD03WNEuUNKE5qD9lQwgJEH9x8XxOtfgTk84UPoscOkHTsK7rhgcagbqT6q40DMfqzjoE0BxdTHAtuXbkhWP49UHFMzyilTbk/fQhpxngqnTXsnS8R8gzg/r5xFmss88yVTWCcjonjkBQGuyuyXIgEHhIrAt8WwXHODqlnttglMECgYEA+bE2G6zKoeQ4ZMmCgj9s894BB8dwtY3u4veM/F2g7b1qt6gh6KCRb+yHv0sOUCVLGsc6mbh/pcw2Ply68ZRleysAog7tAnNIw3YQJtYM1+5To9dCElq0oLBCU8szYgvIrwla00uHFkovrspn4HCwVDmJyQC3Dk9zICP44RlXCyMCgYEAtVVQ4c/mTtkym0iy10YY1HskWiOwAjb0/VnTkXsclePfX/ld3EfUwCeRn93ANhm7Fql8emiU9K5nTx1n/erGhT4AyzMLf3/y4KhIJRa+4dhae6J0W3Sd9oZOnXUiC0WsVxEMVn2BIa9HMFaKdyrKGiu2Vmzqn0Y39xpjPzwrrj8CgYB1MpmMCeGedUmG/RJ14iFYocZoCVO8097hx4H0XloP3M1/YLpxvxQkrafVwPv54FdNPWAjEPdRMfXv9YSFqbqsQjXs2waiFMx9eigAoo2quKGnkHzhspN/rNulCwaWKaPLjJ+F97hzXOTerQBu11XcYplqsBw76kzGNDw4I7W4cwKBgGkAHxay6PyNXnV2kkB/kY8wQyuC8L9HjXNK2WyrajENQ2JypjwQyAwAnZ2BrXRmT+ReffrvphlNB/tS3s20bgHnllQTmbvZng0ixKvdUOi7/CENP+1ZSMLgoJMiqXT3gkTkVU2b3PNhaIqAAivg9ihTWYEQDofuBCgs+n06XVzHAoGAcJKdJR2PPMIkfS7zHec02pZGLiC1mvxQx4rjKKT+OvIyD98KipWCDXieYKseqN2V6EjZE/Nhekpi2Bybhrm8iSQoiJilwaQ33DoBYCnW/pjfwxVLM7ch3fQGsOxJMFLcEC8KLu2k/nZkTGCrfJzmcB9ODA2pfaVXfTA57KIPxuk=";
String appId = "2021002156615717";
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", appId, privateKey, "json", "GBK", alipayPublicKey, "RSA2");
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setGrantType("authorization_code");
request.setCode("4b203fe6c11548bcabd8da5bb087a83b");
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
if (response.isSuccess()) {
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
return AjaxResult.success(response);
}
} }

View File

@ -1,6 +1,7 @@
package com.xhpc.user.controller; package com.xhpc.user.controller;
import com.ruoyi.common.core.utils.SecurityUtils; import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableDataInfo;
@ -13,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -38,7 +40,7 @@ public class XhpcInternetUserController extends BaseController {
@ApiOperation("新增流量用户") @ApiOperation("新增流量用户")
@PreAuthorize(hasPermi = "user:internet:add") @PreAuthorize(hasPermi = "user:internet:add")
@PostMapping("/add") @PostMapping("/add")
public AjaxResult add(@RequestBody XhpcInternetUser xhpcInternetUser) { public AjaxResult add(@Valid @RequestBody XhpcInternetUser xhpcInternetUser) {
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUserName(xhpcInternetUser.getPhone()); sysUser.setUserName(xhpcInternetUser.getPhone());
sysUser.setNickName(xhpcInternetUser.getName()); sysUser.setNickName(xhpcInternetUser.getName());
@ -50,7 +52,7 @@ public class XhpcInternetUserController extends BaseController {
sysUser.setCreateBy(SecurityUtils.getUsername()); sysUser.setCreateBy(SecurityUtils.getUsername());
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcInternetUser.getPhone())); sysUser.setPassword(SecurityUtils.encryptPassword(xhpcInternetUser.getPhone()));
AjaxResult ajaxResult = remoteSystemService.addUser(sysUser); AjaxResult ajaxResult = remoteSystemService.addUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
return toAjax(iXhpcInternetUserService.insert(xhpcInternetUser)); return toAjax(iXhpcInternetUserService.insert(xhpcInternetUser));
@ -62,7 +64,7 @@ public class XhpcInternetUserController extends BaseController {
@ApiOperation("修改流量用户") @ApiOperation("修改流量用户")
@PreAuthorize(hasPermi = "user:internet:edit") @PreAuthorize(hasPermi = "user:internet:edit")
@PostMapping("/edit") @PostMapping("/edit")
public AjaxResult edit(@RequestBody XhpcInternetUser xhpcInternetUser) { public AjaxResult edit(@Valid @RequestBody XhpcInternetUser xhpcInternetUser) {
if (null == xhpcInternetUser.getInternetUserId()) { if (null == xhpcInternetUser.getInternetUserId()) {
return AjaxResult.error("用户id不能为空"); return AjaxResult.error("用户id不能为空");
} }
@ -77,7 +79,7 @@ public class XhpcInternetUserController extends BaseController {
sysUser.setCreateBy(SecurityUtils.getUsername()); sysUser.setCreateBy(SecurityUtils.getUsername());
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcInternetUser.getPhone())); sysUser.setPassword(SecurityUtils.encryptPassword(xhpcInternetUser.getPhone()));
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser); AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
return toAjax(iXhpcInternetUserService.update(xhpcInternetUser)); return toAjax(iXhpcInternetUserService.update(xhpcInternetUser));
@ -89,7 +91,7 @@ public class XhpcInternetUserController extends BaseController {
@ApiOperation("删除流量用户") @ApiOperation("删除流量用户")
@PreAuthorize(hasPermi = "user:internet:remove") @PreAuthorize(hasPermi = "user:internet:remove")
@PostMapping("/remove") @PostMapping("/remove")
public AjaxResult remove(@RequestBody Long[] ids) { public AjaxResult remove(@RequestParam Long[] ids) {
iXhpcInternetUserService.deleteByIds(ids); iXhpcInternetUserService.deleteByIds(ids);
return AjaxResult.success(); return AjaxResult.success();
} }
@ -100,7 +102,7 @@ public class XhpcInternetUserController extends BaseController {
@ApiOperation("流量用户详情") @ApiOperation("流量用户详情")
@PreAuthorize(hasPermi = "user:internet:info") @PreAuthorize(hasPermi = "user:internet:info")
@GetMapping("/info") @GetMapping("/info")
public AjaxResult info(@RequestBody Long internetUserId) { public AjaxResult info(@RequestParam Long internetUserId) {
return AjaxResult.success(iXhpcInternetUserService.info(internetUserId)); return AjaxResult.success(iXhpcInternetUserService.info(internetUserId));
} }
@ -121,7 +123,7 @@ public class XhpcInternetUserController extends BaseController {
@ApiOperation("禁用/启用流量用户") @ApiOperation("禁用/启用流量用户")
@PreAuthorize(hasPermi = "user:internet:status") @PreAuthorize(hasPermi = "user:internet:status")
@PostMapping("/status") @PostMapping("/status")
public AjaxResult status(@RequestBody Long internetUserId) { public AjaxResult status(@RequestParam Long internetUserId) {
iXhpcInternetUserService.status(internetUserId); iXhpcInternetUserService.status(internetUserId);
return AjaxResult.success(); return AjaxResult.success();
} }

View File

@ -2,6 +2,7 @@ package com.xhpc.user.controller;
import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.utils.SecurityUtils; import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableDataInfo;
@ -14,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -36,9 +38,9 @@ public class XhpcOperatorController extends BaseController {
* 新增运营商 * 新增运营商
*/ */
@ApiOperation("新增运营商") @ApiOperation("新增运营商")
@PreAuthorize(hasPermi = "user:operator:add") //@PreAuthorize(hasPermi = "user:operator:add")
@PostMapping("/add") @PostMapping("/add")
public AjaxResult add(@RequestBody XhpcOperator xhpcOperator) { public AjaxResult add(@Valid @RequestBody XhpcOperator xhpcOperator) {
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUserName(xhpcOperator.getPhone()); sysUser.setUserName(xhpcOperator.getPhone());
sysUser.setNickName(xhpcOperator.getName()); sysUser.setNickName(xhpcOperator.getName());
@ -50,8 +52,11 @@ public class XhpcOperatorController extends BaseController {
sysUser.setDataPowerType(1); sysUser.setDataPowerType(1);
sysUser.setCreateBy(SecurityUtils.getUsername()); sysUser.setCreateBy(SecurityUtils.getUsername());
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcOperator.getPhone())); sysUser.setPassword(SecurityUtils.encryptPassword(xhpcOperator.getPhone()));
Long[] roleIds = new Long[1];
roleIds[0] = 3l;
sysUser.setRoleIds(roleIds);
AjaxResult ajaxResult = remoteSystemService.addUser(sysUser); AjaxResult ajaxResult = remoteSystemService.addUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
if (UserConstants.NOT_UNIQUE.equals(iXhpcOperatorService.checkAccountUnique(xhpcOperator))) { if (UserConstants.NOT_UNIQUE.equals(iXhpcOperatorService.checkAccountUnique(xhpcOperator))) {
@ -66,7 +71,7 @@ public class XhpcOperatorController extends BaseController {
@ApiOperation("修改运营商") @ApiOperation("修改运营商")
@PreAuthorize(hasPermi = "user:operator:edit") @PreAuthorize(hasPermi = "user:operator:edit")
@PostMapping("/edit") @PostMapping("/edit")
public AjaxResult edit(@RequestBody XhpcOperator xhpcOperator) { public AjaxResult edit(@Valid @RequestBody XhpcOperator xhpcOperator) {
if (null == xhpcOperator.getOperatorId()) { if (null == xhpcOperator.getOperatorId()) {
return AjaxResult.error("运营商id不能为空"); return AjaxResult.error("运营商id不能为空");
} }
@ -82,7 +87,7 @@ public class XhpcOperatorController extends BaseController {
sysUser.setCreateBy(SecurityUtils.getUsername()); sysUser.setCreateBy(SecurityUtils.getUsername());
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcOperator.getPhone())); sysUser.setPassword(SecurityUtils.encryptPassword(xhpcOperator.getPhone()));
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser); AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
if (UserConstants.NOT_UNIQUE.equals(iXhpcOperatorService.checkAccountUnique(xhpcOperator))) { if (UserConstants.NOT_UNIQUE.equals(iXhpcOperatorService.checkAccountUnique(xhpcOperator))) {
@ -95,9 +100,9 @@ public class XhpcOperatorController extends BaseController {
* 删除运营商 * 删除运营商
*/ */
@ApiOperation("删除运营商") @ApiOperation("删除运营商")
@PreAuthorize(hasPermi = "user:operator:remove") //@PreAuthorize(hasPermi = "user:operator:remove")
@PostMapping("/remove") @PostMapping("/remove")
public AjaxResult remove(@RequestBody Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
iXhpcOperatorService.deleteByIds(ids); iXhpcOperatorService.deleteByIds(ids);
return AjaxResult.success(); return AjaxResult.success();
} }
@ -106,16 +111,16 @@ public class XhpcOperatorController extends BaseController {
* 运营商详情 * 运营商详情
*/ */
@ApiOperation("运营商详情") @ApiOperation("运营商详情")
@PreAuthorize(hasPermi = "user:operator:info") //@PreAuthorize(hasPermi = "user:operator:info")
@GetMapping("/info") @GetMapping("/info")
public AjaxResult info(@RequestBody Long operatorId) { public AjaxResult info(@RequestParam Long operatorId) {
return AjaxResult.success(iXhpcOperatorService.info(operatorId)); return AjaxResult.success(iXhpcOperatorService.info(operatorId));
} }
/** /**
* 获取运营商分页列表 * 获取运营商分页列表
*/ */
@PreAuthorize(hasPermi = "system:operator:page") //@PreAuthorize(hasPermi = "system:operator:page")
@GetMapping("/page") @GetMapping("/page")
public TableDataInfo page(String name, String contactName, String contactPhone) { public TableDataInfo page(String name, String contactName, String contactPhone) {
startPage(); startPage();
@ -127,9 +132,9 @@ public class XhpcOperatorController extends BaseController {
* 禁用/启用运营商 * 禁用/启用运营商
*/ */
@ApiOperation("禁用/启用运营商") @ApiOperation("禁用/启用运营商")
@PreAuthorize(hasPermi = "user:operator:status") //@PreAuthorize(hasPermi = "user:operator:status")
@PostMapping("/status") @PostMapping("/status")
public AjaxResult status(@RequestBody Long operatorId) { public AjaxResult status(@RequestParam Long operatorId) {
iXhpcOperatorService.status(operatorId); iXhpcOperatorService.status(operatorId);
return AjaxResult.success(); return AjaxResult.success();
} }

View File

@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -31,7 +32,7 @@ public class XhpcOperatorInternetBlacklistController extends BaseController {
@ApiOperation("新增流量用户") @ApiOperation("新增流量用户")
@PreAuthorize(hasPermi = "operator:internet:add") @PreAuthorize(hasPermi = "operator:internet:add")
@PostMapping("/add") @PostMapping("/add")
public AjaxResult add(@RequestBody List<XhpcOperatorInternetBlacklist> list) { public AjaxResult add(@Valid @RequestBody List<XhpcOperatorInternetBlacklist> list) {
if (null != list && list.size() > 0) { if (null != list && list.size() > 0) {
Long operatorId = list.get(0).getOperatorId(); Long operatorId = list.get(0).getOperatorId();
xhpcOperatorInternetBlacklistService.deleteByIds(operatorId); xhpcOperatorInternetBlacklistService.deleteByIds(operatorId);

View File

@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -31,7 +32,7 @@ public class XhpcStationInternetBlacklistController extends BaseController {
@ApiOperation("新增电站流量方黑名单") @ApiOperation("新增电站流量方黑名单")
@PreAuthorize(hasPermi = "station:internet:add") @PreAuthorize(hasPermi = "station:internet:add")
@PostMapping("/add") @PostMapping("/add")
public AjaxResult add(@RequestBody List<XhpcStationInternetBlacklist> list) { public AjaxResult add(@Valid @RequestBody List<XhpcStationInternetBlacklist> list) {
if (null != list && list.size() > 0) { if (null != list && list.size() > 0) {
Long internetUserId = list.get(0).getInternetUserId(); Long internetUserId = list.get(0).getInternetUserId();
iXhpcStationInternetBlacklistService.deleteByIds(internetUserId); iXhpcStationInternetBlacklistService.deleteByIds(internetUserId);

View File

@ -1,12 +1,14 @@
package com.xhpc.user.controller; package com.xhpc.user.controller;
import com.ruoyi.common.core.utils.SecurityUtils; import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.PreAuthorize; import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.domain.SysUser;
import com.xhpc.user.openfeign.RemoteSystemService; import com.xhpc.user.openfeign.RemoteSystemService;
import com.xhpc.user.service.IXhpcOperatorService;
import com.xhpc.user.service.IXhpcUserService; import com.xhpc.user.service.IXhpcUserService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -30,12 +32,15 @@ public class XhpcUserController extends BaseController {
@Autowired @Autowired
private RemoteSystemService remoteSystemService; private RemoteSystemService remoteSystemService;
@Autowired
private IXhpcOperatorService iXhpcOperatorService;
/** /**
* 获取平台用户分页列表 * 获取平台用户分页列表
*/ */
@PreAuthorize(hasPermi = "user:pc:page") //@PreAuthorize(hasPermi = "user:pc:page")
@GetMapping("/pc/page") @GetMapping("/pc/page")
public TableDataInfo pcpage(String userName, String nickName) { public TableDataInfo pcPage(String userName, String nickName) {
startPage(); startPage();
List<Map<String, Object>> list = iXhpcUserService.selectPcUserList(userName, nickName); List<Map<String, Object>> list = iXhpcUserService.selectPcUserList(userName, nickName);
return getDataTable(list); return getDataTable(list);
@ -54,7 +59,7 @@ public class XhpcUserController extends BaseController {
sysUser.setUserType("00"); sysUser.setUserType("00");
sysUser.setCreateBy(SecurityUtils.getUsername()); sysUser.setCreateBy(SecurityUtils.getUsername());
AjaxResult ajaxResult = remoteSystemService.addUser(sysUser); AjaxResult ajaxResult = remoteSystemService.addUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
return AjaxResult.success(); return AjaxResult.success();
@ -71,7 +76,7 @@ public class XhpcUserController extends BaseController {
return AjaxResult.error("用户id不能为空"); return AjaxResult.error("用户id不能为空");
} }
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser); AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
return AjaxResult.success(); return AjaxResult.success();
@ -81,7 +86,7 @@ public class XhpcUserController extends BaseController {
* 平台用户详情 * 平台用户详情
*/ */
@ApiOperation("平台用户详情") @ApiOperation("平台用户详情")
@PreAuthorize(hasPermi = "user:pc:info") //@PreAuthorize(hasPermi = "user:pc:info")
@GetMapping("/pc/info") @GetMapping("/pc/info")
public AjaxResult pcInfo(@RequestBody Long userId) { public AjaxResult pcInfo(@RequestBody Long userId) {
return AjaxResult.success(iXhpcUserService.pcInfo(userId)); return AjaxResult.success(iXhpcUserService.pcInfo(userId));
@ -91,7 +96,8 @@ public class XhpcUserController extends BaseController {
/** /**
* 获取运营上用户分页列表 * 获取运营上用户分页列表
*/ */
@PreAuthorize(hasPermi = "user:operator:page") @ApiOperation("获取运营上用户分页列表")
//@PreAuthorize(hasPermi = "user:operator:page")
@GetMapping("/operator/page") @GetMapping("/operator/page")
public TableDataInfo operatorPage(String userName, String nickName, Long operatorId) { public TableDataInfo operatorPage(String userName, String nickName, Long operatorId) {
startPage(); startPage();
@ -107,7 +113,7 @@ public class XhpcUserController extends BaseController {
@PostMapping("/operator/add") @PostMapping("/operator/add")
public AjaxResult operatorAdd(@RequestBody SysUser sysUser) { public AjaxResult operatorAdd(@RequestBody SysUser sysUser) {
if (null == sysUser.getOperatorId()) { if (null == sysUser.getOperatorId()) {
return AjaxResult.error("所属运营不能为空"); return AjaxResult.error("所属运营不能为空");
} }
sysUser.setPhonenumber(sysUser.getUserName()); sysUser.setPhonenumber(sysUser.getUserName());
sysUser.setDeptId(103l); sysUser.setDeptId(103l);
@ -115,7 +121,7 @@ public class XhpcUserController extends BaseController {
sysUser.setUserType("03"); sysUser.setUserType("03");
sysUser.setCreateBy(SecurityUtils.getUsername()); sysUser.setCreateBy(SecurityUtils.getUsername());
AjaxResult ajaxResult = remoteSystemService.addUser(sysUser); AjaxResult ajaxResult = remoteSystemService.addUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
return AjaxResult.success(); return AjaxResult.success();
@ -135,7 +141,7 @@ public class XhpcUserController extends BaseController {
return AjaxResult.error("所属运营上不能为空"); return AjaxResult.error("所属运营上不能为空");
} }
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser); AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
if (null != ajaxResult && !"200".equals(ajaxResult.get("code"))) { if (null != ajaxResult && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
return ajaxResult; return ajaxResult;
} }
return AjaxResult.success(); return AjaxResult.success();
@ -145,9 +151,9 @@ public class XhpcUserController extends BaseController {
* 运营商用户详情 * 运营商用户详情
*/ */
@ApiOperation("运营商用户详情") @ApiOperation("运营商用户详情")
@PreAuthorize(hasPermi = "user:operator:info") //@PreAuthorize(hasPermi = "user:operator:info")
@GetMapping("/operator/info") @GetMapping("/operator/info")
public AjaxResult operatorInfo(@RequestBody Long userId) { public AjaxResult operatorInfo(@RequestParam Long userId) {
return AjaxResult.success(iXhpcUserService.operatorInfo(userId)); return AjaxResult.success(iXhpcUserService.operatorInfo(userId));
} }
@ -155,12 +161,21 @@ public class XhpcUserController extends BaseController {
* 禁用/启用平台和运营商子账号 * 禁用/启用平台和运营商子账号
*/ */
@ApiOperation("禁用/启用平台和运营商子账号") @ApiOperation("禁用/启用平台和运营商子账号")
@PreAuthorize(hasPermi = "user:pc:status") //@PreAuthorize(hasPermi = "user:pc:status")
@PostMapping("/status") @PostMapping("/status")
public AjaxResult status(@RequestBody Long userId) { public AjaxResult status(@RequestParam Long userId) {
iXhpcUserService.status(userId); iXhpcUserService.status(userId);
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 禁用/启用平台和运营商子账号
*/
@ApiOperation("禁用/启用平台和运营商子账号")
//@PreAuthorize(hasPermi = "user:pc:status")
@PostMapping("/remove")
public AjaxResult remove(@RequestParam Long userId) {
iXhpcOperatorService.removeUser(userId);
return AjaxResult.success();
}
} }

View File

@ -2,6 +2,8 @@ package com.xhpc.user.domain;
import com.ruoyi.common.core.web.domain.BaseEntity; import com.ruoyi.common.core.web.domain.BaseEntity;
import java.math.BigDecimal;
/** /**
* C端用户 xhpc_app_user * C端用户 xhpc_app_user
@ -31,6 +33,16 @@ public class XhpcAppUser extends BaseEntity {
*/ */
private String alipayOpenId; private String alipayOpenId;
/**
* 微信是否登录0未登录 1已登录
*/
private Integer weixinLogin;
/**
* 支付宝是否登录0未登录 1已登录
*/
private Integer alipayLogin;
/** /**
* 头像地址 * 头像地址
*/ */
@ -39,7 +51,7 @@ public class XhpcAppUser extends BaseEntity {
/** /**
* 余额 * 余额
*/ */
private Double balance; private BigDecimal balance;
/** /**
* 密码(加密) * 密码(加密)
@ -88,6 +100,22 @@ public class XhpcAppUser extends BaseEntity {
this.alipayOpenId = alipayOpenId; this.alipayOpenId = alipayOpenId;
} }
public Integer getWeixinLogin() {
return weixinLogin;
}
public void setWeixinLogin(Integer weixinLogin) {
this.weixinLogin = weixinLogin;
}
public Integer getAlipayLogin() {
return alipayLogin;
}
public void setAlipayLogin(Integer alipayLogin) {
this.alipayLogin = alipayLogin;
}
public String getAvatar() { public String getAvatar() {
return avatar; return avatar;
} }
@ -96,11 +124,11 @@ public class XhpcAppUser extends BaseEntity {
this.avatar = avatar; this.avatar = avatar;
} }
public Double getBalance() { public BigDecimal getBalance() {
return balance; return balance;
} }
public void setBalance(Double balance) { public void setBalance(BigDecimal balance) {
this.balance = balance; this.balance = balance;
} }

View File

@ -3,6 +3,7 @@ package com.xhpc.user.domain;
import com.ruoyi.common.core.web.domain.BaseEntity; import com.ruoyi.common.core.web.domain.BaseEntity;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
@ -16,7 +17,7 @@ public class XhpcInternetUser extends BaseEntity {
/** /**
* 用户id * 用户id
*/ */
@NotBlank(message = "用户id不能为空") @NotNull(message = "用户id不能为空")
private Long internetUserId; private Long internetUserId;
/** /**
@ -52,31 +53,30 @@ public class XhpcInternetUser extends BaseEntity {
/** /**
* 卡号 * 卡号
*/ */
@NotBlank(message = "卡号不能为空") @NotNull(message = "卡号不能为空")
private Integer cardNumber; private Integer cardNumber;
/** /**
* 合作开始时间 * 合作开始时间
*/ */
@NotBlank(message = "合作开始时间不能为空") @NotNull(message = "合作开始时间不能为空")
private Date cooperationStartTime; private Date cooperationStartTime;
/** /**
* 合作结束时间 * 合作结束时间
*/ */
@NotBlank(message = "合作结束时间不能为空") @NotNull(message = "合作结束时间不能为空")
private Date cooperationEndTime; private Date cooperationEndTime;
/** /**
* 余额 * 余额
*/ */
@NotBlank(message = "余额不能为空")
private Double money; private Double money;
/** /**
* 地址code * 地址code
*/ */
@NotBlank(message = "地址不能为空") @NotNull(message = "地址不能为空")
private Integer areaCode; private Integer areaCode;
/** /**
@ -94,13 +94,13 @@ public class XhpcInternetUser extends BaseEntity {
/** /**
* 提成类型0总金额提成 1服务费提成 * 提成类型0总金额提成 1服务费提成
*/ */
@NotBlank(message = "提成类型不能为空") @NotNull(message = "提成类型不能为空")
private Integer commissionType; private Integer commissionType;
/** /**
* 提成率 * 提成率
*/ */
@NotBlank(message = "提成率不能为空") @NotNull(message = "提成率不能为空")
private Double commissionRate; private Double commissionRate;
/** /**

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/** /**
* 运营商表 xhpc_operator * 运营商表 xhpc_operator
@ -47,7 +48,7 @@ public class XhpcOperator extends BaseEntity {
/** /**
* 运营商属性 * 运营商属性
*/ */
@NotBlank(message = "运营商属性不能为空") @NotNull(message = "运营商属性不能为空")
private Integer attribute; private Integer attribute;
/** /**
@ -65,7 +66,7 @@ public class XhpcOperator extends BaseEntity {
/** /**
* 经度 * 经度
*/ */
@NotBlank(message = "经度不能为空") @NotNull(message = "经度不能为空")
private String longitude; private String longitude;
/** /**
@ -83,19 +84,19 @@ public class XhpcOperator extends BaseEntity {
/** /**
* 提成类型0总金额提成 1服务费提成 * 提成类型0总金额提成 1服务费提成
*/ */
@NotBlank(message = "提成类型不能为空") @NotNull(message = "提成类型不能为空")
private Integer commissionType; private Integer commissionType;
/** /**
* 平台提成 * 平台提成
*/ */
@NotBlank(message = "平台提成不能为空") @NotNull(message = "平台提成不能为空")
private Double platformCommissionRate; private Double platformCommissionRate;
/** /**
* 运维提成 * 运维提成
*/ */
@NotBlank(message = "运维提成不能为空") @NotNull(message = "运维提成不能为空")
private Double maintenanceCommissionRate; private Double maintenanceCommissionRate;
/** /**
@ -107,7 +108,7 @@ public class XhpcOperator extends BaseEntity {
/** /**
* 提现时间tn * 提现时间tn
*/ */
@NotBlank(message = "提现时间不能为空") @NotNull(message = "提现时间不能为空")
private Integer withdrawalTime; private Integer withdrawalTime;
/** /**

View File

@ -1,6 +1,6 @@
package com.xhpc.user.domain; package com.xhpc.user.domain;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -15,13 +15,13 @@ public class XhpcOperatorInternetBlacklist implements Serializable {
/** /**
* 运营商id * 运营商id
*/ */
@NotBlank(message = "运营商id不能为空") @NotNull(message = "运营商id不能为空")
private Long operatorId; private Long operatorId;
/** /**
* 流量用户id * 流量用户id
*/ */
@NotBlank(message = "流量用户id不能为空") @NotNull(message = "流量用户id不能为空")
private Long internetUserId; private Long internetUserId;

View File

@ -1,6 +1,6 @@
package com.xhpc.user.domain; package com.xhpc.user.domain;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -15,13 +15,13 @@ public class XhpcStationInternetBlacklist implements Serializable {
/** /**
* 流量用户id * 流量用户id
*/ */
@NotBlank(message = "流量用户id不能为空") @NotNull(message = "流量用户id不能为空")
private Long internetUserId; private Long internetUserId;
/** /**
* 电站id * 电站id
*/ */
@NotBlank(message = "电站id不能为空") @NotNull(message = "电站id不能为空")
private Long chargingStationId; private Long chargingStationId;

View File

@ -13,6 +13,14 @@ import java.util.Map;
*/ */
public interface XhpcAppUserMapper { public interface XhpcAppUserMapper {
/**
* 新增 C端用户信息
*
* @param xhpcAppUser C端用户信息
* @return 结果
*/
public int insert(XhpcAppUser xhpcAppUser);
/** /**
* 修改C端用户信息 * 修改C端用户信息
* *
@ -38,4 +46,19 @@ public interface XhpcAppUserMapper {
*/ */
public List<Map<String, Object>> selectAppUserList(@Param("phone") String phone); public List<Map<String, Object>> selectAppUserList(@Param("phone") String phone);
/**
* 手机号查询C端用户信息
*
* @param phone 手机号
* @return 结果
*/
public XhpcAppUser getAppUserByPhone(@Param("phone") String phone);
/**
* openid查询C端用户信息
*
* @param openid
* @return 结果
*/
public XhpcAppUser getAppUserByOpenid(@Param("openid") String openid);
} }

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.domain.SysUser;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -21,8 +22,8 @@ public interface RemoteSystemService {
* @param sysUser 用户信息 * @param sysUser 用户信息
* @return 结果 * @return 结果
*/ */
@PostMapping(value = "/user/add") @PostMapping(value = "/user")
public AjaxResult addUser(@RequestBody SysUser sysUser); public AjaxResult addUser(@Validated @RequestBody SysUser sysUser);
/** /**
* 新增用户 * 新增用户
@ -30,7 +31,7 @@ public interface RemoteSystemService {
* @param sysUser 用户信息 * @param sysUser 用户信息
* @return 结果 * @return 结果
*/ */
@PutMapping(value = "/user/edit") @PutMapping(value = "/user")
public AjaxResult editUser(@RequestBody SysUser sysUser); public AjaxResult editUser(@Validated @RequestBody SysUser sysUser);
} }

View File

@ -1,7 +1,9 @@
package com.xhpc.user.service; package com.xhpc.user.service;
import com.ruoyi.common.core.domain.R;
import com.xhpc.user.domain.XhpcAppUser; import com.xhpc.user.domain.XhpcAppUser;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -44,4 +46,38 @@ public interface IXhpcAppUserUserService {
* @return 结果 * @return 结果
*/ */
public void status(Long appUserId); public void status(Long appUserId);
/**
* C端用户注册
*
* @param map C端用户 phone 手机号 code 验证码 type 登录方式1微信2小程序
* @return 结果
*/
public R<?> register(Map<String, Object> map);
/**
* C端用户登录
*
* @param map C端用户 phone 手机号 code 验证码 type 登录方式1微信2小程序
* @return 结果
*/
public R<?> login(Map<String, Object> map);
/**
* 小程序用户退出
*
* @param request
* @param type 退出方式1微信2小程序
* @return
*/
public R<?> loginOut(HttpServletRequest request, String type);
/**
* C端用户自动登录
*
* @param map
* @return
*/
public R<?> voluntaryLogin(Map<String, Object> map);
} }

View File

@ -1,12 +1,23 @@
package com.xhpc.user.service.impl; package com.xhpc.user.service.impl;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.enums.UserStatus;
import com.ruoyi.common.core.exception.BaseException;
import com.ruoyi.common.core.exception.CaptchaException;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import com.xhpc.user.domain.XhpcAppUser; import com.xhpc.user.domain.XhpcAppUser;
import com.xhpc.user.mapper.XhpcAppUserMapper; import com.xhpc.user.mapper.XhpcAppUserMapper;
import com.xhpc.user.service.IXhpcAppUserUserService; import com.xhpc.user.service.IXhpcAppUserUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -21,6 +32,11 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
@Autowired @Autowired
private XhpcAppUserMapper xhpcAppUserMapper; private XhpcAppUserMapper xhpcAppUserMapper;
@Autowired
private RedisService redisService;
@Autowired
private TokenService tokenService;
/** /**
* 更新C端用户 * 更新C端用户
@ -70,4 +86,161 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
xhpcAppUser.setStatus("0".equals(status) ? 1 : 0); xhpcAppUser.setStatus("0".equals(status) ? 1 : 0);
update(xhpcAppUser); update(xhpcAppUser);
} }
/**
* C端用户注册
*
* @param map C端用户 phone 手机号 code 验证码 type 登录方式1微信2小程序
* @return 结果
*/
@Override
public R<?> register(Map<String, Object> map) {
String code = StringUtils.valueOf(map.get("code"));
String phone = StringUtils.valueOf(map.get("phone"));
String type = StringUtils.valueOf(map.get("type"));
String openid = StringUtils.valueOf(map.get("openid"));
if (StringUtils.isEmpty(openid)) {
throw new CaptchaException("openid不能为空");
}
if (StringUtils.isEmpty(code)) {
throw new CaptchaException("验证码不能为空");
}
/*String verifyKey = Constants.CAPTCHA_CODE_KEY + phone;
String captcha = redisService.getCacheObject(verifyKey);
redisService.deleteObject(verifyKey);
if (!code.equalsIgnoreCase(captcha))
{
throw new CaptchaException("验证码错误");
}*/
XhpcAppUser info = xhpcAppUserMapper.getAppUserByPhone(phone);
if (StringUtils.isNotNull(info)) {
throw new CaptchaException("账号已存在");
}
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setPhone(phone);
String password = phone.substring(phone.length() - 6);
xhpcAppUser.setPassword(SecurityUtils.encryptPassword(password));
xhpcAppUserMapper.insert(xhpcAppUser);
return appLogin(phone, type, openid);
}
/**
* C端用户登录
*
* @param map C端用户 phone 手机号 code 验证码 type 登录方式1微信2小程序
* @return 结果
*/
@Override
public R<?> login(Map<String, Object> map) {
String code = StringUtils.valueOf(map.get("code"));
String phone = StringUtils.valueOf(map.get("phone"));
String type = StringUtils.valueOf(map.get("type"));
if (StringUtils.isEmpty(code)) {
throw new CaptchaException("验证码不能为空");
}
String openid = StringUtils.valueOf(map.get("openid"));
if (StringUtils.isEmpty(openid)) {
throw new CaptchaException("openid不能为空");
}
/*String verifyKey = Constants.CAPTCHA_CODE_KEY + phone;
String captcha = redisService.getCacheObject(verifyKey);
redisService.deleteObject(verifyKey);
if (!code.equalsIgnoreCase(captcha))
{
throw new CaptchaException("验证码错误");
}*/
return appLogin(phone, type, openid);
}
/**
* 登录
*/
public R<?> appLogin(String username, String type, String openid) {
// 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username)) {
throw new BaseException("用户必须填写");
}
// 用户名不在指定范围内 错误
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
throw new BaseException("用户名不在指定范围");
}
// 查询用户信息
XhpcAppUser user = xhpcAppUserMapper.getAppUserByPhone(username);
if (StringUtils.isNull(user)) {
throw new BaseException("登录用户:" + username + " 不存在");
}
LoginUser userInfo = new LoginUser();
SysUser sysUser = new SysUser();
sysUser.setUserName(user.getPhone());
sysUser.setUserId(user.getAppUserId());
userInfo.setSysUser(sysUser);
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
throw new BaseException("对不起,您的账号:" + username + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
throw new BaseException("对不起,您的账号:" + username + " 已停用");
}
if ("1".equals(type)) {
if (StringUtils.isNull(user.getWeixinOpenId())) {
user.setWeixinOpenId(openid);
}
user.setWeixinLogin(1);
} else {
if (StringUtils.isNull(user.getAlipayOpenId())) {
user.setAlipayOpenId(openid);
}
user.setAlipayLogin(1);
}
xhpcAppUserMapper.update(user);
// 获取登录token
return R.ok(tokenService.createToken(userInfo));
}
/**
* 小程序用户退出
*
* @param request
* @return 结果
*/
@Override
public R<?> loginOut(HttpServletRequest request, String type) {
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser)) {
String username = loginUser.getUsername();
// 删除用户缓存记录
tokenService.delLoginUser(loginUser.getToken());
XhpcAppUser user = xhpcAppUserMapper.getAppUserByPhone(username);
if (StringUtils.isNull(user)) {
if ("1".equals(type)) {
user.setWeixinLogin(0);
} else {
user.setAlipayLogin(0);
}
xhpcAppUserMapper.update(user);
}
}
return R.ok();
}
/**
* C端用户自动登录
*
* @param map type 登录方式1微信2小程序 openid 微信或支付宝openid
* @return
*/
public R<?> voluntaryLogin(Map<String, Object> map) {
String type = StringUtils.valueOf(map.get("type"));
String openid = StringUtils.valueOf(map.get("openid"));
XhpcAppUser user = xhpcAppUserMapper.getAppUserByOpenid(openid);
if (StringUtils.isNull(user)) {
throw new BaseException("用户不存在");
}
return appLogin(user.getPhone(), type, openid);
}
} }

View File

@ -66,7 +66,7 @@ public class XhpcUserServiceImpl implements IXhpcUserService {
public List<Map<String, Object>> selectOperatorUserList(String userName, String nickName, Long operatorId) { public List<Map<String, Object>> selectOperatorUserList(String userName, String nickName, Long operatorId) {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
SysUser sysUser = xhpcUserMapper.selectUserByUserId(userId); SysUser sysUser = xhpcUserMapper.selectUserByUserId(userId);
if ("00".equals(sysUser.getDataPowerType())) { if ("00".equals(sysUser.getUserType())) {
return xhpcUserMapper.selectOperatorUserList(userName, nickName, operatorId, null); return xhpcUserMapper.selectOperatorUserList(userName, nickName, operatorId, null);
} else { } else {
return xhpcUserMapper.selectOperatorUserList(userName, nickName, operatorId, sysUser.getUserName()); return xhpcUserMapper.selectOperatorUserList(userName, nickName, operatorId, sysUser.getUserName());

View File

@ -9,6 +9,8 @@
<result column="phone" property="phone"/> <result column="phone" property="phone"/>
<result column="weixin_open_id" property="weixinOpenId"/> <result column="weixin_open_id" property="weixinOpenId"/>
<result column="alipay_open_id" property="alipayOpenId"/> <result column="alipay_open_id" property="alipayOpenId"/>
<result column="weixin_login" property="weixinLogin"/>
<result column="alipay_login" property="alipayLogin"/>
<result column="avatar" property="avatar"/> <result column="avatar" property="avatar"/>
<result column="balance" property="balance"/> <result column="balance" property="balance"/>
<result column="password" property="password"/> <result column="password" property="password"/>
@ -21,12 +23,118 @@
<result column="remark" property="remark"/> <result column="remark" property="remark"/>
</resultMap> </resultMap>
<insert id="insert" parameterType="com.xhpc.user.domain.XhpcAppUser">
INSERT INTO xhpc_app_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != appUserId and '' != appUserId">
app_user_id,
</if>
<if test="null != phone and '' != phone">
phone,
</if>
<if test="null != weixinOpenId and '' != weixinOpenId">
weixin_open_id,
</if>
<if test="null != alipayOpenId and '' != alipayOpenId">
alipay_open_id,
</if>
<if test="null != weixinLogin and '' != weixinLogin">
weixin_login,
</if>
<if test="null != alipayLogin and '' != alipayLogin">
alipay_login,
</if>
<if test="null != avatar and '' != avatar">
avatar,
</if>
<if test="null != balance and '' != balance">
balance,
</if>
<if test="null != password and '' != password">
password,
</if>
<if test="null != status and '' != status">
status,
</if>
<if test="null != delFlag and '' != delFlag">
del_flag,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != createTime and '' != createTime">
create_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != updateTime and '' != updateTime">
update_time,
</if>
<if test="null != remark and '' != remark">
remark
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != appUserId and '' != appUserId">
#{appUserId},
</if>
<if test="null != phone and '' != phone">
#{phone},
</if>
<if test="null != weixinOpenId and '' != weixinOpenId">
#{weixinOpenId},
</if>
<if test="null != alipayOpenId and '' != alipayOpenId">
#{alipayOpenId},
</if>
<if test="null != weixinLogin and '' != weixinLogin">
#{weixinLogin},
</if>
<if test="null != alipayLogin and '' != alipayLogin">
#{alipayLogin},
</if>
<if test="null != avatar and '' != avatar">
#{avatar},
</if>
<if test="null != balance and '' != balance">
#{balance},
</if>
<if test="null != password and '' != password">
#{password},
</if>
<if test="null != status and '' != status">
#{status},
</if>
<if test="null != delFlag and '' != delFlag">
#{delFlag},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != createTime and '' != createTime">
#{createTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != updateTime and '' != updateTime">
#{updateTime},
</if>
<if test="null != remark and '' != remark">
#{remark}
</if>
</trim>
</insert>
<update id="update" parameterType="com.xhpc.user.domain.XhpcInternetUser"> <update id="update" parameterType="com.xhpc.user.domain.XhpcInternetUser">
UPDATE xhpc_app_user UPDATE xhpc_app_user
<set> <set>
<if test="null != phone and '' != phone">phone = #{phone},</if> <if test="null != phone and '' != phone">phone = #{phone},</if>
<if test="null != weixinOpenId and '' != weixinOpenId">weixin_open_id = #{weixinOpenId},</if> <if test="null != weixinOpenId and '' != weixinOpenId">weixin_open_id = #{weixinOpenId},</if>
<if test="null != alipayOpenId and '' != alipayOpenId">alipay_open_id = #{alipayOpenId},</if> <if test="null != alipayOpenId and '' != alipayOpenId">alipay_open_id = #{alipayOpenId},</if>
<if test="null != weixinLogin and '' != weixinLogin">weixin_login = #{weixinLogin},</if>
<if test="null != alipayLogin and '' != alipayLogin">alipay_login = #{alipayLogin},</if>
<if test="null != avatar and '' != avatar">avatar = #{avatar},</if> <if test="null != avatar and '' != avatar">avatar = #{avatar},</if>
<if test="null != balance and '' != balance">balance = #{balance},</if> <if test="null != balance and '' != balance">balance = #{balance},</if>
<if test="null != password and '' != password">password = #{password},</if> <if test="null != password and '' != password">password = #{password},</if>
@ -43,11 +151,12 @@
<select id="info" parameterType="java.lang.Long" resultType="java.util.Map"> <select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
select app_user_id appUserId, phone, weixin_open_id weixinOpenId, select app_user_id appUserId, phone, weixin_open_id weixinOpenId,
alipay_open_id alipayOpenId, avatar, balance, password, weixin_login weixinlogin,alipay_login alipayLogin,
`status`,create_by createBy ,create_time createTime, alipay_open_id alipayOpenId, avatar, balance, password,
update_time updateTime, update_by updateBy, `status`,create_by createBy ,create_time createTime,
del_flag delflag, remark, update_time updateTime, update_by updateBy,
CASE WHEN xiu.`status` = 0 THEN '正常' else '禁用' end statusName, del_flag delflag, remark,
CASE WHEN xiu.`status` = 0 THEN '正常' else '禁用' end statusName,
from xhpc_app_user from xhpc_app_user
WHERE del_flag = 0 and app_user_id = #{appUserId} WHERE del_flag = 0 and app_user_id = #{appUserId}
</select> </select>
@ -64,5 +173,15 @@
ORDER BY create_time DESC ORDER BY create_time DESC
</select> </select>
<select id="getAppUserByPhone" parameterType="java.lang.String" resultMap="XhpcAppUserResult">
select *
from xhpc_app_user
WHERE del_flag = 0 and phone = #{phone} LIMIT 1
</select>
<select id="getAppUserByOpenid" parameterType="java.lang.String" resultMap="XhpcAppUserResult">
select *
from xhpc_app_user
WHERE del_flag = 0 and (weixin_open_id = #{openid}or alipay_open_id = #{openid}) LIMIT 1
</select>
</mapper> </mapper>

View File

@ -43,7 +43,8 @@
</sql> </sql>
<insert id="insert" parameterType="com.xhpc.user.domain.XhpcOperator"> <insert id="insert" parameterType="com.xhpc.user.domain.XhpcOperator">
insert into xhpc_operator( insert into xhpc_operator
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != operatorId and '' != operatorId"> <if test="null != operatorId and '' != operatorId">
operator_id, operator_id,
</if> </if>
@ -116,8 +117,10 @@
<if test="null != remark and '' != remark"> <if test="null != remark and '' != remark">
remark remark
</if> </if>
)values( </trim>
<if test="null != operatorId and '' != operatorId"> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != operatorId and '' != operatorId">
#{operatorId}, #{operatorId},
</if> </if>
<if test="null != name and '' != name"> <if test="null != name and '' != name">
@ -189,7 +192,7 @@
<if test="null != remark and '' != remark"> <if test="null != remark and '' != remark">
#{remark} #{remark}
</if> </if>
) </trim>
</insert> </insert>
<update id="update" parameterType="com.xhpc.user.domain.XhpcOperator"> <update id="update" parameterType="com.xhpc.user.domain.XhpcOperator">
@ -242,7 +245,7 @@
<select id="info" parameterType="java.lang.Long" resultType="java.util.Map"> <select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>,
xdb.dict_value attributenName,`xa`.merger_name mergerName, xdb.dict_value attributenName,`xa`.merger_name mergerName,
GROUP_CONCAT(DISTINCT xi.`url` ORDER BY xi.create_time DESC separator ',') businessLicenseUrl GROUP_CONCAT(DISTINCT xi.`url` ORDER BY xi.create_time DESC separator ',') businessLicenseUrl
from xhpc_operator `xo` from xhpc_operator `xo`

View File

@ -8,6 +8,7 @@
<result column="user_id" property="userId"/> <result column="user_id" property="userId"/>
<result column="dept_id" property="deptId"/> <result column="dept_id" property="deptId"/>
<result column="user_name" property="userName"/> <result column="user_name" property="userName"/>
<result column="user_type" property="userType"/>
<result column="nick_name" property="nickName"/> <result column="nick_name" property="nickName"/>
<result column="email" property="email"/> <result column="email" property="email"/>
<result column="phonenumber" property="phonenumber"/> <result column="phonenumber" property="phonenumber"/>
@ -63,7 +64,7 @@
</delete> </delete>
<select id="selectUserByUserId" parameterType="java.lang.Long" resultType="com.ruoyi.system.api.domain.SysUser"> <select id="selectUserByUserId" parameterType="java.lang.Long" resultMap="XhpcUserResult">
select * select *
from sys_user from sys_user
where user_id = #{userId} where user_id = #{userId}
@ -74,7 +75,7 @@
nick_name nickName, email, nick_name nickName, email,
create_by createBy ,create_time createTime create_by createBy ,create_time createTime
from sys_user from sys_user
WHERE del_flag = 0 WHERE del_flag = 0 and user_type = '00'
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
and user_name like concat(concat('%', #{userName}), '%') and user_name like concat(concat('%', #{userName}), '%')
</if> </if>
@ -103,7 +104,7 @@
CASE WHEN su.`status` = 0 THEN '正常' else '禁用' end statusName CASE WHEN su.`status` = 0 THEN '正常' else '禁用' end statusName
from sys_user su from sys_user su
LEFT JOIN xhpc_operator xo on xo.operator_id = su.operator_id LEFT JOIN xhpc_operator xo on xo.operator_id = su.operator_id
WHERE del_flag = 0 WHERE su.del_flag = 0 and user_type = '03'
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
and user_name like concat(concat('%', #{userName}), '%') and user_name like concat(concat('%', #{userName}), '%')
</if> </if>
@ -121,8 +122,8 @@
<select id="operatorInfo" parameterType="java.lang.Long" resultType="java.util.Map"> <select id="operatorInfo" parameterType="java.lang.Long" resultType="java.util.Map">
select su.user_id userId,su.user_name userName, select su.user_id userId,su.user_name userName,
su.nick_name nickName, su.email, su.nick_name nickName, su.email,su.sex,
su.create_by createBy ,su.create_time createTime, su.create_by createBy ,su.create_time createTime,xo.operator_id operatorId,
xo.`name` operatorName,su.`status` , xo.`name` operatorName,su.`status` ,
CASE WHEN su.`status` = 0 THEN '正常' else '禁用' end statusName, CASE WHEN su.`status` = 0 THEN '正常' else '禁用' end statusName,
sdd.dict_label sexName sdd.dict_label sexName