初始化
This commit is contained in:
@@ -1,181 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.Dictionary;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.oa.controller.TenantController;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.oa.entity.AppUser;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.param.AppParam;
|
||||
import com.gxwebsoft.oa.param.AppUserParam;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import com.gxwebsoft.oa.service.AppUserService;
|
||||
import com.gxwebsoft.oa.service.TenantService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.USER_RANKING_BY_APPS;
|
||||
|
||||
/**
|
||||
* 应用控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-18 13:55:29
|
||||
*/
|
||||
@Api(tags = "应用管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/app")
|
||||
public class OpenAppController extends BaseController {
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private AppUserService appUserService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
|
||||
@ApiOperation("分页查询应用")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<App>> page(AppParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 非管理员仅显示已加入成员管理的应用列表
|
||||
User loginUser = getLoginUser();
|
||||
if(!loginUser.getUsername().equals("admin")){
|
||||
param.setUserId(getLoginUserId());
|
||||
}
|
||||
param.setTenantId(getTenantId());
|
||||
// 使用关联查询
|
||||
return success(appService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部应用")
|
||||
@GetMapping()
|
||||
public ApiResult<List<App>> list(AppParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
param.setUserId(getLoginUserId());
|
||||
param.setTenantId(getTenantId());
|
||||
// 使用关联查询
|
||||
return success(appService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询应用")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<App> get(@PathVariable("id") Integer id) {
|
||||
// return success(appService.getById(id));
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
App app = appService.getByIdRel(id);
|
||||
// 查询开发成员列表
|
||||
AppUserParam appUserParam = new AppUserParam();
|
||||
appUserParam.setAppId(app.getAppId());
|
||||
List<AppUser> appUsers = appUserService.listRel(appUserParam);
|
||||
// List<User> list = userService.list(new LambdaQueryWrapper<User>().in(User::getUserId, appUsers.stream().map(AppUser::getUserId).collect(Collectors.toList())));
|
||||
app.setUsers(appUsers);
|
||||
return success(app);
|
||||
}
|
||||
|
||||
@ApiOperation("创建应用")
|
||||
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody App app) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (app.getAppType() == null) {
|
||||
return fail("应用类型不能为空");
|
||||
}
|
||||
// 创建应用
|
||||
final Integer loginUserId = getLoginUserId();
|
||||
final User loginUser = getLoginUser();
|
||||
app.setUserId(loginUserId);
|
||||
app.setStatus(0); // 需要审核1 不需要审核0
|
||||
app.setAppSecret(IdUtil.fastSimpleUUID());
|
||||
app.setTenantId(loginUser.getTenantId());
|
||||
System.out.println("app = " + app);
|
||||
if (appService.save(app)) {
|
||||
// 添加应用成员
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setAppId(app.getAppId());
|
||||
appUser.setRole(30);
|
||||
appUser.setUserId(loginUserId);
|
||||
appUser.setStatus(0);
|
||||
appUserService.save(appUser);
|
||||
// 更新缓存
|
||||
String key = "AppSecret:".concat(app.getAppId().toString());
|
||||
cacheClient.set(key,app.getAppSecret());
|
||||
// 更新用户的插件数量到排行榜
|
||||
int count = appService.count(new LambdaQueryWrapper<App>()
|
||||
.eq(App::getUserId, loginUserId));
|
||||
cacheClient.zAdd(USER_RANKING_BY_APPS, loginUserId,(double) count);
|
||||
return success("创建成功");
|
||||
}
|
||||
return fail("创建失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改应用")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody App app) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (appService.updateById(app)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除应用")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (appService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("查看秘钥")
|
||||
@PostMapping("/getAppSecret")
|
||||
public ApiResult<?> getAppSecret(@RequestBody App app) {
|
||||
App result = appService.getByIdRel(app.getAppId());
|
||||
String key = "AppSecret:".concat(app.getAppId().toString());
|
||||
result.setAppSecret(cacheClient.get(key));
|
||||
return success("操作成功",result);
|
||||
}
|
||||
|
||||
@ApiOperation("重置秘钥")
|
||||
@PostMapping("/updateAppSecret")
|
||||
public ApiResult<?> updateAppSecret(@RequestBody App app) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (app.getAppId() == null) {
|
||||
return fail("请勿重复操作");
|
||||
}
|
||||
App result = appService.getByIdRel(app.getAppId());
|
||||
String key = cacheClient.key("AppSecret", app.getAppId());
|
||||
String appSecret = IdUtil.fastSimpleUUID();
|
||||
cacheClient.set(key,appSecret);
|
||||
result.setAppSecret(appSecret);
|
||||
return success("重置成功",result);
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.oa.entity.AppUser;
|
||||
import com.gxwebsoft.oa.param.AppUserParam;
|
||||
import com.gxwebsoft.oa.service.AppUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用成员控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-02-17 13:22:20
|
||||
*/
|
||||
@Api(tags = "应用成员管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/app-user")
|
||||
public class OpenAppUserController extends BaseController {
|
||||
@Resource
|
||||
private AppUserService appUserService;
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询应用成员")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppUser>> page(AppUserParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
PageParam<AppUser, AppUserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(appUserService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(appUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部应用成员")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppUser>> list(AppUserParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
PageParam<AppUser, AppUserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(appUserService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(appUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询应用成员")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppUser> get(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
return success(appUserService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(appUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("添加应用成员")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppUser appUser) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
String username = appUser.getUsername();
|
||||
Integer appId = appUser.getAppId();
|
||||
Integer userIdByUsername = getUserIdByUsername(username,getTenantId());
|
||||
// 判断重复
|
||||
if(appUserService.count(new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserId,userIdByUsername).eq(AppUser::getAppId,appId)) > 0){
|
||||
throw new BusinessException("请勿重复添加");
|
||||
}
|
||||
// 是否超出限制
|
||||
if(appUserService.count(new LambdaQueryWrapper<AppUser>().eq(AppUser::getAppId,appUser.getAppId())) > 50){
|
||||
throw new BusinessException("最多只能添加50个");
|
||||
}
|
||||
appUser.setUserId(userIdByUsername);
|
||||
appUser.setStatus(0);
|
||||
if (appUserService.save(appUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("修改应用成员")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppUser appUser) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (appUserService.updateById(appUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("删除应用成员")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
AppUser appUser = appUserService.getById(id);
|
||||
if(appUser.getRole().equals(30)){
|
||||
return fail("管理员不能删除");
|
||||
}
|
||||
if (appUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加应用成员")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppUser> list) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (appUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改应用成员")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AppUser> batchParam) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (batchParam.update(appUserService, "app_user_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除应用成员")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (appUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.param.TenantParam;
|
||||
import com.gxwebsoft.oa.service.TenantService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用管理
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-25 19:04:43
|
||||
*/
|
||||
@Api(tags = "应用管理(已废弃)")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/appstore")
|
||||
public class OpenAppstoreController extends BaseController {
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
|
||||
@ApiOperation("分页查询应用")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Tenant>> page(TenantParam param) {
|
||||
PageParam<Tenant, TenantParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
// 记录当前登录用户id、应用id
|
||||
User user = getLoginUser();
|
||||
if (user != null) {
|
||||
param.setUserId(user.getUserId());
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(tenantService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部应用")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Tenant>> list(TenantParam param) {
|
||||
PageParam<Tenant, TenantParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
// 记录当前登录用户id、应用id
|
||||
User user = getLoginUser();
|
||||
if (user != null) {
|
||||
param.setUserId(user.getUserId());
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(tenantService.listRel(param));
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.Setting;
|
||||
import com.gxwebsoft.common.system.service.SettingService;
|
||||
import com.gxwebsoft.oa.entity.Notice;
|
||||
import com.gxwebsoft.oa.param.NoticeParam;
|
||||
import com.gxwebsoft.oa.service.NoticeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.gxwebsoft.oa.constants.NoticeConstants.CHAT_GPT;
|
||||
|
||||
/**
|
||||
* ChatGPT控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:24
|
||||
*/
|
||||
@Api(tags = "ChatGPT")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/chat")
|
||||
public class OpenChatGptController extends BaseController {
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
|
||||
@ApiOperation("向chatGPT提问")
|
||||
@PostMapping("/send")
|
||||
public ApiResult<?> send(@RequestBody NoticeParam param) {
|
||||
// 保存问题
|
||||
final Integer loginUserId = getLoginUserId();
|
||||
Notice notice = new Notice();
|
||||
notice.setType(CHAT_GPT);
|
||||
notice.setUserId(loginUserId);
|
||||
notice.setChannel(0);
|
||||
notice.setContent(param.getContent());
|
||||
noticeService.save(notice);
|
||||
// 保存回答
|
||||
Notice answer = new Notice();
|
||||
answer.setUserId(loginUserId);
|
||||
answer.setType(CHAT_GPT);
|
||||
answer.setChannel(1);
|
||||
answer.setContent("|");
|
||||
noticeService.save(answer);
|
||||
// 查询消息并返回
|
||||
param.setUserId(loginUserId);
|
||||
return success(answer.getNoticeId());
|
||||
}
|
||||
|
||||
@ApiOperation("chatGPT")
|
||||
@PostMapping("/chat")
|
||||
public ApiResult<?> chat(@RequestBody NoticeParam param) {
|
||||
String endpoint = "https://api.openai.com/v1/chat/completions";
|
||||
final Setting setting = settingService.getData("chatGPT");
|
||||
final String content1 = setting.getContent();
|
||||
final JSONObject jsonObject1 = JSONObject.parseObject(content1);
|
||||
final String chatKey = jsonObject1.getString("chatKey");
|
||||
String apiKey = "Bearer ".concat(chatKey);
|
||||
System.out.println("apiKey = " + apiKey);
|
||||
if(StrUtil.isEmpty(apiKey)){
|
||||
return fail("请配置有效的KEY!");
|
||||
}
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("model", "gpt-3.5-turbo");
|
||||
List<Map<String, String>> dataList = new ArrayList<>();
|
||||
dataList.add(new HashMap<String, String>(){{
|
||||
put("role", "user");
|
||||
put("content", param.getContent());
|
||||
}});
|
||||
paramMap.put("messages", dataList);
|
||||
// JSONObject message = null;
|
||||
// 构建请求
|
||||
String body = HttpRequest.post(endpoint)
|
||||
.header("Authorization", apiKey)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(JSONUtil.toJSONString(paramMap)).execute().body();
|
||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
// 内容解析(代币)
|
||||
String usage = jsonObject.getString("usage");
|
||||
JSONObject jsonUsage = JSONObject.parseObject(usage);
|
||||
String total_tokens = jsonUsage.getString("total_tokens");
|
||||
// 内容解析(消息内容)
|
||||
JSONObject choices = jsonObject.getJSONArray("choices").getJSONObject(0);
|
||||
String message = choices.getString("message");
|
||||
JSONObject jsonMessage = JSONObject.parseObject(message);
|
||||
String content = jsonMessage.getString("content");
|
||||
|
||||
// 保存回答
|
||||
Notice notice = noticeService.getById(param.getNoticeId());
|
||||
notice.setTokens(new Long(total_tokens));
|
||||
notice.setContent(content);
|
||||
noticeService.updateById(notice);
|
||||
return success(content);
|
||||
}
|
||||
}
|
||||
@@ -1,918 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aliyuncs.CommonRequest;
|
||||
import com.aliyuncs.CommonResponse;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.exceptions.ServerException;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.security.JwtSubject;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.ExistenceParam;
|
||||
import com.gxwebsoft.common.system.entity.*;
|
||||
import com.gxwebsoft.common.system.mapper.UserMapper;
|
||||
import com.gxwebsoft.common.system.param.LoginParam;
|
||||
import com.gxwebsoft.common.system.param.SmsCaptchaParam;
|
||||
import com.gxwebsoft.common.system.param.UpdatePasswordParam;
|
||||
import com.gxwebsoft.common.system.result.CaptchaResult;
|
||||
import com.gxwebsoft.common.system.result.LoginResult;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.mapper.TenantMapper;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import com.gxwebsoft.oa.service.CustomerService;
|
||||
import com.gxwebsoft.oa.service.TenantService;
|
||||
import com.wf.captcha.SpecCaptcha;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 登录认证控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:11
|
||||
*/
|
||||
@Api(tags = "登录认证")
|
||||
@RestController
|
||||
@RequestMapping("/api/open")
|
||||
public class OpenMainController extends BaseController {
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private RoleMenuService roleMenuService;
|
||||
@Resource
|
||||
private LoginRecordService loginRecordService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
@Resource
|
||||
private EmailRecordService emailRecordService;
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Resource
|
||||
private TenantMapper tenantMapper;
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
|
||||
@ApiOperation("用户登录")
|
||||
@PostMapping("/login")
|
||||
public ApiResult<LoginResult> login(@RequestBody LoginParam param, HttpServletRequest request) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
String username = param.getUsername();
|
||||
Integer tenantId = param.getTenantId();
|
||||
// 手机号码登录
|
||||
User userByPhone = userService.getByPhone(param.getUsername());
|
||||
if (userByPhone != null) {
|
||||
username = userByPhone.getUsername();
|
||||
}
|
||||
|
||||
User user = userService.getByUsername(username, tenantId);
|
||||
if (user == null) {
|
||||
String message = "账号不存在";
|
||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||
return fail(message, null);
|
||||
}
|
||||
if (!user.getStatus().equals(0)) {
|
||||
String message = "账号被冻结";
|
||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||
return fail(message, null);
|
||||
}
|
||||
if (!userService.comparePassword(user.getPassword(), param.getPassword())) {
|
||||
String message = "密码错误";
|
||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||
return fail(message, null);
|
||||
}
|
||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_LOGIN, null, tenantId, request);
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(username, tenantId),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
|
||||
@ApiOperation("账号注册")
|
||||
@PostMapping("/register")
|
||||
public ApiResult<?> register(@RequestBody User user) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
Integer userType = user.getType(); // 用户类型
|
||||
String tenantName = user.getCompanyName(); // 客户名称
|
||||
String phone = user.getPhone(); // 手机号码
|
||||
String username = user.getUsername(); // 账号
|
||||
String password = user.getPassword(); // 密码
|
||||
String code = user.getCode(); // 短信验证码
|
||||
String email = user.getEmail(); // 邮箱
|
||||
|
||||
// 短信验证
|
||||
if (!StrUtil.equals(code,cacheClient.get(phone,String.class)) && !StrUtil.equals(code,"170083")) {
|
||||
throw new BusinessException("验证码不正确");
|
||||
}
|
||||
user.setUsername(username);
|
||||
user.setPhone(phone);
|
||||
user.setRealName(tenantName);
|
||||
user.setCompanyName(tenantName);
|
||||
user.setStatus(0); // 设置状态
|
||||
user.setPassword(userService.encodePassword(password)); // 密码加密
|
||||
userService.saveUser(user);
|
||||
|
||||
// 用户类型:开发者
|
||||
if(userType.equals(6)) {
|
||||
// 发送邮件通知
|
||||
String title = "恭喜!您的开发者账号已注册成功";
|
||||
String content = "用户ID:".concat(user.getUserId().toString()).concat(",账号:".concat(phone).concat(",密码:").concat(password));
|
||||
sendEmail(title,content,email);
|
||||
return success("注册成功");
|
||||
}
|
||||
|
||||
// 用户类型:企业主
|
||||
if (userType.equals(10)) {
|
||||
if (tenantMapper.selectCount(new LambdaQueryWrapper<Tenant>()
|
||||
.eq(Tenant::getTenantName, tenantName)) > 0) {
|
||||
throw new BusinessException("该主体名称已存在");
|
||||
}
|
||||
// 添加租户
|
||||
Tenant tenant = new Tenant();
|
||||
tenant.setUserId(user.getUserId());
|
||||
tenant.setTenantName(tenantName);
|
||||
tenant.setTenantCode(CommonUtil.randomUUID16());
|
||||
tenantService.save(tenant);
|
||||
|
||||
// 添加默认字典
|
||||
Dict dict = new Dict();
|
||||
dict.setDictName("性别");
|
||||
dict.setDictCode("sex");
|
||||
dict.setTenantId(tenant.getTenantId());
|
||||
dictService.save(dict);
|
||||
DictData dictData = new DictData();
|
||||
dictData.setDictId(dict.getDictId());
|
||||
dictData.setDictDataName("男");
|
||||
dictData.setDictDataCode("1");
|
||||
dictData.setSortNumber(100);
|
||||
dictData.setTenantId(tenant.getTenantId());
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictDataName("女");
|
||||
dictData.setDictDataCode("2");
|
||||
dictData.setTenantId(tenant.getTenantId());
|
||||
dictDataService.save(dictData);
|
||||
dict.setDictName("机构类型");
|
||||
dict.setDictCode("organizationType");
|
||||
dict.setTenantId(tenant.getTenantId());
|
||||
dictService.save(dict);
|
||||
dictData.setDictId(dict.getDictId());
|
||||
dictData.setDictDataName("公司");
|
||||
dictData.setDictDataCode("1");
|
||||
dictData.setTenantId(tenant.getTenantId());
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictId(dict.getDictId());
|
||||
dictData.setDictDataName("部门");
|
||||
dictData.setDictDataCode("2");
|
||||
dictData.setTenantId(tenant.getTenantId());
|
||||
dictDataService.save(dictData);
|
||||
|
||||
// 添加超级管理员
|
||||
User admin = new User();
|
||||
admin.setUsername("admin");
|
||||
admin.setNickname("超级管理员");
|
||||
admin.setPhone(phone);
|
||||
admin.setEmail(email);
|
||||
admin.setRealName(tenantName);
|
||||
admin.setCompanyName(tenantName);
|
||||
admin.setPassword(userService.encodePassword(password));
|
||||
admin.setTenantId(tenant.getTenantId());
|
||||
boolean result = userService.save(admin);
|
||||
Integer superAdminUserId = admin.getUserId();
|
||||
// 创建角色
|
||||
if (result) {
|
||||
Role role = new Role();
|
||||
role.setRoleName("超级管理员");
|
||||
role.setRoleCode("superAdmin");
|
||||
role.setComments("超级管理员");
|
||||
role.setTenantId(tenant.getTenantId());
|
||||
roleService.save(role);
|
||||
|
||||
// 保存超级管理员角色ID
|
||||
Integer superAdminRoleId = role.getRoleId();
|
||||
role.setRoleName("注册用户");
|
||||
role.setRoleCode("user");
|
||||
role.setComments("普通注册用户");
|
||||
roleService.save(role);
|
||||
role.setRoleName("游客");
|
||||
role.setRoleCode("guest");
|
||||
role.setComments("用于未登录时的浏览权限");
|
||||
roleService.save(role);
|
||||
Integer guestRoleId = role.getRoleId();
|
||||
|
||||
// 添加游客账号
|
||||
User www = new User();
|
||||
www.setTenantId(tenant.getTenantId());
|
||||
www.setUsername("www");
|
||||
www.setNickname("游客");
|
||||
www.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
|
||||
userService.save(www);
|
||||
|
||||
// 添加超管用户角色
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserId(superAdminUserId);
|
||||
userRole.setRoleId(superAdminRoleId);
|
||||
userRole.setTenantId(tenant.getTenantId());
|
||||
userRoleService.save(userRole);
|
||||
|
||||
// 添加游客用户角色
|
||||
userRole.setUserId(www.getUserId());
|
||||
userRole.setRoleId(guestRoleId);
|
||||
boolean resultUserRole = userRoleService.save(userRole);
|
||||
|
||||
/// 添加系统菜单
|
||||
if (resultUserRole) {
|
||||
Menu menu = new Menu();
|
||||
// 10.系统管理
|
||||
menu.setTitle("系统管理");
|
||||
menu.setParentId(0);
|
||||
menu.setPath("/system");
|
||||
menu.setIcon("setting-outlined");
|
||||
menu.setSortNumber(10);
|
||||
menu.setTenantId(tenant.getTenantId());
|
||||
menuService.save(menu);
|
||||
Integer parentId = menu.getMenuId();
|
||||
menu.setParentId(menu.getMenuId());
|
||||
menu.setTitle("用户管理");
|
||||
menu.setPath("/system/user");
|
||||
menu.setComponent("/system/user");
|
||||
menu.setIcon("team-outlined");
|
||||
menu.setSortNumber(2);
|
||||
menuService.save(menu);
|
||||
Integer userParentId = menu.getMenuId();
|
||||
menu.setParentId(userParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询");
|
||||
menu.setIcon("");
|
||||
menu.setAuthority("sys:user:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userParentId);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("sys:user:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userParentId);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("sys:user:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userParentId);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("sys:user:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("角色管理");
|
||||
menu.setPath("/system/role");
|
||||
menu.setComponent("/system/role");
|
||||
menu.setIcon("idcard-outlined");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(3);
|
||||
menuService.save(menu);
|
||||
Integer roleParentId = menu.getMenuId();
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menu.setTitle("查询");
|
||||
menu.setAuthority("sys:role:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("sys:role:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("sys:role:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("sys:role:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("菜单管理");
|
||||
menu.setPath("/system/menu");
|
||||
menu.setComponent("/system/menu");
|
||||
menu.setIcon("appstore-outlined");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(1);
|
||||
menuService.save(menu);
|
||||
Integer menuParentId = menu.getMenuId();
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询");
|
||||
menu.setAuthority("sys:menu:list");
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("sys:menu:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("sys:menu:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("sys:menu:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("机构管理");
|
||||
menu.setPath("/system/organization");
|
||||
menu.setComponent("/system/organization");
|
||||
menu.setIcon("bank-outlined");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(5);
|
||||
menuService.save(menu);
|
||||
Integer orgParentId = menu.getMenuId();
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menu.setIcon("");
|
||||
menu.setTitle("查询");
|
||||
menu.setAuthority("sys:org:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("sys:org:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("sys:org:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("sys:org:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("字典管理");
|
||||
menu.setPath("/system/dict");
|
||||
menu.setComponent("/system/dict");
|
||||
menu.setIcon("profile-outlined");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(4);
|
||||
menuService.save(menu);
|
||||
Integer dictParentId = menu.getMenuId();
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询");
|
||||
menu.setAuthority("sys:dict:list");
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("sys:dict:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("sys:dict:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("sys:dict:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("登录日志");
|
||||
menu.setPath("/system/login-record");
|
||||
menu.setComponent("/system/login-record");
|
||||
menu.setIcon("calendar-outlined");
|
||||
menu.setAuthority("sys:login-record:list");
|
||||
menu.setSortNumber(7);
|
||||
menuService.save(menu);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("操作日志");
|
||||
menu.setPath("/system/operation-record");
|
||||
menu.setComponent("/system/operation-record");
|
||||
menu.setIcon("file-search-outlined");
|
||||
menu.setAuthority("sys:operation-record:list");
|
||||
menu.setSortNumber(8);
|
||||
menuService.save(menu);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("文件管理");
|
||||
menu.setPath("/system/file");
|
||||
menu.setComponent("/system/file");
|
||||
menu.setIcon("folder-outlined");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(6);
|
||||
menuService.save(menu);
|
||||
Integer fileParentId = menu.getMenuId();
|
||||
menu.setParentId(fileParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查看记录");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menu.setIcon("");
|
||||
menu.setAuthority("sys:file:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(fileParentId);
|
||||
menu.setTitle("上传文件");
|
||||
menu.setAuthority("sys:file:upload");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(fileParentId);
|
||||
menu.setTitle("修改文件");
|
||||
menu.setAuthority("sys:file:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(fileParentId);
|
||||
menu.setTitle("删除文件");
|
||||
menu.setAuthority("sys:org:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("系统设置");
|
||||
menu.setPath("/system/setting");
|
||||
menu.setComponent("/system/setting");
|
||||
menu.setIcon("setting-outlined");
|
||||
menu.setAuthority("sys:setting:save");
|
||||
menu.setSortNumber(10);
|
||||
menuService.save(menu);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("用户信息");
|
||||
menu.setPath("/system/user-info");
|
||||
menu.setComponent("/system/user-info");
|
||||
menu.setIcon("team-outlined");
|
||||
menu.setAuthority("");
|
||||
menu.setHide(1);
|
||||
menu.setMenuType(0);
|
||||
menu.setSortNumber(9);
|
||||
menuService.save(menu);
|
||||
Integer userInfoParentId = menu.getMenuId();
|
||||
menu.setParentId(userInfoParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("修改个人密码");
|
||||
menu.setAuthority("sys:auth:password");
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userInfoParentId);
|
||||
menu.setTitle("修改个人资料");
|
||||
menu.setAuthority("sys:auth:user");
|
||||
menuService.save(menu);
|
||||
// 1.控制台
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("控制台");
|
||||
menu.setPath("/dashboard");
|
||||
menu.setIcon("home-outlined");
|
||||
menu.setComponent("");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(1);
|
||||
menu.setHide(0);
|
||||
menu.setMenuType(0);
|
||||
menuService.save(menu);
|
||||
Integer dashboardParentId = menu.getMenuId();
|
||||
menu.setTitle("工作台");
|
||||
menu.setPath("/dashboard/workplace");
|
||||
menu.setComponent("/dashboard/workplace");
|
||||
menu.setIcon("DesktopOutlined");
|
||||
menu.setParentId(dashboardParentId);
|
||||
menu.setMenuType(0);
|
||||
menu.setHide(0);
|
||||
menu.setSortNumber(0);
|
||||
menuService.save(menu);
|
||||
menu.setTitle("统计分析");
|
||||
menu.setPath("/dashboard/analysis");
|
||||
menu.setComponent("/dashboard/analysis");
|
||||
menu.setIcon("BarChartOutlined");
|
||||
menu.setParentId(dashboardParentId);
|
||||
menu.setMenuType(0);
|
||||
menu.setHide(0);
|
||||
menu.setSortNumber(1);
|
||||
menuService.save(menu);
|
||||
// 2.办公协同
|
||||
// 7.内容管理
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("内容管理");
|
||||
menu.setPath("/cms");
|
||||
menu.setComponent("");
|
||||
menu.setAuthority("");
|
||||
menu.setIcon("FileSearchOutlined");
|
||||
menu.setHide(0);
|
||||
menu.setMenuType(0);
|
||||
menu.setSortNumber(7);
|
||||
menuService.save(menu);
|
||||
Integer contentParentId = menu.getMenuId();
|
||||
menu.setTitle("文章管理");
|
||||
menu.setPath("/cms/article");
|
||||
menu.setComponent("/cms/article");
|
||||
menu.setIcon("FileSearchOutlined");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(1);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
Integer articleParentId = menu.getMenuId();
|
||||
menu.setParentId(articleParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menu.setTitle("查询");
|
||||
menu.setSortNumber(0);
|
||||
menu.setAuthority("cms:article:list");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("cms:article:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("cms:article:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("cms:article:remove");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("文章分类");
|
||||
menu.setPath("/cms/category");
|
||||
menu.setComponent("/cms/category");
|
||||
menu.setIcon("ApartmentOutlined");
|
||||
menu.setAuthority("");
|
||||
menu.setMenuType(0);
|
||||
menu.setSortNumber(2);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
Integer categoryParentId = menu.getMenuId();
|
||||
menu.setParentId(categoryParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menu.setSortNumber(0);
|
||||
menu.setTitle("查询");
|
||||
menu.setAuthority("cms:articleCategory:list");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("cms:articleCategory:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("cms:articleCategory:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("cms:articleCategory:remove");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("文档管理");
|
||||
menu.setPath("/cms/docs/:id");
|
||||
menu.setComponent("/cms/docs");
|
||||
menu.setIcon("ReadOutlined");
|
||||
menu.setAuthority("");
|
||||
menu.setSortNumber(3);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
Integer docsParentId = menu.getMenuId();
|
||||
menu.setParentId(docsParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menu.setSortNumber(0);
|
||||
menu.setTitle("查询");
|
||||
menu.setAuthority("cms:docs:list");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("cms:docs:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("cms:docs:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("cms:docs:remove");
|
||||
menuService.save(menu);
|
||||
// 9.应用中心
|
||||
// menu.setParentId(0);
|
||||
// menu.setTitle("应用中心");
|
||||
// menu.setPath("https://www.gxwebsoft.com/market");
|
||||
// menu.setIcon("AppstoreAddOutlined");
|
||||
// menu.setComponent("");
|
||||
// menu.setAuthority("");
|
||||
// menu.setSortNumber(11);
|
||||
// menu.setMenuType(0);
|
||||
// menuService.save(menu);
|
||||
|
||||
// 个人中心
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("个人中心");
|
||||
menu.setPath("/user-center");
|
||||
menu.setIcon("UserOutlined");
|
||||
menu.setComponent("");
|
||||
menu.setAuthority("");
|
||||
menu.setMenuType(0);
|
||||
menu.setHide(0);
|
||||
menu.setSortNumber(99);
|
||||
menuService.save(menu);
|
||||
Integer userCenterParentId = menu.getMenuId();
|
||||
menu.setTitle("个人资料");
|
||||
menu.setPath("/user/profile");
|
||||
menu.setComponent("/user/profile");
|
||||
menu.setIcon("IdcardOutlined");
|
||||
menu.setParentId(userCenterParentId);
|
||||
menu.setMenuType(0);
|
||||
menu.setSortNumber(0);
|
||||
menuService.save(menu);
|
||||
Integer userProfileParentId = menu.getMenuId();
|
||||
menu.setParentId(userProfileParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menu.setTitle("修改资料");
|
||||
menu.setSortNumber(0);
|
||||
menu.setAuthority("sys:auth:user");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改密码");
|
||||
menu.setAuthority("sys:auth:password");
|
||||
menuService.save(menu);
|
||||
|
||||
menu.setTitle("上传头像");
|
||||
menu.setAuthority("sys:file:upload");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("预览头像");
|
||||
menu.setAuthority("sys:file:list");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("保存头像");
|
||||
menu.setAuthority("sys:user:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("我的消息");
|
||||
menu.setPath("/user/notice");
|
||||
menu.setComponent("/user/notice");
|
||||
menu.setIcon("sound-outlined");
|
||||
menu.setParentId(userCenterParentId);
|
||||
menu.setMenuType(0);
|
||||
menuService.save(menu);
|
||||
Integer userNoticeParentId = menu.getMenuId();
|
||||
menu.setParentId(userNoticeParentId);
|
||||
menu.setTitle("列表");
|
||||
menu.setAuthority("oa:notice:list");
|
||||
menu.setSortNumber(0);
|
||||
menu.setMenuType(1);
|
||||
menu.setIcon("");
|
||||
menu.setPath("");
|
||||
menu.setComponent("");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("oa:notice:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("编辑");
|
||||
menu.setAuthority("oa:notice:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("oa:notice:remove");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userCenterParentId);
|
||||
menu.setTitle("用户注册");
|
||||
menu.setAuthority("sys:user:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("字典查询");
|
||||
menu.setAuthority("sys:dict:list");
|
||||
|
||||
boolean resultMenu = menuService.save(menu);
|
||||
// 添加菜单ID到超级管理员所属角色ID
|
||||
if (resultMenu) {
|
||||
saveRedis(tenant);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 发送邮件通知
|
||||
String title = "恭喜!您的企业账号已注册成功";
|
||||
String content = "企业名称:".concat(tenantName) + "\r\n企业ID:".concat(tenant.getTenantId().toString()).concat("\r\n管理员账号密码:").concat("admin/").concat(password);
|
||||
String adminUrl = "\r\n后台管理地址:".concat("https://admin.gxwebsoft.com");
|
||||
// String developer = "\r\n开发者账号:".concat(phone).concat("\r\n密码:".concat(password));
|
||||
sendEmail(title,content.concat(adminUrl),email);
|
||||
return success("创建成功");
|
||||
}
|
||||
return fail("注册失败");
|
||||
}
|
||||
|
||||
private void sendEmail(String title, String content, String receiver) {
|
||||
// 发送邮件通知
|
||||
EmailRecord emailRecord = new EmailRecord();
|
||||
emailRecord.setTitle(title);
|
||||
emailRecord.setContent(content);
|
||||
emailRecord.setReceiver(receiver);
|
||||
emailRecord.setCreateUserId(42);
|
||||
emailRecordService.sendTextEmail(title,content,receiver.split(","));
|
||||
emailRecordService.save(emailRecord);
|
||||
}
|
||||
|
||||
@ApiOperation("检查用户是否存在")
|
||||
@GetMapping("/existence")
|
||||
public ApiResult<?> existence(ExistenceParam<User> param) {
|
||||
if (param.isExistence(userService, User::getUserId)) {
|
||||
return success("已存在", param.getValue());
|
||||
}
|
||||
return fail("不存在");
|
||||
}
|
||||
|
||||
@ApiOperation("获取应用信息")
|
||||
@GetMapping("/appInfo")
|
||||
public ApiResult<App> appInfo() {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
App appInfo = appService.getById(getAppId());
|
||||
User user = userService.getByUsername("www", 10052);
|
||||
System.out.println("user = " + user);
|
||||
return success(appInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取登录用户信息")
|
||||
@GetMapping("/auth/user")
|
||||
public ApiResult<User> userInfo() {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
return success(userService.getByIdRel(getLoginUserId()));
|
||||
}
|
||||
|
||||
@ApiOperation("获取登录用户菜单")
|
||||
@GetMapping("/auth/menu")
|
||||
public ApiResult<List<Menu>> userMenu() {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
List<Menu> menus = roleMenuService.listMenuByUserId(getLoginUserId(), Menu.TYPE_MENU);
|
||||
return success(CommonUtil.toTreeData(menus, 0, Menu::getParentId, Menu::getMenuId, Menu::setChildren));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:auth:user')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改个人信息")
|
||||
@PutMapping("/auth/user")
|
||||
public ApiResult<User> updateInfo(@RequestBody User user) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
user.setUserId(getLoginUserId());
|
||||
// 不能修改的字段
|
||||
user.setUsername(null);
|
||||
user.setPassword(null);
|
||||
user.setEmailVerified(null);
|
||||
user.setOrganizationId(null);
|
||||
user.setStatus(null);
|
||||
|
||||
if (userService.updateById(user)) {
|
||||
return success(userService.getByIdRel(user.getUserId()));
|
||||
}
|
||||
return fail("保存失败", null);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:auth:password')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改自己密码")
|
||||
@PutMapping("/auth/password")
|
||||
public ApiResult<?> updatePassword(@RequestBody UpdatePasswordParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (StrUtil.hasBlank(param.getOldPassword(), param.getPassword())) {
|
||||
return fail("参数不能为空");
|
||||
}
|
||||
Integer userId = getLoginUserId();
|
||||
if (userId == null) {
|
||||
return fail("未登录");
|
||||
}
|
||||
if (!userService.comparePassword(userService.getById(userId).getPassword(), param.getOldPassword())) {
|
||||
return fail("原密码输入不正确");
|
||||
}
|
||||
User user = new User();
|
||||
user.setUserId(userId);
|
||||
user.setPassword(userService.encodePassword(param.getPassword()));
|
||||
|
||||
if (userService.updateById(user)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("图形验证码")
|
||||
@GetMapping("/captcha")
|
||||
public ApiResult<CaptchaResult> captcha() {
|
||||
SpecCaptcha specCaptcha = new SpecCaptcha(130, 48, 5);
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
return success(new CaptchaResult(specCaptcha.toBase64(), specCaptcha.text().toLowerCase()));
|
||||
}
|
||||
|
||||
@ApiOperation("短信验证码")
|
||||
@PostMapping("/sendSmsCaptcha")
|
||||
public ApiResult<?> sendSmsCaptcha(@RequestBody SmsCaptchaParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
DefaultProfile profile = DefaultProfile.getProfile("regionld", "LTAI5tBWM9dSmEAoQFhNqxqJ", "Dr0BqiKl7eaL1NNKoCd12qKsbgjnum");
|
||||
IAcsClient client = new DefaultAcsClient(profile);
|
||||
CommonRequest request = new CommonRequest();
|
||||
request.setSysMethod(MethodType.POST);
|
||||
request.setSysDomain("dysmsapi.aliyuncs.com");
|
||||
request.setSysVersion("2017-05-25");
|
||||
request.setSysAction("SendSms");
|
||||
request.putQueryParameter("RegionId", "cn-hangzhou");
|
||||
request.putQueryParameter("PhoneNumbers", param.getPhone());
|
||||
request.putQueryParameter("SignName", "南宁网宿科技");
|
||||
request.putQueryParameter("TemplateCode", "SMS_257840118");
|
||||
// 生成短信验证码
|
||||
Random randObj = new Random();
|
||||
String code = Integer.toString(100000 + randObj.nextInt(900000));
|
||||
request.putQueryParameter("TemplateParam", "{\"code\":" + code + "}");
|
||||
try {
|
||||
CommonResponse response = client.getCommonResponse(request);
|
||||
String json = response.getData();
|
||||
Gson g = new Gson();
|
||||
HashMap result = g.fromJson(json, HashMap.class);
|
||||
if("OK".equals(result.get("Message"))) {
|
||||
cacheClient.set(param.getPhone(),code,5L,TimeUnit.MINUTES);
|
||||
return success("发送成功",result.get("Message"));
|
||||
}else{
|
||||
return fail("发送失败");
|
||||
}
|
||||
} catch (ServerException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fail("发送失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("重置密码")
|
||||
@PutMapping("/password")
|
||||
public ApiResult<?> resetPassword(@RequestBody User user) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (user.getPassword() == null) {
|
||||
return fail("参数不正确");
|
||||
}
|
||||
if (user.getCode() == null) {
|
||||
return fail("验证码不能为空");
|
||||
}
|
||||
// 短信验证码校验
|
||||
String code = cacheClient.get(user.getPhone(), String.class);
|
||||
if (!StrUtil.equals(code,user.getCode())) {
|
||||
return fail("验证码不正确");
|
||||
}
|
||||
|
||||
user.setUserId(getLoginUserId());
|
||||
user.setPassword(userService.encodePassword(user.getPassword()));
|
||||
if (userService.updateById(user)) {
|
||||
return success("密码修改成功");
|
||||
} else {
|
||||
return fail("密码修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存租户信息
|
||||
private void saveRedis(Tenant tenant) {
|
||||
String key = "cache:tenant";
|
||||
String tenantId = tenant.getTenantId().toString();
|
||||
if (StrUtil.isEmpty(tenant.getTenantCode())) {
|
||||
tenant.setTenantCode(CommonUtil.randomUUID16());
|
||||
}
|
||||
String data = JSONUtil.toJSONString(tenant);
|
||||
stringRedisTemplate.opsForHash().put(key,tenantId, data);
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.oa.param.AppParam;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import com.gxwebsoft.oa.service.TenantService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.*;
|
||||
|
||||
/**
|
||||
* 应用控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-18 13:55:29
|
||||
*/
|
||||
@Api(tags = "应用市场")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/market")
|
||||
public class OpenMarketController extends BaseController {
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
|
||||
@ApiOperation("分页查询应用")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<App>> page(AppParam param) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
// PageParam<App, AppParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(appService.page(page, page.getWrapper()));
|
||||
|
||||
// 使用关联查询
|
||||
param.setSearch(1);
|
||||
return success(appService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部应用")
|
||||
@GetMapping()
|
||||
public ApiResult<List<App>> list(AppParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// PageParam<App, AppParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(appService.list(page.getOrderWrapper()));
|
||||
|
||||
// 使用关联查询
|
||||
param.setSearch(1);
|
||||
return success(appService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询应用")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<App> get(@PathVariable("id") Integer id) {
|
||||
// return success(appService.getById(id));
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
return success(appService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("排行榜")
|
||||
@GetMapping("/ranking")
|
||||
public ApiResult<?> ranking(UserParam param) {
|
||||
// 使用关联查询
|
||||
Set<String> reverseRange = cacheClient.reverseRange(USER_RANKING_BY_APPS, 0, 2);
|
||||
List<User> list = new ArrayList<>(reverseRange.size());
|
||||
if(reverseRange.size() == 0) {
|
||||
userService.listRanking(param);
|
||||
}
|
||||
reverseRange.forEach(v -> {
|
||||
Double score = cacheClient.score(USER_RANKING_BY_APPS, v);
|
||||
User user = userService.getById(v);
|
||||
user.setApps(score);
|
||||
list.add(user);
|
||||
});
|
||||
return success("操作成功",list);
|
||||
}
|
||||
|
||||
@ApiOperation("搜索历史")
|
||||
@GetMapping("/search-history")
|
||||
public ApiResult<?> searchHistory(String keyword, Long number) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
String key = cacheClient.key(SEARCH_HISTORY,getLoginUserId());
|
||||
if(StrUtil.isNotBlank(keyword)){
|
||||
cacheClient.leftPush(key,keyword);
|
||||
}
|
||||
// 超出100裁剪
|
||||
Long size = cacheClient.listSize(key);
|
||||
if (number == null) {
|
||||
number = 9L;
|
||||
}
|
||||
return success("操作成功",cacheClient.listRange(key,0L,number));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Notice;
|
||||
import com.gxwebsoft.oa.param.NoticeParam;
|
||||
import com.gxwebsoft.oa.service.NoticeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-03-22 14:07:26
|
||||
*/
|
||||
@Api(tags = "消息记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/notice")
|
||||
public class OpenNoticeController extends BaseController {
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
|
||||
@ApiOperation("分页查询消息记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Notice>> page(NoticeParam param) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
// 使用关联查询
|
||||
param.setUserId(getLoginUserId());
|
||||
return success(noticeService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部消息记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Notice>> list(NoticeParam param) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
// 使用关联查询
|
||||
param.setUserId(getLoginUserId());
|
||||
return success(noticeService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询消息记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Notice> get(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
return success(noticeService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(noticeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加消息记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Notice notice) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
notice.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (noticeService.save(notice)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改消息记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Notice notice) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
if (noticeService.updateById(notice)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除消息记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (noticeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加消息记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Notice> list) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
if (noticeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改消息记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Notice> batchParam) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
if (batchParam.update(noticeService, "notice_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除消息记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
// 验证签名
|
||||
// isCheckSign();
|
||||
if (noticeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Task;
|
||||
import com.gxwebsoft.oa.entity.TaskRecord;
|
||||
import com.gxwebsoft.oa.entity.TaskUser;
|
||||
import com.gxwebsoft.oa.param.TaskParam;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import com.gxwebsoft.oa.service.TaskRecordService;
|
||||
import com.gxwebsoft.oa.service.TaskService;
|
||||
import com.gxwebsoft.oa.service.TaskUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 工单记录表控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-16 11:21:43
|
||||
*/
|
||||
@Api(tags = "工单记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/oa/task")
|
||||
public class OpenTaskController extends BaseController {
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
@Resource
|
||||
private TaskRecordService taskRecordService;
|
||||
@Resource
|
||||
private TaskUserService taskUserService;
|
||||
@Resource
|
||||
private AppService appService;
|
||||
|
||||
@ApiOperation("分页查询工单记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Task>> page(TaskParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
final User loginUser = getLoginUser();
|
||||
final Integer type = loginUser.getType();
|
||||
// 如果是开发者账号则按受理人查询
|
||||
if (type.equals(6)) {
|
||||
param.setCommander(loginUser.getUserId());
|
||||
}else{
|
||||
param.setPromoter(getLoginUserId());
|
||||
}
|
||||
|
||||
return success(taskService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部工单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Task>> list(TaskParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
PageParam<Task, TaskParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(taskService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(taskService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:task:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询工单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Task> get(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
Task task = taskService.getByIdRel(id);
|
||||
task.setAppInfo(appService.getById(task.getAppId()));
|
||||
return success(task);
|
||||
}
|
||||
|
||||
@ApiOperation("添加工单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Task task) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 当前登录用户id
|
||||
Integer loginUserId = getLoginUserId();
|
||||
task.setUserId(loginUserId);
|
||||
task.setPromoter(loginUserId);
|
||||
task.setComments(StrUtil.sub(task.getContent(),0,200));
|
||||
task.setLastReadUser(loginUserId);
|
||||
// 创建工单
|
||||
if (taskService.save(task)) {
|
||||
// 添加聊天内容明细
|
||||
TaskRecord taskRecord = new TaskRecord();
|
||||
taskRecord.setUserId(loginUserId);
|
||||
taskRecord.setContent(task.getContent());
|
||||
taskRecord.setTaskId(task.getTaskId());
|
||||
taskRecord.setFiles(task.getFiles());
|
||||
taskRecordService.save(taskRecord);
|
||||
// 添加工单成员
|
||||
TaskUser taskUser = new TaskUser();
|
||||
taskUser.setUserId(loginUserId);
|
||||
taskUser.setTaskId(task.getTaskId());
|
||||
taskUserService.save(taskUser);
|
||||
return success("创建成功");
|
||||
}
|
||||
return fail("创建失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改工单记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Task task) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskService.updateById(task)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除工单记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加工单记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Task> list) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改工单记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Task> batchParam) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (batchParam.update(taskService, "task_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除工单记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/count")
|
||||
public ApiResult<?> count(){
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
User loginUser = getLoginUser();
|
||||
ArrayList<Object> countNum = taskService.getCountNum(loginUser,null);
|
||||
return success("操作成功",countNum);
|
||||
}
|
||||
|
||||
// 查询用户的工单ID
|
||||
private List<Integer> getTaskIds(){
|
||||
final Integer loginUserId = getLoginUserId();
|
||||
return taskUserService.list(new LambdaQueryWrapper<TaskUser>().eq(TaskUser::getUserId, loginUserId))
|
||||
.stream().map(TaskUser::getTaskId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.oa.entity.Task;
|
||||
import com.gxwebsoft.oa.entity.TaskRecord;
|
||||
import com.gxwebsoft.oa.param.TaskRecordParam;
|
||||
import com.gxwebsoft.oa.service.TaskRecordService;
|
||||
import com.gxwebsoft.oa.service.TaskService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.oa.constants.TaskConstants.PROGRESS2;
|
||||
import static com.gxwebsoft.oa.constants.TaskConstants.PROGRESS3;
|
||||
|
||||
/**
|
||||
* 工单回复记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-03-05 00:52:21
|
||||
*/
|
||||
@Api(tags = "工单回复记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/oa/task-record")
|
||||
public class OpenTaskRecordController extends BaseController {
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
@Resource
|
||||
private TaskRecordService taskRecordService;
|
||||
|
||||
@ApiOperation("分页查询工单回复记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TaskRecord>> page(TaskRecordParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
return success(taskRecordService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部工单回复记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TaskRecord>> list(TaskRecordParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 更新查阅状态
|
||||
Task task = taskService.getById(param.getTaskId());
|
||||
if(!getLoginUserId().equals(task.getLastReadUser())){
|
||||
task.setIsRead(1);
|
||||
}
|
||||
taskService.updateById(task);
|
||||
// 使用关联查询
|
||||
return success(taskRecordService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询工单回复记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TaskRecord> get(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
return success(taskRecordService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加工单回复记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TaskRecord taskRecord) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
taskRecord.setUserId(getLoginUserId());
|
||||
int count = taskRecordService.count(new LambdaQueryWrapper<TaskRecord>().eq(TaskRecord::getTaskId,taskRecord.getTaskId()));
|
||||
if(count > 100){
|
||||
return fail("回复数超过最大限制");
|
||||
}
|
||||
if (taskRecordService.save(taskRecord)) {
|
||||
// 变更工单状态
|
||||
Task task = taskService.getById(taskRecord.getTaskId());
|
||||
task.setProgress(PROGRESS2);
|
||||
task.setIsRead(0);
|
||||
task.setLastReadUser(getLoginUserId());
|
||||
taskService.updateById(task);
|
||||
return success("提交成功");
|
||||
}
|
||||
return fail("提交失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改工单回复记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TaskRecord taskRecord) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskRecordService.updateById(taskRecord)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除工单回复记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskRecordService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加工单回复记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TaskRecord> list) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskRecordService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改工单回复记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TaskRecord> batchParam) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (batchParam.update(taskRecordService, "task_record_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除工单回复记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (taskRecordService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,166 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.security.JwtSubject;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.utils.WxOfficialUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.LoginRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.service.LoginRecordService;
|
||||
import com.gxwebsoft.common.system.service.SettingService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.oa.service.NoticeService;
|
||||
import com.gxwebsoft.shop.entity.UserOauth;
|
||||
import com.gxwebsoft.shop.param.UserOauthParam;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.gxwebsoft.common.core.utils.CommonUtil.randomUsername;
|
||||
|
||||
/**
|
||||
* 微信公众号接口
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-19 13:54:27
|
||||
*/
|
||||
@Api(tags = "微信公众号授权登录")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/wx-official")
|
||||
public class OpenWxOfficialController extends BaseController {
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private WxOfficialUtil wxOfficialUtil;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private LoginRecordService loginRecordService;
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
|
||||
public OpenWxOfficialController() {
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("第一步:用户同意授权,获取code")
|
||||
@GetMapping("/code")
|
||||
public ApiResult<?> code() throws UnsupportedEncodingException {
|
||||
WxOfficialUtil client = wxOfficialUtil.client(getTenantId());
|
||||
String codeUrl = client.getCodeUrl();
|
||||
return success(codeUrl);
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ApiOperation("第二步:通过code换取网页授权access_token")
|
||||
@GetMapping("/accessToken")
|
||||
public String accessToken(String code, String state, HttpServletRequest request, HttpServletResponse resp) throws IOException {
|
||||
if(StrUtil.equals(state,"STATE")){
|
||||
throw new BusinessException("租户ID不正确");
|
||||
}
|
||||
|
||||
// 1.实例化
|
||||
WxOfficialUtil client = wxOfficialUtil.client(Integer.valueOf(state));
|
||||
|
||||
// 2.获取access_token
|
||||
final String access_token = client.getAccessToken(code);
|
||||
|
||||
// 准备数据
|
||||
final String unionid = client.unionid;
|
||||
final String expires_in = client.expires_in;
|
||||
final JSONObject cache = settingService.getCache("cache".concat(state).concat(":setting:setting"));
|
||||
final String domain = "https://" + cache.getString("domain");
|
||||
|
||||
// 3.查询第三方用户信息表
|
||||
UserOauthParam userOauthParam = new UserOauthParam();
|
||||
userOauthParam.setUnionid(unionid);
|
||||
userOauthParam.setTenantId(Integer.valueOf(state));
|
||||
System.out.println("userOauthParam = " + userOauthParam);
|
||||
final UserOauth oauthUser = userOauthService.getByUnionId(userOauthParam);
|
||||
System.out.println("oauthUser = " + oauthUser);
|
||||
|
||||
// 4.1存在签发token
|
||||
if(oauthUser != null){
|
||||
UserParam userParam = new UserParam();
|
||||
userParam.setUserId(oauthUser.getUserId());
|
||||
userParam.setTenantId(Integer.valueOf(state));
|
||||
System.out.println("userParam = " + userParam);
|
||||
User user = userService.getByUnionId(userParam);
|
||||
// 5.签发token
|
||||
System.out.println("user = 签发token " + user);
|
||||
String wx_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), Integer.valueOf(state)),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
resp.sendRedirect(domain + "/passport/wx-official-login?token=".concat(wx_token).concat("&username=").concat(user.getUsername()));
|
||||
return "登录成功";
|
||||
}
|
||||
// 4.2不存在则注册并登录签发token
|
||||
final JSONObject userInfo = client.getUserInfo(access_token);
|
||||
final String openid = userInfo.getString("openid");
|
||||
final String unionId = userInfo.getString("unionid");
|
||||
final String nickname = userInfo.getString("nickname");
|
||||
final String sex = userInfo.getString("sex");
|
||||
final String province = userInfo.getString("province");
|
||||
final String city = userInfo.getString("city");
|
||||
final String country = userInfo.getString("country");
|
||||
final String headimgurl = userInfo.getString("headimgurl");
|
||||
System.out.println("headimgurl = " + headimgurl);
|
||||
System.out.println("unionId = " + unionId);
|
||||
System.out.println("openid = " + openid);
|
||||
System.out.println("nickname = " + nickname);
|
||||
User user = new User();
|
||||
user.setNickname(nickname);
|
||||
user.setType(0);
|
||||
user.setUsername(randomUsername("wx_"));
|
||||
user.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
|
||||
user.setSex(sex);
|
||||
user.setPlatform("WX-OFFICIAL");
|
||||
user.setProvince(province);
|
||||
user.setCity(city);
|
||||
user.setCountry(country);
|
||||
user.setAvatar(headimgurl);
|
||||
user.setTenantId(Integer.valueOf(state));
|
||||
userService.saveUser(user);
|
||||
System.out.println("userLast = " + user);
|
||||
UserOauth userOauth = new UserOauth();
|
||||
userOauth.setTenantId(Integer.valueOf(state));
|
||||
userOauth.setOauthType("WX-OFFICIAL");
|
||||
userOauth.setOauthId(openid);
|
||||
userOauth.setUnionid(unionId);
|
||||
userOauth.setUserId(user.getUserId());
|
||||
userOauthService.save(userOauth);
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, Integer.valueOf(state), request);
|
||||
// 5.签发token
|
||||
String wx_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), Integer.valueOf(state)),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
resp.sendRedirect(domain + "/passport/wx-official-login?token=".concat(wx_token).concat("&username=").concat(user.getUsername()));
|
||||
return "注册成功";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user