405 changed files with 40182 additions and 0 deletions
-
0mdp-sys/README.md
-
84mdp-sys/pom.xml
-
175mdp-sys/src/main/java/com/mdp/app/ctrl/AppMdpDefController.java
-
266mdp-sys/src/main/java/com/mdp/app/ctrl/AppShopConfigController.java
-
178mdp-sys/src/main/java/com/mdp/app/ctrl/AppTpAuthController.java
-
174mdp-sys/src/main/java/com/mdp/app/ctrl/AppTpPayController.java
-
72mdp-sys/src/main/java/com/mdp/app/entity/AppMdpDef.java
-
114mdp-sys/src/main/java/com/mdp/app/entity/AppShopConfig.java
-
135mdp-sys/src/main/java/com/mdp/app/entity/AppTpAuth.java
-
124mdp-sys/src/main/java/com/mdp/app/entity/AppTpPay.java
-
24mdp-sys/src/main/java/com/mdp/app/mapper/AppMdpDefMapper.java
-
11mdp-sys/src/main/java/com/mdp/app/mapper/AppMdpDefMapper.xml
-
24mdp-sys/src/main/java/com/mdp/app/mapper/AppShopConfigMapper.java
-
11mdp-sys/src/main/java/com/mdp/app/mapper/AppShopConfigMapper.xml
-
24mdp-sys/src/main/java/com/mdp/app/mapper/AppTpAuthMapper.java
-
11mdp-sys/src/main/java/com/mdp/app/mapper/AppTpAuthMapper.xml
-
24mdp-sys/src/main/java/com/mdp/app/mapper/AppTpPayMapper.java
-
11mdp-sys/src/main/java/com/mdp/app/mapper/AppTpPayMapper.xml
-
34mdp-sys/src/main/java/com/mdp/app/service/AppMdpDefService.java
-
34mdp-sys/src/main/java/com/mdp/app/service/AppShopConfigService.java
-
34mdp-sys/src/main/java/com/mdp/app/service/AppTpAuthService.java
-
34mdp-sys/src/main/java/com/mdp/app/service/AppTpPayService.java
-
38mdp-sys/src/main/java/com/mdp/app/service/WxpubClientService.java
-
290mdp-sys/src/main/java/com/mdp/biz/ctrl/CoopController.java
-
81mdp-sys/src/main/java/com/mdp/biz/entity/Coop.java
-
24mdp-sys/src/main/java/com/mdp/biz/mapper/CoopMapper.java
-
11mdp-sys/src/main/java/com/mdp/biz/mapper/CoopMapper.xml
-
34mdp-sys/src/main/java/com/mdp/biz/service/CoopService.java
-
36mdp-sys/src/main/java/com/mdp/client/AcClient.java
-
44mdp-sys/src/main/java/com/mdp/login/client/SysClient.java
-
345mdp-sys/src/main/java/com/mdp/login/ctrl/TokenPasswordController.java
-
230mdp-sys/src/main/java/com/mdp/login/ctrl/UserInfoController.java
-
890mdp-sys/src/main/java/com/mdp/login/ctrl/UserOperController.java
-
63mdp-sys/src/main/java/com/mdp/login/ctrl/UserResourceController.java
-
21mdp-sys/src/main/java/com/mdp/login/entity/RequestTokenParams.java
-
10mdp-sys/src/main/java/com/mdp/login/entity/RequestUserInfoParams.java
-
5mdp-sys/src/main/java/com/mdp/login/entity/Scope.java
-
225mdp-sys/src/main/java/com/mdp/login/entity/SysUser.java
-
143mdp-sys/src/main/java/com/mdp/login/entity/ValidCode.java
-
29mdp-sys/src/main/java/com/mdp/login/entity/ValidCodeVo.java
-
76mdp-sys/src/main/java/com/mdp/login/integration/IntegrationParams.java
-
22mdp-sys/src/main/java/com/mdp/login/integration/IntegrationParamsContext.java
-
341mdp-sys/src/main/java/com/mdp/login/integration/authenticator/AuthenticatorAdapter.java
-
46mdp-sys/src/main/java/com/mdp/login/integration/authenticator/IntegrationAuthenticator.java
-
15mdp-sys/src/main/java/com/mdp/login/integration/authenticator/PasswordAuthenticator.java
-
89mdp-sys/src/main/java/com/mdp/login/integration/authenticator/PasswordDisplayUseridAuthenticator.java
-
87mdp-sys/src/main/java/com/mdp/login/integration/authenticator/email/EmailAuthenticator.java
-
98mdp-sys/src/main/java/com/mdp/login/integration/authenticator/sms/SmsAuthenticator.java
-
90mdp-sys/src/main/java/com/mdp/login/integration/authenticator/webchat/miniapp/MiniAppAuthenticator.java
-
87mdp-sys/src/main/java/com/mdp/login/integration/authenticator/wechat/wxpub/WxpubAuthenticator.java
-
47mdp-sys/src/main/java/com/mdp/login/mapper/SysUserMapper.java
-
125mdp-sys/src/main/java/com/mdp/login/mapper/SysUserMapper.xml
-
24mdp-sys/src/main/java/com/mdp/login/mapper/ValidCodeMapper.java
-
11mdp-sys/src/main/java/com/mdp/login/mapper/ValidCodeMapper.xml
-
52mdp-sys/src/main/java/com/mdp/login/service/LoginEmailService.java
-
23mdp-sys/src/main/java/com/mdp/login/service/SmsLoginService.java
-
119mdp-sys/src/main/java/com/mdp/login/service/SysUserQueryService.java
-
82mdp-sys/src/main/java/com/mdp/login/service/SysUserResourceService.java
-
48mdp-sys/src/main/java/com/mdp/login/service/SysUserService.java
-
107mdp-sys/src/main/java/com/mdp/login/service/UserDetailsServiceImpl.java
-
99mdp-sys/src/main/java/com/mdp/login/service/UserOperService.java
-
20mdp-sys/src/main/java/com/mdp/login/service/ValidCodeService.java
-
53mdp-sys/src/main/java/com/mdp/login/service/client/SmsClientService.java
-
46mdp-sys/src/main/java/com/mdp/login/util/LockUtil.java
-
57mdp-sys/src/main/java/com/mdp/login/util/ValidUtils.java
-
143mdp-sys/src/main/java/com/mdp/mallm/shop/ctrl/ShopController.java
-
67mdp-sys/src/main/java/com/mdp/mallm/shop/ctrl/ShopLocationController.java
-
150mdp-sys/src/main/java/com/mdp/mallm/shop/entity/Shop.java
-
211mdp-sys/src/main/java/com/mdp/mallm/shop/entity/ShopLocation.java
-
24mdp-sys/src/main/java/com/mdp/mallm/shop/mapper/ShopLocationMapper.java
-
11mdp-sys/src/main/java/com/mdp/mallm/shop/mapper/ShopLocationMapper.xml
-
24mdp-sys/src/main/java/com/mdp/mallm/shop/mapper/ShopMapper.java
-
11mdp-sys/src/main/java/com/mdp/mallm/shop/mapper/ShopMapper.xml
-
31mdp-sys/src/main/java/com/mdp/mallm/shop/service/ShopLocationService.java
-
122mdp-sys/src/main/java/com/mdp/mallm/shop/service/ShopService.java
-
260mdp-sys/src/main/java/com/mdp/menu/ctrl/MenuDefController.java
-
139mdp-sys/src/main/java/com/mdp/menu/ctrl/MenuFavoriteController.java
-
333mdp-sys/src/main/java/com/mdp/menu/ctrl/MenuModuleBranchController.java
-
291mdp-sys/src/main/java/com/mdp/menu/ctrl/MenuModuleController.java
-
251mdp-sys/src/main/java/com/mdp/menu/ctrl/MenuRoleController.java
-
88mdp-sys/src/main/java/com/mdp/menu/entity/MenuDef.java
-
84mdp-sys/src/main/java/com/mdp/menu/entity/MenuFavorite.java
-
99mdp-sys/src/main/java/com/mdp/menu/entity/MenuModule.java
-
105mdp-sys/src/main/java/com/mdp/menu/entity/MenuModuleBranch.java
-
46mdp-sys/src/main/java/com/mdp/menu/entity/MenuRole.java
-
49mdp-sys/src/main/java/com/mdp/menu/entity/MenuToRolesVo.java
-
50mdp-sys/src/main/java/com/mdp/menu/entity/MenusToRoleVo.java
-
49mdp-sys/src/main/java/com/mdp/menu/entity/MenusToRolesVo.java
-
29mdp-sys/src/main/java/com/mdp/menu/mapper/MenuDefMapper.java
-
59mdp-sys/src/main/java/com/mdp/menu/mapper/MenuDefMapper.xml
-
24mdp-sys/src/main/java/com/mdp/menu/mapper/MenuFavoriteMapper.java
-
11mdp-sys/src/main/java/com/mdp/menu/mapper/MenuFavoriteMapper.xml
-
25mdp-sys/src/main/java/com/mdp/menu/mapper/MenuModuleBranchMapper.java
-
35mdp-sys/src/main/java/com/mdp/menu/mapper/MenuModuleBranchMapper.xml
-
24mdp-sys/src/main/java/com/mdp/menu/mapper/MenuModuleMapper.java
-
11mdp-sys/src/main/java/com/mdp/menu/mapper/MenuModuleMapper.xml
-
25mdp-sys/src/main/java/com/mdp/menu/mapper/MenuRoleMapper.java
-
44mdp-sys/src/main/java/com/mdp/menu/mapper/MenuRoleMapper.xml
-
136mdp-sys/src/main/java/com/mdp/menu/service/MenuDefService.java
-
189mdp-sys/src/main/java/com/mdp/menu/service/MenuFavoriteService.java
@ -0,0 +1,84 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>mdp-sys</artifactId> |
|||
|
|||
<packaging>jar</packaging> |
|||
<name>mdp-sys 后台管理系统</name> |
|||
<description>后台管理系统</description> |
|||
<parent> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-lcode-backend</artifactId> |
|||
<version>2.0.0-RELEASE</version> |
|||
</parent> |
|||
<dependencies> |
|||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --> |
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>fastjson</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>druid</artifactId> |
|||
<version>1.2.4</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>druid-spring-boot-starter</artifactId> |
|||
<version>1.2.4</version> |
|||
</dependency> |
|||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.mdp</groupId> |
|||
<scope>test</scope> |
|||
<artifactId>mdp-dev</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-devtools</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-boot-starter</artifactId> |
|||
<version>${mdp.version}</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-tpa-client</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-email-client</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-sms-client</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>cn.hutool</groupId> |
|||
<artifactId>hutool-all</artifactId> |
|||
<version>5.8.0.M4</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>io.jsonwebtoken</groupId> |
|||
<artifactId>jjwt</artifactId> |
|||
<version>0.9.1</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>nl.bitwalker</groupId> |
|||
<artifactId>UserAgentUtils</artifactId> |
|||
<version>1.2.4</version> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
</project> |
|||
@ -0,0 +1,175 @@ |
|||
package com.mdp.app.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.app.entity.AppMdpDef; |
|||
import com.mdp.app.service.AppMdpDefService; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.swagger.ApiEntityParams; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.toMap; |
|||
|
|||
@RestController |
|||
@RequestMapping(value="/**/app/appMdpDef") |
|||
@Api(tags={"MDP平台应用定义表-操作接口"}) |
|||
public class AppMdpDefController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(AppMdpDefController.class); |
|||
|
|||
@Autowired |
|||
private AppMdpDefService appMdpDefService; |
|||
|
|||
|
|||
Map<String,Object> fieldsMap = toMap(new AppMdpDef()); |
|||
|
|||
|
|||
@ApiOperation( value = "MDP平台应用定义表-查询列表",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppMdpDef.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listAppMdpDef(@ApiIgnore @RequestParam Map<String,Object> appMdpDef){ |
|||
try { |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
QueryWrapper<AppMdpDef> qw = QueryTools.initQueryWrapper(AppMdpDef.class , appMdpDef); |
|||
IPage page = QueryTools.initPage(appMdpDef); |
|||
QueryTools.initPage(appMdpDef); |
|||
Map<String,Object> ext=new HashMap<>(); |
|||
List<Map<String,Object>> datas = appMdpDefService.getBaseMapper().selectListMapByWhere(page,qw,ext); |
|||
return Result.ok("query-ok","查询成功").setData(datas).setTotal(page.getTotal()); |
|||
}catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
@ApiOperation( value = "MDP平台应用定义表-新增",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppMdpDef.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addAppMdpDef(@RequestBody AppMdpDef appMdpDef) { |
|||
appMdpDefService.save(appMdpDef); |
|||
return Result.ok("add-ok","添加成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用定义表-删除",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delAppMdpDef(@RequestBody AppMdpDef appMdpDef){ |
|||
appMdpDefService.removeById(appMdpDef); |
|||
return Result.ok("del-ok","删除成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用定义表-修改",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppMdpDef.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editAppMdpDef(@RequestBody AppMdpDef appMdpDef) { |
|||
appMdpDefService.updateById(appMdpDef); |
|||
return Result.ok("edit-ok","修改成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用定义表-批量修改某些字段",notes="") |
|||
@ApiEntityParams( value = AppMdpDef.class, props={ }, remark = "MDP平台应用定义表", paramType = "body" ) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppMdpDef.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST) |
|||
public Result editSomeFields( @ApiIgnore @RequestBody Map<String,Object> appMdpDefMap) { |
|||
try{ |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
appMdpDefService.editSomeFields(appMdpDefMap); |
|||
return Result.ok("edit-ok","更新成功"); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用定义表-批量删除",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelAppMdpDef(@RequestBody List<AppMdpDef> appMdpDefs) { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
try{ |
|||
if(appMdpDefs.size()<=0){ |
|||
return Result.error("appMdpDef-batchDel-data-err-0","请上送待删除数据列表"); |
|||
} |
|||
List<AppMdpDef> datasDb=appMdpDefService.listByIds(appMdpDefs.stream().map(i-> i.getMdpAppid() ).collect(Collectors.toList())); |
|||
|
|||
List<AppMdpDef> can=new ArrayList<>(); |
|||
List<AppMdpDef> no=new ArrayList<>(); |
|||
for (AppMdpDef data : datasDb) { |
|||
if(true){ |
|||
can.add(data); |
|||
}else{ |
|||
no.add(data); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
appMdpDefService.removeByIds(can); |
|||
msgs.add(LangTips.transMsg("del-ok-num","成功删除%s条数据.",can.size())); |
|||
} |
|||
|
|||
if(no.size()>0){ |
|||
msgs.add(LangTips.transMsg("not-allow-del-num","以下%s条数据不能删除:【%s】",no.size(),no.stream().map(i-> i.getMdpAppid() ).collect(Collectors.joining(",")))); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
}catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error(e); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用定义表-根据主键查询一条数据",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppMdpDef.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/queryById",method=RequestMethod.GET) |
|||
public Result queryById(AppMdpDef appMdpDef) { |
|||
AppMdpDef data = (AppMdpDef) appMdpDefService.getById(appMdpDef); |
|||
return Result.ok().setData(data); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,266 @@ |
|||
package com.mdp.app.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.app.entity.AppShopConfig; |
|||
import com.mdp.app.service.AppShopConfigService; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.utils.DateUtils; |
|||
import com.mdp.mallm.shop.entity.Shop; |
|||
import com.mdp.mallm.shop.service.ShopService; |
|||
import com.mdp.plat.entity.Platform; |
|||
import com.mdp.plat.service.PlatformService; |
|||
import com.mdp.qx.HasRole; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* url编制采用rest风格,如对ADM.app_shop_config app_shop_config的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: app/appShopConfig/add <br> |
|||
* 查询: app/appShopConfig/list<br> |
|||
* 模糊查询: app/appShopConfig/listKey<br> |
|||
* 修改: app/appShopConfig/edit <br> |
|||
* 删除: app/appShopConfig/del<br> |
|||
* 批量删除: app/appShopConfig/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppShopConfig 表 ADM.app_shop_config 当前主键(包括多主键): shop_id; |
|||
***/ |
|||
@RestController("mdp.app.appShopConfigController") |
|||
@RequestMapping(value="/**/app/appShopConfig") |
|||
@Api(tags={"app_shop_config操作接口"}) |
|||
public class AppShopConfigController { |
|||
|
|||
static Log logger=LogFactory.getLog(AppShopConfigController.class); |
|||
|
|||
@Autowired |
|||
private AppShopConfigService appShopConfigService; |
|||
|
|||
@Autowired |
|||
RedisTemplate redisTemplate; |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
PlatformService platformService; |
|||
|
|||
@Autowired |
|||
private ShopService shopService; |
|||
|
|||
@ApiOperation( value = "查询app_shop_config信息列表",notes="listAppShopConfig,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppShopConfig.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listAppShopConfig( @ApiIgnore @RequestParam Map<String,Object> appShopConfig){ |
|||
|
|||
IPage page=QueryTools.initPage(appShopConfig); |
|||
QueryWrapper<AppShopConfig> qw= QueryTools.initQueryWrapper(AppShopConfig.class, appShopConfig); |
|||
List<Map<String,Object>> appShopConfigList = appShopConfigService.selectListMapByWhere(page,qw,appShopConfig); |
|||
|
|||
return Result.ok().setData(appShopConfigList).setTotal(page.getTotal()); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "新增一条app_shop_config信息",notes="addAppShopConfig,主键如果为空,后台自动生成") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppShopConfig.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
|
|||
@HasRole(roles= {"superAdmin"}) |
|||
public Result addAppShopConfig(@RequestBody AppShopConfig appShopConfig) { |
|||
|
|||
|
|||
try{ |
|||
|
|||
if(!StringUtils.hasText(appShopConfig.getShopId())){ |
|||
return Result.error("shopId-is-null","商户编号不能为空"); |
|||
} |
|||
Shop shopDb=this.shopService.selectOneObject(new Shop(appShopConfig.getShopId())); |
|||
if(shopDb==null){ |
|||
return Result.error("shop-is-null","商户不存在"); |
|||
} |
|||
AppShopConfig appShopConfigQuery = new AppShopConfig(appShopConfig.getShopId()); |
|||
if(appShopConfigService.countByWhere(appShopConfigQuery)>0){ |
|||
return Result.error("id-exists","编号重复,请修改编号再提交"); |
|||
} |
|||
appShopConfigQuery = new AppShopConfig(); |
|||
appShopConfigQuery.setShopBranchId(appShopConfig.getShopBranchId()); |
|||
if(appShopConfigService.countByWhere(appShopConfigQuery)>0){ |
|||
return Result.error("org-had-another-partner","该机构已经存在一个商户,同一个机构不允许配置多个商户"); |
|||
} |
|||
|
|||
|
|||
Platform platformQuery=new Platform(); |
|||
platformQuery.setStatus("1"); |
|||
List<Platform> platforms=platformService.selectListByWhere(platformQuery); |
|||
if(platforms==null || platforms.size()==0){ |
|||
return Result.error("platform-is-not-found","未找到平台配置信息,请先配置平台信息"); |
|||
} |
|||
|
|||
if(!StringUtils.hasText(platforms.get(0).getShopId())){ |
|||
return Result.error("platform-not-set-shopId","平台未配置平台商户编号,无法创建商户"); |
|||
} |
|||
if(!StringUtils.hasText(platforms.get(0).getBranchId())){ |
|||
return Result.error("platform-not-set-branchId","平台未配置机构编号,无法创建商户"); |
|||
} |
|||
Platform platform=platforms.get(0); |
|||
if(!platform.getShopId().equals(appShopConfig.getPlatShopId())){ |
|||
return Result.error("platShopId-not-right","平台商户不是有效的平台商户"); |
|||
} |
|||
if(appShopConfig.getShopServiceCharges()==null){ |
|||
appShopConfig.setShopServiceCharges(BigDecimal.ZERO); |
|||
} |
|||
if(appShopConfig.getTpServiceCharges()==null){ |
|||
appShopConfig.setTpServiceCharges(BigDecimal.ZERO); |
|||
} |
|||
|
|||
if(appShopConfig.getPlatServiceCharges()==null){ |
|||
appShopConfig.setPlatServiceCharges(BigDecimal.ZERO); |
|||
} |
|||
appShopConfig.setLastUpdateTime(DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss")); |
|||
appShopConfigService.insert(appShopConfig); |
|||
Shop shop=new Shop(); |
|||
shop.setId(appShopConfig.getShopId()); |
|||
shop.setAcctPrjType(appShopConfig.getAcctPrjType()); |
|||
shop.setPlatBranchId(appShopConfig.getPlatBranchId()); |
|||
shop.setPlatShopId(appShopConfig.getPlatShopId()); |
|||
shop.setIsJoinPlat(appShopConfig.getIsJoinPlat()); |
|||
shopService.updateSomeFieldByPk(shop); |
|||
return Result.ok().setData(appShopConfig); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "删除一条app_shop_config信息",notes="delAppShopConfig,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delAppShopConfig(@RequestBody AppShopConfig appShopConfig){ |
|||
|
|||
|
|||
try{ |
|||
appShopConfigService.deleteByPk(appShopConfig); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键修改一条app_shop_config信息",notes="editAppShopConfig") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppShopConfig.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
public Result editAppShopConfig(@RequestBody AppShopConfig appShopConfig) { |
|||
|
|||
|
|||
try{ |
|||
|
|||
if(!StringUtils.hasText(appShopConfig.getShopId())){ |
|||
return Result.error("shopId-is-null","商户编号不能为空"); |
|||
} |
|||
Shop shopDb=this.shopService.selectOneObject(new Shop(appShopConfig.getShopId())); |
|||
if(shopDb==null){ |
|||
return Result.error("shop-is-null","商户不存在"); |
|||
} |
|||
Platform platformQuery=new Platform(); |
|||
platformQuery.setStatus("1"); |
|||
List<Platform> platforms=platformService.selectListByWhere(platformQuery); |
|||
if(platforms==null || platforms.size()==0){ |
|||
return Result.error("platform-is-not-found","未找到平台配置信息,请先配置平台信息"); |
|||
} |
|||
|
|||
if(!StringUtils.hasText(platforms.get(0).getShopId())){ |
|||
return Result.error("platform-not-set-shopId","平台未配置平台商户编号,无法创建商户"); |
|||
} |
|||
if(!StringUtils.hasText(platforms.get(0).getBranchId())){ |
|||
return Result.error("platform-not-set-branchId","平台未配置机构编号,无法创建商户"); |
|||
} |
|||
Platform platform=platforms.get(0); |
|||
if(StringUtils.hasText(appShopConfig.getPlatShopId()) && !platform.getShopId().equals(appShopConfig.getPlatShopId())){ |
|||
return Result.error("platShopId-not-right","归属平台商户编号不是有效的平台商户"); |
|||
} |
|||
appShopConfig.setLastUpdateTime(DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss")); |
|||
appShopConfigService.updateByPk(appShopConfig); |
|||
Shop shop=new Shop(); |
|||
shop.setId(appShopConfig.getShopId()); |
|||
shop.setAcctPrjType(appShopConfig.getAcctPrjType()); |
|||
shop.setPlatBranchId(appShopConfig.getPlatBranchId()); |
|||
shop.setPlatShopId(appShopConfig.getPlatShopId()); |
|||
shop.setIsJoinPlat(appShopConfig.getIsJoinPlat()); |
|||
shopService.updateSomeFieldByPk(shop); |
|||
|
|||
try { |
|||
redisTemplate.opsForHash().delete(AppShopConfig.class.getSimpleName()+"-"+appShopConfig.getShopId()); |
|||
} catch (Exception e) { |
|||
|
|||
} |
|||
return Result.ok().setData(appShopConfig); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键列表批量删除app_shop_config信息",notes="batchDelAppShopConfig,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelAppShopConfig(@RequestBody List<AppShopConfig> appShopConfigs) { |
|||
|
|||
|
|||
try{ |
|||
appShopConfigService.batchDelete(appShopConfigs); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
*/ |
|||
} |
|||
@ -0,0 +1,178 @@ |
|||
package com.mdp.app.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.app.entity.AppTpAuth; |
|||
import com.mdp.app.service.AppTpAuthService; |
|||
import com.mdp.app.service.WxpubClientService; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.qx.HasRole; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* url编制采用rest风格,如对ADMIN.app_tp_auth MDP平台应用与第三方应用关系的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: app/appTpAuth/add <br> |
|||
* 查询: app/appTpAuth/list<br> |
|||
* 模糊查询: app/appTpAuth/listKey<br> |
|||
* 修改: app/appTpAuth/edit <br> |
|||
* 删除: app/appTpAuth/del<br> |
|||
* 批量删除: app/appTpAuth/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppTpAuth 表 ADMIN.app_tp_auth 当前主键(包括多主键): auth_id; |
|||
***/ |
|||
@RestController("mdp.app.appTpAuthController") |
|||
@RequestMapping(value="/**/app/appTpAuth") |
|||
@Api(tags={"MDP平台应用与第三方应用关系操作接口"}) |
|||
public class AppTpAuthController { |
|||
|
|||
static Log logger=LogFactory.getLog(AppTpAuthController.class); |
|||
|
|||
@Autowired |
|||
private AppTpAuthService appTpAuthService; |
|||
@Autowired |
|||
WxpubClientService wxpubClientService; |
|||
|
|||
@Autowired |
|||
private com.mdp.tpa.client.service.AppTpAuthService cacheAppTpAuthService; |
|||
|
|||
@ApiOperation( value = "查询MDP平台应用与第三方应用关系信息列表",notes="listAppTpAuth,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response= AppTpAuth.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listAppTpAuth( @ApiIgnore @RequestParam Map<String,Object> appTpAuth){ |
|||
|
|||
IPage page=QueryTools.initPage(appTpAuth); |
|||
QueryWrapper<AppTpAuth> qw= QueryTools.initQueryWrapper(AppTpAuth.class, appTpAuth); |
|||
List<Map<String,Object>> appTpAuthList = appTpAuthService.selectListMapByWhere(page,qw,appTpAuth); |
|||
return Result.ok().setData(appTpAuthList); |
|||
} |
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "新增一条MDP平台应用与第三方应用关系信息",notes="addAppTpAuth,主键如果为空,后台自动生成") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppTpAuth.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addAppTpAuth(@RequestBody AppTpAuth appTpAuth) { |
|||
|
|||
|
|||
try{ |
|||
if(StringUtils.isEmpty(appTpAuth.getAuthId())) { |
|||
appTpAuth.setAuthId(appTpAuthService.createKey("authId")); |
|||
}else{ |
|||
AppTpAuth appTpAuthQuery = new AppTpAuth(appTpAuth.getAuthId()); |
|||
if(appTpAuthService.countByWhere(appTpAuthQuery)>0){ |
|||
return Result.error("id-exists","编号重复,请修改编号再提交"); |
|||
} |
|||
} |
|||
appTpAuthService.insert(appTpAuth); |
|||
return Result.ok().setData(appTpAuth); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "删除一条MDP平台应用与第三方应用关系信息",notes="delAppTpAuth,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delAppTpAuth(@RequestBody AppTpAuth appTpAuth){ |
|||
|
|||
|
|||
try{ |
|||
appTpAuthService.deleteByPk(appTpAuth); |
|||
cacheAppTpAuthService.clearOne(appTpAuth.getAuthId()); |
|||
wxpubClientService.clearAppTpAuth(appTpAuth.getAuthId()); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键修改一条MDP平台应用与第三方应用关系信息",notes="editAppTpAuth") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppTpAuth.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editAppTpAuth(@RequestBody AppTpAuth appTpAuth) { |
|||
|
|||
|
|||
try{ |
|||
appTpAuthService.updateByPk(appTpAuth); |
|||
cacheAppTpAuthService.clearOne(appTpAuth.getAuthId()); |
|||
wxpubClientService.clearAppTpAuth(appTpAuth.getAuthId()); |
|||
return Result.ok().setData(appTpAuth); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键列表批量删除MDP平台应用与第三方应用关系信息",notes="batchDelAppTpAuth,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelAppTpAuth(@RequestBody List<AppTpAuth> appTpAuths) { |
|||
|
|||
|
|||
try{ |
|||
appTpAuthService.batchDelete(appTpAuths); |
|||
for (AppTpAuth appTpAuth : appTpAuths) { |
|||
cacheAppTpAuthService.clearOne(appTpAuth.getAuthId()); |
|||
wxpubClientService.clearAppTpAuth(appTpAuth.getAuthId()); |
|||
} |
|||
|
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,174 @@ |
|||
package com.mdp.app.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.app.entity.AppTpPay; |
|||
import com.mdp.app.service.AppTpPayService; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.swagger.ApiEntityParams; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.toMap; |
|||
|
|||
@RestController |
|||
@RequestMapping(value="/**/app/appTpPay") |
|||
@Api(tags={"MDP平台应用与第三方支付关系表-操作接口"}) |
|||
public class AppTpPayController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(AppTpPayController.class); |
|||
|
|||
@Autowired |
|||
private AppTpPayService appTpPayService; |
|||
|
|||
|
|||
Map<String,Object> fieldsMap = toMap(new AppTpPay()); |
|||
|
|||
|
|||
@ApiOperation( value = "MDP平台应用与第三方支付关系表-查询列表",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppTpPay.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listAppTpPay(@ApiIgnore @RequestParam Map<String,Object> appTpPay){ |
|||
try { |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
QueryWrapper<AppTpPay> qw = QueryTools.initQueryWrapper(AppTpPay.class , appTpPay); |
|||
IPage page = QueryTools.initPage(appTpPay); |
|||
Map<String,Object> ext=new HashMap<>(); |
|||
List<Map<String,Object>> datas = appTpPayService.selectListMapByWhere(page,qw,ext); |
|||
return Result.ok("query-ok","查询成功").setData(datas).setTotal(page.getTotal()); |
|||
}catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
@ApiOperation( value = "MDP平台应用与第三方支付关系表-新增",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppTpPay.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addAppTpPay(@RequestBody AppTpPay appTpPay) { |
|||
appTpPayService.save(appTpPay); |
|||
return Result.ok("add-ok","添加成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用与第三方支付关系表-删除",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delAppTpPay(@RequestBody AppTpPay appTpPay){ |
|||
appTpPayService.removeById(appTpPay); |
|||
return Result.ok("del-ok","删除成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用与第三方支付关系表-修改",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppTpPay.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editAppTpPay(@RequestBody AppTpPay appTpPay) { |
|||
appTpPayService.updateById(appTpPay); |
|||
return Result.ok("edit-ok","修改成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用与第三方支付关系表-批量修改某些字段",notes="") |
|||
@ApiEntityParams( value = AppTpPay.class, props={ }, remark = "MDP平台应用与第三方支付关系表", paramType = "body" ) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppTpPay.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST) |
|||
public Result editSomeFields( @ApiIgnore @RequestBody Map<String,Object> appTpPayMap) { |
|||
try{ |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
appTpPayService.editSomeFields(appTpPayMap); |
|||
return Result.ok("edit-ok","更新成功"); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用与第三方支付关系表-批量删除",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelAppTpPay(@RequestBody List<AppTpPay> appTpPays) { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
try{ |
|||
if(appTpPays.size()<=0){ |
|||
return Result.error("appTpPay-batchDel-data-err-0","请上送待删除数据列表"); |
|||
} |
|||
List<AppTpPay> datasDb=appTpPayService.listByIds(appTpPays.stream().map(i-> i.getPayAuthId() ).collect(Collectors.toList())); |
|||
|
|||
List<AppTpPay> can=new ArrayList<>(); |
|||
List<AppTpPay> no=new ArrayList<>(); |
|||
for (AppTpPay data : datasDb) { |
|||
if(true){ |
|||
can.add(data); |
|||
}else{ |
|||
no.add(data); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
appTpPayService.removeByIds(can); |
|||
msgs.add(LangTips.transMsg("del-ok-num","成功删除%s条数据.",can.size())); |
|||
} |
|||
|
|||
if(no.size()>0){ |
|||
msgs.add(LangTips.transMsg("not-allow-del-num","以下%s条数据不能删除:【%s】",no.size(),no.stream().map(i-> i.getPayAuthId() ).collect(Collectors.joining(",")))); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
}catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error(e); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@ApiOperation( value = "MDP平台应用与第三方支付关系表-根据主键查询一条数据",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=AppTpPay.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/queryById",method=RequestMethod.GET) |
|||
public Result queryById(AppTpPay appTpPay) { |
|||
AppTpPay data = (AppTpPay) appTpPayService.getById(appTpPay); |
|||
return Result.ok().setData(data); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
package com.mdp.app.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppMdpDef所有属性名: <br> |
|||
* "mdpAppid","应用编号","name","应用名称","logoUrl","应用logo","remark","应用描述","bizType","应用分类","deptid","归属部门","branchId","归属机构","cdate","创建日期","cuserid","创建人","enabled","应用状态0下架1上架","url","首页跳转";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* mdp_appid;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("app_mdp_def") |
|||
@ApiModel(description="MDP平台应用定义表") |
|||
public class AppMdpDef implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="应用编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String mdpAppid; |
|||
|
|||
@ApiModelProperty(notes="应用名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String name; |
|||
|
|||
@ApiModelProperty(notes="应用logo",allowEmptyValue=true,example="",allowableValues="") |
|||
String logoUrl; |
|||
|
|||
@ApiModelProperty(notes="应用描述",allowEmptyValue=true,example="",allowableValues="") |
|||
String remark; |
|||
|
|||
@ApiModelProperty(notes="应用分类",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizType; |
|||
|
|||
@ApiModelProperty(notes="归属部门",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
@ApiModelProperty(notes="归属机构",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="创建日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date cdate; |
|||
|
|||
@ApiModelProperty(notes="创建人",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
@ApiModelProperty(notes="应用状态0下架1上架",allowEmptyValue=true,example="",allowableValues="") |
|||
String enabled; |
|||
|
|||
@ApiModelProperty(notes="首页跳转",allowEmptyValue=true,example="",allowableValues="") |
|||
String url; |
|||
|
|||
/** |
|||
*应用编号 |
|||
**/ |
|||
public AppMdpDef(String mdpAppid) { |
|||
this.mdpAppid = mdpAppid; |
|||
} |
|||
|
|||
/** |
|||
* MDP平台应用定义表 |
|||
**/ |
|||
public AppMdpDef() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,114 @@ |
|||
package com.mdp.app.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppShopConfig所有属性名: <br> |
|||
* "shopBranchId","商户自身归属机构号","shopId","商户编号","tpServiceCharges","第三方手续费费率如支付宝/微信支付的费率比如0.003","platServiceCharges","mdp平台附加手续费费率比如0.002,即该商户下所有交易需要支付给平台的手续费费率","platShopDepositAccountId","mdp平台分配给该商户(门店)预存款账户(一般商户编号-门店编号-01,用于mdp平台与该商户的结算,商户充值等),如果是总部店,为一般商户编号-0-01","platAssetAccountId","平台资产账户,商户缴纳给平台手续费等,从商户预存款账户转出,转入该账户计入平台主营业务收入","platShopId","归属平台商户编号","shopServiceCharges","mdp平台商户手续费费率一般为门店订单交易需要支付一定的手续费给商户","shopAssetAccountId","商户内部主营业务收入账户,在途资金到账后,转入主营业务收入","isPlatSc","商户是否需要向平台缴纳手续费","isShopSc","门店是否需要向商户缴纳手续费","acctPrjType","核算项目platform-由平台结算,shop-由商户独立结算,location-由门店独立结算","paySetType","支付结算方式platform-使用平台支付通道结算,shop-使用商户结算通道,location-使用门店独立结算通道","setLevel","结算级别1-商户2-门店,将在途资金账户余额归入商户的预存款账户还是门店预存款账户","allowLocationWithdraw","是否允许门店提现0否1允许3按门店配置自定义","settleShopId","归属计算商户pay_set_type=platform时,指向平台商户编号platform_shop_id,pay_set_type=shop时指向本商户编号shop_id","isJoinPlat","是否加入平台,如果加入平台将在平台的大商城可以展现数据-同步到shop表,避免多表关联","shopDepositAccountId","商户预存款账户,shop模式下,作为客户","settleBranchId","结算商户对应的机构号","platBranchId","商户归属的平台机构号","headLocationId","总部店铺编号-一般取商户号-0代表总部店铺","shopName","商户名称","headLocationName","总部店名称","signValue","签名信息","lastUpdateTime","最后更新时间yyyy-MM-dd";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* shop_id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("app_shop_config") |
|||
@ApiModel(description="app_shop_config") |
|||
public class AppShopConfig implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="商户编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopId; |
|||
|
|||
@ApiModelProperty(notes="商户自身归属机构号",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopBranchId; |
|||
|
|||
@ApiModelProperty(notes="第三方手续费费率如支付宝/微信支付的费率比如0.003",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal tpServiceCharges; |
|||
|
|||
@ApiModelProperty(notes="mdp平台附加手续费费率比如0.002,即该商户下所有交易需要支付给平台的手续费费率",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal platServiceCharges; |
|||
|
|||
@ApiModelProperty(notes="mdp平台分配给该商户(门店)预存款账户(一般商户编号-门店编号-01,用于mdp平台与该商户的结算,商户充值等),如果是总部店,为一般商户编号-0-01",allowEmptyValue=true,example="",allowableValues="") |
|||
String platShopDepositAccountId; |
|||
|
|||
@ApiModelProperty(notes="平台资产账户,商户缴纳给平台手续费等,从商户预存款账户转出,转入该账户计入平台主营业务收入",allowEmptyValue=true,example="",allowableValues="") |
|||
String platAssetAccountId; |
|||
|
|||
@ApiModelProperty(notes="归属平台商户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String platShopId; |
|||
|
|||
@ApiModelProperty(notes="mdp平台商户手续费费率一般为门店订单交易需要支付一定的手续费给商户",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal shopServiceCharges; |
|||
|
|||
@ApiModelProperty(notes="商户内部主营业务收入账户,在途资金到账后,转入主营业务收入",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopAssetAccountId; |
|||
|
|||
@ApiModelProperty(notes="商户是否需要向平台缴纳手续费",allowEmptyValue=true,example="",allowableValues="") |
|||
String isPlatSc; |
|||
|
|||
@ApiModelProperty(notes="门店是否需要向商户缴纳手续费",allowEmptyValue=true,example="",allowableValues="") |
|||
String isShopSc; |
|||
|
|||
@ApiModelProperty(notes="核算项目platform-由平台结算,shop-由商户独立结算,location-由门店独立结算",allowEmptyValue=true,example="",allowableValues="") |
|||
String acctPrjType; |
|||
|
|||
@ApiModelProperty(notes="支付结算方式platform-使用平台支付通道结算,shop-使用商户结算通道,location-使用门店独立结算通道",allowEmptyValue=true,example="",allowableValues="") |
|||
String paySetType; |
|||
|
|||
@ApiModelProperty(notes="结算级别1-商户2-门店,将在途资金账户余额归入商户的预存款账户还是门店预存款账户",allowEmptyValue=true,example="",allowableValues="") |
|||
String setLevel; |
|||
|
|||
@ApiModelProperty(notes="是否允许门店提现0否1允许3按门店配置自定义",allowEmptyValue=true,example="",allowableValues="") |
|||
String allowLocationWithdraw; |
|||
|
|||
@ApiModelProperty(notes="归属计算商户pay_set_type=platform时,指向平台商户编号platform_shop_id,pay_set_type=shop时指向本商户编号shop_id",allowEmptyValue=true,example="",allowableValues="") |
|||
String settleShopId; |
|||
|
|||
@ApiModelProperty(notes="是否加入平台,如果加入平台将在平台的大商城可以展现数据-同步到shop表,避免多表关联",allowEmptyValue=true,example="",allowableValues="") |
|||
String isJoinPlat; |
|||
|
|||
@ApiModelProperty(notes="商户预存款账户,shop模式下,作为客户",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopDepositAccountId; |
|||
|
|||
@ApiModelProperty(notes="结算商户对应的机构号",allowEmptyValue=true,example="",allowableValues="") |
|||
String settleBranchId; |
|||
|
|||
@ApiModelProperty(notes="商户归属的平台机构号",allowEmptyValue=true,example="",allowableValues="") |
|||
String platBranchId; |
|||
|
|||
@ApiModelProperty(notes="总部店铺编号-一般取商户号-0代表总部店铺",allowEmptyValue=true,example="",allowableValues="") |
|||
String headLocationId; |
|||
|
|||
@ApiModelProperty(notes="商户名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopName; |
|||
|
|||
@ApiModelProperty(notes="总部店名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String headLocationName; |
|||
|
|||
@ApiModelProperty(notes="签名信息",allowEmptyValue=true,example="",allowableValues="") |
|||
String signValue; |
|||
|
|||
@ApiModelProperty(notes="最后更新时间yyyy-MM-dd",allowEmptyValue=true,example="",allowableValues="") |
|||
String lastUpdateTime; |
|||
|
|||
/** |
|||
*商户编号 |
|||
**/ |
|||
public AppShopConfig(String shopId) { |
|||
this.shopId = shopId; |
|||
} |
|||
|
|||
/** |
|||
* app_shop_config |
|||
**/ |
|||
public AppShopConfig() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,135 @@ |
|||
package com.mdp.app.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppTpAuth所有属性名: <br> |
|||
* "authId","第三方应用编号","mdpAppid","应用编号","appid","对应第三方提供给的appid","appSecret","加密串","appToken","登录验证码","name","应用名称","logoUrl","应用logo","remark","应用描述","bizType","应用分类","deptid","归属部门","branchId","归属机构","loginUrl","登录地址","cdate","创建日期","cuserid","创建人","authUrl","授权地址","authPattern","监听发起授权地址","encKey","秘钥EncodingAESKey(消息加密密钥)","enabled","应用状态0下架1上架","payMchid","商户编号(作废)","payNotifyUrl","付款成功通知地址(作废)","openPay","开通支付(作废)","payKey","支付加密秘钥(作废)","msgNotifyUrl","消息推送地址","ips","服务器IP地址列表ip1,ip2,ip3","locationId","绑定的门店(运营方总店)","shopId","绑定的商户编号(运营方总商户编号)","locationName","门店名称","shopName","商户名称","multiLoca","是否为多店0否1是","genUseridType","创建userid的方式创same-branchId不同机构,same-shopId不同商户,same-phone不同手机号码,same-authId不同授权码,same-mdpAppid不同的mdp应用编号","useridLocationidType","用户与门店关联关系0-不创建,1-创建","pubAuthId","第三方应用编号";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* auth_id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("app_tp_auth") |
|||
@ApiModel(description="MDP平台应用与第三方应用关系") |
|||
public class AppTpAuth implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="第三方应用编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String authId; |
|||
|
|||
@ApiModelProperty(notes="应用编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String mdpAppid; |
|||
|
|||
@ApiModelProperty(notes="对应第三方提供给的appid",allowEmptyValue=true,example="",allowableValues="") |
|||
String appid; |
|||
|
|||
@ApiModelProperty(notes="加密串",allowEmptyValue=true,example="",allowableValues="") |
|||
String appSecret; |
|||
|
|||
@ApiModelProperty(notes="登录验证码",allowEmptyValue=true,example="",allowableValues="") |
|||
String appToken; |
|||
|
|||
@ApiModelProperty(notes="应用名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String name; |
|||
|
|||
@ApiModelProperty(notes="应用logo",allowEmptyValue=true,example="",allowableValues="") |
|||
String logoUrl; |
|||
|
|||
@ApiModelProperty(notes="应用描述",allowEmptyValue=true,example="",allowableValues="") |
|||
String remark; |
|||
|
|||
@ApiModelProperty(notes="应用分类",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizType; |
|||
|
|||
@ApiModelProperty(notes="归属部门",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
@ApiModelProperty(notes="归属机构",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="登录地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String loginUrl; |
|||
|
|||
@ApiModelProperty(notes="创建日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date cdate; |
|||
|
|||
@ApiModelProperty(notes="创建人",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
@ApiModelProperty(notes="授权地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String authUrl; |
|||
|
|||
@ApiModelProperty(notes="监听发起授权地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String authPattern; |
|||
|
|||
@ApiModelProperty(notes="秘钥EncodingAESKey(消息加密密钥)",allowEmptyValue=true,example="",allowableValues="") |
|||
String encKey; |
|||
|
|||
@ApiModelProperty(notes="应用状态0下架1上架",allowEmptyValue=true,example="",allowableValues="") |
|||
String enabled; |
|||
|
|||
@ApiModelProperty(notes="商户编号(作废)",allowEmptyValue=true,example="",allowableValues="") |
|||
String payMchid; |
|||
|
|||
@ApiModelProperty(notes="付款成功通知地址(作废)",allowEmptyValue=true,example="",allowableValues="") |
|||
String payNotifyUrl; |
|||
|
|||
@ApiModelProperty(notes="开通支付(作废)",allowEmptyValue=true,example="",allowableValues="") |
|||
String openPay; |
|||
|
|||
@ApiModelProperty(notes="支付加密秘钥(作废)",allowEmptyValue=true,example="",allowableValues="") |
|||
String payKey; |
|||
|
|||
@ApiModelProperty(notes="消息推送地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String msgNotifyUrl; |
|||
|
|||
@ApiModelProperty(notes="服务器IP地址列表ip1,ip2,ip3",allowEmptyValue=true,example="",allowableValues="") |
|||
String ips; |
|||
|
|||
@ApiModelProperty(notes="绑定的门店(运营方总店)",allowEmptyValue=true,example="",allowableValues="") |
|||
String locationId; |
|||
|
|||
@ApiModelProperty(notes="绑定的商户编号(运营方总商户编号)",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopId; |
|||
|
|||
@ApiModelProperty(notes="门店名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String locationName; |
|||
|
|||
@ApiModelProperty(notes="商户名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopName; |
|||
|
|||
@ApiModelProperty(notes="是否为多店0否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String multiLoca; |
|||
|
|||
@ApiModelProperty(notes="创建userid的方式创same-branchId不同机构,same-shopId不同商户,same-phone不同手机号码,same-authId不同授权码,same-mdpAppid不同的mdp应用编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String genUseridType; |
|||
|
|||
@ApiModelProperty(notes="用户与门店关联关系0-不创建,1-创建",allowEmptyValue=true,example="",allowableValues="") |
|||
String useridLocationidType; |
|||
|
|||
@ApiModelProperty(notes="第三方应用编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String pubAuthId; |
|||
|
|||
/** |
|||
*第三方应用编号 |
|||
**/ |
|||
public AppTpAuth(String authId) { |
|||
this.authId = authId; |
|||
} |
|||
|
|||
/** |
|||
* MDP平台应用与第三方应用关系 |
|||
**/ |
|||
public AppTpAuth() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,124 @@ |
|||
package com.mdp.app.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppTpPay所有属性名: <br> |
|||
* "mdpAppid","应用编号","name","应用名称","logoUrl","应用logo","remark","应用描述","payType","付款方式0余额1微信2V麦3支付宝4银行5网银6其他","deptid","归属部门","branchId","归属机构","cdate","创建日期","cuserid","创建人","enabled","应用状态0下架1上架","appid","对应第三方提供给的appid","payMchid","商户编号","payNotifyUrl","付款成功通知地址","openPay","是否开通支付","payKey","支付加密秘钥私钥","ips","服务器IP地址列表ip1,ip2,ip3","locationId","绑定的门店","shopId","绑定的商户编号","locationName","门店名称","shopName","商户名称","payAuthId","主键","payPubKey","支付加密秘钥公钥","tpServiceCharges","第三方手续费费率比如0.003","mdpServiceCharges","mdp平台附加手续费费率比如0.002","mdpPayAccountId","mdp平台分配给该商户(门店)预存款账户(一般商户编号-门店编号-01,用于mdp平台与该商户的结算),如果是总部店,为一般商户编号-0-01","mdpScAccountId","mdp平台手续费收取账户默认1001账户无论是门店交易还是商户交易,均要向平台缴纳一部分手续费","mdpShopServiceCharges","mdp平台商户手续费费率一般为门店订单交易需要支付一定的手续费给商户","settleShopId","结算商户编号如果是单商户模式、则为自己,否则为平台商户编号";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* pay_auth_id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("app_tp_pay") |
|||
@ApiModel(description="MDP平台应用与第三方支付关系表") |
|||
public class AppTpPay implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String payAuthId; |
|||
|
|||
@ApiModelProperty(notes="应用编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String mdpAppid; |
|||
|
|||
@ApiModelProperty(notes="应用名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String name; |
|||
|
|||
@ApiModelProperty(notes="应用logo",allowEmptyValue=true,example="",allowableValues="") |
|||
String logoUrl; |
|||
|
|||
@ApiModelProperty(notes="应用描述",allowEmptyValue=true,example="",allowableValues="") |
|||
String remark; |
|||
|
|||
@ApiModelProperty(notes="付款方式0余额1微信2V麦3支付宝4银行5网银6其他",allowEmptyValue=true,example="",allowableValues="") |
|||
String payType; |
|||
|
|||
@ApiModelProperty(notes="归属部门",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
@ApiModelProperty(notes="归属机构",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="创建日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date cdate; |
|||
|
|||
@ApiModelProperty(notes="创建人",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
@ApiModelProperty(notes="应用状态0下架1上架",allowEmptyValue=true,example="",allowableValues="") |
|||
String enabled; |
|||
|
|||
@ApiModelProperty(notes="对应第三方提供给的appid",allowEmptyValue=true,example="",allowableValues="") |
|||
String appid; |
|||
|
|||
@ApiModelProperty(notes="商户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String payMchid; |
|||
|
|||
@ApiModelProperty(notes="付款成功通知地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String payNotifyUrl; |
|||
|
|||
@ApiModelProperty(notes="是否开通支付",allowEmptyValue=true,example="",allowableValues="") |
|||
String openPay; |
|||
|
|||
@ApiModelProperty(notes="支付加密秘钥私钥",allowEmptyValue=true,example="",allowableValues="") |
|||
String payKey; |
|||
|
|||
@ApiModelProperty(notes="服务器IP地址列表ip1,ip2,ip3",allowEmptyValue=true,example="",allowableValues="") |
|||
String ips; |
|||
|
|||
@ApiModelProperty(notes="绑定的门店",allowEmptyValue=true,example="",allowableValues="") |
|||
String locationId; |
|||
|
|||
@ApiModelProperty(notes="绑定的商户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopId; |
|||
|
|||
@ApiModelProperty(notes="门店名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String locationName; |
|||
|
|||
@ApiModelProperty(notes="商户名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopName; |
|||
|
|||
@ApiModelProperty(notes="支付加密秘钥公钥",allowEmptyValue=true,example="",allowableValues="") |
|||
String payPubKey; |
|||
|
|||
@ApiModelProperty(notes="第三方手续费费率比如0.003",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal tpServiceCharges; |
|||
|
|||
@ApiModelProperty(notes="mdp平台附加手续费费率比如0.002",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal mdpServiceCharges; |
|||
|
|||
@ApiModelProperty(notes="mdp平台分配给该商户(门店)预存款账户(一般商户编号-门店编号-01,用于mdp平台与该商户的结算),如果是总部店,为一般商户编号-0-01",allowEmptyValue=true,example="",allowableValues="") |
|||
String mdpPayAccountId; |
|||
|
|||
@ApiModelProperty(notes="mdp平台手续费收取账户默认1001账户无论是门店交易还是商户交易,均要向平台缴纳一部分手续费",allowEmptyValue=true,example="",allowableValues="") |
|||
String mdpScAccountId; |
|||
|
|||
@ApiModelProperty(notes="mdp平台商户手续费费率一般为门店订单交易需要支付一定的手续费给商户",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal mdpShopServiceCharges; |
|||
|
|||
@ApiModelProperty(notes="结算商户编号如果是单商户模式、则为自己,否则为平台商户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String settleShopId; |
|||
|
|||
/** |
|||
*主键 |
|||
**/ |
|||
public AppTpPay(String payAuthId) { |
|||
this.payAuthId = payAuthId; |
|||
} |
|||
|
|||
/** |
|||
* MDP平台应用与第三方支付关系表 |
|||
**/ |
|||
public AppTpPay() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.app.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppMdpDef; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface AppMdpDefMapper extends BaseMapper<AppMdpDef> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.app.mapper.AppMdpDefMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from app_mdp_def res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.app.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppShopConfig; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface AppShopConfigMapper extends BaseMapper<AppShopConfig> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.app.mapper.AppShopConfigMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from app_shop_config res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.app.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppTpAuth; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface AppTpAuthMapper extends BaseMapper<AppTpAuth> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.app.mapper.AppTpAuthMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from app_tp_auth res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.app.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppTpPay; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface AppTpPayMapper extends BaseMapper<AppTpPay> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.app.mapper.AppTpPayMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from app_tp_pay res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,34 @@ |
|||
package com.mdp.app.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppMdpDef; |
|||
import com.mdp.app.mapper.AppMdpDefMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppMdpDef 表 app_mdp_def 当前主键(包括多主键): mdp_appid; |
|||
***/ |
|||
@Service |
|||
public class AppMdpDefService extends BaseService<AppMdpDefMapper,AppMdpDef> { |
|||
static Logger logger =LoggerFactory.getLogger(AppMdpDefService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,34 @@ |
|||
package com.mdp.app.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppShopConfig; |
|||
import com.mdp.app.mapper.AppShopConfigMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppShopConfig 表 app_shop_config 当前主键(包括多主键): shop_id; |
|||
***/ |
|||
@Service |
|||
public class AppShopConfigService extends BaseService<AppShopConfigMapper,AppShopConfig> { |
|||
static Logger logger =LoggerFactory.getLogger(AppShopConfigService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,34 @@ |
|||
package com.mdp.app.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppTpAuth; |
|||
import com.mdp.app.mapper.AppTpAuthMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppTpAuth 表 app_tp_auth 当前主键(包括多主键): auth_id; |
|||
***/ |
|||
@Service |
|||
public class AppTpAuthService extends BaseService<AppTpAuthMapper,AppTpAuth> { |
|||
static Logger logger =LoggerFactory.getLogger(AppTpAuthService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String, Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,34 @@ |
|||
package com.mdp.app.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.app.entity.AppTpPay; |
|||
import com.mdp.app.mapper.AppTpPayMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mdp 大模块 app 小模块 <br> |
|||
* 实体 AppTpPay 表 app_tp_pay 当前主键(包括多主键): pay_auth_id; |
|||
***/ |
|||
@Service |
|||
public class AppTpPayService extends BaseService<AppTpPayMapper,AppTpPay> { |
|||
static Logger logger =LoggerFactory.getLogger(AppTpPayService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,38 @@ |
|||
package com.mdp.app.service; |
|||
|
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.micro.client.CallBizService; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class WxpubClientService { |
|||
Log log=LogFactory.getLog(WxpubClientService.class); |
|||
@Autowired |
|||
CallBizService restTemplate; |
|||
|
|||
|
|||
@Value("${mdp.api-gate:http://gate}") |
|||
String apiGate="";//http://localhost:7041 |
|||
|
|||
|
|||
/** |
|||
*通知wxpub清理相关缓存 |
|||
**/ |
|||
public Tips clearAppTpAuth(String authId){ |
|||
String url = apiGate + "/wxpub/cache/clearAppTpAuthCache"; |
|||
ResponseEntity<Map> postForEntity = null; |
|||
Map<String,Object> params=new HashMap<>(); |
|||
params.put("authId", authId); |
|||
Tips tips=restTemplate.postForTips(url,params); |
|||
return tips; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,290 @@ |
|||
package com.mdp.biz.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.biz.entity.Coop; |
|||
import com.mdp.biz.service.CoopService; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.msg.client.PushNotifyMsgService; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.swagger.ApiEntityParams; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.fromMap; |
|||
import static com.mdp.core.utils.BaseUtils.toMap; |
|||
|
|||
/** |
|||
* url编制采用rest风格,如对biz_coop 商务合作申请的操作有增删改查,对应的url分别为:<br> |
|||
* 组织 com 顶级模块 mdp 大模块 biz 小模块 <br> |
|||
* 实体 Coop 表 biz_coop 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.biz.coopController") |
|||
@RequestMapping(value="/**/biz/coop") |
|||
@Api(tags={"商务合作申请操作接口"}) |
|||
public class CoopController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(CoopController.class); |
|||
|
|||
@Autowired |
|||
private CoopService coopService; |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
PushNotifyMsgService pushNotifyMsgService; |
|||
|
|||
|
|||
Map<String,Object> fieldsMap = toMap(new Coop()); |
|||
|
|||
|
|||
@ApiOperation( value = "查询商务合作申请信息列表",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Coop.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listCoop( @ApiIgnore @RequestParam Map<String,Object> coop){ |
|||
|
|||
IPage page=QueryTools.initPage(coop); |
|||
QueryWrapper<Coop> qw= QueryTools.initQueryWrapper(Coop.class,coop); |
|||
List<Map<String,Object>> coopList = coopService.selectListMapByWhere(page,qw,coop); |
|||
|
|||
return Result.ok().setData(coopList).setTotal(page.getTotal()); |
|||
} |
|||
|
|||
|
|||
|
|||
@ApiOperation( value = "新增一条商务合作申请信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Coop.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addCoop(@RequestBody Coop coop) { |
|||
|
|||
|
|||
try{ |
|||
boolean createPk=false; |
|||
if(!StringUtils.hasText(coop.getId())) { |
|||
createPk=true; |
|||
coop.setId(coopService.createKey("id")); |
|||
} |
|||
if(createPk==false){ |
|||
if(coopService.selectOneObject(coop) !=null ){ |
|||
return Result.error("pk-exists","编号重复,请修改编号再提交"); |
|||
} |
|||
} |
|||
if(!StringUtils.hasText(coop.getEmail())){ |
|||
return Result.error("email-0","联系邮箱不能为空"); |
|||
} |
|||
if(!StringUtils.hasText(coop.getPhoneno())){ |
|||
return Result.error("phoneno-0","联系电话不能为空"); |
|||
} |
|||
if(!StringUtils.hasText(coop.getRemark())){ |
|||
return Result.error("remark-0","合作需求不能为空"); |
|||
} |
|||
if(!LoginUtils.isGuest()){ |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
coop.setBranchId(user.getBranchId()); |
|||
coop.setUserid(user.getUserid()); |
|||
} |
|||
coop.setCtime(new Date()); |
|||
coop.setStatus("1"); |
|||
coopService.insert(coop); |
|||
pushNotifyMsgService.pushMsg("platform-branch-001","superAdmin","平台管理员",coop.getUserid(),coop.getUsername(),coop.getUsername()+"提交商务合作申请:"+coop.getRemark(),null); |
|||
return Result.ok().setData(coop); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "删除一条商务合作申请信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delCoop(@RequestBody Coop coop){ |
|||
|
|||
|
|||
try{ |
|||
if(!StringUtils.hasText(coop.getId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数id"); |
|||
} |
|||
Coop coopDb = coopService.selectOneObject(coop); |
|||
if( coopDb == null ){ |
|||
return Result.error("data-not-exists","数据不存在,无法删除"); |
|||
} |
|||
coopService.deleteByPk(coop); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键修改一条商务合作申请信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Coop.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editCoop(@RequestBody Coop coop) { |
|||
|
|||
|
|||
try{ |
|||
if(!StringUtils.hasText(coop.getId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数id"); |
|||
} |
|||
Coop coopDb = coopService.selectOneObject(coop); |
|||
if( coopDb == null ){ |
|||
return Result.error("data-not-exists","数据不存在,无法修改"); |
|||
} |
|||
coopService.updateSomeFieldByPk(coop); |
|||
return Result.ok().setData(coop); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
@ApiOperation( value = "批量修改某些字段",notes="") |
|||
@ApiEntityParams( value = Coop.class, props={ }, remark = "商务合作申请", paramType = "body" ) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Coop.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST) |
|||
public Result editSomeFields( @ApiIgnore @RequestBody Map<String,Object> coopMap) { |
|||
|
|||
|
|||
try{ |
|||
List<String> ids= (List<String>) coopMap.get("$pks"); |
|||
if(ids==null || ids.size()==0){ |
|||
return Result.error("ids-0","ids不能为空"); |
|||
} |
|||
|
|||
Set<String> fields=new HashSet<>(); |
|||
fields.add("id"); |
|||
for (String fieldName : coopMap.keySet()) { |
|||
if(fields.contains(fieldName)){ |
|||
return Result.error(fieldName+"-no-edit",fieldName+"不允许修改"); |
|||
} |
|||
} |
|||
Set<String> fieldKey=coopMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet()); |
|||
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(coopMap.get(i) )).collect(Collectors.toSet()); |
|||
|
|||
if(fieldKey.size()<=0) { |
|||
return Result.error("fieldKey-0","没有需要更新的字段"); |
|||
} |
|||
Coop coop = fromMap(coopMap,Coop.class); |
|||
List<Coop> coopsDb=coopService.selectListByIds(ids); |
|||
if(coopsDb==null ||coopsDb.size()==0){ |
|||
return Result.error("data-0","记录已不存在"); |
|||
} |
|||
List<Coop> can=new ArrayList<>(); |
|||
List<Coop> no=new ArrayList<>(); |
|||
User user = LoginUtils.getCurrentUserInfo(); |
|||
for (Coop coopDb : coopsDb) { |
|||
Tips tips2 = new Tips("检查通过"); |
|||
if(!tips2.isOk()){ |
|||
no.add(coopDb); |
|||
}else{ |
|||
can.add(coopDb); |
|||
} |
|||
} |
|||
if(can.size()>0){ |
|||
coopMap.put("$pks",can.stream().map(i->i.getId()).collect(Collectors.toList())); |
|||
coopService.editSomeFields(coopMap); |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
msgs.add(String.format("成功更新以下%s条数据",can.size())); |
|||
} |
|||
if(no.size()>0){ |
|||
msgs.add(String.format("以下%s个数据无权限更新",no.size())); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
//return Result.ok().setData(xmMenu); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "根据主键列表批量删除商务合作申请信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelCoop(@RequestBody List<Coop> coops) { |
|||
|
|||
|
|||
try{ |
|||
if(coops.size()<=0){ |
|||
return Result.error("data-0","请上送待删除数据列表"); |
|||
} |
|||
List<Coop> datasDb=coopService.selectListByIds(coops.stream().map(i-> i.getId() ).collect(Collectors.toList())); |
|||
|
|||
List<Coop> can=new ArrayList<>(); |
|||
List<Coop> no=new ArrayList<>(); |
|||
for (Coop data : datasDb) { |
|||
if(true){ |
|||
can.add(data); |
|||
}else{ |
|||
no.add(data); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
coopService.batchDelete(can); |
|||
msgs.add(String.format("成功删除%s条数据.",can.size())); |
|||
} |
|||
|
|||
if(no.size()>0){ |
|||
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(",")))); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
package com.mdp.biz.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 biz 小模块 <br> |
|||
* 实体 Coop所有属性名: <br> |
|||
* "id","主键","userid","用户编号","username","用户名称","branchId","公司编号","branchName","公司名称","email","邮箱","phoneno","电话","remark","合作要求","status","状态0-初始,1-申请中,2-进行中,3-已结束","ctime","申请日期","replyUserid","根进人编号","replyUsername","跟进人姓名","replyTime","跟进时间","bizType","合作类型1-项目合作,2-广告合作,3-服务商入驻,4-校企合作";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("biz_coop") |
|||
@ApiModel(description="商务合作申请") |
|||
public class Coop implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
@ApiModelProperty(notes="用户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String userid; |
|||
|
|||
@ApiModelProperty(notes="用户名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String username; |
|||
|
|||
@ApiModelProperty(notes="公司编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="公司名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchName; |
|||
|
|||
@ApiModelProperty(notes="邮箱",allowEmptyValue=true,example="",allowableValues="") |
|||
String email; |
|||
|
|||
@ApiModelProperty(notes="电话",allowEmptyValue=true,example="",allowableValues="") |
|||
String phoneno; |
|||
|
|||
@ApiModelProperty(notes="合作要求",allowEmptyValue=true,example="",allowableValues="") |
|||
String remark; |
|||
|
|||
@ApiModelProperty(notes="状态0-初始,1-申请中,2-进行中,3-已结束",allowEmptyValue=true,example="",allowableValues="") |
|||
String status; |
|||
|
|||
@ApiModelProperty(notes="申请日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date ctime; |
|||
|
|||
@ApiModelProperty(notes="根进人编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String replyUserid; |
|||
|
|||
@ApiModelProperty(notes="跟进人姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String replyUsername; |
|||
|
|||
@ApiModelProperty(notes="跟进时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date replyTime; |
|||
|
|||
@ApiModelProperty(notes="合作类型1-项目合作,2-广告合作,3-服务商入驻,4-校企合作",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizType; |
|||
|
|||
/** |
|||
*主键 |
|||
**/ |
|||
public Coop(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 商务合作申请 |
|||
**/ |
|||
public Coop() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.biz.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.biz.entity.Coop; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface CoopMapper extends BaseMapper<Coop> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.biz.mapper.CoopMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from biz_coop res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,34 @@ |
|||
package com.mdp.biz.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.biz.entity.Coop; |
|||
import com.mdp.biz.mapper.CoopMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mdp 大模块 biz 小模块 <br> |
|||
* 实体 Coop 表 biz_coop 当前主键(包括多主键): id; |
|||
***/ |
|||
@Service |
|||
public class CoopService extends BaseService<CoopMapper,Coop> { |
|||
static Logger logger =LoggerFactory.getLogger(CoopService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,36 @@ |
|||
package com.mdp.client; |
|||
|
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.utils.NumberUtil; |
|||
import com.mdp.micro.client.CallBizService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Map; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.map; |
|||
|
|||
@Service |
|||
public class AcClient { |
|||
|
|||
@Autowired |
|||
CallBizService callBizService; |
|||
|
|||
/** |
|||
* 查询用户的历史总收入 |
|||
* @param userid |
|||
* @return |
|||
*/ |
|||
public BigDecimal queryUserTaskReceiveAmount(String userid){ |
|||
String api="/accore/tpa/paymentSeq/queryUserTaskReceiveAmount?userid={userid}"; |
|||
Map<String,Object> map=callBizService.postForMap(api,map("userid",userid)); |
|||
Tips tips= (Tips) map.get("tips"); |
|||
if(tips.isOk()){ |
|||
return NumberUtil.getBigDecimal(map.get("data"),BigDecimal.ZERO); |
|||
}else{ |
|||
throw new BizException(tips); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package com.mdp.login.client; |
|||
|
|||
import com.mdp.mq.queue.Push; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.map; |
|||
|
|||
/** |
|||
* 对sys接口调用 |
|||
*/ |
|||
@Service |
|||
public class SysClient { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
Push push; |
|||
|
|||
/** |
|||
* 登记行用积分流水,并更新用户的信用等级及信用分 |
|||
* 引起信用等级变化的业务分类 bizType |
|||
* 1-个人实名认证,10 |
|||
* 2-企业认证,10 |
|||
* 3-银行卡认证,5 |
|||
* 4-手机号认证,5 |
|||
* 5-邮箱认证,5 |
|||
* 6-微信认证,5 |
|||
* 10-加入三保服务保障,20,40,60 |
|||
* 11-完成平台任务,每个任务3分(舍弃、不再支持) |
|||
* 12-邀请用户实名注册,每个注册用户得2分(舍弃、不再支持) |
|||
* 13-邀请用户完成任务。每个任务完成得3分(舍弃、不再支持) |
|||
* 14-其它 |
|||
* 如果是 |
|||
* @param userid |
|||
* @param bizType |
|||
* @param bizId |
|||
*/ |
|||
public void pushUserCreditScore(String userid,String bizType,String bizId,String remark){ |
|||
String queueKey = "sys-user-credit-record"; |
|||
push.leftPush(queueKey,map("userid",userid,"bizType",bizType,"bizId",bizId,"remark",remark)); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,345 @@ |
|||
/* |
|||
* Copyright 2020 the original author or authors. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* https://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package com.mdp.login.ctrl; |
|||
|
|||
import com.mdp.core.SpringContextUtils; |
|||
import com.mdp.core.api.Sequence; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.utils.BaseUtils; |
|||
import com.mdp.core.utils.RequestUtils; |
|||
import com.mdp.login.entity.RequestTokenParams; |
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.integration.IntegrationParamsContext; |
|||
import com.mdp.login.integration.authenticator.IntegrationAuthenticator; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.login.service.UserDetailsServiceImpl; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.dict.GrantType; |
|||
import com.mdp.safe.client.dict.UserType; |
|||
import com.mdp.safe.client.entity.CommonUserDetails; |
|||
import com.mdp.safe.client.entity.SafeAuthority; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.jwt.JwtLocalLoginService; |
|||
import com.mdp.safe.client.jwt.JwtTool; |
|||
import com.mdp.safe.client.pwd.SafePasswordEncoder; |
|||
import com.mdp.safe.client.service.MdpLoginQueueService; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import nl.bitwalker.useragentutils.Browser; |
|||
import nl.bitwalker.useragentutils.OperatingSystem; |
|||
import nl.bitwalker.useragentutils.UserAgent; |
|||
import nl.bitwalker.useragentutils.Version; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.slf4j.MDC; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.security.core.GrantedAuthority; |
|||
import org.springframework.security.crypto.password.PasswordEncoder; |
|||
import org.springframework.security.oauth2.core.OAuth2AccessToken; |
|||
import org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.reactive.function.client.WebClient; |
|||
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @author Joe Grandja |
|||
* @since 0.0.1 |
|||
*/ |
|||
|
|||
@Controller |
|||
public class TokenPasswordController { |
|||
|
|||
PasswordEncoder passwordEncoder=new SafePasswordEncoder(); |
|||
|
|||
@Autowired |
|||
JwtLocalLoginService jwtLoginService; |
|||
|
|||
|
|||
WebClient webClient=WebClient.create(); |
|||
|
|||
|
|||
Logger logger= LoggerFactory.getLogger(TokenPasswordController.class); |
|||
|
|||
|
|||
@Autowired |
|||
MdpLoginQueueService loginRecordService; |
|||
|
|||
@Autowired |
|||
Sequence sequenceService; |
|||
|
|||
@Autowired |
|||
SysUserQueryService userQueryService; |
|||
|
|||
|
|||
private Collection<IntegrationAuthenticator> authenticators; |
|||
@Autowired |
|||
UserDetailsServiceImpl userDetailsService; |
|||
|
|||
/** |
|||
* 密码登陆 |
|||
* 支持手机、邮箱、微信等多种方式登陆 |
|||
* |
|||
* @param model |
|||
* @return |
|||
*/ |
|||
@GetMapping(value = "/login/token", params = {"grantType=password"}) |
|||
public String clientPasswordGrantWeb(Model model, @RequestParam Map<String,Object> params, RedirectAttributes attributes ) { |
|||
RequestTokenParams requestTokenParams=BaseUtils.fromMap(params,RequestTokenParams.class); |
|||
Map<String,Object> result=this.clientPasswordGrant(params,requestTokenParams); |
|||
Tips tips= (Tips) result.get("tips"); |
|||
if(tips.isOk()){ |
|||
String redirectUri= (String) params.get("redirectUri"); |
|||
OAuth2AccessTokenResponse response= ((OAuth2AccessTokenResponse)(result.get("data"))); |
|||
if(StringUtils.hasText(redirectUri)){ |
|||
attributes.addAttribute("accessToken",response.getAccessToken().getTokenValue()); |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
attributes.addAttribute("userid",user.getUserid()); |
|||
attributes.addAttribute("username",user.getUsername()); |
|||
return "redirect:"+redirectUri; |
|||
}else { |
|||
model.addAllAttributes(result); |
|||
return "index"; |
|||
} |
|||
}else{ |
|||
model.addAllAttributes(result); |
|||
return ""; |
|||
} |
|||
|
|||
} |
|||
/** |
|||
* 密码登陆 |
|||
* 支持手机、邮箱、微信等多种方式登陆 |
|||
* |
|||
* @param webparams |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/login/token", params = "grantType=password") |
|||
@ResponseBody public Result clientPasswordGrant(@RequestParam Map<String,Object> webparams , @RequestBody RequestTokenParams paramsVo) { |
|||
try { |
|||
|
|||
String authType = paramsVo.getAuthType(); |
|||
if (!StringUtils.hasText(authType)) { |
|||
authType = "password"; |
|||
} |
|||
String userid = paramsVo.getUserid(); |
|||
String userloginid = paramsVo.getUserloginid(); |
|||
String password = paramsVo.getPassword(); |
|||
|
|||
String userType = (String) webparams.get("userType"); |
|||
|
|||
//设置集成登录信息 |
|||
IntegrationParams integrationParams = new IntegrationParams(); |
|||
String grantType= (String) webparams.get("grantType"); |
|||
if(!StringUtils.hasText(grantType)){ |
|||
grantType= GrantType.password.name(); |
|||
} |
|||
if(!StringUtils.hasText(authType) && GrantType.password.name().equals(grantType) ){ |
|||
authType= AuthType.password.name(); |
|||
} |
|||
|
|||
if (!StringUtils.hasText(userType)) { |
|||
userType= UserType.staff.name(); |
|||
} |
|||
|
|||
integrationParams.setUserloginid(userloginid); |
|||
integrationParams.setAuthType(authType); |
|||
integrationParams.setUserType(userType); |
|||
|
|||
Map<String,Object> data=webparams; |
|||
data.put("userloginid",userloginid); |
|||
data.put("userType",userType); |
|||
data.put("authType",authType); |
|||
data.put("grantType",grantType); |
|||
data.put("password",password); |
|||
integrationParams.setDatas(data); |
|||
IntegrationParamsContext.set(integrationParams); |
|||
IntegrationAuthenticator authenticator = findIntegrationAuthenticator(integrationParams); |
|||
if(authenticator==null){ |
|||
return Result.error("login-method-not-support","不支持当前登录方式"); |
|||
}else{ |
|||
try{ |
|||
//预处理 |
|||
authenticator.prepare(integrationParams); |
|||
CommonUserDetails userDetails=(CommonUserDetails)userDetailsService.loadUserByUsername(userloginid); |
|||
User user=userDetails.getUser(); |
|||
Map<String, Object> claims = new HashMap<>(); |
|||
claims.put("userInfo", userDetails.getUser().toSimpleString()); |
|||
claims.put("roles", SafeAuthority.toRolesString((Collection<GrantedAuthority>) userDetails.getAuthorities())); |
|||
String jwtToken = JwtTool.createJWT(user.getUserid(), claims, 7 * 24 * 60 * 60 * 1000); |
|||
OAuth2AccessTokenResponse response = OAuth2AccessTokenResponse.withToken(jwtToken) |
|||
.tokenType(OAuth2AccessToken.TokenType.BEARER).build(); |
|||
jwtLoginService.doLocalLoginUseJwtToken(response.getAccessToken().getTokenValue()); |
|||
pushLoginRecord(paramsVo, user); |
|||
//后置处理 |
|||
authenticator.complete(integrationParams); |
|||
return Result.ok().setData(response).put("userInfo", user).put("roles", userDetails.getAuthorities()); |
|||
|
|||
}finally { |
|||
IntegrationParamsContext.clear(); |
|||
} |
|||
} |
|||
|
|||
|
|||
}catch (BizException e){ |
|||
logger.error("登录错误",e); |
|||
pushLoginErrRecord(paramsVo,e.getMessage()); |
|||
return Result.error(e); |
|||
}catch (Exception e1){ |
|||
logger.error("获取令牌错误",e1); |
|||
pushLoginErrRecord(paramsVo,"获取令牌错误"); |
|||
return Result.error("get-ticket-error","获取令牌错误").put("moreMsg",e1.getMessage()); |
|||
} |
|||
|
|||
} |
|||
|
|||
private void pushLoginErrRecord(RequestTokenParams paramsVo,String errMsg){ |
|||
try { |
|||
HttpServletRequest request=RequestUtils.getRequest(); |
|||
String loginIp=RequestUtils.getIpAddr(request); |
|||
Map<String,Object> loginRecord=new HashMap<>(); |
|||
String userid=paramsVo.getUserloginid(); |
|||
loginRecord.put("reqNo", MDC.get("gloNo")); |
|||
loginRecord.put("loginIp",loginIp); |
|||
loginRecord.put("id",this.sequenceService.getTablePK("login_record","id")); |
|||
loginRecord.put("loginTime",new Date()); |
|||
|
|||
|
|||
|
|||
//获取浏览器信息 |
|||
String ua = request.getHeader("User-Agent"); |
|||
//转成UserAgent对象 |
|||
UserAgent userAgent = UserAgent.parseUserAgentString(ua); |
|||
//获取浏览器信息 |
|||
Browser browser = userAgent.getBrowser(); |
|||
//获取系统信息 |
|||
OperatingSystem os = userAgent.getOperatingSystem(); |
|||
//系统名称 |
|||
String system = os.getName(); |
|||
//浏览器名称 |
|||
|
|||
Version borderVersion= browser.getVersion(ua); |
|||
if(borderVersion!=null){ |
|||
loginRecord.put("borderVersion",borderVersion.getVersion()); |
|||
} |
|||
String browserName = browser.getName(); |
|||
loginRecord.put("userAgent",ua); |
|||
loginRecord.put("userid",paramsVo.getUserloginid()); |
|||
if("sms".equals(paramsVo.getAuthType())){ |
|||
loginRecord.put("phoneno",paramsVo.getUserloginid()); |
|||
} |
|||
loginRecord.put("os",os.getName()); |
|||
loginRecord.put("borderName",browserName); |
|||
loginRecord.put("browerGroup",browser.getGroup().getName()); |
|||
loginRecord.put("renderingEngine",browser.getRenderingEngine().name()); |
|||
loginRecord.put("deviceManufacturer",os.getManufacturer().name()); |
|||
loginRecord.put("deviceType",os.getDeviceType().name()); |
|||
loginRecord.put("loginBranchId", paramsVo.getBranchId()); |
|||
loginRecord.put("loginStatus","0"); |
|||
loginRecord.put("loginMsg",errMsg); |
|||
loginRecord.put("authType",paramsVo.getAuthType()); |
|||
loginRecord.put("grantType",paramsVo.getGrantType()); |
|||
loginRecordService.pushLoginRecord(loginRecord); |
|||
|
|||
|
|||
}catch (Exception e){ |
|||
|
|||
} |
|||
} |
|||
|
|||
private void pushLoginRecord(RequestTokenParams paramsVo,User user) { |
|||
try { |
|||
HttpServletRequest request=RequestUtils.getRequest(); |
|||
String loginIp=RequestUtils.getIpAddr(request); |
|||
Map<String,Object> loginRecord=new HashMap<>(); |
|||
loginRecord.putAll(user); |
|||
loginRecord.put("reqNo", MDC.get("gloNo")); |
|||
loginRecord.put("loginIp",loginIp); |
|||
loginRecord.put("id",this.sequenceService.getTablePK("login_record","id")); |
|||
loginRecord.put("loginTime",new Date()); |
|||
|
|||
|
|||
|
|||
//获取浏览器信息 |
|||
String ua = request.getHeader("User-Agent"); |
|||
//转成UserAgent对象 |
|||
UserAgent userAgent = UserAgent.parseUserAgentString(ua); |
|||
//获取浏览器信息 |
|||
Browser browser = userAgent.getBrowser(); |
|||
//获取系统信息 |
|||
OperatingSystem os = userAgent.getOperatingSystem(); |
|||
//系统名称 |
|||
String system = os.getName(); |
|||
//浏览器名称 |
|||
|
|||
Version borderVersion= browser.getVersion(ua); |
|||
if(borderVersion!=null){ |
|||
loginRecord.put("borderVersion",borderVersion.getVersion()); |
|||
} |
|||
String browserName = browser.getName(); |
|||
loginRecord.put("userAgent",ua); |
|||
loginRecord.put("os",os.getName()); |
|||
loginRecord.put("borderName",browserName); |
|||
loginRecord.put("browerGroup",browser.getGroup().getName()); |
|||
loginRecord.put("renderingEngine",browser.getRenderingEngine().name()); |
|||
loginRecord.put("deviceManufacturer",os.getManufacturer().name()); |
|||
loginRecord.put("deviceType",os.getDeviceType().name()); |
|||
loginRecord.put("loginBranchId",user.getBranchId()); |
|||
loginRecord.put("memType",user.getMemType()); |
|||
loginRecord.put("loginShopId",user.getShopId()); |
|||
loginRecord.put("loginLocationId",user.getLocationId()); |
|||
loginRecord.put("loginStatus","1"); |
|||
loginRecord.put("loginMsg","成功"); |
|||
loginRecord.put("authType",paramsVo.getAuthType()); |
|||
loginRecord.put("grantType",paramsVo.getGrantType()); |
|||
loginRecordService.pushLoginRecord(loginRecord); |
|||
|
|||
|
|||
}catch (Exception e){ |
|||
|
|||
} |
|||
} |
|||
|
|||
public IntegrationAuthenticator findIntegrationAuthenticator(IntegrationParams integrationParams){ |
|||
this.init(); |
|||
if (this.authenticators != null) { |
|||
for (IntegrationAuthenticator authenticator : authenticators) { |
|||
if (authenticator.supportAuthType(integrationParams)) { |
|||
return authenticator; |
|||
} |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
public void init(){ |
|||
if(this.authenticators==null){ |
|||
Map<String, IntegrationAuthenticator> beans= SpringContextUtils.getBeansOfType(IntegrationAuthenticator.class); |
|||
System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxffffffffffffffffffff"); |
|||
|
|||
if(beans!=null){ |
|||
this.authenticators=beans.values(); |
|||
}else { |
|||
this.authenticators=new HashSet<>(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,230 @@ |
|||
/* |
|||
* Copyright 2020 the original author or authors. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* https://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package com.mdp.login.ctrl; |
|||
|
|||
|
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.login.entity.RequestUserInfoParams; |
|||
import com.mdp.login.entity.Scope; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.plat.client.PlatClientService; |
|||
import com.mdp.plat.client.entity.PlatformVo; |
|||
import com.mdp.qx.HasRole; |
|||
import com.mdp.safe.client.cache.ModuleBranchRedisCacheService; |
|||
import com.mdp.safe.client.entity.Menu; |
|||
import com.mdp.safe.client.entity.ModuleBranch; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.service.UserResourceQueryService; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @author Joe Grandja |
|||
* @since 0.0.1 |
|||
*/ |
|||
|
|||
@RestController |
|||
public class UserInfoController { |
|||
@Autowired |
|||
SysUserQueryService userQueryService; |
|||
|
|||
@Autowired |
|||
UserResourceQueryService userResourceQueryService; |
|||
|
|||
|
|||
@Autowired |
|||
PlatClientService platClientService; |
|||
|
|||
@Autowired |
|||
ModuleBranchRedisCacheService moduleBranchRedisCacheService; |
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 密码登陆 |
|||
* 支持手机、邮箱、微信等多种方式登陆 |
|||
* |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/info") |
|||
@ResponseBody |
|||
public Result userInfo(@RequestBody RequestUserInfoParams params) { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
Map<String,Object> extsParams=new HashMap<>(); |
|||
if(LoginUtils.isGuest()){ |
|||
return Result.error("user-not-login","未登录用户"); |
|||
} |
|||
if(!StringUtils.hasText(user.getUserType())){ |
|||
user.setUserType("staff"); |
|||
extsParams.put("userType",user.getUserType()); |
|||
}else{ |
|||
extsParams.put("userType",user.getUserType()); |
|||
} |
|||
user=this.getUserBaseInfo(user); |
|||
Result result=Result.ok().put(Scope.userInfo.name(),user).put(Scope.roles.name(),LoginUtils.getAuthorities()); |
|||
String[] roleids=LoginUtils.getMyRoleids(); |
|||
if(params==null || params.getScopes()==null){ |
|||
return result; |
|||
}else { |
|||
if(params.getScopes().contains(Scope.menus.name())){ |
|||
if(!LoginUtils.isSuperAdmin()){ |
|||
Map<String, Menu> menusMap= userResourceQueryService.loadRoleMenusByRoleids(roleids); |
|||
Map<String,ModuleBranch> moduleBranchMap=new HashMap<>(); |
|||
Map<String,Menu> hasQxMenusMap=new HashMap<>(); |
|||
for (Menu menu : menusMap.values()) { |
|||
if("0".equals(menu.getSupVers())){ |
|||
hasQxMenusMap.put(menu.getId(),menu); |
|||
}else { |
|||
String moduleId=menu.getModuleId(); |
|||
if( !StringUtils.hasText(menu.getSupVers()) || "0".equals(menu.getSupVers())){ |
|||
hasQxMenusMap.put(menu.getId(),menu); |
|||
}else { |
|||
ModuleBranch moduleBranch=moduleBranchMap.get(moduleId); |
|||
if(moduleBranch==null && !moduleBranchMap.containsKey(moduleId)){ |
|||
moduleBranch = moduleBranchRedisCacheService.getModuleBranch(user.getBranchId(),moduleId); |
|||
moduleBranchMap.put(moduleId,moduleBranch); |
|||
} |
|||
if(moduleBranch!=null && "1".equals(moduleBranch.getStatus())){ |
|||
if(StringUtils.hasText(moduleBranch.getVer()) && menu.getSupVers().contains(moduleBranch.getVer())){ |
|||
hasQxMenusMap.put(menu.getId(),menu); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
result.put("menus",hasQxMenusMap.values()); |
|||
}else{ |
|||
result.put("menus",null);//超级管理员前端判断全部显示 |
|||
} |
|||
|
|||
} |
|||
if(params.getScopes().contains(Scope.qxs.name())){ |
|||
//Map<String, Qx> qxsMap= userResourceQueryService.loadRoleQxsByRoleids(roleids); |
|||
//result.put("qxs",qxsMap.values()); |
|||
} |
|||
if(params.getScopes().contains(Scope.posts.name())){ |
|||
result.put("posts",userResourceQueryService.loadPostsByUserid(user.getUserid())); |
|||
} |
|||
if(params.getScopes().contains(Scope.depts.name())){ |
|||
//List<Dept> depts=userResourceQueryService.loadDeptsByDeptids(user.getDeptids().toArray(new String[0])); |
|||
//result.put("depts",depts); |
|||
} |
|||
if(params.getScopes().contains(Scope.branchs.name())){ |
|||
//List<Branch> branchs=userResourceQueryService.loadBranchsByBranchIds( user.getBranchIds().toArray(new String[0])); |
|||
//result.put("branchs",branchs); |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* 查询用户的基本信息 |
|||
* 支持手机、邮箱、微信等多种方式登陆 |
|||
* |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value = "/user/baseinfo",method = RequestMethod.GET) |
|||
@HasRole |
|||
@ResponseBody |
|||
public Result baseinfo() { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
user=getUserBaseInfo(user); |
|||
return Result.ok().setData(user); |
|||
} |
|||
/** |
|||
* 根据登录账户查询用户列表,一般在登录前查询一次,如果有多个账户,由用户选择一个登录 |
|||
* 支持手机、邮箱、微信等多种方式登陆 |
|||
* |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value = "/user/queryByUserloginid",method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public Result queryByUserloginid(@RequestParam Map<String,Object> user) { |
|||
String userloginid= (String) user.get("userloginid"); |
|||
if(!StringUtils.hasText(userloginid)){ |
|||
return Result.error("userloginid-0","请上送登录账户"); |
|||
} |
|||
String idType= (String) user.get("idType"); |
|||
if(!StringUtils.hasText(idType)){ |
|||
idType="all"; |
|||
} |
|||
List<User> users=this.userQueryService.queryByUserloginid(userloginid,idType,user); |
|||
List<User> usersDb=new ArrayList<>(); |
|||
if(users!=null && users.size()>0){ |
|||
for (User userDb : users) {//去掉敏感数据 |
|||
userDb.setPassword(null); |
|||
userDb.setEmail(null); |
|||
userDb.setPhoneno(null); |
|||
userDb.setTpaOpenid(null); |
|||
userDb.put("address",null); |
|||
userDb.put("birthday",null); |
|||
userDb.put("sex",null); |
|||
userDb.put("unionid",null); |
|||
usersDb.add(userDb); |
|||
} |
|||
} |
|||
return Result.ok().setData(usersDb); |
|||
} |
|||
|
|||
/** |
|||
* 根据登录账户查询用户列表,一般在登录前查询一次,如果有多个账户,由用户选择一个登录 |
|||
* 支持手机、邮箱、微信等多种方式登陆 |
|||
* |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value = "/user/queryMyUsers",method = RequestMethod.GET) |
|||
@HasRole |
|||
@ResponseBody |
|||
public Result queryMyUsers() { |
|||
User cuser=LoginUtils.getCurrentUserInfo(); |
|||
if(LoginUtils.isGuest()){ |
|||
return Result.error ("user-0","未登录用户不允许查询"); |
|||
} |
|||
List<User> users=this.userQueryService.queryMyUsers(cuser); |
|||
List<User> usersDb=new ArrayList<>(); |
|||
if(users!=null && users.size()>0){ |
|||
for (User userDb : users) {//去掉敏感数据 |
|||
userDb.setPassword(null); |
|||
userDb.setEmail(null); |
|||
userDb.setPhoneno(null); |
|||
userDb.setTpaOpenid(null); |
|||
userDb.put("address",null); |
|||
userDb.put("birthday",null); |
|||
userDb.put("sex",null); |
|||
userDb.put("unionid",null); |
|||
usersDb.add(userDb); |
|||
} |
|||
} |
|||
return Result.ok().setData(usersDb); |
|||
} |
|||
|
|||
User getUserBaseInfo(User user){ |
|||
User userDb=userQueryService.getUserByUserid(user.getUserid(), Collections.emptyMap()); |
|||
user.putAll(userDb); |
|||
return user; |
|||
} |
|||
|
|||
public String getPlatformBranchId(){ |
|||
PlatformVo platformVo=platClientService.getPlatformVo(); |
|||
return platformVo.getBranchId(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,890 @@ |
|||
/* |
|||
* Copyright 2020 the original author or authors. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* https://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package com.mdp.login.ctrl; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.mdp.core.api.Sequence; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.service.SequenceService; |
|||
import com.mdp.core.utils.BaseUtils; |
|||
import com.mdp.core.utils.RequestUtils; |
|||
import com.mdp.email.client.service.EmailService; |
|||
import com.mdp.login.client.SysClient; |
|||
import com.mdp.login.entity.RequestTokenParams; |
|||
import com.mdp.login.entity.ValidCode; |
|||
import com.mdp.login.entity.ValidCodeVo; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.login.service.UserOperService; |
|||
import com.mdp.login.service.ValidCodeService; |
|||
import com.mdp.login.util.ValidUtils; |
|||
import com.mdp.msg.client.PushNotifyMsgService; |
|||
import com.mdp.qx.HasRole; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.dict.TpaType; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.service.TpaUserRegisterService; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.sms.client.api.SmsCodeService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.security.crypto.password.PasswordEncoder; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @author Joe Grandja |
|||
* @since 0.0.1 |
|||
*/ |
|||
|
|||
@Controller |
|||
public class UserOperController { |
|||
|
|||
@Autowired |
|||
UserOperService userOperService; |
|||
|
|||
@Autowired |
|||
SmsCodeService smsCodeService; |
|||
|
|||
@Autowired |
|||
SysUserQueryService userQueryService; |
|||
|
|||
|
|||
@Autowired |
|||
PasswordEncoder passwordEncoder; |
|||
|
|||
@Autowired(required = false) |
|||
Sequence sequenceService; |
|||
|
|||
@Autowired |
|||
TokenPasswordController tokenPasswordController; |
|||
|
|||
|
|||
@Autowired(required = false) |
|||
List<TpaUserRegisterService> tpaUserRegisterServiceList; |
|||
@Autowired |
|||
EmailService emailService; |
|||
@Autowired |
|||
ValidCodeService validCodeService; |
|||
|
|||
@Autowired |
|||
SysClient sysClient; |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
PushNotifyMsgService pushNotifyMsgService; |
|||
|
|||
|
|||
@Value("${spring.mail.username:}") |
|||
String fromEmail=""; |
|||
/** |
|||
* userType:cust-会员,staff.后台管理员,默认后台管理员 |
|||
* validType:0-不验证,1-邮箱,2-手机号码,3-邮箱、手机号码 |
|||
* codeScene验证场景0-重置密码,1-注册验证,2-更换常用邮箱,3-更换备用邮箱 |
|||
* 用户注册,适用于前端客户手动注册,要求上送短信验证码,手机号码, |
|||
* userid/displayUserid/username/phoneno/password/email必须 |
|||
* |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/register") |
|||
@ResponseBody |
|||
public Result register(@RequestBody User params) { |
|||
Tips tips = new Tips("成功"); |
|||
/** |
|||
* 关键要素 账号、手机号码、密码、邮箱不能为空 |
|||
*/ |
|||
|
|||
String displayUserid=params.getDisplayUserid(); |
|||
String phoneno=params.getPhoneno(); |
|||
String password=params.getPassword(); |
|||
String email=params.getEmail(); |
|||
String codeEmail=email; |
|||
String username=params.getUsername(); |
|||
String userType=params.getUserType(); |
|||
String memType=params.getMemType(); |
|||
String branchId= (String) params.get("branchId"); |
|||
String branchName= (String) params.get("branchName"); |
|||
String profeId= (String) params.get("profeId"); |
|||
String profeName= (String) params.get("profeName"); |
|||
String userid=""; |
|||
if(!StringUtils.hasText(memType)){ |
|||
memType="0"; |
|||
} |
|||
if(sequenceService==null){ |
|||
sequenceService=new SequenceService(); |
|||
} |
|||
userid=sequenceService.getUserid(); |
|||
if(!StringUtils.hasText(branchId)){ |
|||
branchId=userid; |
|||
} |
|||
if(!StringUtils.hasText(branchName)){ |
|||
branchName=username; |
|||
} |
|||
String validType= (String) params.get("validType"); |
|||
if(!StringUtils.hasText(validType)){ |
|||
if(StringUtils.hasText(userType)){ |
|||
if(userType.equals("cust")){ |
|||
validType="1"; |
|||
} |
|||
}else{ |
|||
validType="2"; |
|||
} |
|||
} |
|||
if(StringUtils.hasText(email)){ |
|||
tips= ValidUtils.validEmail(email); |
|||
} |
|||
|
|||
if(!StringUtils.hasText(userType)){ |
|||
userType="2"; |
|||
params.setUserType(userType); |
|||
} |
|||
if(!StringUtils.hasText(displayUserid)){ |
|||
tips.setErrMsg("userid-not-allow-null","用户编号不能为空"); |
|||
} |
|||
|
|||
if("2".equals(validType)||"3".equals(validType)) { |
|||
if (!StringUtils.hasText(phoneno)) { |
|||
tips.setErrMsg("phoneno-not-allow-null","手机号码不能为空"); |
|||
} |
|||
} |
|||
|
|||
if("1".equals(validType)||"3".equals(validType)){ |
|||
if(!StringUtils.hasText(email)){ |
|||
tips.setErrMsg("email-not-allow-null","邮箱不能为空"); |
|||
} |
|||
} |
|||
if(!StringUtils.hasText(password)){ |
|||
tips.setErrMsg("password-not-allow-null","密码不能为空"); |
|||
}else if(password.length()<=10){ |
|||
tips.setErrMsg("password-not-encode","密码必须为加密后传输"); |
|||
} |
|||
if(!StringUtils.hasText(username)){ |
|||
username=displayUserid; |
|||
params.setUsername(username); |
|||
//tips.setErrMsg("用户名称不能为空"); |
|||
} |
|||
params.put("memType",memType); |
|||
if(tips.isOk()){ |
|||
//User userDb=userQueryService.getUserByUserid(userid,params); |
|||
List<User> usersDb=userQueryService.queryByUserloginid(displayUserid,"displayUserid",Collections.emptyMap()); |
|||
if( usersDb != null && usersDb.size()>0 ){ |
|||
tips.setErrMsg("userid-had-exists","账户已存在"); |
|||
} |
|||
} |
|||
if(tips.isOk()){ |
|||
if(StringUtils.hasText(phoneno)){ |
|||
List<User> usersDb=userQueryService.queryByUserloginid(phoneno,"phoneno",params); |
|||
if( usersDb != null && usersDb.size()>0 ){ |
|||
tips.setErrMsg("phoneno-had-exists","手机号码已存在"); |
|||
} |
|||
if(tips.isOk() && (validType.equals("2")||validType.equals("3"))){ |
|||
String smsCode= (String) params.get("smsCode"); |
|||
if(StringUtils.hasText(smsCode)){ |
|||
tips=smsCodeService.validateSmsCodeUseCache(phoneno,smsCode,"register"); |
|||
}else { |
|||
tips.setErrMsg("valid-code-not-allow-null","短信验证码不能为空"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
if(tips.isOk()){ |
|||
if(StringUtils.hasText(email)){ |
|||
List<User> usersDb=userQueryService.queryByUserloginid(email,"email",params); |
|||
|
|||
if( usersDb != null && usersDb.size()>0){ |
|||
tips.setErrMsg("email-had-exists","邮箱号码已存在"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
if(tips.isOk()){ |
|||
|
|||
|
|||
if("cust".equals(userType)){ |
|||
if(!validType.equals("0")){ |
|||
params.put("locked","1");//先锁定,邮箱验证通过后再解锁 |
|||
params.put("lockType","0"); |
|||
params.put("lockRemark",""); |
|||
}else{ |
|||
params.put("locked","0"); |
|||
} |
|||
|
|||
} |
|||
params.put("userType",userType); |
|||
password=passwordEncoder.encode(password); |
|||
params.put("password",password); |
|||
params.put("ctime",new Date()); |
|||
params.put("memType",memType); |
|||
params.put("branchName",branchName); |
|||
params.put("branchId",branchId); |
|||
params.put("profeId",profeId); |
|||
params.put("profeName",profeName); |
|||
params.put("gradeId","mg_001"); |
|||
params.put("gradeName","一星学徒"); |
|||
params.put("ilvlId","1"); |
|||
params.put("ilvlName","普通"); |
|||
params.put("guardId","0"); |
|||
params.put("open","1"); |
|||
params.put("userid",userid); |
|||
|
|||
User user=userOperService.userRegister(params); |
|||
if("1".equals(validType) && StringUtils.hasText(email)){ |
|||
|
|||
String valiCode=createValiCode();//生成一个随机码 |
|||
HttpServletRequest request= RequestUtils.getRequest(); |
|||
String callbackUri = (String)params.get("callbackUri"); |
|||
if(!StringUtils.hasText(callbackUri)){ |
|||
callbackUri = request.getScheme()+"://"+ request.getServerName()+":"+request.getServerPort(); |
|||
String requestUri=request.getRequestURI(); |
|||
requestUri=requestUri.substring(0,requestUri.indexOf("register")); |
|||
callbackUri=callbackUri+requestUri+"validEmailCode"; |
|||
String queryString=request.getQueryString(); |
|||
if(StringUtils.hasText(queryString)){ |
|||
callbackUri=callbackUri+"?"+queryString; |
|||
} |
|||
} |
|||
if(callbackUri.indexOf("?")>=0){ |
|||
callbackUri=callbackUri+"&valiCode="+valiCode+"&codeEmail="+codeEmail; |
|||
}else{ |
|||
callbackUri=callbackUri+"?valiCode="+valiCode+"&codeEmail="+codeEmail; |
|||
} |
|||
String text="尊敬的会员您好,请点击以下链接进行验证邮箱<a href='"+callbackUri+"'>去验证邮箱</a>"; |
|||
emailService.sendSimpleMail("验证邮箱",fromEmail,email,text); |
|||
ValidCodeVo validCodeVo=new ValidCodeVo(); |
|||
validCodeVo.setUserid(user.getUserid()); |
|||
validCodeVo.setValiCode(valiCode); |
|||
validCodeVo.setCodeEmail(codeEmail); |
|||
validCodeVo.setCodeSendTime(new Date()); |
|||
validCodeVo.setCodeScene("1"); |
|||
validCodeVo.setUserType(userType); |
|||
validCodeVo.setId(validCodeService.createKey("id")); |
|||
validCodeService.insert(validCodeVo); |
|||
} |
|||
tips.setOkMsg("register-ok","注册成功"); |
|||
} |
|||
return Result.ok().setTips(LangTips.fromTips(tips)); |
|||
} |
|||
|
|||
@PostMapping(value = "/user/unregister") |
|||
@ResponseBody |
|||
public Result register() { |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
if(LoginUtils.isGuest()){ |
|||
return Result.error("guest-no-need-register","游客无须注销"); |
|||
} |
|||
this.userOperService.userUnregister(user); |
|||
pushNotifyMsgService.pushMsg("platform-branch-001","superAdmin","平台管理员",user.getUserid(),user.getUsername(),user.getUsername()+"账户注销申请,请审核",null); |
|||
return Result.ok(); |
|||
} |
|||
/** |
|||
* 绑定主账户 |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/bindMainAccount") |
|||
@HasRole |
|||
@ResponseBody |
|||
public Result bindMainAccount(@RequestBody User params) { |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
if(LoginUtils.isGuest()){ |
|||
return Result.error("no-login","未登录不允许绑定"); |
|||
} |
|||
if(!StringUtils.hasText(params.getUserid())){ |
|||
return Result.error("userid-0","请上送账户编号"); |
|||
} |
|||
if(!StringUtils.hasText(user.getUnionid())){ |
|||
return Result.error("unionid-0","当前账户没有主账户编号,不允许绑定"); |
|||
} |
|||
if(!"1".equals(user.getAtype())){ |
|||
return Result.error("atype-0","当前账户不是主账户,不允许绑定"); |
|||
} |
|||
params=this.userQueryService.getUserByUserid(params.getUserid(),Collections.emptyMap()); |
|||
if(params==null){ |
|||
return Result.error("user-0","账户不存在", (Object) "1"); |
|||
} |
|||
if("1".equals(params.getAtype())){ |
|||
return Result.error("atype-1","【%】属于主账户,不允许绑定其它主账户", (Object) params.getUsername()); |
|||
} |
|||
User userUpdate=new User(); |
|||
userUpdate.setUserid(params.getUserid()); |
|||
userUpdate.setUnionid(user.getUnionid()); |
|||
this.userOperService.userUpdate(userUpdate); |
|||
sysClient.pushUserCreditScore(params.getUserid(),"6",params.getUserid(),"微信认证"); |
|||
return Result.ok(); |
|||
} |
|||
/** |
|||
* 第三方登录注册用户,必须上送 tpaType/tpaOpenid |
|||
* 最好上送 phoneno/userid,如果没有上送userid将自动生成 |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/register/tpa") |
|||
@ResponseBody |
|||
public Result registerByTpa(@RequestBody User params) { |
|||
if(this.tpaUserRegisterServiceList==null || this.tpaUserRegisterServiceList.size()==0){ |
|||
return Result.error("tpa-register-not-foud","未找到第三方登录注册器"); |
|||
} |
|||
TpaType tpaType=TpaType.valueOf((String) params.get("tpaType")); |
|||
TpaUserRegisterService tpaUserRegisterService=null; |
|||
for (TpaUserRegisterService tpaService : this.tpaUserRegisterServiceList) { |
|||
if(tpaService.supportTpa(tpaType)){ |
|||
tpaUserRegisterService=tpaService; |
|||
break; |
|||
} |
|||
} |
|||
if(tpaUserRegisterService==null){ |
|||
return Result.error("tpa-register-not-foud","未找到第三方登录注册器"); |
|||
} |
|||
User user=tpaUserRegisterService.register(params); |
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 注册时,用户输入完整账号后,检查账号是否已存在 |
|||
* |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/check/displayUserid") |
|||
@ResponseBody |
|||
public Result checkDisplayUserid(@RequestBody User params) { |
|||
if(StringUtils.hasText(params.getDisplayUserid())){ |
|||
List<User> usersDb=userQueryService.queryByUserloginid(params.getDisplayUserid(),"displayUserid",Collections.emptyMap()); |
|||
if( usersDb != null && usersDb.size()>0 ){ |
|||
return Result.error("displayUserid-exists","账户已存在"); |
|||
} |
|||
}else{ |
|||
return Result.error("displayUserid-not-allow-empty","账户不能为空"); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
/** |
|||
* 注册时,用户输入完整账号后,检查账号是否已存在 |
|||
* |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/check/userid") |
|||
@ResponseBody |
|||
public Result checkUserid(@RequestBody User params) { |
|||
if(StringUtils.hasText(params.getUserid())){ |
|||
User userDb=userQueryService.getUserByUserid(params.getUserid(),Collections.emptyMap()); |
|||
if( userDb != null ){ |
|||
return Result.error("userid-exists","账户已存在"); |
|||
|
|||
} |
|||
}else{ |
|||
return Result.error("userid-not-allow-empty","账户不能为空"); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
/** |
|||
* 注册时,在用户输入完整手机号码后,自动发起检查手机号码是否已存在 |
|||
* 已存在则不允许注册,可以选则手机验证码登录、密码登录等 |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/check/phoneno") |
|||
@ResponseBody |
|||
public Result checkPhoneno(@RequestBody User params) { |
|||
String phoneno=params.getPhoneno(); |
|||
if(!StringUtils.hasText(phoneno)){ |
|||
return Result.error("phoneno-not-allow-empty","手机号码不能为空"); |
|||
} |
|||
|
|||
Tips tips= ValidUtils.validPhoneno(phoneno); |
|||
|
|||
if(tips.isOk()==false){ |
|||
return Result.error(LangTips.fromTips(tips)); |
|||
} |
|||
List<User> usersDb=userQueryService.queryByUserloginid(phoneno,"phoneno",params); |
|||
if( usersDb != null && usersDb.size()>0 ){ |
|||
return Result.error("phoneno-exists","手机号码已存在"); |
|||
|
|||
} |
|||
return Result.ok(); |
|||
} |
|||
/** |
|||
* 注册时,在用户输入完整手机号码后,自动发起检查手机号码是否已存在 |
|||
* 已存在则不允许注册,可以选则手机验证码登录、密码登录等 |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/check/email") |
|||
@ResponseBody |
|||
public Result checkEmail(@RequestBody User params) { |
|||
String email=params.getEmail(); |
|||
if(!StringUtils.hasText(email)){ |
|||
return Result.error("email-not-allow-empty","邮箱不能为空"); |
|||
} |
|||
|
|||
Tips tips=ValidUtils.validEmail(email); |
|||
if(tips.isOk()==false){ |
|||
return Result.error(LangTips.fromTips(tips)); |
|||
} |
|||
try { |
|||
List<User> usersDb = userQueryService.queryByUserloginid(email,"email", params); |
|||
if( usersDb != null && usersDb.size()>0 ){ |
|||
return Result.error("email-exists","邮箱已存在"); |
|||
} |
|||
}catch (Exception e){ |
|||
return Result.error(e); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
/** |
|||
* 修改用户的基本信息,不允许修改密码 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/update") |
|||
@ResponseBody |
|||
public Result userUpdate(@RequestBody User params) { |
|||
/** |
|||
* 手机号码、邮件账号、密码不允许修改 |
|||
*/ |
|||
|
|||
if(LoginUtils.isGuest()){ |
|||
return Result.error("user-not-login","未登录用户"); |
|||
} |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
params.put("locked",null); |
|||
params.put("orgId",null); |
|||
params.put("lockType",null); |
|||
params.put("memType",null); |
|||
params.put("displayUserid",null); |
|||
params.setUserid(LoginUtils.getCurrentUserInfo().getUserid()); |
|||
params.setPhoneno(null); |
|||
params.setEmail(null); |
|||
params.setPassword(null); |
|||
userOperService.userUpdate(params); |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 修改用户的手机号码 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/update/phoneno") |
|||
@ResponseBody |
|||
public Result userUpdatePhoneno(@RequestBody User params) { |
|||
/** |
|||
* 手机号码、邮件账号、密码不允许修改 |
|||
*/ |
|||
|
|||
if(LoginUtils.isGuest()){ |
|||
return Result.error("user-not-login","未登录用户"); |
|||
} |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
params.setUserid(user.getUserid()); |
|||
User userdb=this.userQueryService.getUserByUserid(user.getUserid(),Collections.emptyMap()); |
|||
if(userdb==null){ |
|||
return Result.error("user-0","用户不存在"); |
|||
} |
|||
if(StringUtils.hasText(userdb.getPhoneno()) && userdb.getPhoneno().equals(params.getPhoneno())){ |
|||
return Result.error("phoneno-same","手机号已经绑定当前账号,无须重复绑定"); |
|||
} |
|||
Tips tips2=smsCodeService.validateSmsCodeUseCache(params.getPhoneno(), (String) params.get("smsCode"),"userPhoneno"); |
|||
if(tips2.isOk()==false){ |
|||
return Result.error(LangTips.fromTips(tips2)); |
|||
} |
|||
if("1".equals(userdb.getAtype())){ |
|||
|
|||
} |
|||
List<User> users=this.userQueryService.queryMyUsers(userdb); |
|||
userdb.setPhoneno(params.getPhoneno()); |
|||
userdb.setUserType(user.getUserType()); |
|||
String validLvls=userdb.getValidLvls(); |
|||
if(!StringUtils.hasText(validLvls)){ |
|||
validLvls="0,1,0,0,0"; |
|||
}else{ |
|||
String[] validLvlss=validLvls.split(","); |
|||
validLvlss[1]="1"; |
|||
validLvls= Arrays.stream(validLvlss).collect(Collectors.joining(",")); |
|||
} |
|||
userdb.setValidLvls(validLvls); |
|||
userOperService.userUpdatePhoneno(userdb); |
|||
sysClient.pushUserCreditScore(userdb.getUserid(),"4",userdb.getPhoneno(),"手机号验证"); |
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 密码方式重置密码 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/password/reset",params = {"type=password"}) |
|||
@ResponseBody |
|||
public Result updatePassword(@RequestBody Map<String,Object> params) { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
String userid=user.getUserid(); |
|||
String oldPassword= (String) params.get("oldPassword"); |
|||
String newPassword= (String) params.get("newPassword"); |
|||
|
|||
if(!StringUtils.hasText(oldPassword)){ |
|||
return Result.error("old-password-not-allow-empty","旧密码不能为空"); |
|||
} |
|||
if(!StringUtils.hasText(userid)){ |
|||
return Result.error("user-not-login","用户未登录"); |
|||
} |
|||
if(!StringUtils.hasText(newPassword)){ |
|||
return Result.error("new-password-not-allow-empty","新密码不能为空"); |
|||
} |
|||
params.put("userType",user.getUserType()); |
|||
params.put("memType",user.getMemType()); |
|||
params.put("userid",userid); |
|||
if(oldPassword.equals(newPassword)){ |
|||
return Result.error("new-and-old-not-allow-same","新旧密码不能一样"); |
|||
} |
|||
User userDb=this.userQueryService.getUserByUserid(userid,Collections.emptyMap()); |
|||
if(userDb==null){ |
|||
return Result.error("userid-not-exists","账户不存在"); |
|||
}else { |
|||
if(!passwordEncoder.matches(oldPassword,userDb.getPassword())){ |
|||
return Result.error("old-password-not-match","旧密码不正确"); |
|||
}; |
|||
} |
|||
userOperService.updatePassword(userid,oldPassword,passwordEncoder.encode(newPassword),params); |
|||
|
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 短信验证码方式重置密码 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/password/reset",params = {"type=sms"}) |
|||
@ResponseBody |
|||
public Result resetPasswordByPhoneno(@RequestBody Map<String,Object> params) { |
|||
|
|||
String userid= (String) params.get("userid"); |
|||
String phoneno= (String) params.get("phoneno"); |
|||
String smsCode= (String) params.get("smsCode"); |
|||
String newPassword= (String) params.get("newPassword"); |
|||
|
|||
if(!StringUtils.hasText(phoneno)){ |
|||
return Result.error("phoneno-not-allow-empty","手机号码不能为空"); |
|||
} |
|||
Result.assertIsFalse(ValidUtils.validPhoneno(phoneno)); |
|||
if(!StringUtils.hasText(smsCode)){ |
|||
return Result.error("valid-code-not-allow-empty","短信验证码不能为空"); |
|||
} |
|||
if(!StringUtils.hasText(newPassword)){ |
|||
return Result.error("new-password-not-allow-empty","新密码不能为空"); |
|||
} |
|||
Result.assertIsFalse(smsCodeService.validateSmsCodeUseCache(phoneno,smsCode,"changePassword")); |
|||
String dbUserid=userid; |
|||
List<User> users=this.userQueryService.queryByUserloginid(phoneno,"phoneno",Collections.emptyMap()); |
|||
if(users==null||users.size()==0){ |
|||
return Result.error("phoneno-err","该手机注册的账户不存在"); |
|||
} |
|||
for (User user : users) { |
|||
userOperService.resetPasswordByPhoneno(user.getUserid(),phoneno,smsCode,passwordEncoder.encode(newPassword),params); |
|||
} |
|||
smsCodeService.clearSmsCode(phoneno,smsCode,"changePassword"); |
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 邮件方式重置密码,提交密码保存 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/password/reset",params = {"type=email"}) |
|||
@ResponseBody |
|||
public Result resetPasswordByEmail(@RequestBody Map<String,Object> params) { |
|||
String userid= (String) params.get("userid"); |
|||
String valiCode= (String) params.get("valiCode"); |
|||
String newPassword= (String) params.get("newPassword"); |
|||
String userType= (String) params.get("userType"); |
|||
if(!StringUtils.hasText(userType)){ |
|||
userType="staff"; |
|||
params.put("userType",userType); |
|||
} |
|||
|
|||
if(!StringUtils.hasText(valiCode)){ |
|||
return Result.error("email-valid-code-not-allow-empty","邮件验证码不能为空"); |
|||
|
|||
} |
|||
if(!StringUtils.hasText(newPassword)){ |
|||
return Result.error("new-password-not-allow-empty","新密码不能为空"); |
|||
} |
|||
List<User> users = this.userQueryService.getUserByEmailCode(userid,"",valiCode,userType); |
|||
if(users!=null && users.size()>0){ |
|||
for (User user : users) { |
|||
userOperService.resetPasswordByEmail(user.getUserid(),"",valiCode,passwordEncoder.encode(newPassword),params); |
|||
} |
|||
}else{ |
|||
Result.error("valid-code-not-match","验证码不正确"); |
|||
} |
|||
|
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 发送重置密码的邮件到用户的邮箱 |
|||
* 验证场景0-重置密码,1-注册验证,2-更换常用邮箱第一步验证旧邮箱,,3-更换常用邮箱第二步验证新邮箱,5-更换备用邮箱验证新邮箱, |
|||
* post |
|||
* @param params {email:'邮箱号码',callbackUri:'回调地址',userType:'用户类型 cust|staff',} |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/user/sendEmail") |
|||
@ResponseBody |
|||
public Result sendEmail(@RequestBody Map<String,Object> params) { |
|||
String codeEmail= (String) params.get("codeEmail"); |
|||
|
|||
String codeScene= (String) params.get("codeScene"); |
|||
String userType= (String) params.get("userType"); |
|||
String callbackUri= (String) params.get("callbackUri"); |
|||
if(!StringUtils.hasText(userType)){ |
|||
return Result.error("user-type-not-allow-empty","请上送客户类型参数userType"); |
|||
} |
|||
if(!StringUtils.hasText(codeScene)){ |
|||
return Result.error("valid-code-not-allow-empty","请上送验证码场景"); |
|||
} |
|||
if(!StringUtils.hasText(callbackUri)){ |
|||
return Result.error("callback-uri-not-allow-empty","请上送回调请求地址callbackUri"); |
|||
} |
|||
if(StringUtils.hasText(codeEmail)) { |
|||
Tips tips2 = ValidUtils.validEmail(codeEmail); |
|||
Result.assertIsFalse(tips2); |
|||
} |
|||
|
|||
if(sequenceService==null){ |
|||
sequenceService=new SequenceService(); |
|||
} |
|||
String valiCode=createValiCode(); |
|||
|
|||
|
|||
String desc=""; |
|||
String goDesc=""; |
|||
User user=null; |
|||
User cuser=LoginUtils.getCurrentUserInfo(); |
|||
if(codeScene.equals("0")){ |
|||
desc="重置密码"; |
|||
goDesc="去重置密码"; |
|||
List<User> users=this.userQueryService.queryByUserloginid(codeEmail,"email",params); |
|||
if(users==null || users.size()==0){ |
|||
return Result.error("email-not-exists","邮箱账号不存在"); |
|||
} |
|||
}else if(codeScene.equals("1")){ |
|||
desc="进行注册邮箱验证"; |
|||
goDesc="去验证注册邮箱"; |
|||
List<User> users=this.userQueryService.queryByUserloginid(codeEmail,"email",params); |
|||
if(users!=null && users.size()>0){ |
|||
return Result.error("email-had-exists","邮箱账号已存在"); |
|||
} |
|||
}else if(codeScene.equals("2")){ |
|||
desc="更换常用邮箱验证"; |
|||
goDesc="去验证原常用邮箱"; |
|||
user=this.userQueryService.getUserByUserid(cuser.getUserid(),params); |
|||
if(user==null || !StringUtils.hasText(user.getEmail()) ){ |
|||
return Result.error("email-not-exists","邮箱账号不存在"); |
|||
|
|||
}else if (!codeEmail.equals(user.getEmail())){ |
|||
return Result.error("email-not-right","邮箱账号不正确"); |
|||
|
|||
} |
|||
codeEmail=user.getEmail(); |
|||
}else if(codeScene.equals("3")){ |
|||
desc="验证新的常用邮箱"; |
|||
goDesc="去验证新的常用邮箱"; |
|||
user=this.userQueryService.getUserByUserid(cuser.getUserid(),params); |
|||
if(user!=null && codeEmail.equals(user.getEmail())){ |
|||
return Result.error("email-had-exists","邮箱账号已存在"); |
|||
} |
|||
}else if(codeScene.equals("5")){ |
|||
desc="验证新的备用邮箱"; |
|||
goDesc="去验证新的备用邮箱"; |
|||
user=this.userQueryService.getUserByUserid(cuser.getUserid(),params); |
|||
if(user!=null && codeEmail.equals(user.getEmail())){ |
|||
return Result.error("email-had-exists","邮箱账号已存在"); |
|||
} |
|||
} |
|||
String text="尊敬的会员您好,唛盟平台欢迎您,请点击以下链接%s <a href='%s'>%s</a>"; |
|||
HttpServletRequest request= RequestUtils.getRequest(); |
|||
if(callbackUri.indexOf("?")>=0){ |
|||
callbackUri=callbackUri+"&valiCode="+valiCode+"&codeEmail="+codeEmail; |
|||
}else{ |
|||
callbackUri=callbackUri+"?valiCode="+valiCode+"&codeEmail="+codeEmail; |
|||
} |
|||
text=String.format(text,desc,callbackUri,goDesc); |
|||
emailService.sendSimpleMail(desc,fromEmail,codeEmail,text); |
|||
ValidCodeVo validCodeVo=new ValidCodeVo(); |
|||
if(user!=null){ |
|||
validCodeVo.setUserid(user.getUserid()); |
|||
}else{ |
|||
if(cuser!=null){ |
|||
validCodeVo.setUserid(cuser.getUserid()); |
|||
}else{ |
|||
cuser=LoginUtils.getCurrentUserInfo(); |
|||
validCodeVo.setUserid(cuser.getUserid()); |
|||
} |
|||
} |
|||
validCodeVo.setValiCode(valiCode); |
|||
validCodeVo.setCodeEmail(codeEmail); |
|||
validCodeVo.setCodeSendTime(new Date()); |
|||
validCodeVo.setCodeScene(codeScene); |
|||
validCodeVo.setUserType(userType); |
|||
validCodeVo.setId(validCodeService.createKey("id")); |
|||
validCodeService.insert(validCodeVo); |
|||
Map<String,Object> data=new HashMap<>(); |
|||
data.put("codeEmail",codeEmail); |
|||
return Result.ok().setData(data); |
|||
} |
|||
|
|||
/** |
|||
* 验证验证码是否正确 |
|||
* |
|||
* @param params {valiCode:'验证码',userType:'staff|cust'} |
|||
* @return |
|||
*/ |
|||
@GetMapping(value = "/user/validEmailCode") |
|||
@ResponseBody |
|||
public Result validEmailCode(@RequestParam Map<String,Object> params) { |
|||
Tips tips = new Tips("成功"); |
|||
String valiCode= (String) params.get("valiCode"); |
|||
if(!StringUtils.hasText(valiCode)){ |
|||
return Result.error("valid-code-not-allow-empty","验证码不能为空"); |
|||
|
|||
} |
|||
String userType= (String) params.get("userType"); |
|||
if(!StringUtils.hasText(valiCode)){ |
|||
return Result.error("user-type-not-allow-empty","用户类型不能为空"); |
|||
|
|||
} |
|||
ValidCodeVo vcVo=new ValidCodeVo(); |
|||
QueryWrapper<ValidCode> qw=new QueryWrapper<>(); |
|||
qw.eq("vali_code",valiCode); |
|||
List<ValidCode> vos= this.validCodeService.list(qw); |
|||
if(vos==null||vos.size()==0){ |
|||
return Result.error("valid-code-not-exists","验证码不存在"); |
|||
|
|||
} |
|||
ValidCodeVo vc=BaseUtils.fromMap(BaseUtils.toMap(vos.get(0)),ValidCodeVo.class); |
|||
vc.setUserType(userType); |
|||
if(vos.get(0).getCodeValidTime()!=null){ |
|||
return Result.error("valid-code-had-used","验证码已使用"); |
|||
} |
|||
|
|||
if("0".equals(vc.getCodeScene())){//重置密码 |
|||
ValidCodeVo validCodeVoUpdate=new ValidCodeVo(); |
|||
validCodeVoUpdate.setUserType(userType); |
|||
validCodeVoUpdate.setId(vc.getId()); |
|||
validCodeVoUpdate.setCodeValidTime(new Date()); |
|||
this.validCodeService.updateSomeFieldByPk(validCodeVoUpdate); |
|||
} else if("1".equals(vc.getCodeScene())){//如果时注册验证 |
|||
User user = new User(); |
|||
user.setUserid(vc.getUserid()); |
|||
user.setUserType(userType); |
|||
user.put("locked","0"); |
|||
user.setEmail(vc.getCodeEmail()); |
|||
User userdb=this.userQueryService.getUserByUserid(vc.getUserid(), BaseUtils.map("userType",userType)); |
|||
String validLvls=userdb.getValidLvls(); |
|||
if(!StringUtils.hasText(validLvls)){ |
|||
validLvls="0,0,1,0,0"; |
|||
}else{ |
|||
String[] validLvlss=validLvls.split(","); |
|||
validLvlss[2]="1"; |
|||
validLvls= Arrays.stream(validLvlss).collect(Collectors.joining(",")); |
|||
user.setValidLvls(validLvls); |
|||
} |
|||
this.userOperService.userUpdate(user); |
|||
this.sysClient.pushUserCreditScore(userdb.getUserid(),"5",userdb.getEmail(),"邮箱验证"); |
|||
//Map<String,Object> org = new HashMap<>(); |
|||
//org.put("orgUserid",vc.getUserid()); |
|||
//org.put("email",vc.getCodeEmail()); |
|||
//this.orgService.updateOrgEmail(org); |
|||
//自动登录 |
|||
Map<String,Object> webParams=new HashMap<>(); |
|||
webParams.put("userType",userType); |
|||
RequestTokenParams requestTokenParams=new RequestTokenParams(); |
|||
requestTokenParams.setUserloginid(user.getEmail()); |
|||
requestTokenParams.setUserid(user.getUserid()); |
|||
requestTokenParams.setAuthType(AuthType.email.name()); |
|||
requestTokenParams.setPassword(valiCode); |
|||
Result result=tokenPasswordController.clientPasswordGrant(webParams,requestTokenParams); |
|||
return result; |
|||
}else if("2".equals(vc.getCodeScene())){//更换常用邮箱第一步, |
|||
ValidCodeVo validCodeVoUpdate=new ValidCodeVo(); |
|||
validCodeVoUpdate.setUserType(userType); |
|||
validCodeVoUpdate.setId(vc.getId()); |
|||
validCodeVoUpdate.setCodeValidTime(new Date()); |
|||
this.validCodeService.updateSomeFieldByPk(validCodeVoUpdate); |
|||
}else if("3".equals(vc.getCodeScene())){//更换常用邮箱第二步,需要把常用邮箱更新为新邮箱 |
|||
ValidCodeVo validCodeVoUpdate=new ValidCodeVo(); |
|||
validCodeVoUpdate.setUserType(userType); |
|||
validCodeVoUpdate.setId(vc.getId()); |
|||
validCodeVoUpdate.setCodeValidTime(new Date()); |
|||
this.validCodeService.updateSomeFieldByPk(validCodeVoUpdate); |
|||
User user = new User(); |
|||
user.setUserType(userType); |
|||
user.setUserid(vc.getUserid()); |
|||
user.setEmail(vc.getCodeEmail()); |
|||
User userdb=this.userQueryService.getUserByUserid(vc.getUserid(), BaseUtils.map("userType",userType)); |
|||
String validLvls=userdb.getValidLvls(); |
|||
if(!StringUtils.hasText(validLvls)){ |
|||
validLvls="0,0,1,0,0"; |
|||
}else{ |
|||
String[] validLvlss=validLvls.split(","); |
|||
validLvlss[2]="1"; |
|||
validLvls= Arrays.stream(validLvlss).collect(Collectors.joining(",")); |
|||
user.setValidLvls(validLvls); |
|||
} |
|||
|
|||
|
|||
this.userOperService.userUpdate(user); |
|||
|
|||
this.sysClient.pushUserCreditScore(userdb.getUserid(),"5",userdb.getEmail(),"邮箱验证"); |
|||
|
|||
//Map<String,Object> org = new HashMap<>(); |
|||
//org.put("orgUserid",vc.getUserid()); |
|||
//org.put("email",vc.getCodeEmail()); |
|||
//this.orgService.updateOrgEmail(org); |
|||
}else if("5".equals(vc.getCodeScene())){//更换备用邮箱第2步,需要把备用邮箱更新成新邮箱 |
|||
ValidCodeVo validCodeVoUpdate=new ValidCodeVo(); |
|||
validCodeVoUpdate.setUserType(userType); |
|||
validCodeVoUpdate.setId(vc.getId()); |
|||
validCodeVoUpdate.setCodeValidTime(new Date()); |
|||
this.validCodeService.updateSomeFieldByPk(validCodeVoUpdate); |
|||
User user = new User(); |
|||
user.setUserid(vc.getUserid()); |
|||
user.setUserType(userType); |
|||
user.put("emailBak",vc.getCodeEmail()); |
|||
this.userOperService.userUpdate(user); |
|||
//Map<String,Object> org = new HashMap<>(); |
|||
//org.put("orgUserid",vc.getUserid()); |
|||
//org.put("emailBak",vc.getCodeEmail()); |
|||
//this.orgService.updateOrgEmail(org); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
public String createValiCode(){ |
|||
if(sequenceService==null){ |
|||
sequenceService=new SequenceService(); |
|||
} |
|||
String valiCode=sequenceService.getCommonNo("{date62:yyyyMMddHHmm}{rands:25}");//生成一个随机码 |
|||
|
|||
return valiCode.toUpperCase(Locale.ROOT); |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package com.mdp.login.ctrl; |
|||
|
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.safe.client.entity.*; |
|||
import com.mdp.safe.client.service.UserResourceQueryService; |
|||
import com.mdp.safe.client.service.remote.UserResourceRemoteService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
public class UserResourceController { |
|||
|
|||
@Autowired |
|||
UserResourceQueryService userResourceService; |
|||
|
|||
|
|||
@Autowired |
|||
UserResourceRemoteService userResourceRemoteService; |
|||
|
|||
@GetMapping(value = "/user/resource/getRoleQxs") |
|||
@ResponseBody public Result getRoleQxsFromRemote(@RequestParam String roleid) { |
|||
Map<String,Qx> qxMap= userResourceService.loadRoleQxsByRoleids(roleid); |
|||
return Result.ok().setData(qxMap); |
|||
} |
|||
|
|||
@GetMapping(value = "/user/resource/getRole") |
|||
@ResponseBody public Result getRoleFromRemote(@RequestParam String roleid) { |
|||
Role role = userResourceRemoteService.getRoleFromRemote(roleid); |
|||
return Result.ok().setData(role); |
|||
} |
|||
|
|||
@GetMapping(value = "/user/resource/getDept") |
|||
@ResponseBody public Result getDeptFromRemote(@RequestParam String deptid) { |
|||
Map<String,Object> result=new HashMap<>(); |
|||
List<Dept> depts = userResourceService.loadDeptsByDeptids(deptid); |
|||
return Result.ok().setData(depts==null||depts.size()==0?null:depts.get(0)); |
|||
} |
|||
|
|||
@GetMapping(value = "/user/resource/getBranch") |
|||
@ResponseBody public Result getBranchFromRemote(@RequestParam String branchId) { |
|||
Map<String,Object> result=new HashMap<>(); |
|||
List<Branch> branchs = userResourceService.loadBranchsByBranchIds(branchId); |
|||
return Result.ok().setData(branchs==null||branchs.size()==0?null:branchs.get(0)); |
|||
} |
|||
|
|||
@GetMapping(value = "/user/resource/getRoleMenus") |
|||
@ResponseBody public Result getRoleMenusFromRemote(@RequestParam String roleid) { |
|||
Map<String,Object> result=new HashMap<>(); |
|||
Map<String,Menu> menuMap= userResourceService.loadRoleMenusByRoleids(roleid); |
|||
return Result.ok().setData(menuMap); |
|||
} |
|||
@GetMapping(value = "/user/resource/getPosts") |
|||
@ResponseBody public Result getPostsFromRemote(@RequestParam String userid) { |
|||
return Result.ok().setData(userResourceRemoteService.getPostsFromRemote(userid)); |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.mdp.login.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class RequestTokenParams { |
|||
String userid;//如果已知道明确的用户编号,比如同一个手机号下,有多个账户的情况下,前端让客户选完一个账户再登录 |
|||
String userloginid; |
|||
String password; |
|||
String clientId; |
|||
String clientSecret; |
|||
String registrationId; |
|||
String authType; |
|||
String grantType; |
|||
String redirectUri; |
|||
|
|||
String deptid;//部门号,可空 |
|||
|
|||
String branchId;//机构号,可空 |
|||
|
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
package com.mdp.login.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
@Data |
|||
public class RequestUserInfoParams { |
|||
List<String> scopes; |
|||
|
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package com.mdp.login.entity; |
|||
|
|||
public enum Scope { |
|||
userInfo,roles,qxs,menus,depts,branchs,posts |
|||
} |
|||
@ -0,0 +1,225 @@ |
|||
package com.mdp.login.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 oauth2.client.user 小模块 <br> |
|||
* 实体 SysUser所有属性名: <br> |
|||
* "unionid","全局唯一编号,也叫主账户,同一个人(比如同一个微信号,同一个邮箱,同一个手机号视为同一个人)。同一个人在mdp有唯一的主账号。","displayUserid","登录展示使用用户编号","userid","内部用户编号(账户编号),如果是机构管理员账户,则=机构号","locked","是否被锁定0否1是","startdate","启用日期","nickname","昵称","username","用户名称","phoneno","移动电话号码","password","密码","salt","盐值","pwdtype","密码类型1指纹2密码","headimgurl","头像地址","country","国家","city","城市","province","省份","address","详细地址","sex","性别","enddate","到期日期","districtId","区县编号","email","邮箱","fgOne","指纹1","fgTwo","指纹2","fgThr","指纹3","idCardNo","身份证号码","officePhoneno","办公室电话","bizProcInstId","当前流程实例编号","bizFlowState","当前流程状态","memType","从平台角度看会员类型0-个人账户、1-企业管理员账户、2-企业员工账户,个人账户无须绑定机构号,个人子账户可升级为企业员工账户,企业账户必须绑定机构编号branchId个人账户升级后,保留个人主账户,个人子账户绑定企业编号成为企业员工账户","orgId","机构会员自己的机构会员的机构号,理解为客户的客户","emailBak","备用邮箱","pwdStrong","1-高风险,2-中风险,3-低风险","lockType","锁定类型:0-注册等待邮箱验证,1-注册等待修改初始密码,2-注册等待验证手机号码,3-密码高风险,等待重新修改密码,9-业务需要锁定禁止登录,10-账户被锁定,请联系客服","lockRemark","锁定原因","ltime","更新日期","atype","相对于平台来说的账户类型0-子账户,1-主账户。","branchId","机构主子账户归属的机构编号,如果是个人,这里填虚拟机构编号,作为虚拟的机构号,方便将来升级成企业号","continent","洲别","cpaType","从入驻企业角度看协作类型0-企业内部人员,1-客户,2-供应商,3-上级机构,4-下属机构","cpaOrg","协作组织0-个人,1机构,如果是机构,机构号填入orgId","roleids","个人账户拥有的角色,逗号分割","birthday","生日","shopId","商户编号","profeId","职业编号","profeName","职业名称","gradeId","等级会员,根据经验值而定","gradeName","等级会员名称","ilvlId","权益等级青铜、白银、黄金、紫金、钻石","ilvlName","权益等级名称","istatus","会员权益状态0-无效,1-有效,2-过期","istime","权益开始时间","ietime","权益结束时间","validLvls","人工验证结果,当审核状态为2时,同步到sys_user表同一个字段,或者sys_branch同一个字段","features","个性化签名","profeType","职业类型1-开发类,2-测试类,3-设计类,4-管理类;","ustatus","用户账户状态0-初始,1-起效,2-注销申请,3-注销后删除","creditId","信用等级编号","creditScore","信用等级分数","guardId","服务保障等级0-初始,1-金,2-银,3-铜","open","是否对互联网用户开放查询0-否1是","remark","简介备注","skills","技能列表,逗号分隔","bizHours","营业时间说明09:00-12:00";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* userid;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("sys_user") |
|||
@ApiModel(description="用户表") |
|||
public class SysUser implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="内部用户编号(账户编号),如果是机构管理员账户,则=机构号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String userid; |
|||
|
|||
@ApiModelProperty(notes="全局唯一编号,也叫主账户,同一个人(比如同一个微信号,同一个邮箱,同一个手机号视为同一个人)。同一个人在mdp有唯一的主账号。",allowEmptyValue=true,example="",allowableValues="") |
|||
String unionid; |
|||
|
|||
@ApiModelProperty(notes="登录展示使用用户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String displayUserid; |
|||
|
|||
@ApiModelProperty(notes="是否被锁定0否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String locked; |
|||
|
|||
@ApiModelProperty(notes="启用日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date startdate; |
|||
|
|||
@ApiModelProperty(notes="昵称",allowEmptyValue=true,example="",allowableValues="") |
|||
String nickname; |
|||
|
|||
@ApiModelProperty(notes="用户名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String username; |
|||
|
|||
@ApiModelProperty(notes="移动电话号码",allowEmptyValue=true,example="",allowableValues="") |
|||
String phoneno; |
|||
|
|||
@ApiModelProperty(notes="密码",allowEmptyValue=true,example="",allowableValues="") |
|||
String password; |
|||
|
|||
@ApiModelProperty(notes="盐值",allowEmptyValue=true,example="",allowableValues="") |
|||
String salt; |
|||
|
|||
@ApiModelProperty(notes="密码类型1指纹2密码",allowEmptyValue=true,example="",allowableValues="") |
|||
String pwdtype; |
|||
|
|||
@ApiModelProperty(notes="头像地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String headimgurl; |
|||
|
|||
@ApiModelProperty(notes="国家",allowEmptyValue=true,example="",allowableValues="") |
|||
String country; |
|||
|
|||
@ApiModelProperty(notes="城市",allowEmptyValue=true,example="",allowableValues="") |
|||
String city; |
|||
|
|||
@ApiModelProperty(notes="省份",allowEmptyValue=true,example="",allowableValues="") |
|||
String province; |
|||
|
|||
@ApiModelProperty(notes="详细地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String address; |
|||
|
|||
@ApiModelProperty(notes="性别",allowEmptyValue=true,example="",allowableValues="") |
|||
String sex; |
|||
|
|||
@ApiModelProperty(notes="到期日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date enddate; |
|||
|
|||
@ApiModelProperty(notes="区县编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String districtId; |
|||
|
|||
@ApiModelProperty(notes="邮箱",allowEmptyValue=true,example="",allowableValues="") |
|||
String email; |
|||
|
|||
@ApiModelProperty(notes="指纹1",allowEmptyValue=true,example="",allowableValues="") |
|||
String fgOne; |
|||
|
|||
@ApiModelProperty(notes="指纹2",allowEmptyValue=true,example="",allowableValues="") |
|||
String fgTwo; |
|||
|
|||
@ApiModelProperty(notes="指纹3",allowEmptyValue=true,example="",allowableValues="") |
|||
String fgThr; |
|||
|
|||
@ApiModelProperty(notes="身份证号码",allowEmptyValue=true,example="",allowableValues="") |
|||
String idCardNo; |
|||
|
|||
@ApiModelProperty(notes="办公室电话",allowEmptyValue=true,example="",allowableValues="") |
|||
String officePhoneno; |
|||
|
|||
@ApiModelProperty(notes="当前流程实例编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizProcInstId; |
|||
|
|||
@ApiModelProperty(notes="当前流程状态",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizFlowState; |
|||
|
|||
@ApiModelProperty(notes="从平台角度看会员类型0-个人账户、1-企业管理员账户、2-企业员工账户,个人账户无须绑定机构号,个人子账户可升级为企业员工账户,企业账户必须绑定机构编号branchId个人账户升级后,保留个人主账户,个人子账户绑定企业编号成为企业员工账户",allowEmptyValue=true,example="",allowableValues="") |
|||
String memType; |
|||
|
|||
@ApiModelProperty(notes="机构会员自己的机构会员的机构号,理解为客户的客户",allowEmptyValue=true,example="",allowableValues="") |
|||
String orgId; |
|||
|
|||
@ApiModelProperty(notes="备用邮箱",allowEmptyValue=true,example="",allowableValues="") |
|||
String emailBak; |
|||
|
|||
@ApiModelProperty(notes="1-高风险,2-中风险,3-低风险",allowEmptyValue=true,example="",allowableValues="") |
|||
String pwdStrong; |
|||
|
|||
@ApiModelProperty(notes="锁定类型:0-注册等待邮箱验证,1-注册等待修改初始密码,2-注册等待验证手机号码,3-密码高风险,等待重新修改密码,9-业务需要锁定禁止登录,10-账户被锁定,请联系客服",allowEmptyValue=true,example="",allowableValues="") |
|||
String lockType; |
|||
|
|||
@ApiModelProperty(notes="锁定原因",allowEmptyValue=true,example="",allowableValues="") |
|||
String lockRemark; |
|||
|
|||
@ApiModelProperty(notes="更新日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date ltime; |
|||
|
|||
@ApiModelProperty(notes="相对于平台来说的账户类型0-子账户,1-主账户。",allowEmptyValue=true,example="",allowableValues="") |
|||
String atype; |
|||
|
|||
@ApiModelProperty(notes="机构主子账户归属的机构编号,如果是个人,这里填虚拟机构编号,作为虚拟的机构号,方便将来升级成企业号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="洲别",allowEmptyValue=true,example="",allowableValues="") |
|||
String continent; |
|||
|
|||
@ApiModelProperty(notes="从入驻企业角度看协作类型0-企业内部人员,1-客户,2-供应商,3-上级机构,4-下属机构",allowEmptyValue=true,example="",allowableValues="") |
|||
String cpaType; |
|||
|
|||
@ApiModelProperty(notes="协作组织0-个人,1机构,如果是机构,机构号填入orgId",allowEmptyValue=true,example="",allowableValues="") |
|||
String cpaOrg; |
|||
|
|||
@ApiModelProperty(notes="个人账户拥有的角色,逗号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String roleids; |
|||
|
|||
@ApiModelProperty(notes="生日",allowEmptyValue=true,example="",allowableValues="") |
|||
Date birthday; |
|||
|
|||
@ApiModelProperty(notes="商户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopId; |
|||
|
|||
@ApiModelProperty(notes="职业编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String profeId; |
|||
|
|||
@ApiModelProperty(notes="职业名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String profeName; |
|||
|
|||
@ApiModelProperty(notes="等级会员,根据经验值而定",allowEmptyValue=true,example="",allowableValues="") |
|||
String gradeId; |
|||
|
|||
@ApiModelProperty(notes="等级会员名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String gradeName; |
|||
|
|||
@ApiModelProperty(notes="权益等级青铜、白银、黄金、紫金、钻石",allowEmptyValue=true,example="",allowableValues="") |
|||
String ilvlId; |
|||
|
|||
@ApiModelProperty(notes="权益等级名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String ilvlName; |
|||
|
|||
@ApiModelProperty(notes="会员权益状态0-无效,1-有效,2-过期",allowEmptyValue=true,example="",allowableValues="") |
|||
String istatus; |
|||
|
|||
@ApiModelProperty(notes="权益开始时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date istime; |
|||
|
|||
@ApiModelProperty(notes="权益结束时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date ietime; |
|||
|
|||
@ApiModelProperty(notes="人工验证结果,当审核状态为2时,同步到sys_user表同一个字段,或者sys_branch同一个字段",allowEmptyValue=true,example="",allowableValues="") |
|||
String validLvls; |
|||
|
|||
@ApiModelProperty(notes="个性化签名",allowEmptyValue=true,example="",allowableValues="") |
|||
String features; |
|||
|
|||
@ApiModelProperty(notes="职业类型1-开发类,2-测试类,3-设计类,4-管理类;",allowEmptyValue=true,example="",allowableValues="") |
|||
String profeType; |
|||
|
|||
@ApiModelProperty(notes="用户账户状态0-初始,1-起效,2-注销申请,3-注销后删除",allowEmptyValue=true,example="",allowableValues="") |
|||
String ustatus; |
|||
|
|||
@ApiModelProperty(notes="信用等级编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String creditId; |
|||
|
|||
@ApiModelProperty(notes="信用等级分数",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer creditScore; |
|||
|
|||
@ApiModelProperty(notes="服务保障等级0-初始,1-金,2-银,3-铜",allowEmptyValue=true,example="",allowableValues="") |
|||
String guardId; |
|||
|
|||
@ApiModelProperty(notes="是否对互联网用户开放查询0-否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String open; |
|||
|
|||
@ApiModelProperty(notes="简介备注",allowEmptyValue=true,example="",allowableValues="") |
|||
String remark; |
|||
|
|||
@ApiModelProperty(notes="技能列表,逗号分隔",allowEmptyValue=true,example="",allowableValues="") |
|||
String skills; |
|||
|
|||
@ApiModelProperty(notes="营业时间说明09:00-12:00",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizHours; |
|||
|
|||
/** |
|||
*内部用户编号(账户编号),如果是机构管理员账户,则=机构号 |
|||
**/ |
|||
public SysUser(String userid) { |
|||
this.userid = userid; |
|||
} |
|||
|
|||
/** |
|||
* 用户表 |
|||
**/ |
|||
public SysUser() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,143 @@ |
|||
package com.mdp.login.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mk 大模块 mem 小模块 <br> |
|||
* 实体 MemberValidCode所有属性名: <br> |
|||
* userid,valiCode,codeSendTime,codeEmail,codeScene,codeValidTime,id;<br> |
|||
* 表 MK.mem_member_valid_code 会员表(前端商城的所有字段名: <br> |
|||
* userid,vali_code,code_send_time,code_email,code_scene,code_valid_time,id;<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@ApiModel(description="会员表(前端商城") |
|||
@TableName("sys_user_valid_code") |
|||
public class ValidCode implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@TableId |
|||
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
|
|||
@ApiModelProperty(notes="内部用户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String userid; |
|||
|
|||
@ApiModelProperty(notes="验证码",allowEmptyValue=true,example="",allowableValues="") |
|||
String valiCode; |
|||
|
|||
@ApiModelProperty(notes="验证码发送时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date codeSendTime; |
|||
|
|||
@ApiModelProperty(notes="验证码接收邮箱编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String codeEmail; |
|||
|
|||
@ApiModelProperty(notes="验证场景0-重置密码,1-注册验证,2-更换常用邮箱第一步验证旧邮箱,,3-更换常用邮箱第二步验证新邮箱,4-更换常用邮箱第一步验证旧邮箱,,5-更换常用邮箱第二步验证新邮箱,",allowEmptyValue=true,example="",allowableValues="") |
|||
String codeScene; |
|||
|
|||
@ApiModelProperty(notes="验证码验证时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date codeValidTime; |
|||
|
|||
/**主键**/ |
|||
public ValidCode(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/**会员表(前端商城**/ |
|||
public ValidCode() { |
|||
} |
|||
|
|||
/** |
|||
* 内部用户编号 |
|||
**/ |
|||
public void setUserid(String userid) { |
|||
this.userid = userid; |
|||
} |
|||
/** |
|||
* 验证码 |
|||
**/ |
|||
public void setValiCode(String valiCode) { |
|||
this.valiCode = valiCode; |
|||
} |
|||
/** |
|||
* 验证码发送时间 |
|||
**/ |
|||
public void setCodeSendTime(Date codeSendTime) { |
|||
this.codeSendTime = codeSendTime; |
|||
} |
|||
/** |
|||
* 验证码接收邮箱编号 |
|||
**/ |
|||
public void setCodeEmail(String codeEmail) { |
|||
this.codeEmail = codeEmail; |
|||
} |
|||
/** |
|||
* 验证场景0-重置密码,1-注册验证,2-更换常用邮箱第一步验证旧邮箱,,3-更换常用邮箱第二步验证新邮箱,4-更换常用邮箱第一步验证旧邮箱,,5-更换常用邮箱第二步验证新邮箱, |
|||
**/ |
|||
public void setCodeScene(String codeScene) { |
|||
this.codeScene = codeScene; |
|||
} |
|||
/** |
|||
* 验证码验证时间 |
|||
**/ |
|||
public void setCodeValidTime(Date codeValidTime) { |
|||
this.codeValidTime = codeValidTime; |
|||
} |
|||
/** |
|||
* 主键 |
|||
**/ |
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 内部用户编号 |
|||
**/ |
|||
public String getUserid() { |
|||
return this.userid; |
|||
} |
|||
/** |
|||
* 验证码 |
|||
**/ |
|||
public String getValiCode() { |
|||
return this.valiCode; |
|||
} |
|||
/** |
|||
* 验证码发送时间 |
|||
**/ |
|||
public Date getCodeSendTime() { |
|||
return this.codeSendTime; |
|||
} |
|||
/** |
|||
* 验证码接收邮箱编号 |
|||
**/ |
|||
public String getCodeEmail() { |
|||
return this.codeEmail; |
|||
} |
|||
/** |
|||
* 验证场景0-重置密码,1-注册验证,2-更换常用邮箱第一步验证旧邮箱,,3-更换常用邮箱第二步验证新邮箱,4-更换常用邮箱第一步验证旧邮箱,,5-更换常用邮箱第二步验证新邮箱, |
|||
**/ |
|||
public String getCodeScene() { |
|||
return this.codeScene; |
|||
} |
|||
/** |
|||
* 验证码验证时间 |
|||
**/ |
|||
public Date getCodeValidTime() { |
|||
return this.codeValidTime; |
|||
} |
|||
/** |
|||
* 主键 |
|||
**/ |
|||
public String getId() { |
|||
return this.id; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package com.mdp.login.entity; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mk 大模块 mem 小模块 <br> |
|||
* 实体 MemberValidCode所有属性名: <br> |
|||
* userid,valiCode,codeSendTime,codeEmail,codeScene,codeValidTime,id;<br> |
|||
* 表 MK.mem_member_valid_code 会员表(前端商城的所有字段名: <br> |
|||
* userid,vali_code,code_send_time,code_email,code_scene,code_valid_time,id;<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@ApiModel(description="会员表(前端商城") |
|||
public class ValidCodeVo extends ValidCode { |
|||
public String getUserType() { |
|||
return userType; |
|||
} |
|||
|
|||
public void setUserType(String userType) { |
|||
this.userType = userType; |
|||
} |
|||
|
|||
/** |
|||
* 用户类型 suerType: cust|staff |
|||
*/ |
|||
String userType; |
|||
|
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
package com.mdp.login.integration; |
|||
|
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author chenyc |
|||
* @date 2018-3-30 |
|||
**/ |
|||
public class IntegrationParams { |
|||
|
|||
private String authType; |
|||
private String userloginid; |
|||
/** |
|||
* userType:cust客户 staff员工 |
|||
*/ |
|||
private String userType; |
|||
|
|||
private Map<String,Object> datas=new HashMap<>(); |
|||
|
|||
private Map<String,String[]> authParameters=new HashMap<>(); |
|||
|
|||
public String getAuthParameter(String paramter){ |
|||
String[] values = this.authParameters.get(paramter); |
|||
if(values != null && values.length > 0){ |
|||
return values[0]; |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public String getAuthType() { |
|||
return authType; |
|||
} |
|||
|
|||
public void setAuthType(String authType) { |
|||
this.authType = authType; |
|||
} |
|||
|
|||
public String getUserloginid() { |
|||
return userloginid; |
|||
} |
|||
|
|||
public void setUserloginid(String userloginid) { |
|||
this.userloginid = userloginid; |
|||
} |
|||
|
|||
public Map<String, Object> getDatas() { |
|||
return datas; |
|||
} |
|||
|
|||
public void setDatas(Map<String, Object> datas) { |
|||
this.datas = datas; |
|||
} |
|||
|
|||
public void put(String key,Object value){ |
|||
this.datas.put(key,value); |
|||
} |
|||
|
|||
public Object get(String key){ |
|||
return this.datas.get(key); |
|||
} |
|||
|
|||
public String getUserType() { |
|||
return userType; |
|||
} |
|||
|
|||
public void setUserType(String userType) { |
|||
this.userType = userType; |
|||
} |
|||
|
|||
public void setAuthParameters(Map<String, String[]> authParameters) { |
|||
this.authParameters = authParameters; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.mdp.login.integration; |
|||
|
|||
/** |
|||
* @author chenyc |
|||
* @date 2018-3-30 |
|||
**/ |
|||
public class IntegrationParamsContext { |
|||
|
|||
private static ThreadLocal<IntegrationParams> holder = new ThreadLocal<>(); |
|||
|
|||
public static void set(IntegrationParams integrationParams){ |
|||
holder.set(integrationParams); |
|||
} |
|||
|
|||
public static IntegrationParams get(){ |
|||
return holder.get(); |
|||
} |
|||
|
|||
public static void clear(){ |
|||
holder.remove(); |
|||
} |
|||
} |
|||
@ -0,0 +1,341 @@ |
|||
package com.mdp.login.integration.authenticator; |
|||
|
|||
import com.mdp.core.utils.Const; |
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.plat.client.PlatClientService; |
|||
import com.mdp.plat.client.entity.PlatformVo; |
|||
import com.mdp.qx.DataLvl; |
|||
import com.mdp.safe.client.cache.RoleRedisCacheService; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.dict.UserType; |
|||
import com.mdp.safe.client.entity.DeptPostRole; |
|||
import com.mdp.safe.client.entity.Role; |
|||
import com.mdp.safe.client.entity.SafeAuthority; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.tpa.client.entity.AppShopConfig; |
|||
import com.mdp.tpa.client.service.AppShopConfigService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.security.core.GrantedAuthority; |
|||
import org.springframework.security.crypto.password.PasswordEncoder; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* 默认登录处理,密码方式 |
|||
* 格式 url: http://${domain}/api/m1/oauth2/oauth/token?grant_type=password&username=${username}&password=${前端密码MD5加密后的密码}&scope=all |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
public class AuthenticatorAdapter implements IntegrationAuthenticator{ |
|||
|
|||
@Autowired |
|||
SysUserQueryService userBaseInfoQueryService; |
|||
|
|||
@Autowired |
|||
public PasswordEncoder passwordEncoder; |
|||
|
|||
@Autowired |
|||
AppShopConfigService appShopConfigService; |
|||
|
|||
@Autowired |
|||
PlatClientService platClientService; |
|||
|
|||
@Autowired |
|||
RoleRedisCacheService roleRedisCacheService; |
|||
|
|||
Logger logger= LoggerFactory.getLogger(AuthenticatorAdapter.class); |
|||
|
|||
|
|||
@Override |
|||
public User authenticate(IntegrationParams integrationParams) { |
|||
User user= loadUserByUserid(integrationParams.getUserloginid(),integrationParams); |
|||
return user; |
|||
} |
|||
|
|||
/** |
|||
* 查找用户基础信息 |
|||
* @param userid 前台登陆编号 |
|||
* @return |
|||
*/ |
|||
public User loadUserByUserid(String userid,IntegrationParams integrationParams){ |
|||
User user= userBaseInfoQueryService.getUserByUserid(userid,null); |
|||
//todo: 为了测试方便,将密码设置为与前端上送的密码一致 |
|||
user.setPassword(passwordEncoder.encode(integrationParams.getAuthParameter("password"))); |
|||
return user; |
|||
} |
|||
|
|||
@Override |
|||
public void prepare(IntegrationParams integrationParams) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public boolean supportAuthType(IntegrationParams integrationParams) { |
|||
return AuthType.password.name().equals(integrationParams.getAuthType()); |
|||
} |
|||
|
|||
@Override |
|||
public void complete(IntegrationParams integrationParams) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Collection<? extends GrantedAuthority> loadAuthorities(User user, IntegrationParams integrationParams) { |
|||
if(user==null){ |
|||
Set<SafeAuthority> safeAuthorities=new HashSet<>(); |
|||
SafeAuthority safeAuthority=new SafeAuthority("guest","游客",DataLvl.myDept.getLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
return safeAuthorities; |
|||
} |
|||
Collection<? extends GrantedAuthority> authorities=new HashSet<>(); |
|||
if(UserType.cust.name().equals(integrationParams.getUserType())){ |
|||
authorities=this.loadAuthoritiesForCust(user, integrationParams); |
|||
}else{ |
|||
authorities=this.loadAuthoritiesForStaff(user, integrationParams); |
|||
} |
|||
return authorities; |
|||
} |
|||
|
|||
|
|||
public Collection<? extends GrantedAuthority> loadAuthoritiesForCust(User user, IntegrationParams integrationParams) { |
|||
Set<SafeAuthority> safeAuthorities=new HashSet<>(); |
|||
//默认用户 |
|||
SafeAuthority safeAuthority=new SafeAuthority("user","普通用户",DataLvl.myDept.getLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
if(user!=null){ |
|||
//机构会员 |
|||
if("1".equals(user.getMemType())){ |
|||
//机构角色 |
|||
SafeAuthority orgAuthority=new SafeAuthority("org","机构会员",DataLvl.myDept.getLvl()); |
|||
safeAuthorities.add(orgAuthority); |
|||
} |
|||
String roleids= (String) user.get("roleids"); |
|||
if(StringUtils.hasText(roleids)){ |
|||
String[] roleidss= roleids.split(","); |
|||
for (String roleid : roleidss) { |
|||
if(safeAuthorities.stream().filter(i->roleid.equals(i.getAuthority())).findAny().isPresent()){ |
|||
continue; |
|||
} |
|||
Role role=this.roleRedisCacheService.getRole(roleid); |
|||
SafeAuthority safeAuthority2=new SafeAuthority(role.getRoleid(),role.getRolename(),role.getDataLvl()); |
|||
safeAuthorities.add(safeAuthority2); |
|||
} |
|||
} |
|||
if("1".equals(user.getMemType())){ |
|||
SafeAuthority orgAuthority=new SafeAuthority("branchAdmin","机构管理员",DataLvl.branch.getLvl()); |
|||
safeAuthorities.add(orgAuthority); |
|||
} |
|||
if("superAdmin".equals(user.getUserid())||"superAdmin".equals(user.getDisplayUserid())){ |
|||
SafeAuthority orgAuthority=new SafeAuthority("superAdmin","超级管理员",DataLvl.allowAll.getLvl()); |
|||
safeAuthorities.add(orgAuthority); |
|||
} |
|||
setShopInfoToUser(user); |
|||
} |
|||
return safeAuthorities; |
|||
} |
|||
|
|||
public Collection<? extends GrantedAuthority> loadAuthoritiesForStaff(User user, IntegrationParams integrationParams) { |
|||
|
|||
if(!"0".equals(user.getMemType())){ |
|||
List<DeptPostRole> deptPostRoles=loadUserRolesByUserid(user.getUserid(),integrationParams); |
|||
return this.calcBranchAuthority(user,integrationParams,deptPostRoles); |
|||
|
|||
}else{ |
|||
return calcPersonAuthority(user, integrationParams); |
|||
} |
|||
} |
|||
|
|||
private Collection<? extends GrantedAuthority> calcPersonAuthority(User user, IntegrationParams integrationParams) { |
|||
Set<SafeAuthority> safeAuthorities=new HashSet<>(); |
|||
String roleids= (String) user.get("roleids"); |
|||
if(StringUtils.hasText(roleids)){ |
|||
String[] roleidss= roleids.split(","); |
|||
for (String roleid : roleidss) { |
|||
if(safeAuthorities.stream().filter(i->roleid.equals(i.getAuthority())).findAny().isPresent()){ |
|||
continue; |
|||
} |
|||
Role role=this.roleRedisCacheService.getRole(roleid); |
|||
SafeAuthority safeAuthority=new SafeAuthority(role.getRoleid(),role.getRolename(),role.getDataLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
} |
|||
} |
|||
if("superAdmin".equals(user.getDisplayUserid())||"superAdmin".equals(user.getUserid())){ |
|||
user.setMaxDataLvl(DataLvl.allowAll.getLvl()); |
|||
SafeAuthority safeAuthority=new SafeAuthority(Const.superAdminRole,"超级管理员",DataLvl.allowAll.getLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
}else { |
|||
if("1".equals(user.getMemType())) { |
|||
user.setMaxDataLvl(DataLvl.branch.getLvl()); |
|||
SafeAuthority safeAuthority=new SafeAuthority("branchAdmin","机构管理员",DataLvl.branch.getLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
} |
|||
} |
|||
return safeAuthorities; |
|||
} |
|||
|
|||
private Collection<? extends GrantedAuthority> calcBranchAuthority(User user, IntegrationParams integrationParams, List<DeptPostRole> deptPostRoles) { |
|||
Set<SafeAuthority> safeAuthorities=new HashSet<>(); |
|||
Set<String> deptids=new HashSet<>(); |
|||
Set<String> branchIds=new HashSet<>(); |
|||
Map<String,DeptPostRole> deptPostRoleMap=new HashMap<>(); |
|||
Map<String,DeptPostRole> masterMap=new HashMap<>(); |
|||
DataLvl maxDataLvl=DataLvl.myDept; |
|||
DeptPostRole maxDataLvlDeptPostRole=null; |
|||
if(deptPostRoles !=null && deptPostRoles.size()>0){ |
|||
for (DeptPostRole deptPostRole : deptPostRoles) { |
|||
|
|||
deptids.add(deptPostRole.getDeptid()); |
|||
branchIds.add(deptPostRole.getBranchId()); |
|||
if(deptPostRole.getDataLvl()==null){ |
|||
deptPostRole.setDataLvl(DataLvl.myDept.getLvl()); |
|||
} |
|||
deptPostRoleMap.put(deptPostRole.getRoleid(),deptPostRole); |
|||
if("1".equals(deptPostRole.getMaster())){ |
|||
masterMap.put(deptPostRole.getRoleid(),deptPostRole); |
|||
} |
|||
if(maxDataLvl.getLvl()<=DataLvl.getDataLvl(deptPostRole.getDataLvl()).getLvl()){ |
|||
maxDataLvl=DataLvl.getDataLvl(deptPostRole.getDataLvl()); |
|||
maxDataLvlDeptPostRole=deptPostRole; |
|||
} |
|||
} |
|||
String roleids= (String) user.get("roleids"); |
|||
if(StringUtils.hasText(roleids)){ |
|||
String[] roleidss= roleids.split(","); |
|||
for (String roleid : roleidss) { |
|||
if(deptPostRoleMap.containsKey(roleid)){ |
|||
continue; |
|||
} |
|||
Role role=this.roleRedisCacheService.getRole(roleid); |
|||
SafeAuthority safeAuthority=new SafeAuthority(role.getRoleid(),role.getRolename(),role.getDataLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
} |
|||
} |
|||
}else{ |
|||
String roleids= (String) user.get("roleids"); |
|||
if(StringUtils.hasText(roleids)){ |
|||
String[] roleidss= roleids.split(","); |
|||
for (String roleid : roleidss) { |
|||
Role role=this.roleRedisCacheService.getRole(roleid); |
|||
SafeAuthority safeAuthority=new SafeAuthority(role.getRoleid(),role.getRolename(),role.getDataLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
} |
|||
}else{ |
|||
//默认用户 |
|||
SafeAuthority safeAuthority=new SafeAuthority("user","普通用户",DataLvl.myDept.getLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
maxDataLvl=DataLvl.myDept; |
|||
} |
|||
|
|||
} |
|||
if(!deptids.isEmpty()){ |
|||
user.setDeptids(deptids); |
|||
} |
|||
if (!branchIds.isEmpty()) { |
|||
user.setBranchIds(branchIds); |
|||
} |
|||
for (DeptPostRole deptPostRole : deptPostRoleMap.values()) { |
|||
SafeAuthority safeAuthority=new SafeAuthority(deptPostRole.getRoleid(),deptPostRole.getRolename(),deptPostRole.getDataLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
} |
|||
|
|||
DataLvl maxDataLvl2=null; |
|||
DeptPostRole maxDataLvlDeptPostRole2=null; |
|||
if( !masterMap.isEmpty() ){ |
|||
maxDataLvl2=DataLvl.myDept; |
|||
if(masterMap.size()>1){ |
|||
//找出等级高的 |
|||
for (DeptPostRole deptPostRole : masterMap.values()) { |
|||
if(maxDataLvl2.getLvl()<=DataLvl.getDataLvl(deptPostRole.getDataLvl()).getLvl()){ |
|||
maxDataLvl2=DataLvl.getDataLvl(deptPostRole.getDataLvl()); |
|||
maxDataLvlDeptPostRole2=deptPostRole; |
|||
} |
|||
} |
|||
|
|||
}else { |
|||
maxDataLvlDeptPostRole2=masterMap.values().stream().findFirst().get(); |
|||
maxDataLvl2=DataLvl.getDataLvl(maxDataLvlDeptPostRole2.getDataLvl()); |
|||
} |
|||
}else { |
|||
maxDataLvl2=maxDataLvl; |
|||
maxDataLvlDeptPostRole2=maxDataLvlDeptPostRole; |
|||
} |
|||
if(maxDataLvlDeptPostRole2==null){ |
|||
maxDataLvlDeptPostRole2=maxDataLvlDeptPostRole; |
|||
} |
|||
if(maxDataLvlDeptPostRole2!=null){ |
|||
user.setDeptid(maxDataLvlDeptPostRole2.getDeptid()); |
|||
user.setDeptName(maxDataLvlDeptPostRole2.getDeptName()); |
|||
user.setBranchId(maxDataLvlDeptPostRole2.getBranchId()); |
|||
user.setBranchName(maxDataLvlDeptPostRole2.getBranchName()); |
|||
} |
|||
|
|||
if("superAdmin".equals(user.getDisplayUserid())||"superAdmin".equals(user.getUserid())){ |
|||
user.setMaxDataLvl(DataLvl.allowAll.getLvl()); |
|||
SafeAuthority safeAuthority=new SafeAuthority(Const.superAdminRole,"超级管理员",DataLvl.allowAll.getLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
}else { |
|||
if("1".equals(user.getMemType())) { |
|||
user.setMaxDataLvl(DataLvl.branch.getLvl()); |
|||
SafeAuthority safeAuthority=new SafeAuthority("branchAdmin","机构管理员",DataLvl.branch.getLvl()); |
|||
safeAuthorities.add(safeAuthority); |
|||
}else { |
|||
user.setMaxDataLvl(maxDataLvl.getLvl()); |
|||
} |
|||
} |
|||
setShopInfoToUser(user); |
|||
return safeAuthorities; |
|||
} |
|||
|
|||
/** |
|||
* 查找用户的角色列表 |
|||
*/ |
|||
public List<DeptPostRole> loadUserRolesByUserid(String userid,IntegrationParams integrationParams){ |
|||
Map<String,Object> extParams=new HashMap<>(); |
|||
String deptid= (String) integrationParams.getAuthParameter("deptid"); |
|||
String branchId= (String) integrationParams.getAuthParameter("branchId"); |
|||
if(StringUtils.hasText(deptid)){ |
|||
extParams.put("deptid",deptid); |
|||
} |
|||
if(StringUtils.hasText(branchId)){ |
|||
extParams.put("branchId",branchId); |
|||
} |
|||
return userBaseInfoQueryService.getUserDeptPostRoles(userid,extParams); |
|||
} |
|||
|
|||
/** |
|||
* 设置用户归属商户 |
|||
* @param user |
|||
*/ |
|||
private void setShopInfoToUser(User user) { |
|||
try { |
|||
if(StringUtils.hasText(user.getBranchId())){ |
|||
AppShopConfig config= appShopConfigService.getShopConfigByBranchId(user.getBranchId()); |
|||
if(config==null){ |
|||
user.setShopId(user.getBranchId()); |
|||
user.setLocationId(user.getBranchId()+"-01"); |
|||
return; |
|||
}else{ |
|||
user.setShopId(config.getShopId()); |
|||
user.setLocationId(config.getHeadLocationId()); |
|||
user.setShopName(config.getShopName()); |
|||
user.setLocationName(config.getHeadLocationName()); |
|||
} |
|||
}else{ |
|||
PlatformVo platformVo=platClientService.getPlatformVo(); |
|||
user.setShopId(platformVo.getShopId()); |
|||
user.setShopName(platformVo.getPlatformTitle()); |
|||
user.setLocationId(platformVo.getLocationId()); |
|||
user.setBranchId(platformVo.getBranchId()); |
|||
user.setBranchName(platformVo.getPlatformName()); |
|||
} |
|||
}catch (Exception e){ |
|||
logger.error("",e); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package com.mdp.login.integration.authenticator; |
|||
|
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.springframework.security.core.GrantedAuthority; |
|||
|
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
public interface IntegrationAuthenticator { |
|||
|
|||
/** |
|||
* 处理集成认证 |
|||
* @param integrationParams |
|||
* @return |
|||
*/ |
|||
User authenticate(IntegrationParams integrationParams); |
|||
|
|||
|
|||
/** |
|||
* 进行预处理 |
|||
* @param integrationParams |
|||
*/ |
|||
void prepare(IntegrationParams integrationParams); |
|||
|
|||
/** |
|||
* 判断是否支持集成认证类型 |
|||
* @param integrationParams |
|||
* @return |
|||
*/ |
|||
boolean supportAuthType(IntegrationParams integrationParams); |
|||
|
|||
/** 认证结束后执行 |
|||
* @param integrationParams |
|||
*/ |
|||
void complete(IntegrationParams integrationParams); |
|||
|
|||
/** |
|||
* 加载用户对应的角色 |
|||
*/ |
|||
Collection<? extends GrantedAuthority> loadAuthorities(User user,IntegrationParams integrationParams) ; |
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package com.mdp.login.integration.authenticator; |
|||
|
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 默认登录处理,密码方式 |
|||
* 格式 url: http://${domain}/api/m1/oauth2/oauth/token?grant_type=password&username=${username}&password=${前端密码MD5加密后的密码}&scope=all |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
@Component |
|||
public class PasswordAuthenticator extends AuthenticatorAdapter{ |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
package com.mdp.login.integration.authenticator; |
|||
|
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.utils.ObjectTools; |
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.util.LockUtil; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.reactive.function.client.WebClientResponseException; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 默认登录处理,密码方式 |
|||
* 格式 url: http://${domain}/api/m1/oauth2/oauth/token?grant_type=password&username=${username}&password=${前端密码MD5加密后的密码}&scope=all |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
@Component |
|||
public class PasswordDisplayUseridAuthenticator extends AuthenticatorAdapter{ |
|||
|
|||
|
|||
|
|||
@Override |
|||
public User authenticate(IntegrationParams integrationParams) { |
|||
User user= getByUserloginid(integrationParams.getUserloginid(),integrationParams); |
|||
|
|||
if(user!=null && "1".equals(user.get("locked"))){ |
|||
String lockType= (String) user.get("lockType"); |
|||
String lockRemark= (String) user.get("lockRemark"); |
|||
String statusText= LockUtil.getLockMsgByLockType(lockType); |
|||
if(!StringUtils.hasText(statusText)){ |
|||
statusText="lock-type-9 账户已锁定"; |
|||
} |
|||
HttpHeaders httpHeaders=new HttpHeaders(); |
|||
throw new WebClientResponseException(401,statusText, httpHeaders,statusText.getBytes() ,null,null); |
|||
//throw new OAuth2AuthenticationException(new OAuth2Error("user-locked","账户锁定,请检查是否已验证邮箱",null)); |
|||
}else if(user!=null && !"1".equals(user.get("locked"))){ |
|||
if(("1".equals(user.getMemType()) || "2".equals(user.getMemType()) ) && StringUtils.hasText(user.getOrgId()) && "1".equals(user.getCpaOrg())){//如果是机构会员,检查机构是否可用 |
|||
Map<String,Object> org= getByUserloginid(integrationParams.getUserloginid(),integrationParams); |
|||
String lockType=""; |
|||
if(org==null || org.isEmpty() ){ |
|||
lockType="7"; |
|||
}else if(!"1".equals(org.get("orgStatus"))){ |
|||
lockType="8"; |
|||
} |
|||
if(StringUtils.hasText(lockType)){ |
|||
String statusText= LockUtil.getLockMsgByLockType(lockType); |
|||
if(!StringUtils.hasText(statusText)){ |
|||
statusText="lock-type-L 账户已锁定 "; |
|||
} |
|||
HttpHeaders httpHeaders=new HttpHeaders(); |
|||
throw new WebClientResponseException(401,statusText, httpHeaders,statusText.getBytes() ,null,null); |
|||
} |
|||
|
|||
} |
|||
} |
|||
String password= (String) integrationParams.getDatas().get("password"); |
|||
if(ObjectTools.isEmpty(password)){ |
|||
throw new BizException("password-required","密码不能为空"); |
|||
} |
|||
if(!passwordEncoder.matches(password,user.getPassword())){ |
|||
throw new BizException("password-error","密码不正确"); |
|||
} |
|||
return user; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 查找用户基础信息 |
|||
* @param displayUserid 前台登陆编号 |
|||
* @return |
|||
*/ |
|||
public User getByUserloginid(String displayUserid,IntegrationParams integrationParams){ |
|||
List<User> users= userBaseInfoQueryService.queryByUserloginid(displayUserid,"all",integrationParams.getDatas()); |
|||
//为了测试方便,将密码设置为与前端上送的密码一致 |
|||
//user.setPassword(passwordEncoder.encode(integrationParams.getAuthParameter("password"))); |
|||
return users!=null && users.size()>0?users.get(0):null; |
|||
} |
|||
|
|||
@Override |
|||
public boolean supportAuthType(IntegrationParams integrationParams) { |
|||
return AuthType.password_display_userid.name().equals(integrationParams.getAuthType()); |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
package com.mdp.login.integration.authenticator.email; |
|||
|
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.integration.authenticator.AuthenticatorAdapter; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 短信验证码登录,也可以认为是密码登录的一种扩展 |
|||
* 格式 url: http://${domain}/api/m1/oauth2/oauth/token?grant_type=password&username=${手机号码}&password=${用户收到的短信验证码明文}&scope=all&auth_type=sms |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
@Component |
|||
public class EmailAuthenticator extends AuthenticatorAdapter { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
SysUserQueryService userBaseInfoQueryService; |
|||
|
|||
/** |
|||
* 查找用户基础信息 |
|||
* @param userloginid 登录账户 |
|||
* @return |
|||
*/ |
|||
public User getByUserloginid(String userloginid, IntegrationParams integrationParams){ |
|||
String userid=integrationParams.getAuthParameter("userid"); |
|||
if(StringUtils.hasText(userid)){ |
|||
User user=userBaseInfoQueryService.getUserByUserid(userid, integrationParams.getDatas()); |
|||
if(user!=null && userloginid.equals(user.getEmail())){ |
|||
return user; |
|||
} |
|||
return null; |
|||
} |
|||
List<User> users= userBaseInfoQueryService.queryByUserloginid(userloginid,"email",integrationParams.getDatas()); |
|||
if(users!=null && users.size()>0){ |
|||
if(users.size()==1){ |
|||
return users.get(0); |
|||
}else{ |
|||
for (User user : users) { |
|||
if(userloginid.equals(user.getEmail())){ |
|||
return user; |
|||
} |
|||
} |
|||
} |
|||
return users.get(0); |
|||
}else{ |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void prepare(IntegrationParams integrationParams) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public User authenticate(IntegrationParams integrationParams) { |
|||
User user= this.getByUserloginid(integrationParams.getUserloginid(),integrationParams); |
|||
if(user==null){ |
|||
return null; |
|||
} |
|||
/** |
|||
* 将短信验证码当作密码,加一次密,否则上层密码匹配不通过 |
|||
*/ |
|||
user.setPassword(this.passwordEncoder.encode(integrationParams.getAuthParameter("password"))); |
|||
return user; |
|||
} |
|||
|
|||
@Override |
|||
public boolean supportAuthType(IntegrationParams integrationParams) { |
|||
return AuthType.email.name().equals(integrationParams.getAuthType()); |
|||
} |
|||
|
|||
@Override |
|||
public void complete(IntegrationParams integrationParams) { |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,98 @@ |
|||
package com.mdp.login.integration.authenticator.sms; |
|||
|
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.integration.authenticator.AuthenticatorAdapter; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.login.service.client.SmsClientService; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 短信验证码登录,也可以认为是密码登录的一种扩展 |
|||
* 格式 url: http://${domain}/api/m1/oauth2/oauth/token?grant_type=password&username=${手机号码}&password=${用户收到的短信验证码明文}&scope=all&auth_type=sms |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
@Component |
|||
public class SmsAuthenticator extends AuthenticatorAdapter { |
|||
|
|||
@Autowired |
|||
SmsClientService smsClientService; |
|||
|
|||
@Autowired |
|||
SysUserQueryService userBaseInfoQueryService; |
|||
|
|||
/** |
|||
* 查找用户基础信息 |
|||
* @param phoneno 手机号码 |
|||
* @return |
|||
*/ |
|||
public User getByUserloginid(String phoneno, IntegrationParams integrationParams){ |
|||
String userid=integrationParams.getAuthParameter("userid"); |
|||
if(StringUtils.hasText(userid)){ |
|||
User user=userBaseInfoQueryService.getUserByUserid(userid,integrationParams.getDatas()); |
|||
if(user!=null && phoneno.equals(user.getPhoneno()) ){ |
|||
return user; |
|||
} |
|||
return null; |
|||
} |
|||
List<User> users= userBaseInfoQueryService.queryByUserloginid(phoneno,"phoneno",integrationParams.getDatas()); |
|||
if(users!=null && users.size()>0){ |
|||
if(users.size()==1){ |
|||
return users.get(0); |
|||
}else{ |
|||
for (User user : users) { |
|||
if(phoneno.equals(user.getPhoneno())){ |
|||
return user; |
|||
} |
|||
} |
|||
} |
|||
return users.get(0); |
|||
}else{ |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void prepare(IntegrationParams integrationParams) { |
|||
//todo 为了开发,暂时默认通过 |
|||
Tips tips=new Tips(); |
|||
tips=smsClientService.validateSmsCodeFromCache(integrationParams.getUserloginid(),integrationParams.getAuthParameter("password")); |
|||
if(tips!=null && tips.isOk()){//验证通过 |
|||
|
|||
}else{ |
|||
throw new BizException("短信验证码不正确"); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public User authenticate(IntegrationParams integrationParams) { |
|||
User user= this.getByUserloginid(integrationParams.getUserloginid(),integrationParams); |
|||
if(user==null){ |
|||
return null; |
|||
} |
|||
/** |
|||
* 将短信验证码当作密码,加一次密,否则上层密码匹配不通过 |
|||
*/ |
|||
user.setPassword(this.passwordEncoder.encode(integrationParams.getAuthParameter("password"))); |
|||
return user; |
|||
} |
|||
|
|||
@Override |
|||
public boolean supportAuthType(IntegrationParams integrationParams) { |
|||
return AuthType.sms.name().equals(integrationParams.getAuthType()); |
|||
} |
|||
|
|||
@Override |
|||
public void complete(IntegrationParams integrationParams) { |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,90 @@ |
|||
package com.mdp.login.integration.authenticator.webchat.miniapp; |
|||
|
|||
|
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.integration.authenticator.AuthenticatorAdapter; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.safe.client.cache.TpaCodeRedisCacheService; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 小程序集成认证 |
|||
* |
|||
* 格式 url: http://${domain}/api/m1/oauth2/oauth/token?grant_type=password&username=${从微信服务器获得的openid}&password=${从微信服务器获取到的sessionKey}&scope=all&auth_type=wechat_mini_app&userid=${userid}&phoneno=${phoneno} |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
@Service |
|||
public class MiniAppAuthenticator extends AuthenticatorAdapter { |
|||
|
|||
@Autowired |
|||
SysUserQueryService userBaseInfoQueryService; |
|||
|
|||
|
|||
@Autowired |
|||
TpaCodeRedisCacheService tpaCodeRedisCacheService; |
|||
|
|||
@Override |
|||
public User authenticate(IntegrationParams integrationParams) { |
|||
String tpOpenid=integrationParams.getUserloginid(); |
|||
User user= loadUserByOpenid(tpOpenid,integrationParams); |
|||
user.setTpaOpenid(integrationParams.getUserloginid()); |
|||
user.setAuthId(integrationParams.getAuthParameter("authId")); |
|||
/** |
|||
* 将sessionKey当作密码,加一次密,否则上层密码匹配不通过 |
|||
*/ |
|||
user.setPassword(this.passwordEncoder.encode(integrationParams.getAuthParameter("password"))); |
|||
return user; |
|||
} |
|||
|
|||
/** |
|||
* 查找用户基础信息 |
|||
* @param openid 从微信服务器获取的openid |
|||
* @return |
|||
*/ |
|||
public User loadUserByOpenid(String openid ,IntegrationParams integrationParams){ |
|||
String userid=integrationParams.getAuthParameter("userid"); |
|||
if(StringUtils.hasText(userid)){ |
|||
User user=userBaseInfoQueryService.getUserByUserid(userid, integrationParams.getDatas()); |
|||
return user; |
|||
} |
|||
List<User> users= userBaseInfoQueryService.queryByUserloginid(openid,"tpaOpenid",integrationParams.getDatas()); |
|||
if(users!=null && users.size()>0){ |
|||
if(users.size()==1){ |
|||
return users.get(0); |
|||
}else{ |
|||
for (User user : users) { |
|||
if("0".equals(user.getMemType())){ |
|||
return user; |
|||
} |
|||
} |
|||
} |
|||
return users.get(0); |
|||
}else{ |
|||
return null; |
|||
} |
|||
} |
|||
@Override |
|||
public void prepare(IntegrationParams integrationParams) { |
|||
String code=integrationParams.getAuthParameter("password"); |
|||
if(!StringUtils.hasText(code)){ |
|||
throw new BizException("从微信服务器获取的密码串为空"); |
|||
} |
|||
String redisCode=tpaCodeRedisCacheService.get(code); |
|||
if(!StringUtils.hasText(redisCode) || !code.equals(redisCode)){ |
|||
throw new BizException("未验证通过"); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public boolean supportAuthType(IntegrationParams integrationParams) { |
|||
return AuthType.wechat_mini_app.name().equals(integrationParams.getAuthType()); |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
package com.mdp.login.integration.authenticator.wechat.wxpub; |
|||
|
|||
|
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.integration.authenticator.AuthenticatorAdapter; |
|||
import com.mdp.login.service.SysUserQueryService; |
|||
import com.mdp.safe.client.cache.TpaCodeRedisCacheService; |
|||
import com.mdp.safe.client.dict.AuthType; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 微信公众号集成认证 |
|||
* @author chenyc |
|||
* @date 2021-01-12 |
|||
**/ |
|||
@Service |
|||
public class WxpubAuthenticator extends AuthenticatorAdapter { |
|||
|
|||
@Autowired |
|||
SysUserQueryService userBaseInfoQueryService; |
|||
|
|||
@Autowired |
|||
TpaCodeRedisCacheService tpaCodeRedisCacheService; |
|||
|
|||
@Override |
|||
public User authenticate(IntegrationParams integrationParams) { |
|||
String tpaOpenid=integrationParams.getUserloginid(); |
|||
User user= loadUserByOpenid(tpaOpenid,integrationParams); |
|||
user.setTpaOpenid(integrationParams.getUserloginid()); |
|||
user.setAuthId(integrationParams.getAuthParameter("authId")); |
|||
/** |
|||
* 将sessionKey当作密码,加一次密,否则上层密码匹配不通过 |
|||
*/ |
|||
user.setPassword(this.passwordEncoder.encode(integrationParams.getAuthParameter("password"))); |
|||
return user; |
|||
} |
|||
|
|||
/** |
|||
* 查找用户基础信息 |
|||
* @param openid 从微信服务器获取的openid |
|||
* @return |
|||
*/ |
|||
public User loadUserByOpenid(String openid ,IntegrationParams integrationParams){ |
|||
String userid=integrationParams.getAuthParameter("userid"); |
|||
if(StringUtils.hasText(userid)){ |
|||
User user=userBaseInfoQueryService.getUserByUserid(userid, integrationParams.getDatas()); |
|||
return user; |
|||
} |
|||
List<User> users= userBaseInfoQueryService.queryByUserloginid(openid,"tpaOpenid",integrationParams.getDatas()); |
|||
if(users!=null && users.size()>0){ |
|||
if(users.size()==1){ |
|||
return users.get(0); |
|||
}else{ |
|||
for (User user : users) { |
|||
if("0".equals(user.getMemType())){ |
|||
return user; |
|||
} |
|||
} |
|||
} |
|||
return users.get(0); |
|||
}else{ |
|||
return null; |
|||
} |
|||
} |
|||
@Override |
|||
public void prepare(IntegrationParams integrationParams) { |
|||
String code=integrationParams.getAuthParameter("password"); |
|||
if(!StringUtils.hasText(code)){ |
|||
throw new BizException("从微信服务器获取的密码串为空"); |
|||
} |
|||
String redisCode=tpaCodeRedisCacheService.get(code); |
|||
if(!StringUtils.hasText(redisCode) || !code.equals(redisCode)){ |
|||
throw new BizException("未验证通过"); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public boolean supportAuthType(IntegrationParams integrationParams) { |
|||
return AuthType.wechat_wxpub.name().equals(integrationParams.getAuthType()); |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
package com.mdp.login.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.login.entity.SysUser; |
|||
import com.mdp.safe.client.entity.*; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface SysUserMapper extends BaseMapper<SysUser> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
List<User> queryByUserloginid(User user); |
|||
|
|||
List<DeptPostRole> loadUserDeptPostRolesByUserid(Map<String,Object> params); |
|||
|
|||
List<User> queryMyUsers(User cuser); |
|||
|
|||
List<Qx> getRoleQxs(String roleid); |
|||
|
|||
Role getRole(String roleid); |
|||
|
|||
Map<String, Object> getDept(String deptid); |
|||
|
|||
Branch getBranch(String branchId); |
|||
|
|||
List<Menu> getRoleMenus(String roleid); |
|||
|
|||
List<Post> loadUserPostsByUserid(String userid); |
|||
|
|||
int updateUserPassword(User user); |
|||
|
|||
|
|||
void unregister(User user); |
|||
} |
|||
|
|||
@ -0,0 +1,125 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.login.mapper.SysUserMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from sys_user res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
<select id="queryByUserloginid" parameterType="com.mdp.safe.client.entity.User" resultType="com.mdp.safe.client.entity.User"> |
|||
select if(u.mem_type='0',u.ilvl_id,c.ilvl_id) as ilvl_id,if(u.mem_type='0',u.ilvl_name,c.ilvl_name) as ilvl_name, u.*,b.branch_name,b.enabled from sys_user u left join sys_branch b on u.branch_id=b.id left join sys_branch_interests c on u.branch_id=c.branch_id |
|||
<where> |
|||
<if test="userid!=null and userid !='' ">and u.userid=#{userid}</if> |
|||
<if test="displayUserid!=null and displayUserid !='' ">and u.display_userid=#{displayUserid}</if> |
|||
<if test="email!=null and email !='' ">and (u.email=#{email} or u.email_bak=#{email})</if> |
|||
<if test="phoneno!=null and phoneno !='' ">and u.phoneno=#{phoneno}</if> |
|||
<if test="atype!=null and atype !='' ">and u.atype=#{atype}</if> |
|||
<if test="memType!=null and memType !='' ">and u.mem_type=#{memType}</if> |
|||
<if test="branchId!=null and branchId !='' ">and u.branch_id=#{branchId}</if> |
|||
<if test="cpaOrg!=null and cpaOrg !='' ">and u.cpa_org=#{cpaOrg}</if> |
|||
<if test="cpaType!=null and cpaType !='' ">and u.cpa_type=#{cpaType}</if> |
|||
<if test="tpaOpenid!=null and tpaOpenid !='' "> |
|||
and exists( |
|||
select 1 from sys_user_tpa tpa where tpa.openid=#{tpaOpenid} and tpa.userid=u.userid |
|||
) |
|||
|
|||
</if> |
|||
<if test="(codeScene!=null and codeScene!='') or (valiCode !=null and valiCode!='') or (codeEmail !=null and codeEmail!='')"> |
|||
and exists ( select 1 from sys_user_valid_code res |
|||
|
|||
<where> |
|||
<if test="userid != null and userid != ''"> and res.userid = #{userid} </if> |
|||
<if test="valiCode != null and valiCode != ''"> and res.vali_code = #{valiCode} and res.userid=u.userid </if> |
|||
<if test="codeSendTime != null"> and date_format(res.code_send_time,'%Y-%m-%d') = date_format(#{codeSendTime},'%Y-%m-%d') </if> |
|||
<if test="codeEmail != null and codeEmail != ''"> and res.code_email = #{codeEmail} </if> |
|||
<if test="codeScene != null and codeScene != ''"> and res.code_scene = #{codeScene} </if> |
|||
<if test="codeValidTime != null"> and date_format(res.code_valid_time,'%Y-%m-%d') = date_format(#{codeValidTime},'%Y-%m-%d') </if> |
|||
</where> |
|||
) |
|||
</if> |
|||
<if test="idType=='all' and userloginid!=null and userloginid!=''"> |
|||
and (userid=#{userloginid} or phoneno=#{userloginid} or email=#{userloginid} or display_userid=#{userloginid}) |
|||
</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="queryMyUsers" parameterType="com.mdp.safe.client.entity.User" resultType="com.mdp.safe.client.entity.User"> |
|||
select u.*,b.branch_name,b.enabled from sys_user u left join sys_branch b on u.branch_id=b.id |
|||
where exists (select 1 from sys_user u2 where u2.userid=#{userid} and ( u2.unionid=ifnull(u.unionid,'xxxxx') or u2.phoneno=ifnull(u.phoneno,'111') or u2.email=ifnull(u.email,'1111'))) |
|||
|
|||
</select> |
|||
|
|||
<!--根据用户编号查询所有的角色 返回 list<Map> add by chenyc 20160223 |
|||
支持根据用户编号+机构号查,或者用户编号+部门号查,或者只根据用户编号查,或者用户编号+机构号+部门号同时查 |
|||
--> |
|||
<select id="loadUserDeptPostRolesByUserid" parameterType="HashMap" resultType="com.mdp.safe.client.entity.DeptPostRole"> |
|||
select r.roleid,r.rolename,d.branch_id,r.roletype,r.data_lvl,dpu.deptid,d.dept_name,b.branch_name, |
|||
dpu.post_id,dpu.master |
|||
from sys_dept_post_user dpu |
|||
inner join sys_post_role pr on dpu.post_id=pr.post_id |
|||
inner join sys_role r on pr.roleid=r.roleid |
|||
inner join sys_dept d on d.deptid=dpu.deptid |
|||
inner JOIN sys_branch b ON b.id = d.branch_id |
|||
<where> |
|||
dpu.userid=#{userid} |
|||
<if test=" branchId != '' and branchId !=null "> and d.branch_id=#{branchId}</if> |
|||
<if test=" branchId != '' and branchId !=null "> |
|||
and (r.branch_id=#{branchId} or (r.branch_id = #{platformBranchId} and r.roletype='1') ) |
|||
</if> |
|||
<if test=" deptid !='' and deptid !=null " > and dpu.deptid=#{deptid}</if> |
|||
</where> |
|||
|
|||
order by r.sort_order asc |
|||
</select> |
|||
<select id="loadUserPostsByUserid" parameterType="String" resultType="com.mdp.safe.client.entity.Post"> |
|||
select distinct d.branch_id,dpu.deptid,d.dept_name,b.branch_name,dpu.post_id,p.post_name |
|||
from sys_dept_post_user dpu |
|||
inner join sys_post p on p.id=dpu.post_id |
|||
inner join sys_dept d on d.deptid=dpu.deptid |
|||
inner JOIN sys_branch b ON b.id = d.branch_id |
|||
where dpu.userid=#{userid} |
|||
</select> |
|||
|
|||
<select id="getRoleQxs" parameterType="HashMap" resultType="com.mdp.safe.client.entity.Qx"> |
|||
select * from sys_qx qx |
|||
where exists ( |
|||
select 1 from sys_role_qx rq where rq.roleid=#{roleid} |
|||
) |
|||
</select> |
|||
<select id="getRole" parameterType="HashMap" resultType="com.mdp.safe.client.entity.Role"> |
|||
select * from sys_role r |
|||
where r.roleid=#{roleid} |
|||
</select> |
|||
|
|||
<select id="getDept" parameterType="HashMap" resultType="HashMap"> |
|||
select * from sys_dept d where d.deptid=#{deptid} |
|||
</select> |
|||
|
|||
|
|||
<select id="getBranch" parameterType="HashMap" resultType="com.mdp.safe.client.entity.Branch"> |
|||
select b.id branch_id,b.* from sys_branch b where b.id=#{branchId} |
|||
</select> |
|||
|
|||
<select id="getRoleMenus" parameterType="HashMap" resultType="com.mdp.safe.client.entity.Menu"> |
|||
select * from menu_def m |
|||
where exists( |
|||
select 1 from menu_role mr where mr.mid=m.id and mr.roleid=#{roleid} |
|||
) |
|||
|
|||
</select> |
|||
<update id="updateUserPassword" parameterType="com.mdp.safe.client.entity.User"> |
|||
update sys_user set password = #{password},pwd_strong = #{pwdStrong} |
|||
<where> |
|||
<if test="phoneno != null and phoneno != ''">and phoneno=#{phoneno}</if> |
|||
<if test="userid != null and userid != ''">and userid=#{userid}</if> |
|||
<if test="email != null and email != ''"> and (email = #{email} or email_bak = #{email} </if> |
|||
</where> |
|||
</update> |
|||
|
|||
<update id="unregister" parameterType="com.mdp.safe.client.entity.User"> |
|||
update sys_user set ustatus='2' |
|||
where userid = #{userid} |
|||
</update> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.login.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.login.entity.ValidCode; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface ValidCodeMapper extends BaseMapper<ValidCode> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.login.mapper.ValidCodeMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from sys_user_valid_code res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,52 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.mail.javamail.JavaMailSender; |
|||
import org.springframework.mail.javamail.MimeMessageHelper; |
|||
import org.springframework.scheduling.annotation.Async; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.mail.internet.MimeMessage; |
|||
import java.util.Date; |
|||
|
|||
@Service |
|||
public class LoginEmailService { |
|||
|
|||
@Autowired |
|||
JavaMailSender javaMailSender; |
|||
|
|||
/** |
|||
* 普通邮件发送 |
|||
*/ |
|||
@Async |
|||
public void sendSimpleMail(String subject,String formEmail,String toEmail,String text) { |
|||
// 构建一个邮件对象 |
|||
MimeMessage message = javaMailSender.createMimeMessage(); |
|||
|
|||
|
|||
// 设置邮件主题 |
|||
try { |
|||
MimeMessageHelper mimeMessageHelper=new MimeMessageHelper(message,true); |
|||
mimeMessageHelper.setSubject(subject); |
|||
mimeMessageHelper.setFrom(formEmail); |
|||
// 设置邮件发送者,这个跟application.yml中设置的要一致 |
|||
// 设置邮件接收者,可以有多个接收者,中间用逗号隔开,以下类似 |
|||
// message.setTo("10*****16@qq.com","12****32*qq.com"); |
|||
mimeMessageHelper.setTo(toEmail); |
|||
mimeMessageHelper.setSubject(subject); |
|||
// 设置邮件抄送人,可以有多个抄送人 |
|||
//message.setCc("12****32*qq.com"); |
|||
// 设置隐秘抄送人,可以有多个 |
|||
//message.setBcc("7******9@qq.com"); |
|||
// 设置邮件发送日期 |
|||
mimeMessageHelper.setSentDate(new Date()); |
|||
// 设置邮件的正文 |
|||
mimeMessageHelper.setText(text,true); |
|||
// 发送邮件 |
|||
javaMailSender.send(message); |
|||
}catch (Exception e){ |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.sms.client.api.SmsCodeService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class SmsLoginService { |
|||
|
|||
@Autowired |
|||
SmsCodeService smsCodeService; |
|||
/** |
|||
* |
|||
* 验证短信验证码是否正确 |
|||
* @param phoneno 手机号码 |
|||
* @param smsCode 短信验证码 |
|||
* @return |
|||
*/ |
|||
public Tips checkPhoneCode(String phoneno, String smsCode ){ |
|||
return smsCodeService.validateSmsCodeUseCache(phoneno,smsCode,"login"); |
|||
} |
|||
} |
|||
@ -0,0 +1,119 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.login.mapper.SysUserMapper; |
|||
import com.mdp.plat.client.PlatClientService; |
|||
import com.mdp.plat.client.entity.PlatformVo; |
|||
import com.mdp.safe.client.entity.DeptPostRole; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.service.remote.UserBaseInfoRemoteQueryService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class SysUserQueryService implements UserBaseInfoRemoteQueryService{ |
|||
|
|||
@Autowired |
|||
SysUserMapper sysUserMapper; |
|||
|
|||
|
|||
@Autowired |
|||
private PlatClientService platClientService; |
|||
|
|||
|
|||
@Override |
|||
public List<User> queryByUserloginid(String userloginid, String idType, Map<String, Object> extParams) { |
|||
User user= new User(); |
|||
user.putAll(extParams); |
|||
if(!StringUtils.hasText(idType)||"all".equals(idType)){ |
|||
user.put("userloginid",userloginid); |
|||
user.put("idType","all"); |
|||
}else if("userid".equals(idType)){ |
|||
user.setUserid(userloginid); |
|||
}else if("phoneno".equals(idType)){ |
|||
user.setPhoneno(userloginid); |
|||
}else if("displayUserid".equals(idType)){ |
|||
user.setDisplayUserid(userloginid); |
|||
}else if("email".equals(idType)){ |
|||
user.setEmail(userloginid); |
|||
}else if("tpaOpenid".equals(idType)){ |
|||
user.setTpaOpenid(userloginid); |
|||
}else if("unionid".equals(idType)){ |
|||
user.setUnionid(userloginid); |
|||
}else{ |
|||
throw new BizException("idType-err","登录参数类型错误"); |
|||
} |
|||
|
|||
user.setUserType((String) extParams.get("userType")); |
|||
return sysUserMapper.queryByUserloginid(user); |
|||
} |
|||
|
|||
@Override |
|||
public User getUserByUserid(String userid, Map<String, Object> extParams) { |
|||
User user= new User(); |
|||
user.setUserid(userid); |
|||
user.setUserType((String) extParams.get("userType")); |
|||
List<User> users=sysUserMapper.queryByUserloginid(user); |
|||
if(users!=null && users.size()>0){ |
|||
return users.get(0); |
|||
}else{ |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public List<DeptPostRole> getUserDeptPostRoles(String userid, Map<String, Object> extParams) { |
|||
Map<String,Object> params = new HashMap<>(); |
|||
params.put("userid",userid); |
|||
params.put("platformBranchId",getPlatformBranchId()); |
|||
if(extParams!=null && extParams.containsKey("deptid")){ |
|||
params.put("deptid",extParams.get("deptid")); |
|||
} |
|||
if(extParams!=null && extParams.containsKey("branchId")){ |
|||
params.put("branchId",extParams.get("branchId")); |
|||
} |
|||
return this.sysUserMapper.loadUserDeptPostRolesByUserid(params); |
|||
} |
|||
|
|||
/** |
|||
* 根据邮箱验证码查找用户信息 |
|||
* |
|||
* @param valiCode |
|||
* @param userType |
|||
* @return |
|||
*/ |
|||
public List<User> getUserByEmailCode(String userid, String codeEmail, String valiCode,String userType) { |
|||
|
|||
User userQ= new User(); |
|||
userQ.setUserid(userid); |
|||
userQ.setEmail(codeEmail); |
|||
userQ.put("codeEmail",codeEmail); |
|||
userQ.put("valiCode",valiCode); |
|||
userQ.setUserType(userType); |
|||
return sysUserMapper.queryByUserloginid(userQ); |
|||
} |
|||
|
|||
public void setUserTypeToUser(String userType,User user){ |
|||
if(user==null){ |
|||
return; |
|||
} |
|||
if(StringUtils.hasText(userType) ){ |
|||
user.setUserType(userType); |
|||
}else{ |
|||
user.setUserType("staff"); |
|||
} |
|||
} |
|||
public String getPlatformBranchId(){ |
|||
PlatformVo platformVo=platClientService.getPlatformVo(); |
|||
return platformVo.getBranchId(); |
|||
} |
|||
|
|||
public List<User> queryMyUsers(User cuser) { |
|||
return this.sysUserMapper.queryMyUsers(cuser); |
|||
} |
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import com.mdp.core.utils.BaseUtils; |
|||
import com.mdp.login.mapper.SysUserMapper; |
|||
import com.mdp.safe.client.entity.*; |
|||
import com.mdp.safe.client.service.remote.DefaultUserResourceRemoteService; |
|||
import com.mdp.safe.client.service.remote.UserResourceRemoteService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 覆盖默认的远程访问接口,由本地数据库提供相关数据 |
|||
* @see DefaultUserResourceRemoteService |
|||
*/ |
|||
@Service |
|||
public class SysUserResourceService implements UserResourceRemoteService { |
|||
|
|||
@Autowired |
|||
SysUserMapper sysUserMapper; |
|||
|
|||
@Override |
|||
public Map<String, Qx> getRoleQxsFromRemote(String roleid) { |
|||
Map<String, Qx> qxMap=new HashMap<>(); |
|||
if( !StringUtils.hasText(roleid) || roleid.startsWith("SCOPE_")){ |
|||
return qxMap; |
|||
} |
|||
List<Qx> qxList=sysUserMapper.getRoleQxs(roleid); |
|||
|
|||
for (Qx qx : qxList) { |
|||
qxMap.put(qx.getQxId(),qx); |
|||
} |
|||
return qxMap; |
|||
} |
|||
|
|||
@Override |
|||
public Role getRoleFromRemote(String roleid) { |
|||
if( !StringUtils.hasText(roleid) || roleid.startsWith("SCOPE_")){ |
|||
return null; |
|||
} |
|||
Role role=sysUserMapper.getRole(roleid); |
|||
return role; |
|||
} |
|||
|
|||
@Override |
|||
public Dept getDeptFromRemote(String deptid) { |
|||
Map<String,Object> deptMap=sysUserMapper.getDept(deptid); |
|||
if(deptMap==null||deptMap.isEmpty()){ |
|||
return null; |
|||
} |
|||
Dept dept= BaseUtils.fromMap(deptMap,Dept.class); |
|||
return dept; |
|||
} |
|||
|
|||
@Override |
|||
public Branch getBranchFromRemote(String branchId) { |
|||
Branch branch=sysUserMapper.getBranch(branchId); |
|||
return branch; |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, Menu> getRoleMenusFromRemote(String roleid) { |
|||
Map<String, Menu> menuMap=new HashMap<>(); |
|||
if( !StringUtils.hasText(roleid) || roleid.startsWith("SCOPE_")){ |
|||
return menuMap; |
|||
} |
|||
List<Menu> menuList=sysUserMapper.getRoleMenus(roleid); |
|||
for (Menu menu : menuList) { |
|||
menuMap.put(menu.getId(),menu); |
|||
} |
|||
return menuMap; |
|||
} |
|||
|
|||
@Override |
|||
public List<Post> getPostsFromRemote(String userid) { |
|||
return sysUserMapper.loadUserPostsByUserid(userid); |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.core.utils.BaseUtils; |
|||
import com.mdp.login.entity.SysUser; |
|||
import com.mdp.login.mapper.SysUserMapper; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mdp 大模块 oauth2.client.user 小模块 <br> |
|||
* 实体 SysUser 表 sys_user 当前主键(包括多主键): userid; |
|||
***/ |
|||
@Service |
|||
public class SysUserService extends BaseService<SysUserMapper, SysUser> { |
|||
static Logger logger =LoggerFactory.getLogger(SysUserService.class); |
|||
|
|||
|
|||
|
|||
|
|||
public void userRegister(User user) { |
|||
save(BaseUtils.fromMap(user,SysUser.class)); |
|||
} |
|||
|
|||
public void userUpdate(User user) { |
|||
updateById(BaseUtils.fromMap(user,SysUser.class)); |
|||
} |
|||
|
|||
public void updatePassword(User user) { |
|||
baseMapper.updateUserPassword(user); |
|||
} |
|||
|
|||
public void resetPasswordByPhoneno(User user) { |
|||
baseMapper.updateUserPassword(user); |
|||
} |
|||
|
|||
public void resetPasswordByEmail(User user) { |
|||
baseMapper.updateUserPassword(user); |
|||
} |
|||
|
|||
public void userUnregister(User user) { |
|||
baseMapper.unregister(user); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,107 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import com.mdp.login.integration.IntegrationParams; |
|||
import com.mdp.login.integration.IntegrationParamsContext; |
|||
import com.mdp.login.integration.authenticator.IntegrationAuthenticator; |
|||
import com.mdp.qx.DataLvl; |
|||
import com.mdp.safe.client.entity.CommonUserDetails; |
|||
import com.mdp.safe.client.entity.SafeAuthority; |
|||
import com.mdp.safe.client.entity.User; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.security.core.GrantedAuthority; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
import org.springframework.security.core.userdetails.UserDetailsService; |
|||
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
|||
import org.springframework.security.crypto.password.PasswordEncoder; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.HashSet; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
import java.util.concurrent.ConcurrentHashMap; |
|||
|
|||
/** |
|||
* UserDetailsServiceImpl |
|||
* |
|||
* @author chenyc |
|||
* @date 2021/01/11 |
|||
*/ |
|||
@Component |
|||
public class UserDetailsServiceImpl implements UserDetailsService { |
|||
|
|||
Map<String,UserDetails> cache=new ConcurrentHashMap<>(); |
|||
|
|||
private List<IntegrationAuthenticator> authenticators; |
|||
|
|||
@Autowired |
|||
private PasswordEncoder passwordEncoder; |
|||
|
|||
|
|||
|
|||
@Override |
|||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |
|||
IntegrationParams integrationParams = IntegrationParamsContext.get(); |
|||
if(!StringUtils.hasText(integrationParams.getUserloginid())){ |
|||
integrationParams.setUserloginid(username); |
|||
} |
|||
String password=integrationParams.getAuthParameter("password"); |
|||
|
|||
String branchId=integrationParams.getAuthParameter("branchId"); |
|||
String deptid=integrationParams.getAuthParameter("deptid"); |
|||
|
|||
String userType=integrationParams.getUserType(); |
|||
/**String cacheKey=integrationParams.getAuthType()+"_"+integrationParams.getUserloginid()+"_"+password+"_"+branchId+"_"+deptid+"_"+userType; |
|||
CommonUserDetails ud= (CommonUserDetails) cache.get(cacheKey); |
|||
if(ud!=null){ |
|||
return ud; |
|||
} |
|||
**/ |
|||
CommonUserDetails ud=null; |
|||
IntegrationAuthenticator authenticator=this.findIntegrationAuthenticator(integrationParams); |
|||
User user= authenticator.authenticate(integrationParams); |
|||
if(user==null){ |
|||
return null; |
|||
} |
|||
user.setUserType(userType); |
|||
ud=CommonUserDetails.fromUser(user); |
|||
Set<GrantedAuthority> safeAuthorities= (Set<GrantedAuthority>) authenticator.loadAuthorities(user,integrationParams); |
|||
if(safeAuthorities==null || safeAuthorities.isEmpty() || !safeAuthorities.stream().anyMatch(x->x.getAuthority().equals("user"))){ |
|||
SafeAuthority sa=new SafeAuthority(); |
|||
sa.setAuthority("user"); |
|||
sa.setRolename("普通用户"); |
|||
sa.setDataLvl(DataLvl.myDept.getLvl()); |
|||
if(safeAuthorities==null){ |
|||
safeAuthorities=new HashSet<>(); |
|||
} |
|||
safeAuthorities.add(sa); |
|||
} |
|||
ud.setAuthorities(safeAuthorities); |
|||
//cache.put(cacheKey,ud); |
|||
return ud; |
|||
} |
|||
|
|||
|
|||
|
|||
public IntegrationAuthenticator findIntegrationAuthenticator(IntegrationParams integrationParams){ |
|||
if (this.authenticators != null) { |
|||
for (IntegrationAuthenticator authenticator : authenticators) { |
|||
if (authenticator.supportAuthType(integrationParams)) { |
|||
return authenticator; |
|||
} |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
@Autowired(required = false) |
|||
public void setIntegrationAuthenticators(List<IntegrationAuthenticator> authenticators) { |
|||
this.authenticators = authenticators; |
|||
} |
|||
|
|||
@Scheduled(cron = "0 0/5 * * * ?") |
|||
public void clearCache(){ |
|||
cache.clear(); |
|||
} |
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import com.mdp.core.api.Sequence; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.service.remote.UserBaseInfoRemoteOperService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.Date; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class UserOperService implements UserBaseInfoRemoteOperService { |
|||
|
|||
@Autowired |
|||
SysUserService sysUserService; |
|||
|
|||
|
|||
@Autowired |
|||
Sequence sequence; |
|||
|
|||
@Override |
|||
public User userRegister(User user) { |
|||
if(!StringUtils.hasText(user.getUnionid())){ |
|||
if(StringUtils.hasText(user.getUserid())){ |
|||
user.setUnionid(user.getUserid()); |
|||
}else{ |
|||
user.setUserid(sequence.getUserid()); |
|||
user.setUnionid(user.getUnionid()); |
|||
} |
|||
} |
|||
String userType=(String) user.get("userType"); |
|||
user.put("startdate",new Date()); |
|||
|
|||
this.sysUserService.userRegister(user); |
|||
return user; |
|||
} |
|||
|
|||
@Override |
|||
public User userUpdate(User user) { |
|||
user.setPassword(null); |
|||
String userType=(String) user.get("userType"); |
|||
|
|||
this.sysUserService.userUpdate(user); |
|||
return user; |
|||
} |
|||
@Override |
|||
public Tips updatePassword(String userid, String oldPassword, String newPassword, Map<String,Object> extParams) { |
|||
Tips tips = new Tips("修改密码成功"); |
|||
User user=new User(); |
|||
user.setPassword(newPassword); |
|||
user.setUserid(userid); |
|||
user.put("pwdStrong",extParams.get("pwdStrong")); |
|||
String userType=(String) extParams.get("userType"); |
|||
this.sysUserService.updatePassword(user); |
|||
return tips; |
|||
} |
|||
|
|||
@Override |
|||
public Tips resetPasswordByPhoneno(String userid,String phoneno, String smsCode, String newPassword, Map<String,Object> extParams) { |
|||
Tips tips = new Tips("修改密码成功"); |
|||
User user=new User(); |
|||
|
|||
user.setUserid(userid); |
|||
user.setPassword(newPassword); |
|||
user.setPhoneno(phoneno); |
|||
user.put("pwdStrong",extParams.get("pwdStrong")); |
|||
String userType=(String) extParams.get("userType"); |
|||
this.sysUserService.resetPasswordByPhoneno(user); |
|||
return tips; |
|||
} |
|||
|
|||
@Override |
|||
public Tips resetPasswordByEmail(String userid,String email, String valiCode, String newPassword, Map<String,Object> extParams) { |
|||
Tips tips = new Tips("修改密码成功"); |
|||
User user=new User(); |
|||
user.setPassword(newPassword); |
|||
user.setUserid(userid); |
|||
user.put("pwdStrong",extParams.get("pwdStrong")); |
|||
String userType=(String) extParams.get("userType"); |
|||
this.sysUserService.resetPasswordByEmail(user); |
|||
return tips; |
|||
} |
|||
|
|||
|
|||
public void userUpdatePhoneno(User params) { |
|||
User user=new User(); |
|||
user.setUserid(params.getUserid()); |
|||
user.setPhoneno(params.getPhoneno()); |
|||
this.sysUserService.userUpdate(user); |
|||
} |
|||
|
|||
public void userUnregister(User user) { |
|||
this.sysUserService.userUnregister(user); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.mdp.login.service; |
|||
|
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.login.entity.ValidCode; |
|||
import com.mdp.login.mapper.ValidCodeMapper; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mk 大模块 mem 小模块 <br> |
|||
* 实体 MemberValidCode 表 MK.mem_member_valid_code 当前主键(包括多主键): id; |
|||
***/ |
|||
@Service |
|||
public class ValidCodeService extends BaseService<ValidCodeMapper, ValidCode> { |
|||
static Logger logger =LoggerFactory.getLogger(ValidCodeService.class); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,53 @@ |
|||
package com.mdp.login.service.client; |
|||
|
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.sms.client.api.SmsCodeService; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class SmsClientService { |
|||
|
|||
|
|||
@Value(value = "${mdp.sms.validate-sms-code-uri:/sms/sms/sms/validateSmsCode}") |
|||
String smsValidCodeUri=""; |
|||
|
|||
@Autowired |
|||
SmsCodeService smsCodeService; |
|||
|
|||
Log log=LogFactory.getLog(SmsClientService.class); |
|||
|
|||
/** |
|||
* 与短信系统交互验证短信验证码的正确性 |
|||
* @param phoneno |
|||
* @param smsCode |
|||
* @return |
|||
*/ |
|||
public Tips validateSmsCode(String phoneno, String smsCode) { |
|||
return smsCodeService.validateSmsCode(phoneno,smsCode,"login"); |
|||
} |
|||
/** |
|||
* 从缓存中验证验证码是否正确,此方式与sms系统直接交互关系 |
|||
* @param phoneno |
|||
* @param smsCode |
|||
* @return |
|||
*/ |
|||
public Tips validateSmsCodeFromCache(String phoneno, String smsCode) { |
|||
Tips tips = new Tips("检验成功"); |
|||
tips=smsCodeService.validateSmsCodeUseCache(phoneno,smsCode,"login"); |
|||
|
|||
if (tips.isOk()) { |
|||
//验证成功要清空短信验证码,防止第二次验证,不需要这样,过期了就无效了,有效期内可以多次验证,防止多次发短信的情况发生。 |
|||
//smsCodeRedisCacheService.putSmsCode(phoneno, smsCode, "login"); |
|||
//smsCodeService.clearSmsCode(phoneno,smsCode,"login"); |
|||
return tips; |
|||
}else { |
|||
tips.setErrMsg("短信验证码已过期或者未存在"); |
|||
return tips; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package com.mdp.login.util; |
|||
|
|||
import org.springframework.util.StringUtils; |
|||
|
|||
public class LockUtil { |
|||
|
|||
/** |
|||
* |
|||
锁定类型:锁定类型: |
|||
0-注册等待邮箱验证, |
|||
1-注册等待修改初始密码, |
|||
2-注册等待验证手机号码, |
|||
3-密码高风险,等待重新修改密码, |
|||
9-业务需要锁定禁止登录, |
|||
L-账户被锁定,请联系客服, |
|||
7-机构不存在 |
|||
8-机构不存在8-机构账户未启用 |
|||
注意不能超过两位数 |
|||
*/ |
|||
public static String getLockMsgByLockType(String lockType){ |
|||
String statusText=new String(); |
|||
if(!StringUtils.hasText(lockType)){ |
|||
return statusText; |
|||
} |
|||
if("0".equals(lockType)){ |
|||
statusText="注册等待邮箱验证"; |
|||
}else if("1".equals(lockType)){ |
|||
statusText="注册等待修改初始密码"; |
|||
}else if("2".equals(lockType)){ |
|||
statusText="注册等待验证手机号码"; |
|||
}else if("3".equals(lockType)){ |
|||
statusText="密码高风险,等待重新修改密码"; |
|||
}else if("9".equals(lockType)){ |
|||
statusText="业务需要锁定禁止登录"; |
|||
}else if("7".equals(lockType)){ |
|||
statusText="机构账户不存在"; |
|||
}else if("8".equals(lockType)){ |
|||
statusText="机构账户未启用"; |
|||
}else if("L".equals(lockType)){ |
|||
statusText="账户被锁定,请联系客服"; |
|||
}else{ |
|||
statusText="账户被锁定,请联系客服"; |
|||
} |
|||
return statusText; |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
package com.mdp.login.util; |
|||
|
|||
import com.mdp.core.entity.Tips; |
|||
|
|||
import java.time.Instant; |
|||
import java.util.Date; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
public class ValidUtils { |
|||
|
|||
/** |
|||
* 验证邮件格式是否正确 |
|||
* @param email |
|||
* @return |
|||
*/ |
|||
public static Tips validEmail(String email){ |
|||
Tips tips = new Tips("邮件格式验证成功"); |
|||
String reg="^[\\.a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"; |
|||
Pattern pattern=Pattern.compile(reg); |
|||
Matcher matcher=pattern.matcher(email); |
|||
if(matcher.matches()==false){ |
|||
tips.setErrMsg("邮件格式不正确"); |
|||
} |
|||
return tips; |
|||
} |
|||
|
|||
/** |
|||
* 手机号格式验证 |
|||
* @param phoneno |
|||
* @return |
|||
*/ |
|||
public static Tips validPhoneno(String phoneno){ |
|||
Tips tips = new Tips("手机号格式验证成功"); |
|||
String reg="^(\\d{11})$"; |
|||
Pattern pattern=Pattern.compile(reg); |
|||
Matcher matcher=pattern.matcher(phoneno); |
|||
if(matcher.matches()==false){ |
|||
tips.setErrMsg("手机号格式不正确"); |
|||
} |
|||
return tips; |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
String emil="c-_yc@163_-xxx.com"; |
|||
validEmail(emil); |
|||
String phoneno="13610336198"; |
|||
validPhoneno(phoneno); |
|||
Instant instant=Instant.now(); |
|||
Long time=instant.toEpochMilli(); |
|||
|
|||
System.out.println(time); |
|||
Date date=new Date(); |
|||
System.out.println(date.getTime()); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,143 @@ |
|||
package com.mdp.mallm.shop.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.utils.NumberUtil; |
|||
import com.mdp.mallm.shop.entity.Shop; |
|||
import com.mdp.mallm.shop.service.ShopService; |
|||
import com.mdp.plat.entity.Platform; |
|||
import com.mdp.plat.service.PlatformService; |
|||
import com.mdp.qx.HasRole; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.sys.ctrl.BranchController; |
|||
import com.mdp.sys.entity.Branch; |
|||
import com.mdp.sys.entity.Dept; |
|||
import com.mdp.sys.service.BranchService; |
|||
import com.mdp.sys.service.DeptService; |
|||
import io.swagger.annotations.Api; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.CollectionUtils; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController("mdp.mallm.shop.shopController") |
|||
@RequestMapping(value="/**/mallm/shop/shop") |
|||
@Api(tags={"商户信息操作接口"}) |
|||
public class ShopController { |
|||
static Log logger=LogFactory.getLog(BranchController.class); |
|||
|
|||
@Autowired |
|||
private ShopService shopService; |
|||
|
|||
@Autowired |
|||
BranchService branchService; |
|||
|
|||
@Autowired |
|||
DeptService deptService; |
|||
|
|||
@Autowired |
|||
PlatformService platformService; |
|||
|
|||
/** |
|||
* 创建商户 |
|||
* @cdate 2019-7-30 16:41 |
|||
* @author lyk |
|||
* */ |
|||
@RequestMapping(value="/createShop",method=RequestMethod.POST) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
public Result addCategory(@RequestBody Map<String,Object> params) { |
|||
|
|||
|
|||
try { |
|||
|
|||
String shopId= (String) params.get("shopId"); |
|||
if(!StringUtils.hasText(shopId)){ |
|||
return Result.error("shopId-is-null","商户编号不能为空"); |
|||
} |
|||
if(this.shopService.countByWhere(new Shop(shopId))>0){ |
|||
return Result.error("shopId-is-exsts","商户编号已存在,无法创建"); |
|||
}; |
|||
String branchId = (String) params.get("branchId"); |
|||
String deptid=(String)params.get("deptid"); |
|||
if(StringUtils.isEmpty(branchId)) { |
|||
throw new BizException("请传递机构编号"); |
|||
} |
|||
Branch customerQueryBranchObject=new Branch(); |
|||
customerQueryBranchObject.setId(branchId); |
|||
customerQueryBranchObject.setEnabled("1"); |
|||
List<Branch> bracnList=branchService.selectListByWhere(customerQueryBranchObject); |
|||
if(CollectionUtils.isEmpty(bracnList)) { |
|||
throw new BizException("查找不到机构信息"); |
|||
} |
|||
Branch branchResult=bracnList.get(0); |
|||
Dept dept=new Dept(); |
|||
dept.setBranchId(branchResult.getId()); |
|||
dept.setState("A"); |
|||
dept.setDeptid(deptid); |
|||
List<Dept> deptList=deptService.selectListByWhere(dept); |
|||
if(CollectionUtils.isEmpty(deptList)) { |
|||
throw new BizException("查找不到部门信息"); |
|||
} |
|||
Shop shopDb=new Shop(); |
|||
shopDb.setBranchId(branchId); |
|||
if(this.shopService.countByWhere(shopDb)>0){ |
|||
throw new BizException("该机构已存在商户,不能再建立商户"); |
|||
}; |
|||
|
|||
Platform platformQuery=new Platform(); |
|||
platformQuery.setStatus("1"); |
|||
List<Platform> platforms=platformService.selectListByWhere(platformQuery); |
|||
if(platforms==null || platforms.size()==0){ |
|||
return Result.error("platform-is-not-found","未找到平台配置信息,请先配置平台信息"); |
|||
} |
|||
|
|||
if(!StringUtils.hasText(platforms.get(0).getShopId())){ |
|||
return Result.error("platform-not-set-shopId","平台未配置平台商户编号,无法创建商户"); |
|||
} |
|||
if(!StringUtils.hasText(platforms.get(0).getBranchId())){ |
|||
return Result.error("platform-not-set-branchId","平台未配置机构编号,无法创建商户"); |
|||
} |
|||
Platform platform=platforms.get(0); |
|||
shopService.createShop(params,branchResult, deptList.get(0),platform); |
|||
return Result.ok(); |
|||
}catch(Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
/** |
|||
* 创建商户 |
|||
* @cdate 2019-7-30 16:41 |
|||
* @author lyk |
|||
* */ |
|||
//@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listShop(@RequestParam Map<String,Object> params) { |
|||
|
|||
|
|||
try { |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
if(!LoginUtils.isSuperAdmin()){ |
|||
params.put("branchId",user.getBranchId()); |
|||
} |
|||
QueryWrapper<Shop> qw= QueryTools.initQueryWrapper(Shop.class,params); |
|||
IPage page=new Page(NumberUtil.getInteger("pageNum",1),NumberUtil.getInteger("pageSize",1000)); |
|||
List<Map<String,Object>> data=shopService.selectListMapByWhere(page,qw,params); |
|||
return Result.ok().setData( data); |
|||
}catch(Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
package com.mdp.mallm.shop.ctrl; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.utils.NumberUtil; |
|||
import com.mdp.mallm.shop.entity.ShopLocation; |
|||
import com.mdp.mallm.shop.service.ShopLocationService; |
|||
import io.swagger.annotations.Api; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
@RestController("mdp.mall.shop.shopLocationController") |
|||
@RequestMapping(value="/**/mallm/shop/shopLocation") |
|||
@Api(tags={"门店地址表操作接口"}) |
|||
public class ShopLocationController { |
|||
static Log logger=LogFactory.getLog(ShopLocationController.class); |
|||
|
|||
@Autowired |
|||
private ShopLocationService shopLocationService; |
|||
|
|||
|
|||
/** |
|||
* 根据sys的dept表id查询这个部门下面的门店 |
|||
* @author lyk |
|||
* @cdate 2019/9/6 10:09 |
|||
* */ |
|||
@RequestMapping(value="/selectshopLocationBySysDeptId",method=RequestMethod.POST) |
|||
public Result selectshopLocationBySysDeptId(@RequestBody Map<String,Object> params) { |
|||
|
|||
|
|||
IPage page=QueryTools.initPage(params); |
|||
try { |
|||
String branchId=(String)params.get("branchId"); |
|||
String deptid=(String)params.get("deptid"); |
|||
if(StringUtils.isEmpty(branchId)) { |
|||
throw new BizException("请传递branchId"); |
|||
} |
|||
if(params.containsKey("isHeadLocation")){ |
|||
params.put("isHead",params.get("isHeadLocation")); |
|||
} |
|||
QueryWrapper<ShopLocation> qw= QueryTools.initQueryWrapper(ShopLocation.class,params); |
|||
List<Map<String,Object>> result= shopLocationService.selectListMapByWhere(page,qw,params); |
|||
return Result.ok().setData( result); |
|||
}catch(Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,150 @@ |
|||
package com.mdp.mallm.shop.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 mallm.shop 小模块 <br> |
|||
* 实体 Shop所有属性名: <br> |
|||
* "id","店铺编号","admin","管理员","createTime","创建时间","isEnable","是否启用0否1","shopType","服务站类别","shopImage","店铺照片","shopBrand","店铺品牌名称","shopLogo","店铺logo","shopRemark","店铺介绍","deptid","所属机构","branchId","云用户机构编号","logoUrl","上传至第三方服务器后返回的logo","localProtocol","授权函本地存储图片","protocol","授权函ID,即通过","endTime","授权函有效期截止时间(东八区时间,单位为秒),需要与提交的扫描件一致","localAgreement","营业执照或个体工商户营业执照彩照或扫描件","agreementMediaId","营业执照或个体工商户营业执照彩照或扫描件的media_id(即上传第三方服务器返回的id)","localOperator","营业执照内登记的经营者身份证彩照或扫描件","operatorMediaId","营业执照内登记的经营者身份证彩照或扫描件的media_id(即上传第三方服务器返回的id)","appId","子商户的公众号app_id,配置后子商户卡券券面上的app_id为该app_id。注意:该app_id须经过认证","primaryCategoryId","一级类目id,可以通过本文档中接口查询(微信接口)","secondaryCategoryId","二级类目id,可以通过本文档中接口查询(微信接口)","merchantId","子商户id,对于一个母商户公众号下唯一","status","子商户状态,CHECKING","cuser","创建人","ldate","最后操作时间","phoneno","联系电话","lopuserid","最后操作人","bizProcInstId","当前流程实例编号","bizFlowState","当前流程状态","acctPrjType","核算项目platform/shop/location","platBranchId","归属平台机构号","platShopId","归属平台商户号","isJoinPlat","是否加入平台显示","shareLvl","0-门店私有,1-商户私有,所有店铺共享,2-平台共有,所有商户共享","mngUserid","管理员账户","mngUsername","管理员姓名";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("shop") |
|||
@ApiModel(description="商户信息") |
|||
public class Shop implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="店铺编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
@ApiModelProperty(notes="管理员",allowEmptyValue=true,example="",allowableValues="") |
|||
String admin; |
|||
|
|||
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date createTime; |
|||
|
|||
@ApiModelProperty(notes="是否启用0否1",allowEmptyValue=true,example="",allowableValues="") |
|||
String isEnable; |
|||
|
|||
@ApiModelProperty(notes="服务站类别",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopType; |
|||
|
|||
@ApiModelProperty(notes="店铺照片",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopImage; |
|||
|
|||
@ApiModelProperty(notes="店铺品牌名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopBrand; |
|||
|
|||
@ApiModelProperty(notes="店铺logo",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopLogo; |
|||
|
|||
@ApiModelProperty(notes="店铺介绍",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopRemark; |
|||
|
|||
@ApiModelProperty(notes="所属机构",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
@ApiModelProperty(notes="云用户机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="上传至第三方服务器后返回的logo",allowEmptyValue=true,example="",allowableValues="") |
|||
String logoUrl; |
|||
|
|||
@ApiModelProperty(notes="授权函本地存储图片",allowEmptyValue=true,example="",allowableValues="") |
|||
String localProtocol; |
|||
|
|||
@ApiModelProperty(notes="授权函ID,即通过",allowEmptyValue=true,example="",allowableValues="") |
|||
String protocol; |
|||
|
|||
@ApiModelProperty(notes="授权函有效期截止时间(东八区时间,单位为秒),需要与提交的扫描件一致",allowEmptyValue=true,example="",allowableValues="") |
|||
Date endTime; |
|||
|
|||
@ApiModelProperty(notes="营业执照或个体工商户营业执照彩照或扫描件",allowEmptyValue=true,example="",allowableValues="") |
|||
String localAgreement; |
|||
|
|||
@ApiModelProperty(notes="营业执照或个体工商户营业执照彩照或扫描件的media_id(即上传第三方服务器返回的id)",allowEmptyValue=true,example="",allowableValues="") |
|||
String agreementMediaId; |
|||
|
|||
@ApiModelProperty(notes="营业执照内登记的经营者身份证彩照或扫描件",allowEmptyValue=true,example="",allowableValues="") |
|||
String localOperator; |
|||
|
|||
@ApiModelProperty(notes="营业执照内登记的经营者身份证彩照或扫描件的media_id(即上传第三方服务器返回的id)",allowEmptyValue=true,example="",allowableValues="") |
|||
String operatorMediaId; |
|||
|
|||
@ApiModelProperty(notes="子商户的公众号app_id,配置后子商户卡券券面上的app_id为该app_id。注意:该app_id须经过认证",allowEmptyValue=true,example="",allowableValues="") |
|||
String appId; |
|||
|
|||
@ApiModelProperty(notes="一级类目id,可以通过本文档中接口查询(微信接口)",allowEmptyValue=true,example="",allowableValues="") |
|||
String primaryCategoryId; |
|||
|
|||
@ApiModelProperty(notes="二级类目id,可以通过本文档中接口查询(微信接口)",allowEmptyValue=true,example="",allowableValues="") |
|||
String secondaryCategoryId; |
|||
|
|||
@ApiModelProperty(notes="子商户id,对于一个母商户公众号下唯一",allowEmptyValue=true,example="",allowableValues="") |
|||
String merchantId; |
|||
|
|||
@ApiModelProperty(notes="子商户状态,CHECKING",allowEmptyValue=true,example="",allowableValues="") |
|||
String status; |
|||
|
|||
@ApiModelProperty(notes="创建人",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuser; |
|||
|
|||
@ApiModelProperty(notes="最后操作时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date ldate; |
|||
|
|||
@ApiModelProperty(notes="联系电话",allowEmptyValue=true,example="",allowableValues="") |
|||
String phoneno; |
|||
|
|||
@ApiModelProperty(notes="最后操作人",allowEmptyValue=true,example="",allowableValues="") |
|||
String lopuserid; |
|||
|
|||
@ApiModelProperty(notes="当前流程实例编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizProcInstId; |
|||
|
|||
@ApiModelProperty(notes="当前流程状态",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizFlowState; |
|||
|
|||
@ApiModelProperty(notes="核算项目platform/shop/location",allowEmptyValue=true,example="",allowableValues="") |
|||
String acctPrjType; |
|||
|
|||
@ApiModelProperty(notes="归属平台机构号",allowEmptyValue=true,example="",allowableValues="") |
|||
String platBranchId; |
|||
|
|||
@ApiModelProperty(notes="归属平台商户号",allowEmptyValue=true,example="",allowableValues="") |
|||
String platShopId; |
|||
|
|||
@ApiModelProperty(notes="是否加入平台显示",allowEmptyValue=true,example="",allowableValues="") |
|||
String isJoinPlat; |
|||
|
|||
@ApiModelProperty(notes="0-门店私有,1-商户私有,所有店铺共享,2-平台共有,所有商户共享",allowEmptyValue=true,example="",allowableValues="") |
|||
String shareLvl; |
|||
|
|||
@ApiModelProperty(notes="管理员账户",allowEmptyValue=true,example="",allowableValues="") |
|||
String mngUserid; |
|||
|
|||
@ApiModelProperty(notes="管理员姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String mngUsername; |
|||
|
|||
/** |
|||
*店铺编号 |
|||
**/ |
|||
public Shop(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 商户信息 |
|||
**/ |
|||
public Shop() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,211 @@ |
|||
package com.mdp.mallm.shop.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.mdp.core.dao.annotation.TableIds; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 mallm.shop 小模块 <br> |
|||
* 实体 ShopLocation所有属性名: <br> |
|||
* "id","门店编号","shopId","店铺编号","longitude","经度","latitude","纬度","address","地址","rank","服务范围","province","省","city","市","district","区","admin","主负责人","createTime","创建时间","title","门店简称","formatAddress","地址简称","country","国家","districtId","区县编号","deptid","机构编号","branchId","云用户机构编号","businessName","门店名称(仅为商户名,如:国美、麦当劳,不应包含地区、地址、分店名等信息,错误示例:北京国美)","branchName","分店名称(不应包含地区信息,不应与门店名有重复,错误示例:北京王府井店)","telephone","门店的电话(纯数字,区号、分机号均由“-”隔开)","categories","门店的类型(不同级分类用“,”隔开,如:美食,川菜,火锅。详细分类参见附件:微信门店类目表)","offsetType","坐标类型:","recommend","推荐品,餐厅可为推荐菜;酒店为推荐套房;景点为推荐游玩景点等,针对自己行业的推荐内容","special","特色服务,如免费wifi,免费停车,送货上门等商户能提供的特色功能或服务","introduction","商户简介,主要介绍商户信息等","openTime","营业时间,24","avgPrice","人均价格,大于0","status","审核状态","reason","不通过原因","poiId","微信传回的对应id","serialNum","门店编号","admcity","职能城市","admcityCode","职能城市代码","admarea","职能地区","admareaCode","职能地区代码","provinceCode","省份代码","cityCode","城市代码","street","街道","streetCode","街道代码","localtion","定位地址","shopStatus","门店状态:1-预热","labelId","标签id","serviceContent","服务内容","orders","排序","dataStatus","状态:0-正常","cuserid","创建人","lopuserid","最后操作人","lopcreate","最后操作时间","locationType","门店类型:1-直营","regionId","区域编号精确到4级街道或者乡镇","goodsImageShowType","多个商品情况下商品的展示方式(1:三个商品并排,2:两列,第一列放一个商品,第二列两个商品)","bizProcInstId","当前流程实例编号","bizFlowState","当前流程状态","shareLvl","0-门店私有,1-商户私有,所有店铺共享,2-平台共有,所有商户共享","isHead","是否总部店","mngUserid","管理员账户","mngUsername","管理员姓名";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id,shop_id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("shop_location") |
|||
@ApiModel(description="门店地址表") |
|||
public class ShopLocation implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableIds |
|||
@ApiModelProperty(notes="门店编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
@TableIds |
|||
@ApiModelProperty(notes="店铺编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopId; |
|||
|
|||
@ApiModelProperty(notes="经度",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal longitude; |
|||
|
|||
@ApiModelProperty(notes="纬度",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal latitude; |
|||
|
|||
@ApiModelProperty(notes="地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String address; |
|||
|
|||
@ApiModelProperty(notes="服务范围",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal rank; |
|||
|
|||
@ApiModelProperty(notes="省",allowEmptyValue=true,example="",allowableValues="") |
|||
String province; |
|||
|
|||
@ApiModelProperty(notes="市",allowEmptyValue=true,example="",allowableValues="") |
|||
String city; |
|||
|
|||
@ApiModelProperty(notes="区",allowEmptyValue=true,example="",allowableValues="") |
|||
String district; |
|||
|
|||
@ApiModelProperty(notes="主负责人",allowEmptyValue=true,example="",allowableValues="") |
|||
String admin; |
|||
|
|||
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date createTime; |
|||
|
|||
@ApiModelProperty(notes="门店简称",allowEmptyValue=true,example="",allowableValues="") |
|||
String title; |
|||
|
|||
@ApiModelProperty(notes="地址简称",allowEmptyValue=true,example="",allowableValues="") |
|||
String formatAddress; |
|||
|
|||
@ApiModelProperty(notes="国家",allowEmptyValue=true,example="",allowableValues="") |
|||
String country; |
|||
|
|||
@ApiModelProperty(notes="区县编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String districtId; |
|||
|
|||
@ApiModelProperty(notes="机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
@ApiModelProperty(notes="云用户机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="门店名称(仅为商户名,如:国美、麦当劳,不应包含地区、地址、分店名等信息,错误示例:北京国美)",allowEmptyValue=true,example="",allowableValues="") |
|||
String businessName; |
|||
|
|||
@ApiModelProperty(notes="分店名称(不应包含地区信息,不应与门店名有重复,错误示例:北京王府井店)",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchName; |
|||
|
|||
@ApiModelProperty(notes="门店的电话(纯数字,区号、分机号均由“-”隔开)",allowEmptyValue=true,example="",allowableValues="") |
|||
String telephone; |
|||
|
|||
@ApiModelProperty(notes="门店的类型(不同级分类用“,”隔开,如:美食,川菜,火锅。详细分类参见附件:微信门店类目表)",allowEmptyValue=true,example="",allowableValues="") |
|||
String categories; |
|||
|
|||
@ApiModelProperty(notes="坐标类型:",allowEmptyValue=true,example="",allowableValues="") |
|||
String offsetType; |
|||
|
|||
@ApiModelProperty(notes="推荐品,餐厅可为推荐菜;酒店为推荐套房;景点为推荐游玩景点等,针对自己行业的推荐内容",allowEmptyValue=true,example="",allowableValues="") |
|||
String recommend; |
|||
|
|||
@ApiModelProperty(notes="特色服务,如免费wifi,免费停车,送货上门等商户能提供的特色功能或服务",allowEmptyValue=true,example="",allowableValues="") |
|||
String special; |
|||
|
|||
@ApiModelProperty(notes="商户简介,主要介绍商户信息等",allowEmptyValue=true,example="",allowableValues="") |
|||
String introduction; |
|||
|
|||
@ApiModelProperty(notes="营业时间,24",allowEmptyValue=true,example="",allowableValues="") |
|||
String openTime; |
|||
|
|||
@ApiModelProperty(notes="人均价格,大于0",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal avgPrice; |
|||
|
|||
@ApiModelProperty(notes="审核状态",allowEmptyValue=true,example="",allowableValues="") |
|||
String status; |
|||
|
|||
@ApiModelProperty(notes="不通过原因",allowEmptyValue=true,example="",allowableValues="") |
|||
String reason; |
|||
|
|||
@ApiModelProperty(notes="微信传回的对应id",allowEmptyValue=true,example="",allowableValues="") |
|||
String poiId; |
|||
|
|||
@ApiModelProperty(notes="门店编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String serialNum; |
|||
|
|||
@ApiModelProperty(notes="职能城市",allowEmptyValue=true,example="",allowableValues="") |
|||
String admcity; |
|||
|
|||
@ApiModelProperty(notes="职能城市代码",allowEmptyValue=true,example="",allowableValues="") |
|||
String admcityCode; |
|||
|
|||
@ApiModelProperty(notes="职能地区",allowEmptyValue=true,example="",allowableValues="") |
|||
String admarea; |
|||
|
|||
@ApiModelProperty(notes="职能地区代码",allowEmptyValue=true,example="",allowableValues="") |
|||
String admareaCode; |
|||
|
|||
@ApiModelProperty(notes="省份代码",allowEmptyValue=true,example="",allowableValues="") |
|||
String provinceCode; |
|||
|
|||
@ApiModelProperty(notes="城市代码",allowEmptyValue=true,example="",allowableValues="") |
|||
String cityCode; |
|||
|
|||
@ApiModelProperty(notes="街道",allowEmptyValue=true,example="",allowableValues="") |
|||
String street; |
|||
|
|||
@ApiModelProperty(notes="街道代码",allowEmptyValue=true,example="",allowableValues="") |
|||
String streetCode; |
|||
|
|||
@ApiModelProperty(notes="定位地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String localtion; |
|||
|
|||
@ApiModelProperty(notes="门店状态:1-预热",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopStatus; |
|||
|
|||
@ApiModelProperty(notes="标签id",allowEmptyValue=true,example="",allowableValues="") |
|||
String labelId; |
|||
|
|||
@ApiModelProperty(notes="服务内容",allowEmptyValue=true,example="",allowableValues="") |
|||
String serviceContent; |
|||
|
|||
@ApiModelProperty(notes="排序",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal orders; |
|||
|
|||
@ApiModelProperty(notes="状态:0-正常",allowEmptyValue=true,example="",allowableValues="") |
|||
String dataStatus; |
|||
|
|||
@ApiModelProperty(notes="创建人",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
@ApiModelProperty(notes="最后操作人",allowEmptyValue=true,example="",allowableValues="") |
|||
String lopuserid; |
|||
|
|||
@ApiModelProperty(notes="最后操作时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date lopcreate; |
|||
|
|||
@ApiModelProperty(notes="门店类型:1-直营",allowEmptyValue=true,example="",allowableValues="") |
|||
String locationType; |
|||
|
|||
@ApiModelProperty(notes="区域编号精确到4级街道或者乡镇",allowEmptyValue=true,example="",allowableValues="") |
|||
String regionId; |
|||
|
|||
@ApiModelProperty(notes="多个商品情况下商品的展示方式(1:三个商品并排,2:两列,第一列放一个商品,第二列两个商品)",allowEmptyValue=true,example="",allowableValues="") |
|||
String goodsImageShowType; |
|||
|
|||
@ApiModelProperty(notes="当前流程实例编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizProcInstId; |
|||
|
|||
@ApiModelProperty(notes="当前流程状态",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizFlowState; |
|||
|
|||
@ApiModelProperty(notes="0-门店私有,1-商户私有,所有店铺共享,2-平台共有,所有商户共享",allowEmptyValue=true,example="",allowableValues="") |
|||
String shareLvl; |
|||
|
|||
@ApiModelProperty(notes="是否总部店",allowEmptyValue=true,example="",allowableValues="") |
|||
String isHead; |
|||
|
|||
@ApiModelProperty(notes="管理员账户",allowEmptyValue=true,example="",allowableValues="") |
|||
String mngUserid; |
|||
|
|||
@ApiModelProperty(notes="管理员姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String mngUsername; |
|||
|
|||
/** |
|||
*门店编号,店铺编号 |
|||
**/ |
|||
public ShopLocation(String id,String shopId) { |
|||
this.id = id; |
|||
this.shopId = shopId; |
|||
} |
|||
|
|||
/** |
|||
* 门店地址表 |
|||
**/ |
|||
public ShopLocation() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.mallm.shop.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.mallm.shop.entity.ShopLocation; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface ShopLocationMapper extends BaseMapper<ShopLocation> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.mallm.shop.mapper.ShopLocationMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from shop_location res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.mallm.shop.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.mallm.shop.entity.Shop; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface ShopMapper extends BaseMapper<Shop> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.mallm.shop.mapper.ShopMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from shop res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,31 @@ |
|||
package com.mdp.mallm.shop.service; |
|||
|
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.mallm.shop.entity.ShopLocation; |
|||
import com.mdp.mallm.shop.mapper.ShopLocationMapper; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
@Service("mdp.mallm.shop.ShopLocationService") |
|||
@DS("mall-ds") |
|||
public class ShopLocationService extends BaseService<ShopLocationMapper, ShopLocation> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,122 @@ |
|||
package com.mdp.mallm.shop.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.core.utils.DateUtils; |
|||
import com.mdp.mallm.shop.entity.Shop; |
|||
import com.mdp.mallm.shop.entity.ShopLocation; |
|||
import com.mdp.mallm.shop.mapper.ShopMapper; |
|||
import com.mdp.plat.entity.Platform; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.sys.entity.Branch; |
|||
import com.mdp.sys.entity.Dept; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.CollectionUtils; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com.qqkj 顶级模块 mallm 大模块 shop 小模块 <br> |
|||
* 实体 Shop 表 shop 当前主键(包括多主键): id; |
|||
***/ |
|||
|
|||
@Service("mdp.mallm.shop.shopService") |
|||
@DS("mall-ds") |
|||
public class ShopService extends BaseService<ShopMapper,Shop> { |
|||
|
|||
|
|||
@Autowired |
|||
private ShopLocationService locationService; |
|||
/** |
|||
* 创建商户 |
|||
* |
|||
* @cdate 2019-7-30 16:41 |
|||
* @author lyk |
|||
*/ |
|||
@Transactional |
|||
public void createShop(Map<String, Object> params, Branch branch, Dept dept, Platform platform) { |
|||
String shopBrand = (String) params.get("shopBrand"); |
|||
String shopRemark = (String) params.get("shopRemark"); |
|||
String shopLogo = (String) params.get("shopLogo"); |
|||
String shopId=(String)params.get("shopId"); |
|||
Shop shopQuery=new Shop(); |
|||
shopQuery.setBranchId(branch.getId()); |
|||
shopQuery.setDeptid(dept.getDeptid()); |
|||
List<Shop> shopList=this.selectListByWhere(shopQuery); |
|||
if(!CollectionUtils.isEmpty(shopList)) { |
|||
throw new BizException("这个机构下的这个部门已经创建过商户了,不能再创建"); |
|||
} |
|||
Shop shop=new Shop(); |
|||
shop.setId(shopId); |
|||
Date date=DateUtils.getNowDate(); |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
if(StringUtils.hasText(dept.getManager())){ |
|||
shop.setAdmin(dept.getManager()); |
|||
shop.setMngUserid(dept.getManager()); |
|||
shop.setMngUsername(dept.getManagerName()); |
|||
}else { |
|||
shop.setAdmin(branch.getAdmUserid()); |
|||
shop.setMngUserid(branch.getAdmUserid()); |
|||
shop.setMngUsername(branch.getAdmUsername()); |
|||
} |
|||
|
|||
shop.setIsEnable("1"); |
|||
shop.setCreateTime(date); |
|||
shop.setShopBrand(shopBrand); |
|||
shop.setShopLogo(shopLogo); |
|||
shop.setDeptid(dept.getDeptid()); |
|||
shop.setBranchId(branch.getId()); |
|||
shop.setCuser(user.getUsername()); |
|||
shop.setLdate(date); |
|||
shop.setPlatShopId(platform.getShopId()); |
|||
shop.setPlatBranchId(platform.getBranchId()); |
|||
shop.setIsJoinPlat("1"); |
|||
if(!StringUtils.isEmpty(shopRemark)) { |
|||
shop.setShopRemark(shopRemark); |
|||
} |
|||
this.insert(shop); |
|||
//插入shop_location表的数据 |
|||
ShopLocation location=new ShopLocation(); |
|||
location.setId(shop.getId()+"-0");//创建总部店铺 |
|||
location.setShopId(shop.getId()); |
|||
location.setAdmin(shop.getAdmin()); |
|||
location.setBranchId(shop.getBranchId()); |
|||
location.setDeptid(shop.getDeptid()); |
|||
location.setBusinessName(dept.getDeptName()); |
|||
location.setCreateTime(new Date()); |
|||
location.setBranchName(user.getBranchName()); |
|||
location.setStatus("0"); |
|||
location.setDataStatus("0"); |
|||
location.setLocationType("1"); |
|||
location.setShopStatus("3"); |
|||
location.setCuserid(user.getUserid()); |
|||
location.setCreateTime(date); |
|||
location.setLopuserid(user.getUserid()); |
|||
location.setLopcreate(date); |
|||
location.setMngUserid(shop.getMngUserid()); |
|||
location.setMngUsername(shop.getMngUsername()); |
|||
locationService.insert(location); |
|||
} |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,260 @@ |
|||
package com.mdp.menu.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.menu.entity.MenuDef; |
|||
import com.mdp.menu.service.MenuDefService; |
|||
import com.mdp.qx.HasQx; |
|||
import com.mdp.qx.HasRole; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import io.swagger.annotations.*; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* url编制采用rest风格,如对ADMIN.menu_def 前端功能菜单表的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: menu/menuDef/add <br> |
|||
* 查询: menu/menuDef/list<br> |
|||
* 模糊查询: menu/menuDef/listKey<br> |
|||
* 修改: menu/menuDef/edit <br> |
|||
* 删除: menu/menuDef/del<br> |
|||
* 批量删除: menu/menuDef/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuDef 表 ADMIN.menu_def 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.menu.menuDefController") |
|||
@RequestMapping(value="/**/menu/menuDef") |
|||
@Api(tags={"前端功能菜单表操作接口"}) |
|||
public class MenuDefController { |
|||
|
|||
static Log logger=LogFactory.getLog(MenuDefController.class); |
|||
|
|||
@Autowired |
|||
private MenuDefService menuDefService; |
|||
|
|||
|
|||
|
|||
@ApiOperation( value = "查询前端功能菜单表信息列表",notes="listMenuDef,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'},如果是超级管理员,查询所有,如果不是,根据角色查询") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response= MenuDef.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listMenuDef( @ApiIgnore @RequestParam Map<String,Object> menuDef){ |
|||
|
|||
IPage page=QueryTools.initPage(menuDef); |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
QueryWrapper<MenuDef> qw= QueryTools.initQueryWrapper(MenuDef.class,menuDef); |
|||
Map<String,Object> ext=new HashMap<>(); |
|||
if(!LoginUtils.isSuperAdmin() && !LoginUtils.isBranchAdmin(user.getBranchId())) { |
|||
ext.put("branchId",user.getBranchId()); |
|||
List<String> roleids= Arrays.asList(LoginUtils.getMyRoleids()); |
|||
ext.put("roleids", roleids); |
|||
}else if(LoginUtils.isBranchAdmin(user.getBranchId())){ |
|||
ext.put("branchId",user.getBranchId()); |
|||
List<String> roleids= new ArrayList<>(); |
|||
roleids.add("branchAdmin"); |
|||
ext.put("roleids",roleids); |
|||
} |
|||
List<Map<String,Object>> menuDefList = menuDefService.selectListMapByWhere(page,qw,ext); |
|||
|
|||
return Result.ok().setData(menuDefList).setTotal(page.getTotal()); |
|||
|
|||
|
|||
} |
|||
@ApiOperation( value = "查询前端功能菜单表信息列表",notes="listMenuDef,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'},如果是超级管理员,查所有,如果不是,按角色查询所有上级") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name="deptid",value="部门编号",required=false), |
|||
@ApiImplicitParam(name="branchId",value="机构编号",required=false) |
|||
}) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuDef.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list/tree",method=RequestMethod.GET) |
|||
public Result listMenuTee( @ApiIgnore @RequestParam Map<String,Object> menuDef){ |
|||
IPage page=QueryTools.initPage(menuDef); |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
QueryWrapper<MenuDef> qw= QueryTools.initQueryWrapper(MenuDef.class,menuDef); |
|||
List<Map<String,Object>> menuDefList = menuDefService.selectListMapByWhere(page,qw,menuDef); |
|||
return Result.ok().setData(menuDefList).setTotal(page.getTotal()); |
|||
} |
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "新增一条前端功能菜单表信息",notes="addMenuDef,主键如果为空,后台自动生成") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuDef.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@HasQx(value="sys_menu_def_add",name="新增菜单",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addMenuDef(@RequestBody MenuDef menuDef) { |
|||
|
|||
|
|||
try{ |
|||
if(StringUtils.isEmpty(menuDef.getId())) { |
|||
menuDef.setId(menuDefService.createKey("id")); |
|||
}else{ |
|||
MenuDef menuDefQuery = new MenuDef(menuDef.getId()); |
|||
if(menuDefService.countByWhere(menuDefQuery)>0){ |
|||
return Result.error("id-exists","编号重复,请修改编号再提交"); |
|||
} |
|||
} |
|||
|
|||
menuDefService.insert(menuDef); |
|||
return Result.ok().setData(menuDef); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "删除一条前端功能菜单表信息",notes="delMenuDef,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@HasQx(value="sys_menu_def_del",name="删除菜单",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delMenuDef(@RequestBody MenuDef menuDef){ |
|||
|
|||
|
|||
try{ |
|||
MenuDef menuDefQ=new MenuDef(); |
|||
menuDefQ.setPid(menuDef.getId()); |
|||
if(menuDefService.countByWhere(menuDefQ)>0) { |
|||
return Result.error("had-sub-menus-not-allow-del","该菜单有子菜单,不能直接删除,请先删除子菜单"); |
|||
}; |
|||
menuDefService.deleteByPk(menuDef); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键修改一条前端功能菜单表信息",notes="editMenuDef") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuDef.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@HasQx(value="sys_menu_def_edit",name="修改菜单",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editMenuDef(@RequestBody MenuDef menuDef) { |
|||
|
|||
try{ |
|||
menuDefService.updateByPk(menuDef); |
|||
return Result.ok().setData(menuDef); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键列表批量删除前端功能菜单表信息",notes="batchDelMenuDef,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@HasQx(value="sys_menu_def_batchDel",name="批量删除菜单",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelMenuDef(@RequestBody List<MenuDef> menuDefs) { |
|||
|
|||
|
|||
try{ |
|||
if(menuDefService.countChildrenByIds(menuDefs)>0) { |
|||
return Result.error("had-sub-menus-not-allow-del","该菜单有子菜单,不能直接删除,请先删除子菜单"); |
|||
} |
|||
menuDefService.batchDelete(menuDefs); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键列表批量删除前端功能菜单表信息",notes="batchDelMenuDef,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@HasQx(value="sys_menu_def_batchInsert",name="批量新增菜单",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/batchInsert",method=RequestMethod.POST) |
|||
public Result batchInsertMenuDef(@RequestBody List<MenuDef> menuDefs) { |
|||
|
|||
|
|||
try{ |
|||
List<MenuDef> menuDefsNotExists=menuDefService.getNotExistsMenuDefByRpathAndModuleId(menuDefs); |
|||
if(menuDefsNotExists==null || menuDefsNotExists.size()==0) { |
|||
return Result.error("menus-exists","菜单全部都已存在,无须再导入"); |
|||
} |
|||
|
|||
if(menuDefsNotExists!=null && menuDefsNotExists.size()>0) { |
|||
menuDefService.batchInsert(menuDefsNotExists); |
|||
} |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
@ApiOperation( value = "批量保存按钮",notes="batchSaveButton,按钮列表(包括新增修改的按钮)") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@HasRole(roles= {"superAdmin"}) |
|||
@HasQx(value="sys_menu_def_batchSaveButton",name="批量调整菜单",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/batchSaveButton",method=RequestMethod.POST) |
|||
public Result batchSaveButton(@RequestBody List<MenuDef> menuDefs) { |
|||
|
|||
|
|||
try{ |
|||
Tips tips=menuDefService.batchSaveButton(menuDefs); |
|||
Result.assertIsFalse(tips); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,139 @@ |
|||
package com.mdp.menu.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.menu.entity.MenuFavorite; |
|||
import com.mdp.menu.service.MenuFavoriteService; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* url编制采用rest风格,如对menu_favorite 菜单收藏夹的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: menu/menuFavorite/add <br> |
|||
* 查询: menu/menuFavorite/list<br> |
|||
* 模糊查询: menu/menuFavorite/listKey<br> |
|||
* 修改: menu/menuFavorite/edit <br> |
|||
* 删除: menu/menuFavorite/del<br> |
|||
* 批量删除: menu/menuFavorite/batchDel<br> |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuFavorite 表 menu_favorite 当前主键(包括多主键): favoriteid; |
|||
***/ |
|||
@RestController("mdp.menu.menuFavoriteController") |
|||
@RequestMapping(value="/**/menu/menuFavorite") |
|||
@Api(tags={"菜单收藏夹操作接口"}) |
|||
public class MenuFavoriteController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(MenuFavoriteController.class); |
|||
|
|||
@Autowired |
|||
private MenuFavoriteService menuFavoriteService; |
|||
|
|||
@ApiOperation( value = "查询菜单收藏夹信息列表",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuFavorite.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listMenuFavorite( @ApiIgnore @RequestParam Map<String,Object> menuFavorite){ |
|||
|
|||
|
|||
|
|||
IPage page=QueryTools.initPage(menuFavorite); |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
QueryWrapper<MenuFavorite> qw= QueryTools.initQueryWrapper(MenuFavorite.class,menuFavorite); |
|||
qw.eq("userid",user.getUserid()); |
|||
List<Map<String,Object>> menuFavoriteList = menuFavoriteService.selectListMapByWhere(page,qw,menuFavorite); |
|||
|
|||
return Result.ok().setData(menuFavoriteList).setTotal(page.getTotal()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 快捷入口的添加 保存用户设置的快捷入口 |
|||
* @author 林钰坤 |
|||
* @cdate 2019/1/24 20:10 |
|||
* @params 用户需要保存的快捷入口的对象 |
|||
*/ |
|||
@RequestMapping(value = "/saveMenuFavorites", method = RequestMethod.POST) |
|||
public Map<String, Object> saveMenuFavorites(@RequestBody Map<String, Object> params) { |
|||
Map<String, Object> m = new HashMap<>(); |
|||
try { |
|||
menuFavoriteService.saveMenuFavorites(params); // 列出MenuFavorite列表 |
|||
return Result.ok(); |
|||
} catch (Exception e) {// 吧错误的信息返回去 |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@RequestMapping(value = "/batchSaveMenuFavorites", method = RequestMethod.POST) |
|||
public Map<String, Object> batchSaveMenuFavorites(@RequestBody Map<String, Object> params) { |
|||
Map<String, Object> m = new HashMap<>(); |
|||
try { |
|||
List<Map<String,Object>> data = (List<Map<String, Object>>) params.get("data"); |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
menuFavoriteService.batchSaveMenuFavorites(data, user.getUserid()); // 列出MenuFavorite列表 |
|||
return Result.ok(); |
|||
} catch (Exception e) { // 吧错误的信息返回去 |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 得到快捷入口所有的路径 |
|||
* @author 林钰坤 |
|||
* @cdate 2019/1/24 20:50 |
|||
*/ |
|||
@RequestMapping(value = "/getMenuFavorites", method = RequestMethod.POST) |
|||
public Map<String, Object> getMenuFavorites(@RequestBody Map<String, Object> params) { |
|||
try { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
List<MenuFavorite> data=menuFavoriteService.getMenuFavorites(user.getUserid()); // 列出MenuFavorite列表 |
|||
return Result.ok().setData( data); |
|||
} catch (Exception e) {// 吧错误的信息返回去 |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 新增快捷入口的图标 |
|||
* @author 林钰坤 |
|||
* @cdate 2019/1/25 14:02 |
|||
*/ |
|||
@RequestMapping(value = "/addMenuFavoriteIcon", method = RequestMethod.POST) |
|||
public Map<String, Object> addMenuFavoriteIcon(@RequestBody Map<String, Object> params) { |
|||
Map<String, Object> m = new HashMap<>(); |
|||
Tips tips = new Tips("新增图标成功");// 假设查询成功 |
|||
try { |
|||
menuFavoriteService.addMenuFavoriteIcon(params); // 列出MenuFavorite列表 |
|||
return Result.ok(); |
|||
} catch (Exception e) {// 吧错误的信息返回去 |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,333 @@ |
|||
package com.mdp.menu.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.menu.entity.MenuModule; |
|||
import com.mdp.menu.entity.MenuModuleBranch; |
|||
import com.mdp.menu.service.MenuModuleBranchService; |
|||
import com.mdp.menu.service.MenuModuleService; |
|||
import com.mdp.qx.HasRole; |
|||
import com.mdp.safe.client.cache.ModuleBranchRedisCacheService; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.*; |
|||
|
|||
|
|||
/** |
|||
* url编制采用rest风格,如对menu_module_branch 机构开通模块对应关系表的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: menu/menuModuleBranch/add <br> |
|||
* 查询: menu/menuModuleBranch/list<br> |
|||
* 模糊查询: menu/menuModuleBranch/listKey<br> |
|||
* 修改: menu/menuModuleBranch/edit <br> |
|||
* 删除: menu/menuModuleBranch/del<br> |
|||
* 批量删除: menu/menuModuleBranch/batchDel<br> |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuModuleBranch 表 menu_module_branch 当前主键(包括多主键): branch_id,module_id; |
|||
***/ |
|||
@RestController("mdp.menu.menuModuleBranchController") |
|||
@RequestMapping(value="/**/menu/menuModuleBranch") |
|||
@Api(tags={"机构开通模块对应关系表操作接口"}) |
|||
public class MenuModuleBranchController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(MenuModuleBranchController.class); |
|||
|
|||
@Autowired |
|||
private MenuModuleBranchService menuModuleBranchService; |
|||
|
|||
@Autowired |
|||
MenuModuleService moduleService; |
|||
|
|||
@Autowired |
|||
ModuleBranchRedisCacheService redisCacheService; |
|||
|
|||
|
|||
Map<String,Object> fieldsMap = toMap(new MenuModuleBranch()); |
|||
|
|||
|
|||
@ApiOperation( value = "查询机构开通模块对应关系表信息列表",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModuleBranch.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listMenuModuleBranch( @ApiIgnore @RequestParam Map<String,Object> menuModuleBranch){ |
|||
|
|||
|
|||
|
|||
IPage page=QueryTools.initPage(menuModuleBranch); |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
if(!LoginUtils.isSuperAdmin()){ |
|||
menuModuleBranch.put("branchId",user.getBranchId()); |
|||
} |
|||
QueryWrapper<MenuModuleBranch> qw=QueryTools.initQueryWrapper(MenuModuleBranch.class,menuModuleBranch); |
|||
List<Map<String,Object>> menuModuleBranchList = menuModuleBranchService.selectListMapByWhere(page,qw,menuModuleBranch); |
|||
|
|||
return Result.ok().setData(menuModuleBranchList).setTotal(page.getTotal()); |
|||
|
|||
} |
|||
@ApiOperation( value = "统计企业开通产品情况",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModuleBranch.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/calcBranchModule",method=RequestMethod.GET) |
|||
public Result calcBranchModule( ){ |
|||
|
|||
|
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
Map<String,Object> data=this.menuModuleBranchService.calcBranchModule(user.getBranchId()); |
|||
return Result.ok().setData(data); |
|||
} |
|||
|
|||
@ApiOperation( value = "新增一条机构开通模块对应关系表信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModuleBranch.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addMenuModuleBranch(@RequestBody MenuModuleBranch menuModuleBranch) { |
|||
|
|||
|
|||
try{ |
|||
if(!StringUtils.hasText(menuModuleBranch.getBranchId())) { |
|||
return Result.error("pk-0","请上送机构编号"); |
|||
} |
|||
if(!StringUtils.hasText(menuModuleBranch.getModuleId())) { |
|||
return Result.error("pk-0","请上送模块编号"); |
|||
} |
|||
MenuModule moduleDb=this.moduleService.selectOneById(menuModuleBranch.getModuleId()); |
|||
if(moduleDb==null){ |
|||
return Result.error("module-0","模块已不存在"); |
|||
} |
|||
if(menuModuleBranchService.selectOneObject(menuModuleBranch) !=null ){ |
|||
return Result.error("pk-exists","已经开通,无须再开"); |
|||
} |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
menuModuleBranch.setModuleName(moduleDb.getName()); |
|||
menuModuleBranch.setCtime(new Date()); |
|||
menuModuleBranch.setCuserid(user.getUserid()); |
|||
menuModuleBranch.setCusername(user.getUsername()); |
|||
menuModuleBranch.setStatus("0"); |
|||
menuModuleBranch.setLtime(new Date()); |
|||
menuModuleBranch.setLuserid(user.getUserid()); |
|||
menuModuleBranch.setLusername(user.getUsername()); |
|||
menuModuleBranchService.insert(menuModuleBranch); |
|||
return Result.ok().setData(menuModuleBranch); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "删除一条机构开通模块对应关系表信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delMenuModuleBranch(@RequestBody MenuModuleBranch menuModuleBranch){ |
|||
|
|||
|
|||
try{ |
|||
if(!StringUtils.hasText(menuModuleBranch.getBranchId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数branchId"); |
|||
} |
|||
if(!StringUtils.hasText(menuModuleBranch.getModuleId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数moduleId"); |
|||
} |
|||
MenuModuleBranch menuModuleBranchDb = menuModuleBranchService.selectOneObject(menuModuleBranch); |
|||
if( menuModuleBranchDb == null ){ |
|||
return Result.error("data-not-exists","数据不存在,无法删除"); |
|||
} |
|||
menuModuleBranchService.deleteByPk(menuModuleBranch); |
|||
redisCacheService.clear(menuModuleBranchDb.getBranchId(),menuModuleBranchDb.getModuleId()); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "根据主键修改一条机构开通模块对应关系表信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModuleBranch.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editMenuModuleBranch(@RequestBody MenuModuleBranch menuModuleBranch) { |
|||
|
|||
|
|||
try{ |
|||
if(!StringUtils.hasText(menuModuleBranch.getBranchId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数branchId"); |
|||
} |
|||
if(!StringUtils.hasText(menuModuleBranch.getModuleId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数moduleId"); |
|||
} |
|||
MenuModuleBranch menuModuleBranchDb = menuModuleBranchService.selectOneObject(menuModuleBranch); |
|||
if( menuModuleBranchDb == null ){ |
|||
return Result.error("data-not-exists","数据不存在,无法修改"); |
|||
} |
|||
menuModuleBranchService.updateSomeFieldByPk(menuModuleBranch); |
|||
redisCacheService.clear(menuModuleBranchDb.getBranchId(),menuModuleBranchDb.getModuleId()); |
|||
return Result.ok().setData(menuModuleBranch); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "批量修改某些字段",notes="") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModuleBranch.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST) |
|||
public Result editSomeFields(@RequestBody Map<String,Object> menuModuleBranchMap) { |
|||
|
|||
|
|||
try{ |
|||
List<Map<String,Object>> pkList= (List<Map<String,Object>>) menuModuleBranchMap.get("pkList"); |
|||
if(pkList==null || pkList.size()==0){ |
|||
return Result.error("pkList-0","pkList不能为空"); |
|||
} |
|||
|
|||
Set<String> fields=new HashSet<>(); |
|||
fields.add("branchId"); |
|||
fields.add("moduleId"); |
|||
for (String fieldName : menuModuleBranchMap.keySet()) { |
|||
if(fields.contains(fieldName)){ |
|||
return Result.error(fieldName+"-no-edit",fieldName+"不允许修改"); |
|||
} |
|||
} |
|||
Set<String> fieldKey=menuModuleBranchMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet()); |
|||
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(menuModuleBranchMap.get(i) )).collect(Collectors.toSet()); |
|||
|
|||
if(fieldKey.size()<=0) { |
|||
return Result.error("fieldKey-0","没有需要更新的字段"); |
|||
} |
|||
MenuModuleBranch menuModuleBranch = fromMap(menuModuleBranchMap,MenuModuleBranch.class); |
|||
List<MenuModuleBranch> menuModuleBranchsDb=menuModuleBranchService.selectListByIds(pkList); |
|||
if(menuModuleBranchsDb==null ||menuModuleBranchsDb.size()==0){ |
|||
return Result.error("data-0","记录已不存在"); |
|||
} |
|||
List<MenuModuleBranch> can=new ArrayList<>(); |
|||
List<MenuModuleBranch> no=new ArrayList<>(); |
|||
User user = LoginUtils.getCurrentUserInfo(); |
|||
for (MenuModuleBranch menuModuleBranchDb : menuModuleBranchsDb) { |
|||
Tips tips2 = new Tips("检查通过"); |
|||
if(!tips2.isOk()){ |
|||
no.add(menuModuleBranchDb); |
|||
}else{ |
|||
can.add(menuModuleBranchDb); |
|||
} |
|||
} |
|||
if(can.size()>0){ |
|||
menuModuleBranchMap.put("pkList",can.stream().map(i->map( "branchId",i.getBranchId(), "moduleId",i.getModuleId())).collect(Collectors.toList())); |
|||
menuModuleBranchService.editSomeFields(menuModuleBranchMap); |
|||
for (MenuModuleBranch moduleBranch : can) { |
|||
redisCacheService.clear(moduleBranch.getBranchId(),moduleBranch.getModuleId()); |
|||
} |
|||
|
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
msgs.add(String.format("成功更新以下%s条数据",can.size())); |
|||
} |
|||
if(no.size()>0){ |
|||
msgs.add(String.format("以下%s个数据无权限更新",no.size())); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
//return Result.ok().setData(xmMenu); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "根据主键列表批量删除机构开通模块对应关系表信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelMenuModuleBranch(@RequestBody List<MenuModuleBranch> menuModuleBranchs) { |
|||
|
|||
|
|||
try{ |
|||
if(menuModuleBranchs.size()<=0){ |
|||
return Result.error("data-0","请上送待删除数据列表"); |
|||
} |
|||
List<MenuModuleBranch> datasDb=menuModuleBranchService.selectListByIds(menuModuleBranchs.stream().map(i->map( "branchId",i.getBranchId() , "moduleId",i.getModuleId() )).collect(Collectors.toList())); |
|||
|
|||
List<MenuModuleBranch> can=new ArrayList<>(); |
|||
List<MenuModuleBranch> no=new ArrayList<>(); |
|||
for (MenuModuleBranch data : datasDb) { |
|||
if(true){ |
|||
can.add(data); |
|||
}else{ |
|||
no.add(data); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
menuModuleBranchService.batchDelete(can); |
|||
msgs.add(String.format("成功删除%s条数据.",can.size())); |
|||
for (MenuModuleBranch moduleBranch : can) { |
|||
redisCacheService.clear(moduleBranch.getBranchId(),moduleBranch.getModuleId()); |
|||
} |
|||
} |
|||
|
|||
if(no.size()>0){ |
|||
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getBranchId() +" "+ i.getModuleId() ).collect(Collectors.joining(",")))); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,291 @@ |
|||
package com.mdp.menu.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.menu.entity.MenuModule; |
|||
import com.mdp.menu.service.MenuModuleService; |
|||
import com.mdp.qx.HasRole; |
|||
import com.mdp.safe.client.cache.ModuleRedisCacheService; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.fromMap; |
|||
import static com.mdp.core.utils.BaseUtils.toMap; |
|||
|
|||
/** |
|||
* url编制采用rest风格,如对menu_module 模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: menu/menuModule/add <br> |
|||
* 查询: menu/menuModule/list<br> |
|||
* 模糊查询: menu/menuModule/listKey<br> |
|||
* 修改: menu/menuModule/edit <br> |
|||
* 删除: menu/menuModule/del<br> |
|||
* 批量删除: menu/menuModule/batchDel<br> |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuModule 表 menu_module 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.menu.menuModuleController") |
|||
@RequestMapping(value="/**/menu/menuModule") |
|||
@Api(tags={"模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问操作接口"}) |
|||
public class MenuModuleController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(MenuModuleController.class); |
|||
|
|||
@Autowired |
|||
private MenuModuleService menuModuleService; |
|||
|
|||
@Autowired |
|||
private ModuleRedisCacheService redisCacheService; |
|||
|
|||
Map<String,Object> fieldsMap = toMap(new MenuModule()); |
|||
|
|||
|
|||
@ApiOperation( value = "查询模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问信息列表",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModule.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listMenuModule( @ApiIgnore @RequestParam Map<String,Object> menuModule){ |
|||
|
|||
IPage page=QueryTools.initPage(menuModule); |
|||
|
|||
QueryWrapper<MenuModule> qw= QueryTools.initQueryWrapper(MenuModule.class,menuModule); |
|||
List<Map<String,Object>> menuModuleList = menuModuleService.selectListMapByWhere(page,qw,menuModule); |
|||
|
|||
return Result.ok().setData(menuModuleList).setTotal(page.getTotal()); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
@ApiOperation( value = "新增一条模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModule.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addMenuModule(@RequestBody MenuModule menuModule) { |
|||
|
|||
|
|||
try{ |
|||
boolean createPk=false; |
|||
if(!StringUtils.hasText(menuModule.getId())) { |
|||
createPk=true; |
|||
menuModule.setId(menuModuleService.createKey("id")); |
|||
} |
|||
if(createPk==false){ |
|||
if(menuModuleService.selectOneObject(menuModule) !=null ){ |
|||
return Result.error("pk-exists","编号重复,请修改编号再提交"); |
|||
} |
|||
} |
|||
menuModuleService.insert(menuModule); |
|||
return Result.ok().setData(menuModule); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "删除一条模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delMenuModule(@RequestBody MenuModule menuModule){ |
|||
|
|||
|
|||
try{ |
|||
if(!StringUtils.hasText(menuModule.getId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数id"); |
|||
} |
|||
MenuModule menuModuleDb = menuModuleService.selectOneObject(menuModule); |
|||
if( menuModuleDb == null ){ |
|||
return Result.error("data-not-exists","数据不存在,无法删除"); |
|||
} |
|||
menuModuleService.deleteByPk(menuModule); |
|||
redisCacheService.clear(menuModuleDb.getId()); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "根据主键修改一条模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModule.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editMenuModule(@RequestBody MenuModule menuModule) { |
|||
|
|||
|
|||
try{ |
|||
if(!StringUtils.hasText(menuModule.getId())) { |
|||
return Result.error("pk-not-exists","请上送主键参数id"); |
|||
} |
|||
MenuModule menuModuleDb = menuModuleService.selectOneObject(menuModule); |
|||
if( menuModuleDb == null ){ |
|||
return Result.error("data-not-exists","数据不存在,无法修改"); |
|||
} |
|||
menuModuleService.updateSomeFieldByPk(menuModule); |
|||
redisCacheService.clear(menuModuleDb.getId()); |
|||
return Result.ok().setData(menuModule); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "批量修改某些字段",notes="") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuModule.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST) |
|||
public Result editSomeFields(@RequestBody Map<String,Object> menuModuleMap) { |
|||
|
|||
|
|||
try{ |
|||
List<String> ids= (List<String>) menuModuleMap.get("$pks"); |
|||
if(ids==null || ids.size()==0){ |
|||
return Result.error("ids-0","ids不能为空"); |
|||
} |
|||
|
|||
Set<String> fields=new HashSet<>(); |
|||
fields.add("id"); |
|||
for (String fieldName : menuModuleMap.keySet()) { |
|||
if(fields.contains(fieldName)){ |
|||
return Result.error(fieldName+"-no-edit",fieldName+"不允许修改"); |
|||
} |
|||
} |
|||
Set<String> fieldKey=menuModuleMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet()); |
|||
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(menuModuleMap.get(i) )).collect(Collectors.toSet()); |
|||
|
|||
if(fieldKey.size()<=0) { |
|||
return Result.error("fieldKey-0","没有需要更新的字段"); |
|||
} |
|||
MenuModule menuModule = fromMap(menuModuleMap,MenuModule.class); |
|||
List<MenuModule> menuModulesDb=menuModuleService.selectListByIds(ids); |
|||
if(menuModulesDb==null ||menuModulesDb.size()==0){ |
|||
return Result.error("data-0","记录已不存在"); |
|||
} |
|||
List<MenuModule> can=new ArrayList<>(); |
|||
List<MenuModule> no=new ArrayList<>(); |
|||
User user = LoginUtils.getCurrentUserInfo(); |
|||
for (MenuModule menuModuleDb : menuModulesDb) { |
|||
Tips tips2 = new Tips("检查通过"); |
|||
if(!tips2.isOk()){ |
|||
no.add(menuModuleDb); |
|||
}else{ |
|||
can.add(menuModuleDb); |
|||
} |
|||
} |
|||
if(can.size()>0){ |
|||
menuModuleMap.put("$pks",can.stream().map(i->i.getId()).collect(Collectors.toList())); |
|||
menuModuleService.editSomeFields(menuModuleMap); |
|||
for (MenuModule module : can) { |
|||
redisCacheService.clear(module.getId()); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
msgs.add(String.format("成功更新以下%s条数据",can.size())); |
|||
} |
|||
if(no.size()>0){ |
|||
msgs.add(String.format("以下%s个数据无权限更新",no.size())); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
//return Result.ok().setData(xmMenu); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "根据主键列表批量删除模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@HasRole(roles = {"superAdmin"}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelMenuModule(@RequestBody List<MenuModule> menuModules) { |
|||
|
|||
|
|||
try{ |
|||
if(menuModules.size()<=0){ |
|||
return Result.error("data-0","请上送待删除数据列表"); |
|||
} |
|||
List<MenuModule> datasDb=menuModuleService.selectListByIds(menuModules.stream().map(i-> i.getId() ).collect(Collectors.toList())); |
|||
|
|||
List<MenuModule> can=new ArrayList<>(); |
|||
List<MenuModule> no=new ArrayList<>(); |
|||
for (MenuModule data : datasDb) { |
|||
if(true){ |
|||
can.add(data); |
|||
}else{ |
|||
no.add(data); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
menuModuleService.batchDelete(menuModules); |
|||
msgs.add(String.format("成功删除%s条数据.",can.size())); |
|||
for (MenuModule module : can) { |
|||
redisCacheService.clear(module.getId()); |
|||
} |
|||
} |
|||
|
|||
if(no.size()>0){ |
|||
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(",")))); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,251 @@ |
|||
package com.mdp.menu.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.menu.entity.MenuRole; |
|||
import com.mdp.menu.entity.MenuToRolesVo; |
|||
import com.mdp.menu.entity.MenusToRoleVo; |
|||
import com.mdp.menu.entity.MenusToRolesVo; |
|||
import com.mdp.menu.service.MenuRoleService; |
|||
import com.mdp.qx.HasQx; |
|||
import com.mdp.safe.client.cache.RoleMenusRedisCacheService; |
|||
import com.mdp.safe.client.cache.RoleRedisCacheService; |
|||
import io.swagger.annotations.*; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* url编制采用rest风格,如对ADMIN.menu_role 菜单角色分配的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: menu/menuRole/add <br> |
|||
* 查询: menu/menuRole/list<br> |
|||
* 模糊查询: menu/menuRole/listKey<br> |
|||
* 修改: menu/menuRole/edit <br> |
|||
* 删除: menu/menuRole/del<br> |
|||
* 批量删除: menu/menuRole/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuRole 表 ADMIN.menu_role 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.menu.menuRoleController") |
|||
@RequestMapping(value="/**/menu/menuRole") |
|||
@Api(tags={"菜单角色分配操作接口"}) |
|||
public class MenuRoleController { |
|||
|
|||
static Log logger=LogFactory.getLog(MenuRoleController.class); |
|||
|
|||
@Autowired |
|||
private MenuRoleService menuRoleService; |
|||
@Autowired |
|||
RoleMenusRedisCacheService roleMenusRedisCacheService; |
|||
|
|||
@Autowired |
|||
RoleRedisCacheService roleRedisCacheService; |
|||
|
|||
@ApiOperation( value = "查询菜单角色分配信息列表",notes="listMenuRole,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name="id",value="编号,主键",required=false), |
|||
@ApiImplicitParam(name="roleid",value="用户组编号",required=false), |
|||
@ApiImplicitParam(name="mid",value="菜单编号",required=false), |
|||
@ApiImplicitParam(name="pageSize",value="每页记录数",required=false), |
|||
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false), |
|||
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), |
|||
@ApiImplicitParam(name="orderFields",value="排序列 如性别、学生编号排序 ['sex','studentId']",required=false), |
|||
@ApiImplicitParam(name="orderDirs",value="排序方式,与orderFields对应,升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']",required=false) |
|||
}) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response= MenuRole.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listMenuRole( @ApiIgnore @RequestParam Map<String,Object> menuRole){ |
|||
|
|||
IPage page=QueryTools.initPage(menuRole); |
|||
QueryWrapper<MenuRole> qw= QueryTools.initQueryWrapper(MenuRole.class,menuRole); |
|||
List<Map<String,Object>> menuRoleList = menuRoleService.selectListMapByWhere(page,qw,menuRole); |
|||
return Result.ok().setData(menuRoleList).setTotal(page.getTotal()); |
|||
|
|||
|
|||
} |
|||
|
|||
@ApiOperation( value = "批量分配一个菜单给多个角色",notes="batchEditMenuToRoles,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
|
|||
@HasQx(value="sys_menu_role_batchEditMenuToRoles",name="批量分配一个菜单给多个角色",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/batchEditMenuToRoles",method=RequestMethod.POST) |
|||
public Result batchEditMenuToRoles(@RequestBody MenuToRolesVo menuVo) { |
|||
|
|||
|
|||
try{ |
|||
Tips tips=menuRoleService.batchEditMenuToRoles(menuVo); |
|||
Result.assertIsFalse(tips); |
|||
roleMenusRedisCacheService.clearRoleMenus( menuVo.getRoleids().toArray(new String[menuVo.getRoleids().size()])); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "批量分配多个菜单到多个角色",notes="batchEditMenusToRoles,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
|
|||
@HasQx(value="sys_menu_role_batchEditMenusToRoles",name="批量分配多个菜单到多个角色",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/batchEditMenusToRoles",method=RequestMethod.POST) |
|||
public Result batchEditMenusToRoles(@RequestBody MenusToRolesVo menuVo) { |
|||
|
|||
|
|||
try{ |
|||
if(menuVo.getMids()==null ||menuVo.getMids().size()==0){ |
|||
return Result.error("mids不能为空","请选中菜单"); |
|||
} |
|||
if(menuVo.getRoleids()==null ||menuVo.getRoleids().size()==0){ |
|||
return Result.error("roleids不能为空","请选中角色"); |
|||
} |
|||
Tips tips=menuRoleService.batchEditMenusToRoles(menuVo); |
|||
Result.assertIsFalse(tips); |
|||
roleMenusRedisCacheService.clearRoleMenus(menuVo.getRoleids().toArray(new String[menuVo.getRoleids().size()])); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "批量分配多个菜单给到一个角色",notes="batchEditMenusToRole,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
|
|||
@HasQx(value="sys_menu_role_batchEditMenusToRole",name="批量分配多个菜单给到一个角色",moduleId = "mdp-sys",moduleName = "组织管理") |
|||
@RequestMapping(value="/batchEditMenusToRole",method=RequestMethod.POST) |
|||
public Result batchEditMenusToRole(@RequestBody MenusToRoleVo menuVo) { |
|||
|
|||
|
|||
try{ |
|||
Tips tips=menuRoleService.batchEditMenusToRole(menuVo); |
|||
Result.assertIsFalse(tips); |
|||
roleMenusRedisCacheService.clearRoleMenus(menuVo.getRoleid()); |
|||
return Result.ok(); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
/** |
|||
@ApiOperation( value = "新增一条菜单角色分配信息",notes="addMenuRole,主键如果为空,后台自动生成") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuRole.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addMenuRole(@RequestBody MenuRole menuRole) { |
|||
|
|||
|
|||
try{ |
|||
if(StringUtils.isEmpty(menuRole.getId())) { |
|||
menuRole.setId(menuRoleService.createKey("id")); |
|||
}else{ |
|||
MenuRole menuRoleQuery = new MenuRole(menuRole.getId()); |
|||
if(menuRoleService.countByWhere(menuRoleQuery)>0){ |
|||
return Result.error("id-exists","编号重复,请修改编号再提交"); |
|||
} |
|||
} |
|||
menuRoleService.insert(menuRole); |
|||
return Result.ok().setData(menuRole); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
/** |
|||
@ApiOperation( value = "删除一条菜单角色分配信息",notes="delMenuRole,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delMenuRole(@RequestBody MenuRole menuRole){ |
|||
|
|||
|
|||
try{ |
|||
menuRoleService.deleteByPk(menuRole); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键修改一条菜单角色分配信息",notes="editMenuRole") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=MenuRole.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editMenuRole(@RequestBody MenuRole menuRole) { |
|||
|
|||
|
|||
try{ |
|||
menuRoleService.updateByPk(menuRole); |
|||
return Result.ok().setData(menuRole); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键列表批量删除菜单角色分配信息",notes="batchDelMenuRole,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelMenuRole(@RequestBody List<MenuRole> menuRoles) { |
|||
|
|||
|
|||
try{ |
|||
menuRoleService.batchDelete(menuRoles); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
*/ |
|||
} |
|||
@ -0,0 +1,88 @@ |
|||
package com.mdp.menu.entity; |
|||
import lombok.Data; |
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.mdp.core.dao.annotation.TableIds; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuDef所有属性名: <br> |
|||
* "id","菜单编号","pid","上级菜单编号","accUrl","访问路径","msort","菜单顺序","mcate","菜单大类-指向menu_module.mcate","icon","菜单图标","mname","菜单名称","rpath","路由PATH","rid","路由编号","isShow","是否显示","menuType","菜单类型1菜单2按钮","operQxId","绑定的操作权限编号","supVers","支持版本0-免费版可用,1-企业版。假如企业属于企业版,则可以适用免费版和企业版的功能。假如企业为免费版,则只可以使用免费版功能","moduleId","模块编号-指向menu_module.id","arole","是否所有角色可用,0-否,1-不区分角色均可以用","qxType","一般按钮才需要区分权限类型c-新增,r-读,u-更新,d-删除","apiRules","对应后台的url地址,支持ant表达式匹配,用于后台接口调用时权限控制,多个逗号分隔,多个为or关系";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("menu_def") |
|||
@ApiModel(description="前端功能菜单表") |
|||
public class MenuDef implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="菜单编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
@ApiModelProperty(notes="上级菜单编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String pid; |
|||
|
|||
@ApiModelProperty(notes="访问路径",allowEmptyValue=true,example="",allowableValues="") |
|||
String accUrl; |
|||
|
|||
@ApiModelProperty(notes="菜单顺序",allowEmptyValue=true,example="",allowableValues="") |
|||
String msort; |
|||
|
|||
@ApiModelProperty(notes="菜单大类-指向menu_module.mcate",allowEmptyValue=true,example="",allowableValues="") |
|||
String mcate; |
|||
|
|||
@ApiModelProperty(notes="菜单图标",allowEmptyValue=true,example="",allowableValues="") |
|||
String icon; |
|||
|
|||
@ApiModelProperty(notes="菜单名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String mname; |
|||
|
|||
@ApiModelProperty(notes="路由PATH",allowEmptyValue=true,example="",allowableValues="") |
|||
String rpath; |
|||
|
|||
@ApiModelProperty(notes="路由编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String rid; |
|||
|
|||
@ApiModelProperty(notes="是否显示",allowEmptyValue=true,example="",allowableValues="") |
|||
String isShow; |
|||
|
|||
@ApiModelProperty(notes="菜单类型1菜单2按钮",allowEmptyValue=true,example="",allowableValues="") |
|||
String menuType; |
|||
|
|||
@ApiModelProperty(notes="绑定的操作权限编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String operQxId; |
|||
|
|||
@ApiModelProperty(notes="支持版本0-免费版可用,1-企业版。假如企业属于企业版,则可以适用免费版和企业版的功能。假如企业为免费版,则只可以使用免费版功能",allowEmptyValue=true,example="",allowableValues="") |
|||
String supVers; |
|||
|
|||
@ApiModelProperty(notes="模块编号-指向menu_module.id",allowEmptyValue=true,example="",allowableValues="") |
|||
String moduleId; |
|||
|
|||
@ApiModelProperty(notes="是否所有角色可用,0-否,1-不区分角色均可以用",allowEmptyValue=true,example="",allowableValues="") |
|||
String arole; |
|||
|
|||
@ApiModelProperty(notes="一般按钮才需要区分权限类型c-新增,r-读,u-更新,d-删除",allowEmptyValue=true,example="",allowableValues="") |
|||
String qxType; |
|||
|
|||
@ApiModelProperty(notes="对应后台的url地址,支持ant表达式匹配,用于后台接口调用时权限控制,多个逗号分隔,多个为or关系",allowEmptyValue=true,example="",allowableValues="") |
|||
String apiRules; |
|||
|
|||
/** |
|||
*菜单编号 |
|||
**/ |
|||
public MenuDef(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 前端功能菜单表 |
|||
**/ |
|||
public MenuDef() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
package com.mdp.menu.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuFavorite所有属性名: <br> |
|||
* "favoriteid","菜单收藏夹ID","deptPostUserid","部门-岗位-用户ID(暂时不用)","deptid","部门ID(暂时不用)","postid","岗位ID(暂时不用)","userid","用户ID(暂时不用)","menuid","菜单ID(暂时不用)","menuname","菜单名称","sort","排序","branchId","云用户机构编号","cuserid","创建人","cdate","创建时间","lopuserid","最后操作人","lopcreate","最后操作时间","accUrl","访问路径","icon","菜单图标";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* favoriteid;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("menu_favorite") |
|||
@ApiModel(description="菜单收藏夹") |
|||
public class MenuFavorite implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="菜单收藏夹ID,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String favoriteid; |
|||
|
|||
@ApiModelProperty(notes="部门-岗位-用户ID(暂时不用)",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptPostUserid; |
|||
|
|||
@ApiModelProperty(notes="部门ID(暂时不用)",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
@ApiModelProperty(notes="岗位ID(暂时不用)",allowEmptyValue=true,example="",allowableValues="") |
|||
String postid; |
|||
|
|||
@ApiModelProperty(notes="用户ID(暂时不用)",allowEmptyValue=true,example="",allowableValues="") |
|||
String userid; |
|||
|
|||
@ApiModelProperty(notes="菜单ID(暂时不用)",allowEmptyValue=true,example="",allowableValues="") |
|||
String menuid; |
|||
|
|||
@ApiModelProperty(notes="菜单名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String menuname; |
|||
|
|||
@ApiModelProperty(notes="排序",allowEmptyValue=true,example="",allowableValues="") |
|||
String sort; |
|||
|
|||
@ApiModelProperty(notes="云用户机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="创建人",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date cdate; |
|||
|
|||
@ApiModelProperty(notes="最后操作人",allowEmptyValue=true,example="",allowableValues="") |
|||
String lopuserid; |
|||
|
|||
@ApiModelProperty(notes="最后操作时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date lopcreate; |
|||
|
|||
@ApiModelProperty(notes="访问路径",allowEmptyValue=true,example="",allowableValues="") |
|||
String accUrl; |
|||
|
|||
@ApiModelProperty(notes="菜单图标",allowEmptyValue=true,example="",allowableValues="") |
|||
String icon; |
|||
|
|||
/** |
|||
*菜单收藏夹ID |
|||
**/ |
|||
public MenuFavorite(String favoriteid) { |
|||
this.favoriteid = favoriteid; |
|||
} |
|||
|
|||
/** |
|||
* 菜单收藏夹 |
|||
**/ |
|||
public MenuFavorite() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
package com.mdp.menu.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuModule所有属性名: <br> |
|||
* "id","编号","name","模块名称","fee","模块费用","billMode","计费模式:0-不计费,1-按购买人数计费,2-总包费用,3-按实际使用人数每月计费","uniFee","人均费用,单位人天","discount","折扣比率,可折上折,叠加折扣。-按最大人数、按天数优惠","url","匹配的url,如果匹配得到,则计费,以逗号分割多个","ignoreUrl","匹配这个地址的不计费","bizFlowState","审核状态","procInstId","审核流程实例编号","status","0-下架,1-上架。开放后才可以购买使用","mcate","分类1-协同、2-研发、3-电商","logoUrl","logo地址","feeDesc","费用解释","udisRate","人数折算比例。企业总人数*折扣率为当前模块购买人数","udis","是否折算人数0否1是,按企业总人数*人数折算比例计算","saleDesc","营销文案","ucheck","是否控制总人数0-否1是","crowd","是否为众包","seq","序号0-1000,默认999";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("menu_module") |
|||
@ApiModel(description="模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问") |
|||
public class MenuModule implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
@ApiModelProperty(notes="编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
@ApiModelProperty(notes="模块名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String name; |
|||
|
|||
@ApiModelProperty(notes="模块费用",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal fee; |
|||
|
|||
@ApiModelProperty(notes="计费模式:0-不计费,1-按购买人数计费,2-总包费用,3-按实际使用人数每月计费",allowEmptyValue=true,example="",allowableValues="") |
|||
String billMode; |
|||
|
|||
@ApiModelProperty(notes="人均费用,单位人天",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal uniFee; |
|||
|
|||
@ApiModelProperty(notes="折扣比率,可折上折,叠加折扣。-按最大人数、按天数优惠",allowEmptyValue=true,example="",allowableValues="") |
|||
String discount; |
|||
|
|||
@ApiModelProperty(notes="匹配的url,如果匹配得到,则计费,以逗号分割多个",allowEmptyValue=true,example="",allowableValues="") |
|||
String url; |
|||
|
|||
@ApiModelProperty(notes="匹配这个地址的不计费",allowEmptyValue=true,example="",allowableValues="") |
|||
String ignoreUrl; |
|||
|
|||
@ApiModelProperty(notes="审核状态",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizFlowState; |
|||
|
|||
@ApiModelProperty(notes="审核流程实例编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String procInstId; |
|||
|
|||
@ApiModelProperty(notes="0-下架,1-上架。开放后才可以购买使用",allowEmptyValue=true,example="",allowableValues="") |
|||
String status; |
|||
|
|||
@ApiModelProperty(notes="分类1-协同、2-研发、3-电商",allowEmptyValue=true,example="",allowableValues="") |
|||
String mcate; |
|||
|
|||
@ApiModelProperty(notes="logo地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String logoUrl; |
|||
|
|||
@ApiModelProperty(notes="费用解释",allowEmptyValue=true,example="",allowableValues="") |
|||
String feeDesc; |
|||
|
|||
@ApiModelProperty(notes="人数折算比例。企业总人数*折扣率为当前模块购买人数",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer udisRate; |
|||
|
|||
@ApiModelProperty(notes="是否折算人数0否1是,按企业总人数*人数折算比例计算",allowEmptyValue=true,example="",allowableValues="") |
|||
String udis; |
|||
|
|||
@ApiModelProperty(notes="营销文案",allowEmptyValue=true,example="",allowableValues="") |
|||
String saleDesc; |
|||
|
|||
@ApiModelProperty(notes="是否控制总人数0-否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String ucheck; |
|||
|
|||
@ApiModelProperty(notes="是否为众包",allowEmptyValue=true,example="",allowableValues="") |
|||
String crowd; |
|||
|
|||
@ApiModelProperty(notes="序号0-1000,默认999",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer seq; |
|||
|
|||
/** |
|||
*编号 |
|||
**/ |
|||
public MenuModule(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 模块定义表-用于进行机构级别的权限控制,机构如果购买了模块,则能够进行访问 |
|||
**/ |
|||
public MenuModule() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
package com.mdp.menu.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.mdp.core.dao.annotation.TableIds; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuModuleBranch所有属性名: <br> |
|||
* "branchId","机构编号","moduleName","模块名称","moduleId","模块编号","startTime","启用日期","endTime","结束日期","ctime","创建日期","ltime","更新日期","cuserid","创建人编号","cusername","创建人姓名","luserid","修改人编号","lusername","修改人姓名","status","状态0停用1启用2待续费","musers","购买用户数","mbidNum","可投标次数-每月恢复为套餐数量,包含公司账户次数+个人以组织名义接单的次数,以上每接一单扣减此处","sfeeRate","服务费率,15=15%","ver","购买版本0-免费版,1-企业版","feeDate","开始计费日期","crowd","是否为众包","ousers","企业总人数","udisRate","人数折算比例。企业总人数*折扣率为当前模块购买人数","udis","是否折算人数0否1是,按企业总人数*人数折算比例计算","mcate","分类1-协同、2-研发、3-电商";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* branch_id,module_id;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("menu_module_branch") |
|||
@ApiModel(description="机构开通模块对应关系表") |
|||
public class MenuModuleBranch implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableIds |
|||
@ApiModelProperty(notes="机构编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
@TableIds |
|||
@ApiModelProperty(notes="模块编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String moduleId; |
|||
|
|||
@ApiModelProperty(notes="模块名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String moduleName; |
|||
|
|||
@ApiModelProperty(notes="启用日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date startTime; |
|||
|
|||
@ApiModelProperty(notes="结束日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date endTime; |
|||
|
|||
@ApiModelProperty(notes="创建日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date ctime; |
|||
|
|||
@ApiModelProperty(notes="更新日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date ltime; |
|||
|
|||
@ApiModelProperty(notes="创建人编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
@ApiModelProperty(notes="创建人姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String cusername; |
|||
|
|||
@ApiModelProperty(notes="修改人编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String luserid; |
|||
|
|||
@ApiModelProperty(notes="修改人姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String lusername; |
|||
|
|||
@ApiModelProperty(notes="状态0停用1启用2待续费",allowEmptyValue=true,example="",allowableValues="") |
|||
String status; |
|||
|
|||
@ApiModelProperty(notes="购买用户数",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer musers; |
|||
|
|||
@ApiModelProperty(notes="可投标次数-每月恢复为套餐数量,包含公司账户次数+个人以组织名义接单的次数,以上每接一单扣减此处",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer mbidNum; |
|||
|
|||
@ApiModelProperty(notes="服务费率,15=15%",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer sfeeRate; |
|||
|
|||
@ApiModelProperty(notes="购买版本0-免费版,1-企业版",allowEmptyValue=true,example="",allowableValues="") |
|||
String ver; |
|||
|
|||
@ApiModelProperty(notes="开始计费日期",allowEmptyValue=true,example="",allowableValues="") |
|||
Date feeDate; |
|||
|
|||
@ApiModelProperty(notes="是否为众包",allowEmptyValue=true,example="",allowableValues="") |
|||
String crowd; |
|||
|
|||
@ApiModelProperty(notes="企业总人数",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer ousers; |
|||
|
|||
@ApiModelProperty(notes="人数折算比例。企业总人数*折扣率为当前模块购买人数",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer udisRate; |
|||
|
|||
@ApiModelProperty(notes="是否折算人数0否1是,按企业总人数*人数折算比例计算",allowEmptyValue=true,example="",allowableValues="") |
|||
String udis; |
|||
|
|||
@ApiModelProperty(notes="分类1-协同、2-研发、3-电商",allowEmptyValue=true,example="",allowableValues="") |
|||
String mcate; |
|||
|
|||
/** |
|||
*机构编号,模块编号 |
|||
**/ |
|||
public MenuModuleBranch(String branchId,String moduleId) { |
|||
this.branchId = branchId; |
|||
this.moduleId = moduleId; |
|||
} |
|||
|
|||
/** |
|||
* 机构开通模块对应关系表 |
|||
**/ |
|||
public MenuModuleBranch() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package com.mdp.menu.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.mdp.core.dao.annotation.TableIds; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuRole所有属性名: <br> |
|||
* "roleid","用户组编号","mid","菜单编号","half","是否半选状态";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* roleid,mid;<br> |
|||
*/ |
|||
@Data |
|||
@TableName("menu_role") |
|||
@ApiModel(description="菜单角色分配") |
|||
public class MenuRole implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableIds |
|||
@ApiModelProperty(notes="用户组编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String roleid; |
|||
@TableIds |
|||
@ApiModelProperty(notes="菜单编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String mid; |
|||
|
|||
@ApiModelProperty(notes="是否半选状态",allowEmptyValue=true,example="",allowableValues="") |
|||
String half; |
|||
|
|||
/** |
|||
*用户组编号,菜单编号 |
|||
**/ |
|||
public MenuRole(String roleid,String mid) { |
|||
this.roleid = roleid; |
|||
this.mid = mid; |
|||
} |
|||
|
|||
/** |
|||
* 菜单角色分配 |
|||
**/ |
|||
public MenuRole() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
package com.mdp.menu.entity; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 res 小模块 <br> |
|||
* 实体 ResOperRole所有属性名: <br> |
|||
* id,roleid,operId;<br> |
|||
* 表 ADMIN.res_oper_role 角色资源关系表的所有字段名: <br> |
|||
* id,roleid,oper_id;<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@ApiModel(description="角色资源关系表") |
|||
public class MenuToRolesVo implements java.io.Serializable { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = -664684104957484091L; |
|||
|
|||
/** |
|||
* 菜单编号 |
|||
*/ |
|||
String mid; |
|||
|
|||
/** |
|||
* 角色编号 |
|||
*/ |
|||
List<String> roleids; |
|||
|
|||
public String getMid() { |
|||
return mid; |
|||
} |
|||
|
|||
public void setMid(String mid) { |
|||
this.mid = mid; |
|||
} |
|||
|
|||
public List<String> getRoleids() { |
|||
return roleids; |
|||
} |
|||
|
|||
public void setRoleids(List<String> roleids) { |
|||
this.roleids = roleids; |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.mdp.menu.entity; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 res 小模块 <br> |
|||
* 实体 ResOperRole所有属性名: <br> |
|||
* id,roleid,operId;<br> |
|||
* 表 ADMIN.res_oper_role 角色资源关系表的所有字段名: <br> |
|||
* id,roleid,oper_id;<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@ApiModel(description="角色资源关系表") |
|||
public class MenusToRoleVo implements java.io.Serializable { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = -664684104957484091L; |
|||
|
|||
/** |
|||
* 菜单编号 |
|||
*/ |
|||
List<String> mids; |
|||
|
|||
/** |
|||
* 角色编号 |
|||
*/ |
|||
String roleid; |
|||
|
|||
public List<String> getMids() { |
|||
return mids; |
|||
} |
|||
|
|||
public void setMids(List<String> mids) { |
|||
this.mids = mids; |
|||
} |
|||
|
|||
public String getRoleid() { |
|||
return roleid; |
|||
} |
|||
|
|||
public void setRoleid(String roleid) { |
|||
this.roleid = roleid; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
package com.mdp.menu.entity; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 res 小模块 <br> |
|||
* 实体 ResOperRole所有属性名: <br> |
|||
* id,roleid,operId;<br> |
|||
* 表 ADMIN.res_oper_role 角色资源关系表的所有字段名: <br> |
|||
* id,roleid,oper_id;<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@ApiModel(description="角色资源关系表") |
|||
public class MenusToRolesVo implements java.io.Serializable { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = -664684104957484091L; |
|||
|
|||
/** |
|||
* 菜单编号 |
|||
*/ |
|||
List<String> mids; |
|||
|
|||
/** |
|||
* 角色编号 |
|||
*/ |
|||
List<String> roleids; |
|||
|
|||
public List<String> getMids() { |
|||
return mids; |
|||
} |
|||
|
|||
public void setMids(List<String> mids) { |
|||
this.mids = mids; |
|||
} |
|||
|
|||
public List<String> getRoleids() { |
|||
return roleids; |
|||
} |
|||
|
|||
public void setRoleids(List<String> roleids) { |
|||
this.roleids = roleids; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package com.mdp.menu.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.menu.entity.MenuDef; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface MenuDefMapper extends BaseMapper<MenuDef> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
Long countChildrenByIds(List<MenuDef> menuDefs); |
|||
|
|||
List<MenuDef> selectMenusInDbByRpathAndModuleId(List<MenuDef> menuDefs); |
|||
|
|||
List<MenuDef> selectExistsButonsByIds(List<MenuDef> buttons); |
|||
} |
|||
|
|||
@ -0,0 +1,59 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.menu.mapper.MenuDefMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from menu_def res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<if test=" ext.roleids!=null "> |
|||
and exists (select 1 from menu_role mr where mr.mid=res.id and mr.roleid in |
|||
<foreach collection="ext.roleids" item="item" index="index" open="(" separator="," close=")" > |
|||
#{item } |
|||
</foreach> |
|||
) |
|||
</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectMenusByRoleid" parameterType="HashMap" resultType="HashMap"> |
|||
select res.* from menu_def res |
|||
<where> |
|||
<if test="key != null and key !='' "> </if> |
|||
and exists (select 1 from menu_role r where r.mid=res.id and r.roleid = #{roleid}) |
|||
</where> |
|||
</select> |
|||
<!-- 通过条件查询获取数据列表 返回list<map> --> |
|||
<select id="selectMenusByRoleids" parameterType="List" resultType="com.mdp.menu.entity.MenuDef"> |
|||
select res.* from menu_def res where exists (select 1 from menu_role r where r.mid = res.id |
|||
and r.roleid in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
#{item.roleid } |
|||
</foreach> |
|||
) |
|||
</select> |
|||
|
|||
<!-- 获取数据条目 返回long --> |
|||
<select id="countChildrenByIds" parameterType="List" resultType="long"> |
|||
select count(1) from menu_def res |
|||
where pid in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
#{item.id } |
|||
</foreach> |
|||
</select> |
|||
<select id="selectMenusInDbByRpathAndModuleId" parameterType="List" resultType="com.mdp.menu.entity.MenuDef"> |
|||
select * from menu_def res |
|||
where (res.module_id,res.rpath) in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
(#{item.moduleId },#{item.rpath}) |
|||
</foreach> |
|||
</select> |
|||
|
|||
<select id="selectExistsButonsByIds" parameterType="List" resultType="com.mdp.menu.entity.MenuDef"> |
|||
select * from menu_def res |
|||
where res.id in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
#{item.id } |
|||
</foreach> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.menu.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.menu.entity.MenuFavorite; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface MenuFavoriteMapper extends BaseMapper<MenuFavorite> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.menu.mapper.MenuFavoriteMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from menu_favorite res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,25 @@ |
|||
package com.mdp.menu.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.menu.entity.MenuModuleBranch; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface MenuModuleBranchMapper extends BaseMapper<MenuModuleBranch> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
Map<String, Object> calcBranchModule(String branchId); |
|||
} |
|||
|
|||
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.menu.mapper.MenuModuleBranchMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from menu_module_branch res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
|
|||
|
|||
<select id="countModuleUsersByBranchIdAndPostIds" parameterType="HashMap" resultType="HashMap"> |
|||
select mo.category,count(DISTINCT dpu.USERID) as users from sys_dept_post_user dpu |
|||
inner join sys_dept d on d.deptid=dpu.deptid |
|||
inner join ( |
|||
select pr.POST_ID,m.CATEGORY from menu_role mr |
|||
inner join menu_def m on m.id=mr.mid |
|||
inner join sys_post_role pr on pr.ROLEID=mr.ROLEID |
|||
where pr.post_id in |
|||
<foreach collection="postIds" item="item" index="index" open="(" separator="," close=")" > |
|||
#{item} |
|||
</foreach> |
|||
|
|||
) as mo on mo.post_id=dpu.POST_ID |
|||
where d.branch_id=#{branchId} |
|||
GROUP BY mo.category |
|||
</select> |
|||
<select id="calcBranchModule" resultType="HashMap" parameterType="String"> |
|||
select count(*) as all_modules,sum(if(m.bill_mode='0',1,0)) as free_modules, |
|||
count(distinct res.module_id) as had_modules,sum(if(m.bill_mode='0' and res.module_id ,1,0)) as had_free_modules |
|||
from menu_module m left join menu_module_branch res on m.id=res.module_id and res.branch_id=#{branchId} |
|||
where m.status='1' |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.menu.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.menu.entity.MenuModule; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface MenuModuleMapper extends BaseMapper<MenuModule> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.menu.mapper.MenuModuleMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from menu_module res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,25 @@ |
|||
package com.mdp.menu.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.menu.entity.MenuRole; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface MenuRoleMapper extends BaseMapper<MenuRole> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
List<MenuRole> selectListByMidAndBranchId(Map<String, Object> map); |
|||
} |
|||
|
|||
@ -0,0 +1,44 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.mdp.menu.mapper.MenuRoleMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from menu_role res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
</where> |
|||
</select> |
|||
<delete id="deleteMenuRoleByMids"> |
|||
delete from menu_role |
|||
where mid in |
|||
<foreach collection="array" item="item" index="index" open="(" separator="," close=")" > |
|||
#{item } |
|||
</foreach> |
|||
</delete> |
|||
<delete id="deleteMenuRoleByRoleids"> |
|||
delete from menu_role |
|||
where roleid in |
|||
<foreach collection="array" item="item" index="index" open="(" separator="," close=")" > |
|||
#{item } |
|||
</foreach> |
|||
</delete> |
|||
|
|||
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> --> |
|||
<select id="selectExistsMenuRoles" parameterType="com.mdp.menu.entity.MenuRole" resultType="com.mdp.menu.entity.MenuRole"> |
|||
select * from menu_role res |
|||
where (res.roleid,res.mid) in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
( #{item.roleid },#{item.mid} ) |
|||
</foreach> |
|||
</select> |
|||
<delete id="deleteExistsMenuRoles" parameterType="list"> |
|||
delete from menu_role |
|||
where (roleid,mid) in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
( #{item.roleid },#{item.mid} ) |
|||
</foreach> |
|||
</delete> |
|||
<select id="selectListByMidAndBranchId" parameterType="HashMap" resultType="com.mdp.menu.entity.MenuRole"> |
|||
select res.* from menu_role res inner join sys_role r on r.roleid=res.roleid where res.mid=#{mid} and r.branch_id=#{branchId} |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,136 @@ |
|||
package com.mdp.menu.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.menu.entity.MenuDef; |
|||
import com.mdp.menu.mapper.MenuDefMapper; |
|||
import com.mdp.safe.client.cache.RoleMenusRedisCacheService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuDef 表 ADMIN.menu_def 当前主键(包括多主键): id; |
|||
***/ |
|||
@Service("mdp.menu.menuDefService") |
|||
public class MenuDefService extends BaseService<MenuDefMapper,MenuDef> { |
|||
|
|||
@Autowired |
|||
RoleMenusRedisCacheService roleMenusRedisCacheService; |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
public List<MenuDef> selectMenusByRoleids(String...roleids) { |
|||
List<MenuDef> allMenus=new ArrayList<>(); |
|||
if(roleids==null || roleids.length<=0) { |
|||
return allMenus; |
|||
} |
|||
QueryWrapper<MenuDef> qw=new QueryWrapper<>(); |
|||
qw.in("roleid",roleids); |
|||
return list(qw); |
|||
} |
|||
|
|||
|
|||
public Long countChildrenByIds( List<MenuDef> menuDefs ) { |
|||
return baseMapper.countChildrenByIds(menuDefs); |
|||
|
|||
} |
|||
public List<MenuDef> getNotExistsMenuDefByRpathAndModuleId(List<MenuDef> menuDefs) { |
|||
List<MenuDef> existsList= getBaseMapper().selectMenusInDbByRpathAndModuleId(menuDefs); |
|||
List<MenuDef> notExistsList=new ArrayList<>(); |
|||
for (MenuDef menuDef : menuDefs) { |
|||
boolean exists=false; |
|||
for (MenuDef def : existsList) { |
|||
|
|||
if(def.getRpath().equals(menuDef.getRpath())) { |
|||
exists=true; |
|||
} |
|||
} |
|||
if(exists==true) { |
|||
continue; |
|||
}else { |
|||
notExistsList.add(menuDef); |
|||
} |
|||
} |
|||
return notExistsList; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 批量保存按钮到菜单表 |
|||
* @param buttons |
|||
* @return |
|||
*/ |
|||
public Tips batchSaveButton(List<MenuDef> buttons) { |
|||
|
|||
if(buttons==null) { |
|||
return LangTips.errMsg("buttons-required","按钮为空,不允许保存"); |
|||
} |
|||
for (MenuDef btn : buttons) { |
|||
if(StringUtils.isEmpty(btn.getPid())) { |
|||
return LangTips.errMsg("pid-not-empty", "pid", "按钮没有指定菜单,不允许保存"); |
|||
} |
|||
if(StringUtils.isEmpty(btn.getMenuType())) { |
|||
btn.setMenuType("2"); |
|||
} |
|||
if(StringUtils.isEmpty(btn.getId())) { |
|||
btn.setId(super.createKey("btnId")); |
|||
} |
|||
} |
|||
List<MenuDef> buttonsDb=selectExistsButonsByIds(buttons); |
|||
List<MenuDef> insertButtons=new ArrayList<>(); |
|||
List<MenuDef> updateButtons=new ArrayList<>(); |
|||
for (MenuDef menuDef : buttons) { |
|||
boolean exists=false; |
|||
for (MenuDef menuDefdb : buttonsDb) { |
|||
if(menuDefdb.getId().equals(menuDef.getId()) && menuDefdb.getPid().equals(menuDef.getPid())) { |
|||
updateButtons.add(menuDef); |
|||
exists=true; |
|||
break; |
|||
}else { |
|||
if(menuDefdb.getId().equals(menuDef.getId()) && !menuDefdb.getPid().equals(menuDef.getPid())) { |
|||
throw new BizException("id-exists", "id","按钮"+ menuDef.getMname()+"的编号【"+menuDef.getId()+"】已存在,请重新编号"); |
|||
} |
|||
} |
|||
} |
|||
if(exists==false) { |
|||
insertButtons.add(menuDef); |
|||
} |
|||
} |
|||
if(insertButtons.size()>0) { |
|||
super.batchInsert(insertButtons); |
|||
} |
|||
if(updateButtons.size()>0) { |
|||
super.batchUpdate(updateButtons); |
|||
} |
|||
|
|||
return LangTips.okMsg("ok","成功"); |
|||
|
|||
} |
|||
|
|||
private List<MenuDef> selectExistsButonsByIds(List<MenuDef> buttons) { |
|||
return getBaseMapper().selectExistsButonsByIds(buttons); |
|||
} |
|||
/** 请在此类添加自定义函数 */ |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,189 @@ |
|||
package com.mdp.menu.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.core.utils.DateUtils; |
|||
import com.mdp.menu.entity.MenuFavorite; |
|||
import com.mdp.menu.mapper.MenuFavoriteMapper; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 mdp 大模块 menu 小模块 <br> |
|||
* 实体 MenuFavorite 表 menu_favorite 当前主键(包括多主键): favoriteid; |
|||
***/ |
|||
@Service("mdp.menu.menuFavoriteService") |
|||
public class MenuFavoriteService extends BaseService<MenuFavoriteMapper,MenuFavorite> { |
|||
static Logger logger =LoggerFactory.getLogger(MenuFavoriteService.class); |
|||
@Autowired |
|||
private MenuDefService menuDefService; |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
/** |
|||
* 快捷入口的添加 |
|||
* |
|||
* @author 林钰坤 |
|||
* @cdate 2019/1/24 20:10 |
|||
*/ |
|||
public void saveMenuFavorites(Map<String, Object> params) { |
|||
List<Map<String, Object>> menuFavoriteListMap = (List) params.get("menuFavorites"); |
|||
Map<String, Object> userInfoMap = (Map) params.get("userInfo"); |
|||
String deptid = (String) userInfoMap.get("deptid"); |
|||
String userid = (String) userInfoMap.get("userid"); |
|||
String branchId = (String) userInfoMap.get("branchId"); |
|||
if (!StringUtils.hasText(userid)) { |
|||
throw new BizException("用户名不能为空"); |
|||
} |
|||
if (!StringUtils.hasText(deptid)) { |
|||
throw new BizException("请传递部门编号"); |
|||
} |
|||
if (!StringUtils.hasText(branchId)) { |
|||
throw new BizException("请传递机构编号"); |
|||
} |
|||
/* |
|||
* MenuFavorite getUserBeforeSetExpressEntry=new MenuFavorite(); |
|||
* getUserBeforeSetExpressEntry.setUserid(userid);//用户id |
|||
* getUserBeforeSetExpressEntry.setDeptid(deptid);//部门id List<MenuFavorite> |
|||
* UserBeforeMenuFavoriteList=this.selectListByWhere( |
|||
* getUserBeforeSetExpressEntry);//得到某个用户的设置的快捷入口 int |
|||
* UserBeforeMenuFavoriteLength=0;//用户之前设置的快捷入口的数量 int |
|||
* UserBeforeMenuFavoriteIndex=0; |
|||
* if(!CollectionUtils.isEmpty(UserBeforeMenuFavoriteList)) {//如果获取出来的对象不为空 |
|||
* UserBeforeMenuFavoriteLength=UserBeforeMenuFavoriteList.size();//赋值 } |
|||
*/ |
|||
/* |
|||
* MenuFavorite customerMenuFavoriteSelectObject=new MenuFavorite();//自定义的删除对象 |
|||
* customerMenuFavoriteSelectObject.setUserid(userid); |
|||
* customerMenuFavoriteSelectObject.setDeptid(deptid); |
|||
* customerMenuFavoriteSelectObject.setBranchId(branchId); List<MenuFavorite> |
|||
* customerMenuFavoriteSelectObjectList=this.selectListByWhere( |
|||
* customerMenuFavoriteSelectObject); for(int |
|||
* i=0;i<customerMenuFavoriteSelectObjectList.size();i++) {//获取出数据库中的内容 |
|||
* |
|||
* } |
|||
*/ |
|||
MenuFavorite customerMenuFavoriteDeleteObject = new MenuFavorite();// 自定义的删除对象 |
|||
customerMenuFavoriteDeleteObject.setUserid(userid); |
|||
customerMenuFavoriteDeleteObject.setDeptid(deptid); |
|||
customerMenuFavoriteDeleteObject.setBranchId(branchId); |
|||
this.deleteByWhere(customerMenuFavoriteDeleteObject); |
|||
for (int i = 0; i < menuFavoriteListMap.size(); i++) {// 遍历 |
|||
Map<String, Object> mf = menuFavoriteListMap.get(i); |
|||
String mfName =null; |
|||
String accUrl = (String) mf.get("accUrl");// 二级路径路径 |
|||
String favoriteid = (String) mf.get("favoriteid");// 二级路径路径 |
|||
String menuname = (String) mf.get("menuname");// 二级路径名字 |
|||
String iconUrl = (String) mf.get("icon");// 二级路径名字 |
|||
String mfPath = null; |
|||
if (!StringUtils.hasText(accUrl)) {// 如果为空 |
|||
mfPath = (String) mf.get("path");// 二级路径路径 |
|||
mfName= (String) mf.get("name");// 二级路径名字 |
|||
} else { |
|||
mfPath = accUrl; |
|||
mfName=menuname; |
|||
} |
|||
MenuFavorite menuFavorite = new MenuFavorite(); |
|||
if (!StringUtils.hasText(favoriteid)) {// 如果是空的 |
|||
favoriteid = createKey("favoriteid"); |
|||
} |
|||
menuFavorite.setFavoriteid(favoriteid);// 设置主键 |
|||
menuFavorite.setAccUrl(mfPath);// 设置路径 |
|||
menuFavorite.setBranchId(branchId);// 机构编号 |
|||
menuFavorite.setMenuname(mfName);// 设置菜单名字 |
|||
menuFavorite.setDeptid(deptid);// 设置部门编号 |
|||
menuFavorite.setUserid(userid);// 设置创建人 |
|||
menuFavorite.setCuserid(userid);// 得到用户id |
|||
menuFavorite.setLopuserid(userid);// 设置修改人 |
|||
menuFavorite.setIcon(iconUrl); |
|||
Date date = DateUtils.getNowDate(); |
|||
menuFavorite.setCdate(date);// 创建时间 |
|||
menuFavorite.setLopcreate(date);// 修改时间 |
|||
this.insert(menuFavorite);// 插入对象 |
|||
/* } */ |
|||
} |
|||
} |
|||
|
|||
public void batchSaveMenuFavorites(List<Map<String, Object>> params, String userid) { |
|||
//先删除 |
|||
if (!StringUtils.hasText(userid)) { |
|||
throw new BizException("用户名不能为空"); |
|||
} |
|||
MenuFavorite customerMenuFavoriteDeleteObject = new MenuFavorite();// 自定义的删除对象 |
|||
customerMenuFavoriteDeleteObject.setUserid(userid); |
|||
this.deleteByWhere(customerMenuFavoriteDeleteObject); |
|||
//添加modules |
|||
for (Map<String, Object> param : params) { |
|||
MenuFavorite menuFavorite = new MenuFavorite(); |
|||
menuFavorite.setFavoriteid(createKey("favoriteid")); |
|||
menuFavorite.setBranchId((String) param.get("branchId"));// 机构编号 |
|||
menuFavorite.setMenuname((String) param.get("menuname"));// 设置菜单名字 |
|||
menuFavorite.setMenuid((String) param.get("menuid")); |
|||
menuFavorite.setDeptid((String) param.get("deptid"));// 设置部门编号 |
|||
menuFavorite.setUserid(userid);// 设置创建人 |
|||
menuFavorite.setCuserid(userid);// 得到用户id |
|||
menuFavorite.setLopuserid(userid);// 设置修改人 |
|||
menuFavorite.setIcon((String) param.get("icon")); |
|||
this.insert(menuFavorite); //插入对象 |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 得到快捷入口所有的路径 |
|||
* |
|||
* @author 林钰坤 |
|||
* @cdate 2019/1/24 20:51 |
|||
*/ |
|||
public List<MenuFavorite> getMenuFavorites(String userid) { |
|||
|
|||
MenuFavorite customerMenuFavoriteQueryObject = new MenuFavorite(); |
|||
customerMenuFavoriteQueryObject.setUserid(userid);// 设置用户 |
|||
List<MenuFavorite> menuFavoriteList = this.selectListByWhere(customerMenuFavoriteQueryObject); |
|||
return menuFavoriteList; |
|||
} |
|||
|
|||
/** |
|||
* 新增快捷入口的图标 |
|||
* |
|||
* @author 林钰坤 |
|||
* @cdate 2019/1/25 14:02 |
|||
*/ |
|||
public void addMenuFavoriteIcon(Map<String, Object> params) { |
|||
Map<String, Object> menuFavorite = (Map) params.get("menuFavorite"); |
|||
String iconUrl = (String) params.get("iconUrl"); |
|||
String favoriteid = (String) menuFavorite.get("favoriteid"); |
|||
if (!StringUtils.hasText(favoriteid)) { |
|||
throw new BizException("请传入favoriteid"); |
|||
} |
|||
MenuFavorite customerMenuFavoriteUpdateObject = new MenuFavorite(); |
|||
customerMenuFavoriteUpdateObject.setFavoriteid(favoriteid); |
|||
customerMenuFavoriteUpdateObject.setIcon(iconUrl); |
|||
this.updateSomeFieldByPk(customerMenuFavoriteUpdateObject); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue