用户模块区分是否管理员身份,是否商户身份

This commit is contained in:
gxwebsoft
2024-04-30 10:16:10 +08:00
parent c8c17add3f
commit a7d2cc44c4
10 changed files with 141 additions and 28 deletions

View File

@@ -83,17 +83,7 @@ public class MainController extends BaseController {
@Resource
private CompanyService companyService;
@Resource
private MenuService menuService;
@Resource
private RoleService roleService;
@Resource
private UserRoleService userRoleService;
@Resource
private DictService dictService;
@Resource
private DictDataService dictDataService;
@Resource
private EmailRecordService emailRecordService;
private MerchantAccountService merchantAccountService;
@ApiOperation("用户登录")
@PostMapping("/login")
@@ -134,19 +124,12 @@ public class MainController extends BaseController {
tokenExpireTime = Long.valueOf(ExpireTime);
}
}
String path = "/shop/merchant-account?=phone" + username;
// 链式构建请求
String result = HttpRequest.get("https://modules.gxwebsoft.com/api".concat(path))
.header("Authorization", JwtUtil.getAccessToken(request))
.header("Tenantid", "10154")
.timeout(20000)//超时,毫秒
.execute().body();
JSONObject jsonObject = JSONObject.parseObject(result);
final String data = jsonObject.getString("data");
final MerchantAccount merchantAccount = JSONObject.parseObject(data, MerchantAccount.class);
user.setMerchantAccount(merchantAccount);
// 是否管理员
if(param.getIsAdmin() != null && !user.getIsAdmin()){
return fail("不是管理员账号",null);
}
// 读取商户账号
user.setMerchantAccount(merchantAccountService.getOne(new LambdaQueryWrapper<MerchantAccount>().eq(MerchantAccount::getPhone,user.getPhone()).last("limit 1")));
// 签发token
String access_token = JwtUtil.buildToken(new JwtSubject(username, tenantId),

View File

@@ -28,7 +28,7 @@ import java.util.List;
*/
@Api(tags = "商户账号管理")
@RestController
@RequestMapping("/api/shop/merchant-account")
@RequestMapping("/api/system/merchant-account")
public class MerchantAccountController extends BaseController {
@Resource
private MerchantAccountService merchantAccountService;

View File

@@ -22,7 +22,7 @@ import java.util.List;
*/
@Api(tags = "商户入驻申请管理")
@RestController
@RequestMapping("/api/shop/merchant-apply")
@RequestMapping("/api/system/merchant-apply")
public class MerchantApplyController extends BaseController {
@Resource
private MerchantApplyService merchantApplyService;

View File

@@ -29,7 +29,7 @@ import java.util.List;
*/
@Api(tags = "商户管理")
@RestController
@RequestMapping("/api/shop/merchant")
@RequestMapping("/api/system/merchant")
public class MerchantController extends BaseController {
@Resource
private MerchantService merchantService;

View File

@@ -0,0 +1,111 @@
package com.gxwebsoft.common.system.controller;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.MerchantType;
import com.gxwebsoft.common.system.entity.MerchantType;
import com.gxwebsoft.common.system.param.MerchantTypeParam;
import com.gxwebsoft.common.system.service.MerchantTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 商户类型控制器
*
* @author 科技小王子
* @since 2024-04-05 00:08:51
*/
@Api(tags = "商户类型管理")
@RestController
@RequestMapping("/api/system/merchant-type")
public class MerchantTypeController extends BaseController {
@Resource
private MerchantTypeService merchantTypeService;
@ApiOperation("分页查询商户类型")
@GetMapping("/page")
public ApiResult<PageResult<MerchantType>> page(MerchantTypeParam param) {
// 使用关联查询
return success(merchantTypeService.pageRel(param));
}
@ApiOperation("查询全部商户类型")
@GetMapping()
public ApiResult<List<MerchantType>> list(MerchantTypeParam param) {
// 使用关联查询
return success(merchantTypeService.listRel(param));
}
@ApiOperation("根据id查询商户类型")
@GetMapping("/{id}")
public ApiResult<MerchantType> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(merchantTypeService.getByIdRel(id));
}
@ApiOperation("添加商户类型")
@PostMapping()
public ApiResult<?> save(@RequestBody MerchantType merchantType) {
// 记录当前登录用户id
// User loginUser = getLoginUser();
// if (loginUser != null) {
// merchantType.setUserId(loginUser.getUserId());
// }
if (merchantTypeService.save(merchantType)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改商户类型")
@PutMapping()
public ApiResult<?> update(@RequestBody MerchantType merchantType) {
if (merchantTypeService.updateById(merchantType)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除商户类型")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (merchantTypeService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加商户类型")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<MerchantType> list) {
if (merchantTypeService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改商户类型")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<MerchantType> batchParam) {
if (batchParam.update(merchantTypeService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除商户类型")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (merchantTypeService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -160,6 +160,9 @@ public class Company implements Serializable {
@ApiModelProperty(value = "微信小程序二维码")
private String mpWeixinCode;
@ApiModelProperty(value = "支付宝小程序二维码")
private String mpAlipayCode;
@ApiModelProperty(value = "H5端应用二维码")
private String h5Code;

View File

@@ -170,6 +170,16 @@ public class User implements UserDetails {
@ApiModelProperty("客户端ID")
private String clientId;
@ApiModelProperty(value = "商户ID")
private Integer merchantId;
@ApiModelProperty(value = "商户名称")
@TableField(exist = false)
private Integer merchantName;
@ApiModelProperty(value = "是否管理员")
private Boolean isAdmin;
@ApiModelProperty("评论数")
private Integer commentNumbers;

View File

@@ -29,7 +29,8 @@
c.dict_data_name sex_name,
e.tenant_name,
g.grade_id,g.name as gradeName,
h.dealer_id
h.dealer_id,
i.merchant_name
FROM sys_user a
LEFT JOIN sys_organization b ON a.organization_id = b.organization_id
LEFT JOIN (
@@ -41,6 +42,7 @@
LEFT JOIN sys_tenant e ON a.tenant_id = e.tenant_id
LEFT JOIN sys_user_grade g ON a.grade_id = g.grade_id
LEFT JOIN sys_user_referee h ON a.user_id = h.user_id and h.deleted = 0
LEFT JOIN sys_merchant h ON a.merchant_id = h.merchant_id
<where>
<if test="param.userId != null">
AND a.user_id = #{param.userId}

View File

@@ -31,6 +31,9 @@ public class LoginParam implements Serializable {
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("是否管理员")
private Boolean isAdmin;
@ApiModelProperty(value = "租户id")
private Integer tenantId;

View File

@@ -108,6 +108,7 @@ public class TenantServiceImpl extends ServiceImpl<TenantMapper, Tenant> impleme
admin.setNickname("超级管理员");
admin.setPhone(company.getPhone());
admin.setEmail(company.getEmail());
admin.setIsAdmin(true);
admin.setRealName(company.getBusinessEntity());
admin.setCompanyName(company.getShortName());
admin.setPassword(userService.encodePassword(company.getPassword()));