diff --git a/src/main/java/com/gxwebsoft/common/core/utils/WxUtil.java b/src/main/java/com/gxwebsoft/common/core/utils/WxUtil.java index 035ce91..ad45abe 100644 --- a/src/main/java/com/gxwebsoft/common/core/utils/WxUtil.java +++ b/src/main/java/com/gxwebsoft/common/core/utils/WxUtil.java @@ -73,24 +73,44 @@ public class WxUtil { // 获取access_token public void getAccessToken(String code) { String key = "cache"+ this.tenantId +":ww:access_token"; - final String access_token = stringRedisTemplate.opsForValue().get(key); - if(access_token != null){ - this.getUserInfo(code,access_token); - }else { - String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" +this.appId+ "&corpsecret="+ this.appSecret; - System.out.println("url = " + url); - String response = HttpUtil.get(url, CharsetUtil.CHARSET_UTF_8); - System.out.println("response = " + response); - final JSONObject jsonObject = JSONObject.parseObject(response); - // 获取成功 - if(jsonObject.getString("access_token") != null){ - this.access_token = jsonObject.getString("access_token"); - this.expires_in = jsonObject.getString("expires_in"); - stringRedisTemplate.opsForValue().set(key,this.access_token,7000, TimeUnit.SECONDS); - System.out.println("获取access_token成功 = " + this.access_token); - this.getUserInfo(code,this.access_token); + final String cachedValue = stringRedisTemplate.opsForValue().get(key); + + if(cachedValue != null){ + try { + // 尝试解析JSON格式的缓存 + JSONObject cachedJson = JSONObject.parseObject(cachedValue); + String accessToken = cachedJson.getString("access_token"); + if (accessToken != null) { + this.access_token = accessToken; + this.getUserInfo(code, accessToken); + return; + } + } catch (Exception e) { + // 如果解析失败,可能是旧格式的纯字符串token + System.out.println("企业微信缓存token格式异常,使用原值: " + e.getMessage()); + this.access_token = cachedValue; + this.getUserInfo(code, cachedValue); + return; } } + + // 缓存中没有,重新获取 + String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" +this.appId+ "&corpsecret="+ this.appSecret; + System.out.println("调用企业微信API获取token - URL: " + url); + String response = HttpUtil.get(url, CharsetUtil.CHARSET_UTF_8); + System.out.println("企业微信API响应: " + response); + final JSONObject jsonObject = JSONObject.parseObject(response); + + // 获取成功 + if(jsonObject.getString("access_token") != null){ + this.access_token = jsonObject.getString("access_token"); + this.expires_in = jsonObject.getString("expires_in"); + + // 缓存完整的JSON响应,与其他方法保持一致 + stringRedisTemplate.opsForValue().set(key, response, 7000, TimeUnit.SECONDS); + System.out.println("获取企业微信access_token成功 = " + this.access_token); + this.getUserInfo(code, this.access_token); + } } // 获取userinfo diff --git a/src/main/java/com/gxwebsoft/common/core/utils/WxWorkUtil.java b/src/main/java/com/gxwebsoft/common/core/utils/WxWorkUtil.java index 5a4e449..70635ed 100644 --- a/src/main/java/com/gxwebsoft/common/core/utils/WxWorkUtil.java +++ b/src/main/java/com/gxwebsoft/common/core/utils/WxWorkUtil.java @@ -73,24 +73,44 @@ public class WxWorkUtil { // 获取access_token public void getAccessToken(String code) { String key = "cache"+ this.tenantId +":ww:access_token"; - final String access_token = stringRedisTemplate.opsForValue().get(key); - if(access_token != null){ - this.getUserInfo(code,access_token); - }else { - String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" +this.appId+ "&corpsecret="+ this.appSecret; - System.out.println("url = " + url); - String response = HttpUtil.get(url, CharsetUtil.CHARSET_UTF_8); - System.out.println("response = " + response); - final JSONObject jsonObject = JSONObject.parseObject(response); - // 获取成功 - if(jsonObject.getString("access_token") != null){ - this.access_token = jsonObject.getString("access_token"); - this.expires_in = jsonObject.getString("expires_in"); - stringRedisTemplate.opsForValue().set(key,this.access_token,7000, TimeUnit.SECONDS); - System.out.println("获取access_token成功 = " + this.access_token); - this.getUserInfo(code,this.access_token); + final String cachedValue = stringRedisTemplate.opsForValue().get(key); + + if(cachedValue != null){ + try { + // 尝试解析JSON格式的缓存 + JSONObject cachedJson = JSONObject.parseObject(cachedValue); + String accessToken = cachedJson.getString("access_token"); + if (accessToken != null) { + this.access_token = accessToken; + this.getUserInfo(code, accessToken); + return; + } + } catch (Exception e) { + // 如果解析失败,可能是旧格式的纯字符串token + System.out.println("企业微信Work缓存token格式异常,使用原值: " + e.getMessage()); + this.access_token = cachedValue; + this.getUserInfo(code, cachedValue); + return; } } + + // 缓存中没有,重新获取 + String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" +this.appId+ "&corpsecret="+ this.appSecret; + System.out.println("调用企业微信Work API获取token - URL: " + url); + String response = HttpUtil.get(url, CharsetUtil.CHARSET_UTF_8); + System.out.println("企业微信Work API响应: " + response); + final JSONObject jsonObject = JSONObject.parseObject(response); + + // 获取成功 + if(jsonObject.getString("access_token") != null){ + this.access_token = jsonObject.getString("access_token"); + this.expires_in = jsonObject.getString("expires_in"); + + // 缓存完整的JSON响应,与其他方法保持一致 + stringRedisTemplate.opsForValue().set(key, response, 7000, TimeUnit.SECONDS); + System.out.println("获取企业微信Work access_token成功 = " + this.access_token); + this.getUserInfo(code, this.access_token); + } } // 获取userinfo diff --git a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java index 1e40d16..0ac4e3b 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java @@ -49,683 +49,714 @@ import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KE @RequestMapping("/api/wx-login") @Tag(name = "微信小程序登录API") public class WxLoginController extends BaseController { - private final StringRedisTemplate redisTemplate; - private final OkHttpClient http = new OkHttpClient(); - private final ObjectMapper om = new ObjectMapper(); - private volatile long tokenExpireEpoch = 0L; // 过期的 epoch 秒 - @Resource - private SettingService settingService; - @Resource - private UserService userService; - @Resource - private ConfigProperties configProperties; - @Resource - private UserRoleService userRoleService; - @Resource - private LoginRecordService loginRecordService; - @Resource - private RoleService roleService; - @Resource - private RedisUtil redisUtil; - @Resource - private RequestUtil requestUtil; - @Resource - private ConfigProperties config; - @Resource - private UserRefereeService userRefereeService; - - - - public WxLoginController(StringRedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - } - - @Operation(summary = "获取微信AccessToken") - @Transactional(rollbackFor = {Exception.class}) - @PostMapping("/getAccessToken") - public ApiResult getMpAccessToken() { - return success("操作成功", getAccessToken()); - } - - @Operation(summary = "获取微信openId") - @Transactional(rollbackFor = {Exception.class}) - @PostMapping("/getOpenId") - public ApiResult getOpenId(@RequestBody UserParam userParam, HttpServletRequest request) { - // 1.获取openid - JSONObject result = getOpenIdByCode(userParam); + private final StringRedisTemplate redisTemplate; + private final OkHttpClient http = new OkHttpClient(); + private final ObjectMapper om = new ObjectMapper(); + private volatile long tokenExpireEpoch = 0L; // 过期的 epoch 秒 + @Resource + private SettingService settingService; + @Resource + private UserService userService; + @Resource + private ConfigProperties configProperties; + @Resource + private UserRoleService userRoleService; + @Resource + private LoginRecordService loginRecordService; + @Resource + private RoleService roleService; + @Resource + private RedisUtil redisUtil; + @Resource + private RequestUtil requestUtil; + @Resource + private ConfigProperties config; + @Resource + private UserRefereeService userRefereeService; + + + public WxLoginController(StringRedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + @Operation(summary = "获取微信AccessToken") + @Transactional(rollbackFor = {Exception.class}) + @PostMapping("/getAccessToken") + public ApiResult getMpAccessToken() { + return success("操作成功", getAccessToken()); + } + + @Operation(summary = "获取微信openId") + @Transactional(rollbackFor = {Exception.class}) + @PostMapping("/getOpenId") + public ApiResult getOpenId(@RequestBody UserParam userParam, HttpServletRequest request) { + // 1.获取openid + JSONObject result = getOpenIdByCode(userParam); + String openid = result.getString("openid"); + String unionid = result.getString("unionid"); + if (openid == null) { + return fail("获取openid失败", null); + } + // 2.通过openid查询用户是否已存在 + User user = userService.getByOauthId(userParam); + // 3.存在则签发token并返回登录成功,不存在则注册新用户 + if (user == null) { + user = addUser(userParam); + } + // 4.签发token + loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request); + String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()), + configProperties.getTokenExpireTime(), configProperties.getTokenKey()); + return success("登录成功", new LoginResult(access_token, user)); + } + + @Operation(summary = "微信授权手机号码并登录") + @Transactional(rollbackFor = {Exception.class}) + @PostMapping("/loginByMpWxPhone") + public ApiResult loginByMpWxPhone(@RequestBody UserParam userParam, HttpServletRequest request) { + // 获取手机号码 + String phone = getPhoneByCode(userParam); + if (phone == null) { + String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString()); + redisTemplate.delete(key); + throw new BusinessException("授权失败,请重试"); + } + // 查询是否存在 + User user = userService.getByPhone(phone); + // 不存在则注册 + if (user == null) { + if ((userParam.getOpenid() == null || userParam.getOpenid().isEmpty()) && userParam.getAuthCode() != null) { + UserParam userParam2 = new UserParam(); + userParam2.setCode(userParam.getAuthCode()); + JSONObject result = getOpenIdByCode(userParam2); String openid = result.getString("openid"); - String unionid = result.getString("unionid"); - if (openid == null) { - return fail("获取openid失败", null); - } - // 2.通过openid查询用户是否已存在 - User user = userService.getByOauthId(userParam); - // 3.存在则签发token并返回登录成功,不存在则注册新用户 - if (user == null) { - user = addUser(userParam); - } - // 4.签发token - loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request); - String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()), - configProperties.getTokenExpireTime(), configProperties.getTokenKey()); - return success("登录成功", new LoginResult(access_token, user)); - } - - @Operation(summary = "微信授权手机号码并登录") - @Transactional(rollbackFor = {Exception.class}) - @PostMapping("/loginByMpWxPhone") - public ApiResult loginByMpWxPhone(@RequestBody UserParam userParam, HttpServletRequest request) { - // 获取手机号码 - String phone = getPhoneByCode(userParam); - if (phone == null) { - String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString()); - redisTemplate.delete(key); - throw new BusinessException("授权失败,请重试"); - } - // 查询是否存在 - User user = userService.getByPhone(phone); - // 不存在则注册 - if (user == null) { - if ((userParam.getOpenid() == null || userParam.getOpenid().isEmpty()) && userParam.getAuthCode() != null) { - UserParam userParam2 = new UserParam(); - userParam2.setCode(userParam.getAuthCode()); - JSONObject result = getOpenIdByCode(userParam2); - String openid = result.getString("openid"); // String unionid = result.getString("unionid"); - userParam.setOpenid(openid); - } - userParam.setPhone(phone); - user = addUser(userParam); - user.setRecommend(1); - }else { - // 存在则检查绑定上级 - if (userParam.getSceneType() != null && userParam.getSceneType().equals("save_referee") && userParam.getRefereeId() != null && userParam.getRefereeId() != 0) { - UserReferee check = userRefereeService.check(user.getUserId(), userParam.getRefereeId()); - if (check == null) { - UserReferee userReferee = new UserReferee(); - userReferee.setDealerId(userParam.getRefereeId()); - userReferee.setUserId(user.getUserId()); - userRefereeService.save(userReferee); - } - } + userParam.setOpenid(openid); + } + userParam.setPhone(phone); + user = addUser(userParam); + user.setRecommend(1); + } else { + // 存在则检查绑定上级 + if (userParam.getSceneType() != null && userParam.getSceneType().equals("save_referee") && userParam.getRefereeId() != null && userParam.getRefereeId() != 0) { + UserReferee check = userRefereeService.check(user.getUserId(), userParam.getRefereeId()); + if (check == null) { + UserReferee userReferee = new UserReferee(); + userReferee.setDealerId(userParam.getRefereeId()); + userReferee.setUserId(user.getUserId()); + userRefereeService.save(userReferee); } - // 签发token - String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()), - configProperties.getTokenExpireTime(), configProperties.getTokenKey()); - loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_REGISTER, null, user.getTenantId(), request); - // 附加体育中心项目用户信息 + } + } + // 签发token + String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()), + configProperties.getTokenExpireTime(), configProperties.getTokenKey()); + loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_REGISTER, null, user.getTenantId(), request); + // 附加体育中心项目用户信息 // user.setBookingUser(); - return success("登录成功", new LoginResult(access_token, user)); - } - - @Operation(summary = "微信授权手机号码并更新") - @Transactional(rollbackFor = {Exception.class}) - @PostMapping("/updatePhoneByMpWx") - public ApiResult updatePhoneByMpWx(@RequestBody UserParam userParam) { - // 获取微信授权手机号 - String phone = getPhoneByCode(userParam); - // 查询当前用户 - User user = userService.getById(userParam.getUserId()); - if (user != null && phone != null) { - user.setPhone(phone); - userService.updateUser(user); - return success("更新成功", phone); - } - return fail("更新失败"); - } - - /** - * 新用户注册 - */ - private User addUser(UserParam userParam) { - User addUser = new User(); - // 注册用户 - addUser.setStatus(0); - addUser.setUsername(createUsername("wx_")); - addUser.setNickname("微信用户"); - addUser.setPlatform(MP_WEIXIN); - addUser.setGradeId(2); - if (userParam.getGradeId() != null) { - addUser.setGradeId(userParam.getGradeId()); - } - if (userParam.getPhone() != null) { - addUser.setPhone(userParam.getPhone()); - } - if (StrUtil.isNotBlank(userParam.getOpenid())) { - addUser.setOpenid(userParam.getOpenid()); - } - if (StrUtil.isNotBlank(userParam.getUnionid())) { - addUser.setUnionid(userParam.getUnionid()); - } - addUser.setPassword(userService.encodePassword(CommonUtil.randomUUID16())); - addUser.setTenantId(getTenantId()); - addUser.setRecommend(1); - Role role = roleService.getOne(new QueryWrapper().eq("role_code", "user"), false); - addUser.setRoleId(role.getRoleId()); - if (userService.saveUser(addUser)) { - // 添加用户角色 - final UserRole userRole = new UserRole(); - userRole.setUserId(addUser.getUserId()); - userRole.setTenantId(addUser.getTenantId()); - userRole.setRoleId(addUser.getRoleId()); - userRoleService.save(userRole); - } - // 绑定关系 - if (userParam.getSceneType() != null && userParam.getSceneType().equals("save_referee") && userParam.getRefereeId() != null && userParam.getRefereeId() != 0) { - UserReferee check = userRefereeService.check(addUser.getUserId(), userParam.getRefereeId()); - if (check == null) { - UserReferee userReferee = new UserReferee(); - userReferee.setDealerId(userParam.getRefereeId()); - userReferee.setUserId(addUser.getUserId()); - userRefereeService.save(userReferee); - } - } - return addUser; - } - - // 获取openid - private JSONObject getOpenIdByCode(UserParam userParam) { - // 获取微信小程序配置信息 - JSONObject setting = settingService.getBySettingKey("mp-weixin",getTenantId()); - // 获取openId - String apiUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + setting.getString("appId") + "&secret=" + setting.getString("appSecret") + "&js_code=" + userParam.getCode() + "&grant_type=authorization_code"; - // 执行get请求 - String result = HttpUtil.get(apiUrl); - // 解析access_token - return JSON.parseObject(result); - } - - /** - * 获取微信手机号码 - * - * @param userParam 需要传微信凭证code - */ - private String getPhoneByCode(UserParam userParam) { - // 获取手机号码 - String apiUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + getAccessToken(); - HashMap paramMap = new HashMap<>(); - if (StrUtil.isBlank(userParam.getCode())) { - throw new BusinessException("code不能为空"); - } - paramMap.put("code", userParam.getCode()); - // 执行post请求 - String post = HttpUtil.post(apiUrl, JSON.toJSONString(paramMap)); - JSONObject json = JSON.parseObject(post); - if (json.get("errcode").equals(0)) { - JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info")); - // 微信用户的手机号码 - final String phoneNumber = phoneInfo.getString("phoneNumber"); - // 验证手机号码 + return success("登录成功", new LoginResult(access_token, user)); + } + + @Operation(summary = "微信授权手机号码并更新") + @Transactional(rollbackFor = {Exception.class}) + @PostMapping("/updatePhoneByMpWx") + public ApiResult updatePhoneByMpWx(@RequestBody UserParam userParam) { + // 获取微信授权手机号 + String phone = getPhoneByCode(userParam); + // 查询当前用户 + User user = userService.getById(userParam.getUserId()); + if (user != null && phone != null) { + user.setPhone(phone); + userService.updateUser(user); + return success("更新成功", phone); + } + return fail("更新失败"); + } + + /** + * 新用户注册 + */ + private User addUser(UserParam userParam) { + User addUser = new User(); + // 注册用户 + addUser.setStatus(0); + addUser.setUsername(createUsername("wx_")); + addUser.setNickname("微信用户"); + addUser.setPlatform(MP_WEIXIN); + addUser.setGradeId(2); + if (userParam.getGradeId() != null) { + addUser.setGradeId(userParam.getGradeId()); + } + if (userParam.getPhone() != null) { + addUser.setPhone(userParam.getPhone()); + } + if (StrUtil.isNotBlank(userParam.getOpenid())) { + addUser.setOpenid(userParam.getOpenid()); + } + if (StrUtil.isNotBlank(userParam.getUnionid())) { + addUser.setUnionid(userParam.getUnionid()); + } + addUser.setPassword(userService.encodePassword(CommonUtil.randomUUID16())); + addUser.setTenantId(getTenantId()); + addUser.setRecommend(1); + Role role = roleService.getOne(new QueryWrapper().eq("role_code", "user"), false); + addUser.setRoleId(role.getRoleId()); + if (userService.saveUser(addUser)) { + // 添加用户角色 + final UserRole userRole = new UserRole(); + userRole.setUserId(addUser.getUserId()); + userRole.setTenantId(addUser.getTenantId()); + userRole.setRoleId(addUser.getRoleId()); + userRoleService.save(userRole); + } + // 绑定关系 + if (userParam.getSceneType() != null && userParam.getSceneType().equals("save_referee") && userParam.getRefereeId() != null && userParam.getRefereeId() != 0) { + UserReferee check = userRefereeService.check(addUser.getUserId(), userParam.getRefereeId()); + if (check == null) { + UserReferee userReferee = new UserReferee(); + userReferee.setDealerId(userParam.getRefereeId()); + userReferee.setUserId(addUser.getUserId()); + userRefereeService.save(userReferee); + } + } + return addUser; + } + + // 获取openid + private JSONObject getOpenIdByCode(UserParam userParam) { + // 获取微信小程序配置信息 + JSONObject setting = settingService.getBySettingKey("mp-weixin", getTenantId()); + // 获取openId + String apiUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + setting.getString("appId") + "&secret=" + setting.getString("appSecret") + "&js_code=" + userParam.getCode() + "&grant_type=authorization_code"; + // 执行get请求 + String result = HttpUtil.get(apiUrl); + // 解析access_token + return JSON.parseObject(result); + } + + /** + * 获取微信手机号码 + * + * @param userParam 需要传微信凭证code + */ + private String getPhoneByCode(UserParam userParam) { + // 获取手机号码 + String apiUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + getAccessToken(); + HashMap paramMap = new HashMap<>(); + if (StrUtil.isBlank(userParam.getCode())) { + throw new BusinessException("code不能为空"); + } + paramMap.put("code", userParam.getCode()); + // 执行post请求 + String post = HttpUtil.post(apiUrl, JSON.toJSONString(paramMap)); + JSONObject json = JSON.parseObject(post); + if (json.get("errcode").equals(0)) { + JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info")); + // 微信用户的手机号码 + final String phoneNumber = phoneInfo.getString("phoneNumber"); + // 验证手机号码 // if (userParam.getNotVerifyPhone() == null && !Validator.isMobile(phoneNumber)) { // String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString()); // redisTemplate.delete(key); // throw new BusinessException("手机号码格式不正确"); // } - return phoneNumber; - } - return null; - } - - /** - * 生成随机账号 - * - * @return username - */ - private String createUsername(String type) { - return type.concat(RandomUtil.randomString(12)); - } - - /** - * 获取接口调用凭据AccessToken - * ... - */ - public String getAccessToken() { - Integer tenantId = getTenantId(); - String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId.toString()); - - // 使用跨租户方式获取微信小程序配置信息 - JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); - if (setting == null) { - throw new BusinessException("请先配置小程序"); - } - - // 从缓存获取access_token - String value = redisTemplate.opsForValue().get(key); - if (value != null) { - // 解析access_token - JSONObject response = JSON.parseObject(value); - String accessToken = response.getString("access_token"); - if (accessToken != null) { - return accessToken; - } - } + return phoneNumber; + } + return null; + } + + /** + * 生成随机账号 + * + * @return username + */ + private String createUsername(String type) { + return type.concat(RandomUtil.randomString(12)); + } + + /** + * 获取接口调用凭据AccessToken + * ... + */ + public String getAccessToken() { + Integer tenantId = getTenantId(); + String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId.toString()); + + // 使用跨租户方式获取微信小程序配置信息 + JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); + if (setting == null) { + throw new BusinessException("请先配置小程序"); + } - // 微信获取凭证接口 - String apiUrl = "https://api.weixin.qq.com/cgi-bin/token"; - // 组装url参数 - String url = apiUrl.concat("?grant_type=client_credential") - .concat("&appid=").concat(setting.getString("appId")) - .concat("&secret=").concat(setting.getString("appSecret")); - - // 执行get请求 - String result = HttpUtil.get(url); - // 解析access_token - JSONObject response = JSON.parseObject(result); - if (response.getString("access_token") != null) { - // 存入缓存 - redisTemplate.opsForValue().set(key, result, 7000L, TimeUnit.SECONDS); - return response.getString("access_token"); - } - throw new BusinessException("小程序配置不正确"); + // 从缓存获取access_token + String value = redisTemplate.opsForValue().get(key); + if (value != null) { + // 解析access_token + JSONObject response = JSON.parseObject(value); + String accessToken = response.getString("access_token"); + if (accessToken != null) { + return accessToken; + } } - @Operation(summary = "获取微信openId并更新") - @PostMapping("/getWxOpenId") - public ApiResult getWxOpenId(@RequestBody UserParam userParam) { - final User loginUser = getLoginUser(); - if (loginUser == null) { - return fail("请先登录"); - } - // 已存在直接返回 - if (StrUtil.isNotBlank(loginUser.getOpenid())) { - return success(loginUser); - } - // 请求微信接口获取openid - String apiUrl = "https://api.weixin.qq.com/sns/jscode2session"; - final HashMap map = new HashMap<>(); - final JSONObject setting = settingService.getBySettingKey("mp-weixin",getTenantId()); - final String appId = setting.getString("appId"); - final String appSecret = setting.getString("appSecret"); - map.put("appid", appId); - map.put("secret", appSecret); - map.put("js_code", userParam.getCode()); - map.put("grant_type", "authorization_code"); - final String response = HttpUtil.get(apiUrl, map); - final JSONObject jsonObject = JSONObject.parseObject(response); - String openid = jsonObject.getString("openid"); - String sessionKey = jsonObject.getString("session_key"); - String unionid = jsonObject.getString("unionid"); - // 保存openID - if (loginUser.getOpenid() == null || StrUtil.isBlank(loginUser.getOpenid())) { - loginUser.setOpenid(openid); - loginUser.setUnionid(unionid); - requestUtil.updateUser(loginUser); + // 微信获取凭证接口 + String apiUrl = "https://api.weixin.qq.com/cgi-bin/token"; + // 组装url参数 + String url = apiUrl.concat("?grant_type=client_credential") + .concat("&appid=").concat(setting.getString("appId")) + .concat("&secret=").concat(setting.getString("appSecret")); + + // 执行get请求 + String result = HttpUtil.get(url); + // 解析access_token + JSONObject response = JSON.parseObject(result); + if (response.getString("access_token") != null) { + // 存入缓存 + redisTemplate.opsForValue().set(key, result, 7000L, TimeUnit.SECONDS); + return response.getString("access_token"); + } + throw new BusinessException("小程序配置不正确"); + } + + @Operation(summary = "获取微信openId并更新") + @PostMapping("/getWxOpenId") + public ApiResult getWxOpenId(@RequestBody UserParam userParam) { + final User loginUser = getLoginUser(); + if (loginUser == null) { + return fail("请先登录"); + } + // 已存在直接返回 + if (StrUtil.isNotBlank(loginUser.getOpenid())) { + return success(loginUser); + } + // 请求微信接口获取openid + String apiUrl = "https://api.weixin.qq.com/sns/jscode2session"; + final HashMap map = new HashMap<>(); + final JSONObject setting = settingService.getBySettingKey("mp-weixin", getTenantId()); + final String appId = setting.getString("appId"); + final String appSecret = setting.getString("appSecret"); + map.put("appid", appId); + map.put("secret", appSecret); + map.put("js_code", userParam.getCode()); + map.put("grant_type", "authorization_code"); + final String response = HttpUtil.get(apiUrl, map); + final JSONObject jsonObject = JSONObject.parseObject(response); + String openid = jsonObject.getString("openid"); + String sessionKey = jsonObject.getString("session_key"); + String unionid = jsonObject.getString("unionid"); + // 保存openID + if (loginUser.getOpenid() == null || StrUtil.isBlank(loginUser.getOpenid())) { + loginUser.setOpenid(openid); + loginUser.setUnionid(unionid); + requestUtil.updateUser(loginUser); // userService.updateById(loginUser); - } - return success("获取成功", jsonObject); - } - - @Operation(summary = "仅获取微信openId") - @PostMapping("/getWxOpenIdOnly") - public ApiResult getWxOpenIdOnly(@RequestBody UserParam userParam) { - - String apiUrl = "https://api.weixin.qq.com/sns/jscode2session"; - final HashMap map = new HashMap<>(); - final JSONObject setting = settingService.getBySettingKey("mp-weixin",getTenantId()); - final String appId = setting.getString("appId"); - final String appSecret = setting.getString("appSecret"); - map.put("appid", appId); - map.put("secret", appSecret); - map.put("js_code", userParam.getCode()); - map.put("grant_type", "authorization_code"); - final String response = HttpUtil.get(apiUrl, map); - final JSONObject jsonObject = JSONObject.parseObject(response); - return success("获取成功", jsonObject); - } - - @Operation(summary = "获取微信小程序码-用户ID") - @GetMapping("/getUserQRCode") - public ApiResult getQRCode() { - String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken(); - final HashMap map = new HashMap<>(); - map.put("path", "/package/user/qrcode?user_id=" + getLoginUserId()); + } + return success("获取成功", jsonObject); + } + + @Operation(summary = "仅获取微信openId") + @PostMapping("/getWxOpenIdOnly") + public ApiResult getWxOpenIdOnly(@RequestBody UserParam userParam) { + + String apiUrl = "https://api.weixin.qq.com/sns/jscode2session"; + final HashMap map = new HashMap<>(); + final JSONObject setting = settingService.getBySettingKey("mp-weixin", getTenantId()); + final String appId = setting.getString("appId"); + final String appSecret = setting.getString("appSecret"); + map.put("appid", appId); + map.put("secret", appSecret); + map.put("js_code", userParam.getCode()); + map.put("grant_type", "authorization_code"); + final String response = HttpUtil.get(apiUrl, map); + final JSONObject jsonObject = JSONObject.parseObject(response); + return success("获取成功", jsonObject); + } + + @Operation(summary = "获取微信小程序码-用户ID") + @GetMapping("/getUserQRCode") + public ApiResult getQRCode() { + String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken(); + final HashMap map = new HashMap<>(); + map.put("path", "/package/user/qrcode?user_id=" + getLoginUserId()); // map.put("env_version","trial"); - // 获取图片 Buffer - byte[] qrCode = HttpRequest.post(apiUrl) - .body(JSON.toJSONString(map)) - .execute().bodyBytes(); - - // 保存的文件名称 - final String fileName = CommonUtil.randomUUID8().concat(".png"); - // 保存路径 - String filePath = getUploadDir().concat("qrcode/") + fileName; - File file = FileUtil.writeBytes(qrCode, filePath); - if (file != null) { - return success(config.getFileServer().concat("/qrcode/").concat(fileName)); - } - return fail("获取失败", null); - } - - @Operation(summary = "获取微信小程序码-订单核销码") - @GetMapping("/getOrderQRCode/{orderNo}") - public ApiResult getOrderQRCode(@PathVariable("orderNo") String orderNo) { - String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken(); - final HashMap map = new HashMap<>(); - map.put("path", "/package/admin/order-scan?orderNo=".concat(orderNo)); - map.put("env_version", "release"); - // 获取图片 Buffer - byte[] qrCode = HttpRequest.post(apiUrl) - .body(JSON.toJSONString(map)) - .execute().bodyBytes(); - - // 保存的文件名称 - final String fileName = CommonUtil.randomUUID8().concat(".png"); - // 保存路径 - String filePath = getUploadDir().concat("qrcode/") + fileName; - File file = FileUtil.writeBytes(qrCode, filePath); - if (file != null) { - return success(config.getFileServer().concat("/qrcode/").concat(fileName)); - } - return fail("获取失败", null); + // 获取图片 Buffer + byte[] qrCode = HttpRequest.post(apiUrl) + .body(JSON.toJSONString(map)) + .execute().bodyBytes(); + + // 保存的文件名称 + final String fileName = CommonUtil.randomUUID8().concat(".png"); + // 保存路径 + String filePath = getUploadDir().concat("qrcode/") + fileName; + File file = FileUtil.writeBytes(qrCode, filePath); + if (file != null) { + return success(config.getFileServer().concat("/qrcode/").concat(fileName)); } - - @Operation(summary = "获取微信小程序码-订单核销码-数量极多的业务场景") - @GetMapping("/getOrderQRCodeUnlimited/{scene}") - public void getOrderQRCodeUnlimited(@PathVariable("scene") String scene, HttpServletResponse response) throws IOException { - try { - // 从scene参数中解析租户ID - Integer tenantId = extractTenantIdFromScene(scene); - System.out.println("从scene参数中解析租户ID = " + tenantId); - if (tenantId == null) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.getWriter().write("{\"error\":\"无法从scene参数中获取租户信息\"}"); - return; - } - - // 使用指定租户ID获取 access_token - String accessToken = getAccessTokenForTenant(tenantId); - String apiUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken; - - final HashMap map = new HashMap<>(); - map.put("scene", scene); - map.put("page", "pages/index/index"); - map.put("env_version", "release"); - - String jsonBody = JSON.toJSONString(map); - System.out.println("请求的 JSON body = " + jsonBody); - - // 获取微信 API 响应 - cn.hutool.http.HttpResponse httpResponse = HttpRequest.post(apiUrl) - .body(jsonBody) - .execute(); - - byte[] responseBytes = httpResponse.bodyBytes(); - String contentType = httpResponse.header("Content-Type"); - - // 检查响应内容类型,判断是否为错误响应 - if (contentType != null && contentType.contains("application/json")) { - // 微信返回了错误信息(JSON格式) - String errorResponse = new String(responseBytes, "UTF-8"); - System.err.println("微信 API 错误响应: " + errorResponse); - - // 返回错误信息给前端 - response.setContentType("application/json;charset=UTF-8"); - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.getWriter().write(errorResponse); - return; - } - - // 成功获取二维码图片 - response.setContentType("image/png"); - response.setHeader("Cache-Control", "no-cache"); - response.setHeader("Content-Disposition", "inline; filename=qrcode.png"); - - // 输出图片 - response.getOutputStream().write(responseBytes); - System.out.println("二维码生成成功,大小: " + responseBytes.length + " bytes"); - - } catch (Exception e) { - System.err.println("生成二维码失败: " + e.getMessage()); - e.printStackTrace(); - - // 返回错误信息 - response.setContentType("application/json;charset=UTF-8"); - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - response.getWriter().write("{\"error\":\"生成二维码失败: " + e.getMessage() + "\"}"); - } + return fail("获取失败", null); + } + + @Operation(summary = "获取微信小程序码-订单核销码") + @GetMapping("/getOrderQRCode/{orderNo}") + public ApiResult getOrderQRCode(@PathVariable("orderNo") String orderNo) { + String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken(); + final HashMap map = new HashMap<>(); + map.put("path", "/package/admin/order-scan?orderNo=".concat(orderNo)); + map.put("env_version", "release"); + // 获取图片 Buffer + byte[] qrCode = HttpRequest.post(apiUrl) + .body(JSON.toJSONString(map)) + .execute().bodyBytes(); + + // 保存的文件名称 + final String fileName = CommonUtil.randomUUID8().concat(".png"); + // 保存路径 + String filePath = getUploadDir().concat("qrcode/") + fileName; + File file = FileUtil.writeBytes(qrCode, filePath); + if (file != null) { + return success(config.getFileServer().concat("/qrcode/").concat(fileName)); } - - @Operation(summary = "获取微信小程序码-用户ID") - @GetMapping("/getQRCodeText") - public byte[] getQRCodeText(String scene, String page, Integer width, - Boolean isHyaline, String envVersion) throws IOException { - HttpUrl url = HttpUrl.parse("https://api.weixin.qq.com/wxa/getwxacodeunlimit") - .newBuilder() - .addQueryParameter("access_token", getLocalAccessToken()) - .build(); - - System.out.println("page = " + page); - // 构造请求 JSON - // 注意:scene 仅支持可见字符,长度上限 32,尽量 URL-safe(字母数字下划线等) - // page 必须是已发布小程序内的路径(不带开头斜杠也可) - var root = om.createObjectNode(); - root.put("scene", scene); - if (page != null) root.put("page", page); - if (width != null) root.put("width", width); // 默认 430,建议 280~1280 - if (isHyaline != null) root.put("is_hyaline", isHyaline); - if (envVersion != null) root.put("env_version", envVersion); // release/trial/develop - - okhttp3.RequestBody reqBody = okhttp3.RequestBody.create( - root.toString(), MediaType.parse("application/json; charset=utf-8")); - Request req = new Request.Builder().url(url).post(reqBody).build(); - - try (Response resp = http.newCall(req).execute()) { - if (!resp.isSuccessful()) { - throw new IOException("HTTP " + resp.code() + " calling getwxacodeunlimit"); - } - MediaType ct = resp.body().contentType(); - byte[] bytes = resp.body().bytes(); - // 微信出错时返回 JSON,需要识别一下 - if (ct != null && ct.subtype() != null && ct.subtype().contains("json")) { - String err = new String(bytes); - throw new IOException("WeChat error: " + err); - } - return bytes; // 成功就是图片二进制(PNG) + return fail("获取失败", null); + } + + @Operation(summary = "获取微信小程序码-订单核销码-数量极多的业务场景") + @GetMapping("/getOrderQRCodeUnlimited/{scene}") + public void getOrderQRCodeUnlimited(@PathVariable("scene") String scene, HttpServletResponse response) throws IOException { + try { + // 从scene参数中解析租户ID + Integer tenantId = extractTenantIdFromScene(scene); + System.out.println("从scene参数中解析租户ID = " + tenantId); + if (tenantId == null) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + response.getWriter().write("{\"error\":\"无法从scene参数中获取租户信息\"}"); + return; } - } - /** 获取/刷新 access_token */ - public String getLocalAccessToken() throws IOException { - long now = Instant.now().getEpochSecond(); - String key = "AccessToken:Local:" + getTenantId(); + // 使用指定租户ID获取 access_token + String accessToken = getAccessTokenForTenant(tenantId); + String apiUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken; + + final HashMap map = new HashMap<>(); + map.put("scene", scene); + map.put("page", "pages/index/index"); + map.put("env_version", "release"); + + String jsonBody = JSON.toJSONString(map); + System.out.println("请求的 JSON body = " + jsonBody); + + // 获取微信 API 响应 + cn.hutool.http.HttpResponse httpResponse = HttpRequest.post(apiUrl) + .body(jsonBody) + .execute(); + + byte[] responseBytes = httpResponse.bodyBytes(); + String contentType = httpResponse.header("Content-Type"); + + // 检查响应内容类型,判断是否为错误响应 + if (contentType != null && contentType.contains("application/json")) { + // 微信返回了错误信息(JSON格式) + String errorResponse = new String(responseBytes, "UTF-8"); + System.err.println("微信 API 错误响应: " + errorResponse); + + // 返回错误信息给前端 + response.setContentType("application/json;charset=UTF-8"); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + response.getWriter().write(errorResponse); + return; + } - if (redisUtil.get(key) != null && now < tokenExpireEpoch - 60) { - return redisUtil.get(key); - } + // 成功获取二维码图片 + response.setContentType("image/png"); + response.setHeader("Cache-Control", "no-cache"); + response.setHeader("Content-Disposition", "inline; filename=qrcode.png"); - // 使用跨租户方式获取微信小程序配置信息 - Integer tenantId = getTenantId(); - JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); - if (setting == null) { - throw new IOException("请先配置小程序"); - } + // 输出图片 + response.getOutputStream().write(responseBytes); + System.out.println("二维码生成成功,大小: " + responseBytes.length + " bytes"); - String appId = setting.getString("appId"); - String appSecret = setting.getString("appSecret"); + } catch (Exception e) { + System.err.println("生成二维码失败: " + e.getMessage()); + e.printStackTrace(); - if (appId == null || appSecret == null) { - throw new IOException("小程序配置不完整,缺少 appId 或 appSecret"); - } - - HttpUrl url = HttpUrl.parse("https://api.weixin.qq.com/cgi-bin/token") - .newBuilder() - .addQueryParameter("grant_type", "client_credential") - .addQueryParameter("appid", appId) - .addQueryParameter("secret", appSecret) - .build(); - - Request req = new Request.Builder().url(url).get().build(); - try (Response resp = http.newCall(req).execute()) { - String body = resp.body().string(); - JsonNode json = om.readTree(body); - if (json.has("access_token")) { - String token = json.get("access_token").asText(); - long expiresIn = json.get("expires_in").asInt(7200); - redisUtil.set(key, token, expiresIn, TimeUnit.SECONDS); - tokenExpireEpoch = now + expiresIn; - return token; - } else { - throw new IOException("Get access_token failed: " + body); - } - } + // 返回错误信息 + response.setContentType("application/json;charset=UTF-8"); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + response.getWriter().write("{\"error\":\"生成二维码失败: " + e.getMessage() + "\"}"); + } + } + + @Operation(summary = "获取微信小程序码-用户ID") + @GetMapping("/getQRCodeText") + public byte[] getQRCodeText(String scene, String page, Integer width, + Boolean isHyaline, String envVersion) throws IOException { + HttpUrl url = HttpUrl.parse("https://api.weixin.qq.com/wxa/getwxacodeunlimit") + .newBuilder() + .addQueryParameter("access_token", getLocalAccessToken()) + .build(); + + System.out.println("page = " + page); + // 构造请求 JSON + // 注意:scene 仅支持可见字符,长度上限 32,尽量 URL-safe(字母数字下划线等) + // page 必须是已发布小程序内的路径(不带开头斜杠也可) + var root = om.createObjectNode(); + root.put("scene", scene); + if (page != null) root.put("page", page); + if (width != null) root.put("width", width); // 默认 430,建议 280~1280 + if (isHyaline != null) root.put("is_hyaline", isHyaline); + if (envVersion != null) root.put("env_version", envVersion); // release/trial/develop + + okhttp3.RequestBody reqBody = okhttp3.RequestBody.create( + root.toString(), MediaType.parse("application/json; charset=utf-8")); + Request req = new Request.Builder().url(url).post(reqBody).build(); + + try (Response resp = http.newCall(req).execute()) { + if (!resp.isSuccessful()) { + throw new IOException("HTTP " + resp.code() + " calling getwxacodeunlimit"); + } + MediaType ct = resp.body().contentType(); + byte[] bytes = resp.body().bytes(); + // 微信出错时返回 JSON,需要识别一下 + if (ct != null && ct.subtype() != null && ct.subtype().contains("json")) { + String err = new String(bytes); + throw new IOException("WeChat error: " + err); + } + return bytes; // 成功就是图片二进制(PNG) + } + } + + /** + * 获取/刷新 access_token + */ + public String getLocalAccessToken() throws IOException { + long now = Instant.now().getEpochSecond(); + String key = "AccessToken:Local:" + getTenantId(); + + // 从缓存获取access_token,使用JSON格式 + String value = redisUtil.get(key); + if (value != null && now < tokenExpireEpoch - 60) { + try { + // 尝试解析为JSON格式 + JSONObject response = JSON.parseObject(value); + String accessToken = response.getString("access_token"); + if (accessToken != null) { + System.out.println("从缓存获取到access_token(Local): " + accessToken.substring(0, Math.min(10, accessToken.length())) + "..."); + return accessToken; + } + } catch (Exception e) { + // 如果解析失败,可能是旧格式的纯字符串token + System.out.println("本地缓存token格式异常,使用原值: " + e.getMessage()); + return value; + } } - /** - * 文件上传位置(服务器) - */ - private String getUploadDir() { - return config.getUploadPath(); + // 使用跨租户方式获取微信小程序配置信息 + Integer tenantId = getTenantId(); + JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); + if (setting == null) { + throw new IOException("请先配置小程序"); } - @Operation(summary = "调试:检查微信小程序配置") - @GetMapping("/debug/checkWxConfig") - public ApiResult debugCheckWxConfig() { - Integer tenantId = getTenantId(); - Map result = new HashMap<>(); - result.put("tenantId", tenantId); + String appId = setting.getString("appId"); + String appSecret = setting.getString("appSecret"); - try { - // 尝试获取配置 - JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); - result.put("hasConfig", true); - result.put("config", setting); - } catch (Exception e) { - result.put("hasConfig", false); - result.put("error", e.getMessage()); - - // 提供创建配置的建议 - Map suggestion = new HashMap<>(); - suggestion.put("message", "请在系统设置中创建微信小程序配置"); - suggestion.put("configKey", "mp-weixin"); - suggestion.put("tenantId", tenantId); - suggestion.put("sampleConfig", createSampleWxConfig()); - result.put("suggestion", suggestion); - } + if (appId == null || appSecret == null) { + throw new IOException("小程序配置不完整,缺少 appId 或 appSecret"); + } - return success("配置检查完成", result); + HttpUrl url = HttpUrl.parse("https://api.weixin.qq.com/cgi-bin/token") + .newBuilder() + .addQueryParameter("grant_type", "client_credential") + .addQueryParameter("appid", appId) + .addQueryParameter("secret", appSecret) + .build(); + + Request req = new Request.Builder().url(url).get().build(); + try (Response resp = http.newCall(req).execute()) { + String body = resp.body().string(); + JsonNode json = om.readTree(body); + if (json.has("access_token")) { + String token = json.get("access_token").asText(); + long expiresIn = json.get("expires_in").asInt(7200); + + // 缓存完整的JSON响应,与其他方法保持一致 + redisUtil.set(key, body, expiresIn, TimeUnit.SECONDS); + tokenExpireEpoch = now + expiresIn; + System.out.println("获取新的access_token成功(Local),租户ID: " + tenantId); + return token; + } else { + throw new IOException("Get access_token failed: " + body); + } + } + } + + /** + * 文件上传位置(服务器) + */ + private String getUploadDir() { + return config.getUploadPath(); + } + + @Operation(summary = "调试:检查微信小程序配置") + @GetMapping("/debug/checkWxConfig") + public ApiResult debugCheckWxConfig() { + Integer tenantId = getTenantId(); + Map result = new HashMap<>(); + result.put("tenantId", tenantId); + + try { + // 尝试获取配置 + JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); + result.put("hasConfig", true); + result.put("config", setting); + } catch (Exception e) { + result.put("hasConfig", false); + result.put("error", e.getMessage()); + + // 提供创建配置的建议 + Map suggestion = new HashMap<>(); + suggestion.put("message", "请在系统设置中创建微信小程序配置"); + suggestion.put("configKey", "mp-weixin"); + suggestion.put("tenantId", tenantId); + suggestion.put("sampleConfig", createSampleWxConfig()); + result.put("suggestion", suggestion); } - @Operation(summary = "调试:创建示例微信小程序配置") - @PostMapping("/debug/createSampleWxConfig") - public ApiResult debugCreateSampleWxConfig(@RequestBody Map params) { - Integer tenantId = getTenantId(); + return success("配置检查完成", result); + } - String appId = params.get("appId"); - String appSecret = params.get("appSecret"); + @Operation(summary = "调试:创建示例微信小程序配置") + @PostMapping("/debug/createSampleWxConfig") + public ApiResult debugCreateSampleWxConfig(@RequestBody Map params) { + Integer tenantId = getTenantId(); - if (appId == null || appSecret == null) { - return fail("请提供 appId 和 appSecret", null); - } + String appId = params.get("appId"); + String appSecret = params.get("appSecret"); - try { - // 创建配置对象 - Setting setting = new Setting(); - setting.setSettingKey("mp-weixin"); - setting.setTenantId(tenantId); - - // 创建配置内容 - Map config = new HashMap<>(); - config.put("appId", appId); - config.put("appSecret", appSecret); - setting.setContent(JSON.toJSONString(config)); - setting.setComments("微信小程序配置"); - setting.setSortNumber(1); - - // 保存配置 - settingService.save(setting); - - return success("微信小程序配置创建成功", setting); - } catch (Exception e) { - return fail("创建配置失败: " + e.getMessage(), null); - } + if (appId == null || appSecret == null) { + return fail("请提供 appId 和 appSecret", null); } - private Map createSampleWxConfig() { - Map sample = new HashMap<>(); - sample.put("appId", "wx_your_app_id_here"); - sample.put("appSecret", "your_app_secret_here"); - return sample; + try { + // 创建配置对象 + Setting setting = new Setting(); + setting.setSettingKey("mp-weixin"); + setting.setTenantId(tenantId); + + // 创建配置内容 + Map config = new HashMap<>(); + config.put("appId", appId); + config.put("appSecret", appSecret); + setting.setContent(JSON.toJSONString(config)); + setting.setComments("微信小程序配置"); + setting.setSortNumber(1); + + // 保存配置 + settingService.save(setting); + + return success("微信小程序配置创建成功", setting); + } catch (Exception e) { + return fail("创建配置失败: " + e.getMessage(), null); } + } + + private Map createSampleWxConfig() { + Map sample = new HashMap<>(); + sample.put("appId", "wx_your_app_id_here"); + sample.put("appSecret", "your_app_secret_here"); + return sample; + } + + /** + * 从scene参数中提取租户ID + * scene格式可能是: uid_33103 或其他包含用户ID的格式 + */ + private Integer extractTenantIdFromScene(String scene) { + try { + System.out.println("解析scene参数: " + scene); + + // 如果scene包含uid_前缀,提取用户ID + if (scene != null && scene.startsWith("uid_")) { + String userIdStr = scene.substring(4); // 去掉"uid_"前缀 + Integer userId = Integer.parseInt(userIdStr); + + // 根据用户ID查询用户信息,获取租户ID + User user = userService.getByIdIgnoreTenant(userId); + if (user != null) { + System.out.println("从用户ID " + userId + " 获取到租户ID: " + user.getTenantId()); + return user.getTenantId(); + } else { + System.err.println("未找到用户ID: " + userId); + } + } - /** - * 从scene参数中提取租户ID - * scene格式可能是: uid_33103 或其他包含用户ID的格式 - */ - private Integer extractTenantIdFromScene(String scene) { - try { - System.out.println("解析scene参数: " + scene); - - // 如果scene包含uid_前缀,提取用户ID - if (scene != null && scene.startsWith("uid_")) { - String userIdStr = scene.substring(4); // 去掉"uid_"前缀 - Integer userId = Integer.parseInt(userIdStr); - - // 根据用户ID查询用户信息,获取租户ID - User user = userService.getByIdIgnoreTenant(userId); - if (user != null) { - System.out.println("从用户ID " + userId + " 获取到租户ID: " + user.getTenantId()); - return user.getTenantId(); - } else { - System.err.println("未找到用户ID: " + userId); - } - } - - // 如果无法解析,默认使用租户10550 - System.out.println("无法解析scene参数,使用默认租户ID: 10550"); - return 10550; + // 如果无法解析,默认使用租户10550 + System.out.println("无法解析scene参数,使用默认租户ID: 10550"); + return 10550; - } catch (Exception e) { - System.err.println("解析scene参数异常: " + e.getMessage()); - // 出现异常时,默认使用租户10550 - return 10550; - } + } catch (Exception e) { + System.err.println("解析scene参数异常: " + e.getMessage()); + // 出现异常时,默认使用租户10550 + return 10550; } + } + + /** + * 为指定租户获取AccessToken + */ + private String getAccessTokenForTenant(Integer tenantId) { + try { + String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId.toString()); + + // 使用跨租户方式获取微信小程序配置信息 + JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); + if (setting == null) { + throw new RuntimeException("租户 " + tenantId + " 的小程序未配置"); + } - /** - * 为指定租户获取AccessToken - */ - private String getAccessTokenForTenant(Integer tenantId) { + // 从缓存获取access_token + String value = redisUtil.get(key); + if (value != null) { try { - String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId.toString()); - - // 使用跨租户方式获取微信小程序配置信息 - JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId); - if (setting == null) { - throw new RuntimeException("租户 " + tenantId + " 的小程序未配置"); - } - - // 从缓存获取access_token - String accessToken = redisTemplate.opsForValue().get(key); - if (accessToken != null) { - System.out.println("从缓存获取到access_token"); - return accessToken; - } - - // 缓存中没有,重新获取 - String appId = setting.getString("appId"); - String appSecret = setting.getString("appSecret"); - - String apiUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret; - String result = HttpUtil.get(apiUrl); - JSONObject json = JSON.parseObject(result); - - if (json.containsKey("access_token")) { - accessToken = json.getString("access_token"); - Integer expiresIn = json.getInteger("expires_in"); - - // 缓存access_token,提前5分钟过期 - redisTemplate.opsForValue().set(key, accessToken, expiresIn - 300, TimeUnit.SECONDS); - - System.out.println("获取新的access_token成功,租户ID: " + tenantId); - return accessToken; - } else { - throw new RuntimeException("获取access_token失败: " + result); - } - + // 尝试解析为JSON格式(与getAccessToken方法保持一致) + JSONObject response = JSON.parseObject(value); + String accessToken = response.getString("access_token"); + if (accessToken != null) { + System.out.println("从缓存获取到access_token: " + accessToken.substring(0, Math.min(10, accessToken.length())) + "..."); + return accessToken; + } } catch (Exception e) { - System.err.println("获取access_token异常,租户ID: " + tenantId + ", 错误: " + e.getMessage()); - throw new RuntimeException("获取access_token失败: " + e.getMessage()); + // 如果解析失败,可能是旧格式的纯字符串token,直接返回 + System.out.println("缓存token格式异常,使用原值: " + e.getMessage()); + return value; } + } + + // 缓存中没有,重新获取 + String appId = setting.getString("appId"); + String appSecret = setting.getString("appSecret"); + + String apiUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret; + System.out.println("调用微信API获取token - 租户ID: " + tenantId + ", AppID: " + (appId != null ? appId.substring(0, Math.min(8, appId.length())) + "..." : "null")); + String result = HttpUtil.get(apiUrl); + System.out.println("微信API响应: " + result); + JSONObject json = JSON.parseObject(result); + + if (json.containsKey("access_token")) { + String accessToken = json.getString("access_token"); + Integer expiresIn = json.getInteger("expires_in"); + + // 缓存access_token,存储完整JSON响应(与getAccessToken方法保持一致) + redisUtil.set(key, result, (long) (expiresIn - 300), TimeUnit.SECONDS); + + System.out.println("获取新的access_token成功,租户ID: " + tenantId); + return accessToken; + } else { + throw new RuntimeException("获取access_token失败: " + result); + } + + } catch (Exception e) { + System.err.println("获取access_token异常,租户ID: " + tenantId + ", 错误: " + e.getMessage()); + throw new RuntimeException("获取access_token失败: " + e.getMessage()); } + } } diff --git a/src/main/java/com/gxwebsoft/hjm/service/impl/WxNotificationServiceImpl.java b/src/main/java/com/gxwebsoft/hjm/service/impl/WxNotificationServiceImpl.java index 161f412..eba893c 100644 --- a/src/main/java/com/gxwebsoft/hjm/service/impl/WxNotificationServiceImpl.java +++ b/src/main/java/com/gxwebsoft/hjm/service/impl/WxNotificationServiceImpl.java @@ -108,10 +108,22 @@ public class WxNotificationServiceImpl implements WxNotificationService { private String getWxAccessToken(Integer tenantId) { String cacheKey = "wx_official_access_token:" + tenantId; - // 先从缓存获取 - String cachedToken = stringRedisTemplate.opsForValue().get(cacheKey); - if (cachedToken != null) { - return cachedToken; + // 先从缓存获取,支持JSON格式 + String cachedValue = stringRedisTemplate.opsForValue().get(cacheKey); + if (cachedValue != null) { + try { + // 尝试解析JSON格式的缓存 + JSONObject cachedJson = JSONObject.parseObject(cachedValue); + String accessToken = cachedJson.getString("access_token"); + if (accessToken != null) { + System.out.println("从缓存获取到微信公众号access_token: " + accessToken.substring(0, Math.min(10, accessToken.length())) + "..."); + return accessToken; + } + } catch (Exception e) { + // 如果解析失败,可能是旧格式的纯字符串token + System.out.println("微信公众号缓存token格式异常,使用原值: " + e.getMessage()); + return cachedValue; + } } // 缓存中没有,重新获取 @@ -124,14 +136,13 @@ public class WxNotificationServiceImpl implements WxNotificationService { throw new RuntimeException("微信公众号配置不完整"); } - - - // 调用微信API获取access_token + // 调用微信API获取access_token String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret; + System.out.println("调用微信公众号API获取token - 租户ID: " + tenantId); String response = HttpUtil.get(url, CharsetUtil.CHARSET_UTF_8); - System.out.println("response = " + response); + System.out.println("微信公众号API响应: " + response); JSONObject jsonObject = JSONObject.parseObject(response); String accessToken = jsonObject.getString("access_token"); @@ -142,10 +153,11 @@ public class WxNotificationServiceImpl implements WxNotificationService { throw new RuntimeException("获取access_token失败: " + errorMsg); } - // 缓存access_token,提前5分钟过期 + // 缓存完整的JSON响应,与其他方法保持一致 int cacheSeconds = expiresIn != null ? expiresIn - 300 : 7200 - 300; - stringRedisTemplate.opsForValue().set(cacheKey, accessToken, cacheSeconds, TimeUnit.SECONDS); + stringRedisTemplate.opsForValue().set(cacheKey, response, cacheSeconds, TimeUnit.SECONDS); + System.out.println("获取微信公众号access_token成功,租户ID: " + tenantId); return accessToken; } catch (Exception e) { diff --git a/src/main/java/com/gxwebsoft/oa/controller/OaAppController.java b/src/main/java/com/gxwebsoft/oa/controller/OaAppController.java index 977cbf2..35d6640 100644 --- a/src/main/java/com/gxwebsoft/oa/controller/OaAppController.java +++ b/src/main/java/com/gxwebsoft/oa/controller/OaAppController.java @@ -8,7 +8,6 @@ import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.gxwebsoft.common.core.config.ConfigProperties; import com.gxwebsoft.common.core.security.JwtUtil; import com.gxwebsoft.common.core.utils.CommonUtil; import com.gxwebsoft.common.core.utils.RedisUtil; @@ -60,8 +59,6 @@ public class OaAppController extends BaseController { private OaAppUserService oaAppUserService; @Resource private RedisUtil redisUtil; - @Resource - private ConfigProperties configProperties; @PreAuthorize("hasAuthority('oa:app:list')") @Operation(summary = "分页查询应用") @@ -79,6 +76,7 @@ public class OaAppController extends BaseController { if(!StrUtil.equals(d.getRoleCode(),"superAdmin") && !StrUtil.equals(d.getRoleCode(),"admin")){ // 非管理员按项目成员权限显示 final List list = oaAppUserService.list(new LambdaQueryWrapper().eq(OaAppUser::getUserId, userId)); + System.out.println("list = " + list); final Set collect = list.stream().map(OaAppUser::getAppId).collect(Collectors.toSet()); param.setAppIds(collect); } @@ -201,42 +199,42 @@ public class OaAppController extends BaseController { @GetMapping("/data") public ApiResult> data() { Map data = new HashMap<>(); - long totalNum = oaAppService.count( + Integer totalNum = oaAppService.count( new LambdaQueryWrapper<>() ); - long totalNum2 = oaAppService.count( + Integer totalNum2 = oaAppService.count( new LambdaQueryWrapper() .eq(OaApp::getAppStatus, "开发中") ); - long totalNum3 = oaAppService.count( + Integer totalNum3 = oaAppService.count( new LambdaQueryWrapper() .eq(OaApp::getAppStatus, "已上架") ); - long totalNum4 = oaAppService.count( + Integer totalNum4 = oaAppService.count( new LambdaQueryWrapper() .eq(OaApp::getAppStatus, "已上架") .eq(OaApp::getShowExpiration,false) ); - long totalNum5 = oaAppService.count( + Integer totalNum5 = oaAppService.count( new LambdaQueryWrapper() .eq(OaApp::getAppStatus, "已下架") ); - long totalNum6 = oaAppService.count( + Integer totalNum6 = oaAppService.count( new LambdaQueryWrapper() .eq(OaApp::getShowCase,true) ); - long totalNum7 = oaAppService.count( + Integer totalNum7 = oaAppService.count( new LambdaQueryWrapper() .eq(OaApp::getShowIndex, true) ); - data.put("totalNum", Math.toIntExact(totalNum)); - data.put("totalNum2", Math.toIntExact(totalNum2)); - data.put("totalNum3", Math.toIntExact(totalNum3)); - data.put("totalNum4", Math.toIntExact(totalNum4)); - data.put("totalNum5", Math.toIntExact(totalNum5)); - data.put("totalNum6", Math.toIntExact(totalNum6)); - data.put("totalNum7", Math.toIntExact(totalNum7)); + data.put("totalNum", totalNum); + data.put("totalNum2", totalNum2); + data.put("totalNum3", totalNum3); + data.put("totalNum4", totalNum4); + data.put("totalNum5", totalNum5); + data.put("totalNum6", totalNum6); + data.put("totalNum7", totalNum7); return success(data); } @@ -252,7 +250,7 @@ public class OaAppController extends BaseController { // 读取项目附件(链式构建GET请求) HashMap map = new HashMap<>(); map.put("appId", d.getAppId()); - final String build = UrlBuilder.of(configProperties.getServerUrl() + "/page").setQuery(new UrlQuery(map)).build(); + final String build = UrlBuilder.of("https://server.gxwebsoft.com/api/file/page").setQuery(new UrlQuery(map)).build(); String response = HttpRequest.get(build) .header("Authorization", param.getToken()) .header("Tenantid", d.getTenantId().toString()) diff --git a/src/main/java/com/gxwebsoft/oa/controller/OaAppRenewController.java b/src/main/java/com/gxwebsoft/oa/controller/OaAppRenewController.java index cc98044..bcd62bc 100644 --- a/src/main/java/com/gxwebsoft/oa/controller/OaAppRenewController.java +++ b/src/main/java/com/gxwebsoft/oa/controller/OaAppRenewController.java @@ -1,7 +1,10 @@ package com.gxwebsoft.oa.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.oa.entity.OaApp; import com.gxwebsoft.oa.service.OaAppRenewService; import com.gxwebsoft.oa.entity.OaAppRenew; import com.gxwebsoft.oa.param.OaAppRenewParam; @@ -10,13 +13,18 @@ import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.oa.service.OaAppService; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 续费管理控制器 @@ -30,6 +38,8 @@ import java.util.List; public class OaAppRenewController extends BaseController { @Resource private OaAppRenewService oaAppRenewService; + @Resource + private OaAppService oaAppService; @Operation(summary = "分页查询续费管理") @GetMapping("/page") @@ -67,6 +77,7 @@ public class OaAppRenewController extends BaseController { oaAppRenew.setUserId(loginUser.getUserId()); } if (oaAppRenewService.save(oaAppRenew)) { + oaAppService.update(new LambdaUpdateWrapper().eq(OaApp::getAppId, oaAppRenew.getAppId()).set(OaApp::getShowExpiration, true)); return success("添加成功"); } return fail("添加失败"); @@ -117,4 +128,36 @@ public class OaAppRenewController extends BaseController { return fail("删除失败"); } + + @Operation(summary = "统计信息") + @GetMapping("/data") + public ApiResult> data() { + Map data = new HashMap<>(); + final User loginUser = getLoginUser(); + if(loginUser == null){ + return fail("请先登录",null); + } + + // 获取当前年份的起止时间 + LocalDateTime startOfYear = LocalDateTime.now().withMonth(1).withDayOfMonth(1) + .withHour(0).withMinute(0).withSecond(0); + LocalDateTime endOfYear = startOfYear.plusYears(1).minusNanos(1); + + // 今年应收续费总金额(到期时间在今年的记录) + BigDecimal totalNum1 = oaAppService.sumMoney(new LambdaQueryWrapper() + .between(OaApp::getExpirationTime, startOfYear, endOfYear)); + // 今年已收续费总金额(到期时间在今年的记录) + BigDecimal totalNum2 = oaAppRenewService.sumMoney(new LambdaQueryWrapper() + .between(OaAppRenew::getEndTime, startOfYear, endOfYear)); + + // 今年已收续费总金额(创建时间在今年且已支付的记录) + BigDecimal totalNum3 = oaAppRenewService.sumMoney(new LambdaQueryWrapper() + .between(OaAppRenew::getCreateTime, startOfYear, endOfYear) + .isNotNull(OaAppRenew::getMoney)); + + data.put("totalNum1", totalNum1 != null ? totalNum1 : BigDecimal.ZERO); + data.put("totalNum2", totalNum2 != null ? totalNum2 : BigDecimal.ZERO); + return success(data); + } + } diff --git a/src/main/java/com/gxwebsoft/oa/controller/OaAppUserController.java b/src/main/java/com/gxwebsoft/oa/controller/OaAppUserController.java index d544035..ab3687d 100644 --- a/src/main/java/com/gxwebsoft/oa/controller/OaAppUserController.java +++ b/src/main/java/com/gxwebsoft/oa/controller/OaAppUserController.java @@ -41,11 +41,8 @@ public class OaAppUserController extends BaseController { @Operation(summary = "查询全部应用成员") @GetMapping() public ApiResult> list(OaAppUserParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("create_time desc"); - return success(oaAppUserService.list(page.getOrderWrapper())); // 使用关联查询 - //return success(oaAppUserService.listRel(param)); + return success(oaAppUserService.listRel(param)); } @PreAuthorize("hasAuthority('oa:oaAppUser:list')") @@ -53,19 +50,13 @@ public class OaAppUserController extends BaseController { @Operation(summary = "根据id查询应用成员") @GetMapping("/{id}") public ApiResult get(@PathVariable("id") Integer id) { - return success(oaAppUserService.getById(id)); // 使用关联查询 - //return success(oaAppUserService.getByIdRel(id)); + return success(oaAppUserService.getByIdRel(id)); } @Operation(summary = "添加应用成员") @PostMapping() public ApiResult save(@RequestBody OaAppUser oaAppUser) { - // 记录当前登录用户id - User loginUser = getLoginUser(); - if (loginUser != null) { - oaAppUser.setUserId(loginUser.getUserId()); - } if (oaAppUserService.save(oaAppUser)) { return success("添加成功"); } diff --git a/src/main/java/com/gxwebsoft/oa/controller/OaAssetsServerController.java b/src/main/java/com/gxwebsoft/oa/controller/OaAssetsServerController.java index 8865482..f8d4275 100644 --- a/src/main/java/com/gxwebsoft/oa/controller/OaAssetsServerController.java +++ b/src/main/java/com/gxwebsoft/oa/controller/OaAssetsServerController.java @@ -1,15 +1,13 @@ package com.gxwebsoft.oa.controller; +import com.gxwebsoft.common.core.web.ApiResult; import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.common.core.web.BatchParam; +import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; -import com.gxwebsoft.oa.service.OaAssetsServerService; import com.gxwebsoft.oa.entity.OaAssetsServer; import com.gxwebsoft.oa.param.OaAssetsServerParam; -import com.gxwebsoft.common.core.web.ApiResult; -import com.gxwebsoft.common.core.web.PageResult; -import com.gxwebsoft.common.core.web.PageParam; -import com.gxwebsoft.common.core.web.BatchParam; -import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.oa.service.OaAssetsServerService; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import org.springframework.security.access.prepost.PreAuthorize; @@ -19,53 +17,47 @@ import javax.annotation.Resource; import java.util.List; /** - * 服务器资产记录表控制器 + * 服务控制器 * * @author 科技小王子 - * @since 2024-09-10 20:57:41 + * @since 2024-10-21 19:15:26 */ -@Tag(name = "服务器资产记录表管理") +@Tag(name = "服务管理") @RestController @RequestMapping("/api/oa/oa-assets-server") public class OaAssetsServerController extends BaseController { @Resource private OaAssetsServerService oaAssetsServerService; - @Operation(summary = "分页查询服务器资产记录表") + @Operation(summary = "分页查询服务") @GetMapping("/page") public ApiResult> page(OaAssetsServerParam param) { // 使用关联查询 return success(oaAssetsServerService.pageRel(param)); } - @Operation(summary = "查询全部服务器资产记录表") + @Operation(summary = "查询全部服务") @GetMapping() public ApiResult> list(OaAssetsServerParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("create_time desc"); - return success(oaAssetsServerService.list(page.getOrderWrapper())); // 使用关联查询 - //return success(oaAssetsServerService.listRel(param)); + return success(oaAssetsServerService.listRel(param)); } - @PreAuthorize("hasAuthority('oa:oaAssetsServer:list')") - @OperationLog - @Operation(summary = "根据id查询服务器资产记录表") + @Operation(summary = "根据id查询服务") @GetMapping("/{id}") public ApiResult get(@PathVariable("id") Integer id) { - return success(oaAssetsServerService.getById(id)); // 使用关联查询 - //return success(oaAssetsServerService.getByIdRel(id)); + return success(oaAssetsServerService.getByIdRel(id)); } - - @Operation(summary = "添加服务器资产记录表") + @PreAuthorize("hasAuthority('oa:oaAssetsServer:save')") + @Operation(summary = "添加服务") @PostMapping() public ApiResult save(@RequestBody OaAssetsServer oaAssetsServer) { // 记录当前登录用户id - - User loginUser = getLoginUser(); + User loginUser = getLoginUser(); if (loginUser != null) { oaAssetsServer.setUserId(loginUser.getUserId()); + oaAssetsServer.setTenantId(loginUser.getTenantId()); } if (oaAssetsServerService.save(oaAssetsServer)) { return success("添加成功"); @@ -73,7 +65,8 @@ public class OaAssetsServerController extends BaseController { return fail("添加失败"); } - @Operation(summary = "修改服务器资产记录表") + @PreAuthorize("hasAuthority('oa:oaAssetsServer:update')") + @Operation(summary = "修改服务") @PutMapping() public ApiResult update(@RequestBody OaAssetsServer oaAssetsServer) { if (oaAssetsServerService.updateById(oaAssetsServer)) { @@ -82,7 +75,8 @@ public class OaAssetsServerController extends BaseController { return fail("修改失败"); } - @Operation(summary = "删除服务器资产记录表") + @PreAuthorize("hasAuthority('oa:oaAssetsServer:remove')") + @Operation(summary = "删除服务") @DeleteMapping("/{id}") public ApiResult remove(@PathVariable("id") Integer id) { if (oaAssetsServerService.removeById(id)) { @@ -91,7 +85,8 @@ public class OaAssetsServerController extends BaseController { return fail("删除失败"); } - @Operation(summary = "批量添加服务器资产记录表") + @PreAuthorize("hasAuthority('oa:oaAssetsServer:save')") + @Operation(summary = "批量添加服务") @PostMapping("/batch") public ApiResult saveBatch(@RequestBody List list) { if (oaAssetsServerService.saveBatch(list)) { @@ -100,16 +95,18 @@ public class OaAssetsServerController extends BaseController { return fail("添加失败"); } - @Operation(summary = "批量修改服务器资产记录表") + @PreAuthorize("hasAuthority('oa:oaAssetsServer:update')") + @Operation(summary = "批量修改服务") @PutMapping("/batch") public ApiResult removeBatch(@RequestBody BatchParam batchParam) { - if (batchParam.update(oaAssetsServerService, "server_id")) { + if (batchParam.update(oaAssetsServerService, "id")) { return success("修改成功"); } return fail("修改失败"); } - @Operation(summary = "批量删除服务器资产记录表") + @PreAuthorize("hasAuthority('oa:oaAssetsServer:remove')") + @Operation(summary = "批量删除服务") @DeleteMapping("/batch") public ApiResult removeBatch(@RequestBody List ids) { if (oaAssetsServerService.removeByIds(ids)) { diff --git a/src/main/java/com/gxwebsoft/oa/controller/OaTaskRecordController.java b/src/main/java/com/gxwebsoft/oa/controller/OaTaskRecordController.java new file mode 100644 index 0000000..8fa9d1d --- /dev/null +++ b/src/main/java/com/gxwebsoft/oa/controller/OaTaskRecordController.java @@ -0,0 +1,120 @@ +package com.gxwebsoft.oa.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.oa.service.OaTaskRecordService; +import com.gxwebsoft.oa.entity.OaTaskRecord; +import com.gxwebsoft.oa.param.OaTaskRecordParam; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.BatchParam; +import com.gxwebsoft.common.core.annotation.OperationLog; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 工单回复记录表控制器 + * + * @author 科技小王子 + * @since 2024-09-10 20:57:42 + */ +@Tag(name = "工单回复记录表管理") +@RestController +@RequestMapping("/api/oa/oa-task-record") +public class OaTaskRecordController extends BaseController { + @Resource + private OaTaskRecordService oaTaskRecordService; + + @Operation(summary = "分页查询工单回复记录表") + @GetMapping("/page") + public ApiResult> page(OaTaskRecordParam param) { + // 使用关联查询 + return success(oaTaskRecordService.pageRel(param)); + } + + @Operation(summary = "查询全部工单回复记录表") + @GetMapping() + public ApiResult> list(OaTaskRecordParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("create_time desc"); + return success(oaTaskRecordService.list(page.getOrderWrapper())); + // 使用关联查询 + //return success(oaTaskRecordService.listRel(param)); + } + + @PreAuthorize("hasAuthority('oa:oaTaskRecord:list')") + @OperationLog + @Operation(summary = "根据id查询工单回复记录表") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + return success(oaTaskRecordService.getById(id)); + // 使用关联查询 + //return success(oaTaskRecordService.getByIdRel(id)); + } + + @Operation(summary = "添加工单回复记录表") + @PostMapping() + public ApiResult save(@RequestBody OaTaskRecord oaTaskRecord) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + oaTaskRecord.setUserId(loginUser.getUserId()); + } + if (oaTaskRecordService.save(oaTaskRecord)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @Operation(summary = "修改工单回复记录表") + @PutMapping() + public ApiResult update(@RequestBody OaTaskRecord oaTaskRecord) { + if (oaTaskRecordService.updateById(oaTaskRecord)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @Operation(summary = "删除工单回复记录表") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (oaTaskRecordService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @Operation(summary = "批量添加工单回复记录表") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (oaTaskRecordService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @Operation(summary = "批量修改工单回复记录表") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(oaTaskRecordService, "task_record_id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @Operation(summary = "批量删除工单回复记录表") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (oaTaskRecordService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaApp.java b/src/main/java/com/gxwebsoft/oa/entity/OaApp.java index bc301cb..4f2d41c 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaApp.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaApp.java @@ -4,10 +4,10 @@ import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; +import java.util.Date; import java.util.List; import com.gxwebsoft.common.system.entity.FileRecord; @@ -195,8 +195,7 @@ public class OaApp implements Serializable { private Integer recommend; @Schema(description = "到期时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime expirationTime; + private Date expirationTime; @Schema(description = "续费金额") private BigDecimal renewMoney; @@ -227,12 +226,10 @@ public class OaApp implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; @Schema(description = "成员管理") @TableField(exist = false) diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAppField.java b/src/main/java/com/gxwebsoft/oa/entity/OaAppField.java index 2e6b0dc..2245088 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAppField.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAppField.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; @@ -49,7 +48,6 @@ public class OaAppField implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAppRenew.java b/src/main/java/com/gxwebsoft/oa/entity/OaAppRenew.java index 67da767..f7be2ca 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAppRenew.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAppRenew.java @@ -3,8 +3,7 @@ package com.gxwebsoft.oa.entity; import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -37,12 +36,10 @@ public class OaAppRenew implements Serializable { private String comments; @Schema(description = "开始时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "企业ID") private Integer companyId; @@ -63,7 +60,6 @@ public class OaAppRenew implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAppUrl.java b/src/main/java/com/gxwebsoft/oa/entity/OaAppUrl.java index 5ba08de..c3369ed 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAppUrl.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAppUrl.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -51,8 +50,7 @@ public class OaAppUrl implements Serializable { private Integer status; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "租户id") private Integer tenantId; diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAppUser.java b/src/main/java/com/gxwebsoft/oa/entity/OaAppUser.java index 2a29374..eaf1a08 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAppUser.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAppUser.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -45,7 +44,6 @@ public class OaAppUser implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssets.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssets.java index 647b4bf..d4afe3e 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssets.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssets.java @@ -6,9 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -99,11 +99,11 @@ public class OaAssets implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -151,11 +151,9 @@ public class OaAssets implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsCode.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsCode.java index 40d6cbb..f304395 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsCode.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsCode.java @@ -6,8 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -82,11 +81,9 @@ public class OaAssetsCode implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsDomain.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsDomain.java index 4a617ac..5943d6a 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsDomain.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsDomain.java @@ -7,9 +7,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -54,11 +54,11 @@ public class OaAssetsDomain implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -94,11 +94,9 @@ public class OaAssetsDomain implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsEmail.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsEmail.java index c72eb5c..a0e805b 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsEmail.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsEmail.java @@ -7,9 +7,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -54,11 +54,11 @@ public class OaAssetsEmail implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -94,11 +94,9 @@ public class OaAssetsEmail implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsMysql.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsMysql.java index 86009d9..b39315c 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsMysql.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsMysql.java @@ -4,11 +4,11 @@ import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -59,11 +59,11 @@ public class OaAssetsMysql implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -99,11 +99,9 @@ public class OaAssetsMysql implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsServer.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsServer.java index 3c856d3..d389f06 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsServer.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsServer.java @@ -1,133 +1,56 @@ package com.gxwebsoft.oa.entity; -import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableLogic; -import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serializable; +import java.util.Date; + /** - * 服务器资产记录表 + * 服务 * * @author 科技小王子 - * @since 2024-09-10 20:57:41 + * @since 2024-10-21 19:15:26 */ @Data @EqualsAndHashCode(callSuper = false) -@Schema(name = "OaAssetsServer对象", description = "服务器资产记录表") +@Schema(name = "OaAssetsServer对象", description = "服务") public class OaAssetsServer implements Serializable { private static final long serialVersionUID = 1L; - @Schema(description = "资产ID") - @TableId(value = "server_id", type = IdType.AUTO) - private Integer serverId; - - @Schema(description = "资产名称") - private String name; - - @Schema(description = "资产标识") - private String code; - - @Schema(description = "资产类型") - private String type; - - @Schema(description = "服务器厂商") - private String brand; - - @Schema(description = "服务器配置") - private String configuration; - - @Schema(description = "初始账号") - private String account; - - @Schema(description = "初始密码") - private String password; - - @Schema(description = "(阿里云/腾讯云)登录账号") - private String brandAccount; - - @Schema(description = "(阿里云/腾讯云)登录密码") - private String brandPassword; - - @Schema(description = "宝塔面板") - private String panel; - - @Schema(description = "宝塔面板账号") - private String panelAccount; - - @Schema(description = "宝塔面板密码") - private String panelPassword; - - @Schema(description = "财务信息-合同金额") - private BigDecimal financeAmount; - - @Schema(description = "购买年限") - private Integer financeYears; + @Schema(description = "插件id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; - @Schema(description = "续费金额") - private BigDecimal financeRenew; + @Schema(description = "服务名称") + private String server; - @Schema(description = "客户名称") - private String financeCustomerName; + @Schema(description = "接口地址") + private String serverUrl; - @Schema(description = "客户联系人") - private String financeCustomerContact; - - @Schema(description = "客户联系电话") - private String financeCustomerPhone; - - @Schema(description = "客户ID") - private Integer customerId; - - @Schema(description = "客户名称") - private String customerName; - - @Schema(description = "开放端口") - private String openPort; - - @Schema(description = "详情内容") - private String content; - - @Schema(description = "购买时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; - - @Schema(description = "到期时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; - - @Schema(description = "置顶状态") - private String isTop; - - @Schema(description = "可见性(public,private,protected)") - private String visibility; - - @Schema(description = "宝塔接口秘钥") - private String btSign; - - @Schema(description = "文章排序(数字越小越靠前)") + @Schema(description = "排序号") private Integer sortNumber; - @Schema(description = "描述") + @Schema(description = "服务器ID") + private Integer assetsId; + + @Schema(description = "备注") private String comments; - @Schema(description = "客户ID") - private Integer companyId; + @Schema(description = "状态, 10待审核 20已通过 30已驳回") + private Integer status; @Schema(description = "用户ID") private Integer userId; - @Schema(description = "机构id") - private Integer organizationId; - - @Schema(description = "状态, 0正常, 1冻结") - private String status; + @Schema(description = "可见用户") + private String userIds; @Schema(description = "是否删除, 0否, 1是") @TableLogic @@ -136,12 +59,15 @@ public class OaAssetsServer implements Serializable { @Schema(description = "租户id") private Integer tenantId; - @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + @Schema(description = "应用名称") + @TableField(exist = false) + private String tenantName; - @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + @Schema(description = "应用图标") + @TableField(exist = false) + private String logo; + + @Schema(description = "创建时间") + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSite.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSite.java index cfaad45..705a419 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSite.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSite.java @@ -5,8 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -66,8 +65,7 @@ public class OaAssetsSite implements Serializable { private Integer version; @Schema(description = "服务到期时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime expirationTime; + private Date expirationTime; @Schema(description = "模版ID") private Integer templateId; @@ -160,11 +158,9 @@ public class OaAssetsSite implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSoftwareCert.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSoftwareCert.java index c2c7b2d..78e2938 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSoftwareCert.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSoftwareCert.java @@ -4,11 +4,11 @@ import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -53,11 +53,11 @@ public class OaAssetsSoftwareCert implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -93,11 +93,9 @@ public class OaAssetsSoftwareCert implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSsl.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSsl.java index 7db42bb..b89e837 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSsl.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsSsl.java @@ -4,11 +4,11 @@ import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -62,11 +62,11 @@ public class OaAssetsSsl implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -105,11 +105,9 @@ public class OaAssetsSsl implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsTrademark.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsTrademark.java index ef1a052..2b52097 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsTrademark.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsTrademark.java @@ -4,11 +4,11 @@ import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -53,11 +53,11 @@ public class OaAssetsTrademark implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -93,11 +93,9 @@ public class OaAssetsTrademark implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsUser.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsUser.java index f940415..f38b406 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsUser.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsUser.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -45,7 +44,6 @@ public class OaAssetsUser implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsVhost.java b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsVhost.java index c6cfe72..43d8628 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaAssetsVhost.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaAssetsVhost.java @@ -6,9 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -59,11 +59,11 @@ public class OaAssetsVhost implements Serializable { @Schema(description = "购买时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "到期时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime endTime; + private Date endTime; @Schema(description = "置顶状态") private String isTop; @@ -102,11 +102,9 @@ public class OaAssetsVhost implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaCompany.java b/src/main/java/com/gxwebsoft/oa/entity/OaCompany.java index d300f5b..5949c02 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaCompany.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaCompany.java @@ -6,8 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -71,12 +70,10 @@ public class OaCompany implements Serializable { private String businessEntity; @Schema(description = "服务开始时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime startTime; + private Date startTime; @Schema(description = "服务到期时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime expirationTime; + private Date expirationTime; @Schema(description = "应用版本 10体验版 20授权版 30旗舰版") private Integer version; @@ -187,11 +184,9 @@ public class OaCompany implements Serializable { private String logo; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaCompanyField.java b/src/main/java/com/gxwebsoft/oa/entity/OaCompanyField.java index fd28376..57029bd 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaCompanyField.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaCompanyField.java @@ -4,8 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -50,7 +49,6 @@ public class OaCompanyField implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaCompanyUser.java b/src/main/java/com/gxwebsoft/oa/entity/OaCompanyUser.java index 0c78ab0..6eee867 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaCompanyUser.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaCompanyUser.java @@ -4,8 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serializable; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -47,7 +46,6 @@ public class OaCompanyUser implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaLink.java b/src/main/java/com/gxwebsoft/oa/entity/OaLink.java index 423d120..416ad21 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaLink.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaLink.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; @@ -68,7 +67,6 @@ public class OaLink implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaProduct.java b/src/main/java/com/gxwebsoft/oa/entity/OaProduct.java index 2df86dc..919c2b6 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaProduct.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaProduct.java @@ -3,8 +3,7 @@ package com.gxwebsoft.oa.entity; import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; @@ -96,11 +95,9 @@ public class OaProduct implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaProductTabs.java b/src/main/java/com/gxwebsoft/oa/entity/OaProductTabs.java index d2b6c64..a46f516 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaProductTabs.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaProductTabs.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; @@ -71,11 +70,9 @@ public class OaProductTabs implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaTask.java b/src/main/java/com/gxwebsoft/oa/entity/OaTask.java index 10c76d1..dd0babd 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaTask.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaTask.java @@ -3,8 +3,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import java.time.LocalDate; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; @@ -126,11 +125,9 @@ public class OaTask implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "修改时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaTaskCount.java b/src/main/java/com/gxwebsoft/oa/entity/OaTaskCount.java index 6ff5bd3..c84a00a 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaTaskCount.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaTaskCount.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -63,11 +62,9 @@ public class OaTaskCount implements Serializable { private Integer tenantId; @Schema(description = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; @Schema(description = "更新时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; + private Date updateTime; } diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaTaskRecord.java b/src/main/java/com/gxwebsoft/oa/entity/OaTaskRecord.java new file mode 100644 index 0000000..568b5e4 --- /dev/null +++ b/src/main/java/com/gxwebsoft/oa/entity/OaTaskRecord.java @@ -0,0 +1,72 @@ +package com.gxwebsoft.oa.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableLogic; +import java.io.Serializable; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 工单回复记录表 + * + * @author 科技小王子 + * @since 2024-09-10 20:57:42 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "OaTaskRecord对象", description = "工单回复记录表") +public class OaTaskRecord implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "回复ID") + @TableId(value = "task_record_id", type = IdType.AUTO) + private Integer taskRecordId; + + @Schema(description = "上级id, 0是顶级") + private Integer parentId; + + @Schema(description = "工单ID") + private Integer taskId; + + @Schema(description = "内容") + private String content; + + @Schema(description = "机密信息") + private String confidential; + + @Schema(description = "联系电话") + private String phone; + + @Schema(description = "工单附件") + private String files; + + @Schema(description = "用户ID") + private Integer userId; + + @Schema(description = "排序(数字越小越靠前)") + private Integer sortNumber; + + @Schema(description = "备注") + private String comments; + + @Schema(description = "状态, 0待处理, 1已完成") + private Integer status; + + @Schema(description = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @Schema(description = "租户id") + private Integer tenantId; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + private Date updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/oa/entity/OaTaskUser.java b/src/main/java/com/gxwebsoft/oa/entity/OaTaskUser.java index 362f388..b82227b 100644 --- a/src/main/java/com/gxwebsoft/oa/entity/OaTaskUser.java +++ b/src/main/java/com/gxwebsoft/oa/entity/OaTaskUser.java @@ -2,8 +2,7 @@ package com.gxwebsoft.oa.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.Date; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; @@ -45,7 +44,6 @@ public class OaTaskUser implements Serializable { private Integer tenantId; @Schema(description = "加入时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Date createTime; } diff --git a/src/main/java/com/gxwebsoft/oa/mapper/OaAppFieldMapper.java b/src/main/java/com/gxwebsoft/oa/mapper/OaAppFieldMapper.java index 810bc09..5d66286 100644 --- a/src/main/java/com/gxwebsoft/oa/mapper/OaAppFieldMapper.java +++ b/src/main/java/com/gxwebsoft/oa/mapper/OaAppFieldMapper.java @@ -1,11 +1,13 @@ package com.gxwebsoft.oa.mapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.gxwebsoft.oa.entity.OaAppField; import com.gxwebsoft.oa.param.OaAppFieldParam; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; /** @@ -16,22 +18,22 @@ import java.util.List; */ public interface OaAppFieldMapper extends BaseMapper { - /** - * 分页查询 - * - * @param page 分页对象 - * @param param 查询参数 - * @return List - */ - List selectPageRel(@Param("page") IPage page, - @Param("param") OaAppFieldParam param); + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") OaAppFieldParam param); - /** - * 查询全部 - * - * @param param 查询参数 - * @return List - */ - List selectListRel(@Param("param") OaAppFieldParam param); + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") OaAppFieldParam param); } diff --git a/src/main/java/com/gxwebsoft/oa/mapper/OaAppMapper.java b/src/main/java/com/gxwebsoft/oa/mapper/OaAppMapper.java index 6447c90..8975d8b 100644 --- a/src/main/java/com/gxwebsoft/oa/mapper/OaAppMapper.java +++ b/src/main/java/com/gxwebsoft/oa/mapper/OaAppMapper.java @@ -1,11 +1,13 @@ package com.gxwebsoft.oa.mapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.gxwebsoft.oa.entity.OaApp; import com.gxwebsoft.oa.param.OaAppParam; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; /** @@ -16,22 +18,30 @@ import java.util.List; */ public interface OaAppMapper extends BaseMapper { - /** - * 分页查询 - * - * @param page 分页对象 - * @param param 查询参数 - * @return List - */ - List selectPageRel(@Param("page") IPage page, - @Param("param") OaAppParam param); + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") OaAppParam param); - /** - * 查询全部 - * - * @param param 查询参数 - * @return List - */ - List selectListRel(@Param("param") OaAppParam param); + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") OaAppParam param); + + /** + * 统计金额总和 + * + * @param wrapper 查询条件 + * @return 金额总和 + */ + BigDecimal selectSumMoney(@Param("ew") Wrapper wrapper); } diff --git a/src/main/java/com/gxwebsoft/oa/mapper/OaAppRenewMapper.java b/src/main/java/com/gxwebsoft/oa/mapper/OaAppRenewMapper.java index e04c9dc..40ceb78 100644 --- a/src/main/java/com/gxwebsoft/oa/mapper/OaAppRenewMapper.java +++ b/src/main/java/com/gxwebsoft/oa/mapper/OaAppRenewMapper.java @@ -1,11 +1,14 @@ package com.gxwebsoft.oa.mapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.gxwebsoft.oa.entity.OaAppRenew; import com.gxwebsoft.oa.param.OaAppRenewParam; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; /** @@ -34,4 +37,11 @@ public interface OaAppRenewMapper extends BaseMapper { */ List selectListRel(@Param("param") OaAppRenewParam param); + /** + * 统计金额总和 + * + * @param wrapper 查询条件 + * @return 金额总和 + */ + BigDecimal selectSumMoney(@Param("ew") Wrapper wrapper); } diff --git a/src/main/java/com/gxwebsoft/oa/mapper/OaAssetsServerMapper.java b/src/main/java/com/gxwebsoft/oa/mapper/OaAssetsServerMapper.java index 0c163af..fd08087 100644 --- a/src/main/java/com/gxwebsoft/oa/mapper/OaAssetsServerMapper.java +++ b/src/main/java/com/gxwebsoft/oa/mapper/OaAssetsServerMapper.java @@ -9,10 +9,10 @@ import org.apache.ibatis.annotations.Param; import java.util.List; /** - * 服务器资产记录表Mapper + * 服务Mapper * * @author 科技小王子 - * @since 2024-09-10 20:57:41 + * @since 2024-10-21 19:15:26 */ public interface OaAssetsServerMapper extends BaseMapper { diff --git a/src/main/java/com/gxwebsoft/oa/mapper/OaTaskRecordMapper.java b/src/main/java/com/gxwebsoft/oa/mapper/OaTaskRecordMapper.java new file mode 100644 index 0000000..f12d10e --- /dev/null +++ b/src/main/java/com/gxwebsoft/oa/mapper/OaTaskRecordMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.oa.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.oa.entity.OaTaskRecord; +import com.gxwebsoft.oa.param.OaTaskRecordParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 工单回复记录表Mapper + * + * @author 科技小王子 + * @since 2024-09-10 20:57:42 + */ +public interface OaTaskRecordMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") OaTaskRecordParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") OaTaskRecordParam param); + +} diff --git a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAppMapper.xml b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAppMapper.xml index af8176b..e21d750 100644 --- a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAppMapper.xml +++ b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAppMapper.xml @@ -226,4 +226,13 @@ + + + diff --git a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAppRenewMapper.xml b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAppRenewMapper.xml new file mode 100644 index 0000000..d949637 --- /dev/null +++ b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAppRenewMapper.xml @@ -0,0 +1,70 @@ + + + + + + + SELECT a.*, + b.company_name,b.short_name,b.company_logo, + c.app_name + FROM oa_app_renew a + LEFT JOIN oa_company b ON a.company_id = b.company_id + LEFT JOIN oa_app c ON a.app_id = c.app_id + + + AND a.app_renew_id = #{param.appRenewId} + + + AND a.money = #{param.money} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%') + + + AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%') + + + AND a.user_id = #{param.userId} + + + AND a.app_id = #{param.appId} + + + AND a.company_id = #{param.companyId} + + + + AND a.status = #{param.status} + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsMapper.xml b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsMapper.xml index 2ae8353..b6b4fc5 100644 --- a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsMapper.xml +++ b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsMapper.xml @@ -128,6 +128,7 @@ AND (a.tenant_id = #{param.keywords} OR a.name LIKE CONCAT('%', #{param.keywords}, '%') + OR a.code LIKE CONCAT('%', #{param.keywords}, '%') ) diff --git a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsServerMapper.xml b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsServerMapper.xml index edd376e..1e7770e 100644 --- a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsServerMapper.xml +++ b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaAssetsServerMapper.xml @@ -7,107 +7,32 @@ SELECT a.* FROM oa_assets_server a - - AND a.server_id = #{param.serverId} + + AND a.id = #{param.id} - - AND a.name LIKE CONCAT('%', #{param.name}, '%') + + AND a.server LIKE CONCAT('%', #{param.server}, '%') - - AND a.code LIKE CONCAT('%', #{param.code}, '%') - - - AND a.type LIKE CONCAT('%', #{param.type}, '%') - - - AND a.brand LIKE CONCAT('%', #{param.brand}, '%') - - - AND a.configuration LIKE CONCAT('%', #{param.configuration}, '%') - - - AND a.account LIKE CONCAT('%', #{param.account}, '%') - - - AND a.password LIKE CONCAT('%', #{param.password}, '%') - - - AND a.brand_account LIKE CONCAT('%', #{param.brandAccount}, '%') - - - AND a.brand_password LIKE CONCAT('%', #{param.brandPassword}, '%') - - - AND a.panel LIKE CONCAT('%', #{param.panel}, '%') - - - AND a.panel_account LIKE CONCAT('%', #{param.panelAccount}, '%') - - - AND a.panel_password LIKE CONCAT('%', #{param.panelPassword}, '%') - - - AND a.finance_amount = #{param.financeAmount} - - - AND a.finance_years = #{param.financeYears} - - - AND a.finance_renew = #{param.financeRenew} - - - AND a.finance_customer_name LIKE CONCAT('%', #{param.financeCustomerName}, '%') - - - AND a.finance_customer_contact LIKE CONCAT('%', #{param.financeCustomerContact}, '%') - - - AND a.finance_customer_phone LIKE CONCAT('%', #{param.financeCustomerPhone}, '%') - - - AND a.customer_id = #{param.customerId} - - - AND a.customer_name LIKE CONCAT('%', #{param.customerName}, '%') - - - AND a.open_port LIKE CONCAT('%', #{param.openPort}, '%') - - - AND a.content LIKE CONCAT('%', #{param.content}, '%') - - - AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%') - - - AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%') - - - AND a.is_top LIKE CONCAT('%', #{param.isTop}, '%') - - - AND a.visibility LIKE CONCAT('%', #{param.visibility}, '%') - - - AND a.bt_sign LIKE CONCAT('%', #{param.btSign}, '%') + + AND a.server_url LIKE CONCAT('%', #{param.serverUrl}, '%') AND a.sort_number = #{param.sortNumber} + + AND a.assets_id = #{param.assetsId} + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') - - AND a.company_id = #{param.companyId} + + AND a.status = #{param.status} AND a.user_id = #{param.userId} - - AND a.organization_id = #{param.organizationId} - - - AND a.status LIKE CONCAT('%', #{param.status}, '%') + + AND a.user_ids LIKE CONCAT('%', #{param.userIds}, '%') AND a.deleted = #{param.deleted} @@ -121,6 +46,11 @@ AND a.create_time <= #{param.createTimeEnd} + + AND (a.tenant_id = #{param.keywords} + OR a.server_url LIKE CONCAT('%', #{param.keywords}, '%') + ) + diff --git a/src/main/java/com/gxwebsoft/oa/mapper/xml/OaTaskRecordMapper.xml b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaTaskRecordMapper.xml new file mode 100644 index 0000000..b9bd366 --- /dev/null +++ b/src/main/java/com/gxwebsoft/oa/mapper/xml/OaTaskRecordMapper.xml @@ -0,0 +1,68 @@ + + + + + + + SELECT a.* + FROM oa_task_record a + + + AND a.task_record_id = #{param.taskRecordId} + + + AND a.parent_id = #{param.parentId} + + + AND a.task_id = #{param.taskId} + + + AND a.content LIKE CONCAT('%', #{param.content}, '%') + + + AND a.confidential LIKE CONCAT('%', #{param.confidential}, '%') + + + AND a.phone LIKE CONCAT('%', #{param.phone}, '%') + + + AND a.files LIKE CONCAT('%', #{param.files}, '%') + + + AND a.user_id = #{param.userId} + + + AND a.sort_number = #{param.sortNumber} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.status = #{param.status} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/oa/param/OaAppParam.java b/src/main/java/com/gxwebsoft/oa/param/OaAppParam.java index 2a09e83..589b255 100644 --- a/src/main/java/com/gxwebsoft/oa/param/OaAppParam.java +++ b/src/main/java/com/gxwebsoft/oa/param/OaAppParam.java @@ -243,4 +243,8 @@ public class OaAppParam extends BaseParam { @TableField(exist = false) private Set appIds; + @Schema(description = "访问令牌") + @TableField(exist = false) + private String token; + } diff --git a/src/main/java/com/gxwebsoft/oa/param/OaAssetsServerParam.java b/src/main/java/com/gxwebsoft/oa/param/OaAssetsServerParam.java index 9633536..47316f4 100644 --- a/src/main/java/com/gxwebsoft/oa/param/OaAssetsServerParam.java +++ b/src/main/java/com/gxwebsoft/oa/param/OaAssetsServerParam.java @@ -1,139 +1,58 @@ package com.gxwebsoft.oa.param; +import com.fasterxml.jackson.annotation.JsonInclude; import com.gxwebsoft.common.core.annotation.QueryField; import com.gxwebsoft.common.core.annotation.QueryType; import com.gxwebsoft.common.core.web.BaseParam; -import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; -import java.math.BigDecimal; - /** - * 服务器资产记录表查询参数 + * 服务查询参数 * * @author 科技小王子 - * @since 2024-09-10 20:57:41 + * @since 2024-10-21 19:15:26 */ @Data @EqualsAndHashCode(callSuper = false) @JsonInclude(JsonInclude.Include.NON_NULL) -@Schema(name = "OaAssetsServerParam对象", description = "服务器资产记录表查询参数") +@Schema(name = "OaAssetsServerParam对象", description = "服务查询参数") public class OaAssetsServerParam extends BaseParam { private static final long serialVersionUID = 1L; - @Schema(description = "资产ID") - @QueryField(type = QueryType.EQ) - private Integer serverId; - - @Schema(description = "资产名称") - private String name; - - @Schema(description = "资产标识") - private String code; - - @Schema(description = "资产类型") - private String type; - - @Schema(description = "服务器厂商") - private String brand; - - @Schema(description = "服务器配置") - private String configuration; - - @Schema(description = "初始账号") - private String account; - - @Schema(description = "初始密码") - private String password; - - @Schema(description = "(阿里云/腾讯云)登录账号") - private String brandAccount; - - @Schema(description = "(阿里云/腾讯云)登录密码") - private String brandPassword; - - @Schema(description = "宝塔面板") - private String panel; - - @Schema(description = "宝塔面板账号") - private String panelAccount; - - @Schema(description = "宝塔面板密码") - private String panelPassword; - - @Schema(description = "财务信息-合同金额") + @Schema(description = "插件id") @QueryField(type = QueryType.EQ) - private BigDecimal financeAmount; + private Integer id; - @Schema(description = "购买年限") - @QueryField(type = QueryType.EQ) - private Integer financeYears; - - @Schema(description = "续费金额") - @QueryField(type = QueryType.EQ) - private BigDecimal financeRenew; - - @Schema(description = "客户名称") - private String financeCustomerName; - - @Schema(description = "客户联系人") - private String financeCustomerContact; + @Schema(description = "服务名称") + private String server; - @Schema(description = "客户联系电话") - private String financeCustomerPhone; + @Schema(description = "接口地址") + private String serverUrl; - @Schema(description = "客户ID") + @Schema(description = "排序号") @QueryField(type = QueryType.EQ) - private Integer customerId; - - @Schema(description = "客户名称") - private String customerName; - - @Schema(description = "开放端口") - private String openPort; - - @Schema(description = "详情内容") - private String content; - - @Schema(description = "购买时间") - private String startTime; - - @Schema(description = "到期时间") - private String endTime; - - @Schema(description = "置顶状态") - private String isTop; - - @Schema(description = "可见性(public,private,protected)") - private String visibility; - - @Schema(description = "宝塔接口秘钥") - private String btSign; + private Integer sortNumber; - @Schema(description = "文章排序(数字越小越靠前)") + @Schema(description = "服务器ID") @QueryField(type = QueryType.EQ) - private Integer sortNumber; + private Integer assetsId; - @Schema(description = "描述") + @Schema(description = "备注") private String comments; - @Schema(description = "客户ID") + @Schema(description = "状态, 10待审核 20已通过 30已驳回") @QueryField(type = QueryType.EQ) - private Integer companyId; + private Integer status; @Schema(description = "用户ID") @QueryField(type = QueryType.EQ) private Integer userId; - @Schema(description = "机构id") - @QueryField(type = QueryType.EQ) - private Integer organizationId; - - @Schema(description = "状态, 0正常, 1冻结") - private String status; + @Schema(description = "可见用户") + private String userIds; @Schema(description = "是否删除, 0否, 1是") @QueryField(type = QueryType.EQ) diff --git a/src/main/java/com/gxwebsoft/oa/service/OaAppRenewService.java b/src/main/java/com/gxwebsoft/oa/service/OaAppRenewService.java index 2cb38cf..c41f20f 100644 --- a/src/main/java/com/gxwebsoft/oa/service/OaAppRenewService.java +++ b/src/main/java/com/gxwebsoft/oa/service/OaAppRenewService.java @@ -1,10 +1,14 @@ package com.gxwebsoft.oa.service; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.oa.entity.OaAppRenew; import com.gxwebsoft.oa.param.OaAppRenewParam; +import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; /** @@ -39,4 +43,11 @@ public interface OaAppRenewService extends IService { */ OaAppRenew getByIdRel(Integer appRenewId); + /** + * 统计金额总和 + * @param wrapper 查询条件 + * @return 金额总和 + */ + BigDecimal sumMoney(LambdaQueryWrapper wrapper); + } diff --git a/src/main/java/com/gxwebsoft/oa/service/OaAppService.java b/src/main/java/com/gxwebsoft/oa/service/OaAppService.java index 98bb4c4..e9c76b2 100644 --- a/src/main/java/com/gxwebsoft/oa/service/OaAppService.java +++ b/src/main/java/com/gxwebsoft/oa/service/OaAppService.java @@ -1,10 +1,12 @@ package com.gxwebsoft.oa.service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.oa.entity.OaApp; import com.gxwebsoft.oa.param.OaAppParam; +import java.math.BigDecimal; import java.util.List; /** @@ -39,4 +41,11 @@ public interface OaAppService extends IService { */ OaApp getByIdRel(Integer appId); + /** + * 统计金额总和 + * + * @param wrapper 查询条件 + * @return 金额总和 + */ + BigDecimal sumMoney(LambdaQueryWrapper wrapper); } diff --git a/src/main/java/com/gxwebsoft/oa/service/OaAssetsServerService.java b/src/main/java/com/gxwebsoft/oa/service/OaAssetsServerService.java index 0b91d35..8e1c558 100644 --- a/src/main/java/com/gxwebsoft/oa/service/OaAssetsServerService.java +++ b/src/main/java/com/gxwebsoft/oa/service/OaAssetsServerService.java @@ -8,10 +8,10 @@ import com.gxwebsoft.oa.param.OaAssetsServerParam; import java.util.List; /** - * 服务器资产记录表Service + * 服务Service * * @author 科技小王子 - * @since 2024-09-10 20:57:41 + * @since 2024-10-21 19:15:26 */ public interface OaAssetsServerService extends IService { @@ -34,9 +34,9 @@ public interface OaAssetsServerService extends IService { /** * 根据id查询 * - * @param serverId 资产ID + * @param id 插件id * @return OaAssetsServer */ - OaAssetsServer getByIdRel(Integer serverId); + OaAssetsServer getByIdRel(Integer id); } diff --git a/src/main/java/com/gxwebsoft/oa/service/OaTaskRecordService.java b/src/main/java/com/gxwebsoft/oa/service/OaTaskRecordService.java new file mode 100644 index 0000000..8045be0 --- /dev/null +++ b/src/main/java/com/gxwebsoft/oa/service/OaTaskRecordService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.oa.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.oa.entity.OaTaskRecord; +import com.gxwebsoft.oa.param.OaTaskRecordParam; + +import java.util.List; + +/** + * 工单回复记录表Service + * + * @author 科技小王子 + * @since 2024-09-10 20:57:42 + */ +public interface OaTaskRecordService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(OaTaskRecordParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(OaTaskRecordParam param); + + /** + * 根据id查询 + * + * @param taskRecordId 回复ID + * @return OaTaskRecord + */ + OaTaskRecord getByIdRel(Integer taskRecordId); + +} diff --git a/src/main/java/com/gxwebsoft/oa/service/impl/OaAppRenewServiceImpl.java b/src/main/java/com/gxwebsoft/oa/service/impl/OaAppRenewServiceImpl.java index 9e8bd8d..682e7e2 100644 --- a/src/main/java/com/gxwebsoft/oa/service/impl/OaAppRenewServiceImpl.java +++ b/src/main/java/com/gxwebsoft/oa/service/impl/OaAppRenewServiceImpl.java @@ -1,5 +1,6 @@ package com.gxwebsoft.oa.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gxwebsoft.oa.mapper.OaAppRenewMapper; import com.gxwebsoft.oa.service.OaAppRenewService; @@ -9,6 +10,7 @@ import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageResult; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.List; /** @@ -44,4 +46,9 @@ public class OaAppRenewServiceImpl extends ServiceImpl wrapper) { + return baseMapper.selectSumMoney(wrapper); + } + } diff --git a/src/main/java/com/gxwebsoft/oa/service/impl/OaAppServiceImpl.java b/src/main/java/com/gxwebsoft/oa/service/impl/OaAppServiceImpl.java index 81f8f01..bdc1596 100644 --- a/src/main/java/com/gxwebsoft/oa/service/impl/OaAppServiceImpl.java +++ b/src/main/java/com/gxwebsoft/oa/service/impl/OaAppServiceImpl.java @@ -1,5 +1,6 @@ package com.gxwebsoft.oa.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gxwebsoft.oa.mapper.OaAppMapper; import com.gxwebsoft.oa.service.OaAppService; @@ -9,6 +10,7 @@ import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageResult; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.List; /** @@ -23,7 +25,7 @@ public class OaAppServiceImpl extends ServiceImpl implements @Override public PageResult pageRel(OaAppParam param) { PageParam page = new PageParam<>(param); - page.setDefaultOrder("sort_number asc, create_time desc"); + page.setDefaultOrder("create_time desc"); List list = baseMapper.selectPageRel(page, param); return new PageResult<>(list, page.getTotal()); } @@ -44,4 +46,9 @@ public class OaAppServiceImpl extends ServiceImpl implements return param.getOne(baseMapper.selectListRel(param)); } + @Override + public BigDecimal sumMoney(LambdaQueryWrapper wrapper) { + return baseMapper.selectSumMoney(wrapper); + } + } diff --git a/src/main/java/com/gxwebsoft/oa/service/impl/OaAppUserServiceImpl.java b/src/main/java/com/gxwebsoft/oa/service/impl/OaAppUserServiceImpl.java index ae43f9a..9372af0 100644 --- a/src/main/java/com/gxwebsoft/oa/service/impl/OaAppUserServiceImpl.java +++ b/src/main/java/com/gxwebsoft/oa/service/impl/OaAppUserServiceImpl.java @@ -23,7 +23,6 @@ public class OaAppUserServiceImpl extends ServiceImpl pageRel(OaAppUserParam param) { PageParam page = new PageParam<>(param); - page.setDefaultOrder("create_time desc"); List list = baseMapper.selectPageRel(page, param); return new PageResult<>(list, page.getTotal()); } @@ -33,7 +32,6 @@ public class OaAppUserServiceImpl extends ServiceImpl list = baseMapper.selectListRel(param); // 排序 PageParam page = new PageParam<>(); - page.setDefaultOrder("create_time desc"); return page.sortRecords(list); } diff --git a/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsServerServiceImpl.java b/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsServerServiceImpl.java index 7788484..b2e327b 100644 --- a/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsServerServiceImpl.java +++ b/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsServerServiceImpl.java @@ -1,21 +1,21 @@ package com.gxwebsoft.oa.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.gxwebsoft.oa.mapper.OaAssetsServerMapper; -import com.gxwebsoft.oa.service.OaAssetsServerService; -import com.gxwebsoft.oa.entity.OaAssetsServer; -import com.gxwebsoft.oa.param.OaAssetsServerParam; import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.oa.entity.OaAssetsServer; +import com.gxwebsoft.oa.mapper.OaAssetsServerMapper; +import com.gxwebsoft.oa.param.OaAssetsServerParam; +import com.gxwebsoft.oa.service.OaAssetsServerService; import org.springframework.stereotype.Service; import java.util.List; /** - * 服务器资产记录表Service实现 + * 服务Service实现 * * @author 科技小王子 - * @since 2024-09-10 20:57:41 + * @since 2024-10-21 19:15:26 */ @Service public class OaAssetsServerServiceImpl extends ServiceImpl implements OaAssetsServerService { @@ -23,7 +23,7 @@ public class OaAssetsServerServiceImpl extends ServiceImpl pageRel(OaAssetsServerParam param) { PageParam page = new PageParam<>(param); - page.setDefaultOrder("create_time desc"); + page.setDefaultOrder("sort_number asc, create_time desc"); List list = baseMapper.selectPageRel(page, param); return new PageResult<>(list, page.getTotal()); } @@ -33,14 +33,14 @@ public class OaAssetsServerServiceImpl extends ServiceImpl list = baseMapper.selectListRel(param); // 排序 PageParam page = new PageParam<>(); - page.setDefaultOrder("create_time desc"); + page.setDefaultOrder("sort_number asc, create_time desc"); return page.sortRecords(list); } @Override - public OaAssetsServer getByIdRel(Integer serverId) { + public OaAssetsServer getByIdRel(Integer id) { OaAssetsServerParam param = new OaAssetsServerParam(); - param.setServerId(serverId); + param.setId(id); return param.getOne(baseMapper.selectListRel(param)); } diff --git a/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsSslServiceImpl.java b/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsSslServiceImpl.java index 39df8ec..c705669 100644 --- a/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsSslServiceImpl.java +++ b/src/main/java/com/gxwebsoft/oa/service/impl/OaAssetsSslServiceImpl.java @@ -1,5 +1,6 @@ package com.gxwebsoft.oa.service.impl; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gxwebsoft.oa.mapper.OaAssetsSslMapper; import com.gxwebsoft.oa.service.OaAssetsSslService; @@ -27,11 +28,10 @@ public class OaAssetsSslServiceImpl extends ServiceImpl list = baseMapper.selectPageRel(page, param); list.forEach(d -> { - LocalDateTime now = LocalDateTime.now(); // 即将过期(一周内过期的) - d.setSoon(d.getEndTime().minusDays(7).compareTo(now)); + d.setSoon(DateUtil.offsetDay(d.getEndTime(), -7).compareTo(DateUtil.date())); // 是否过期 -1已过期 大于0 未过期 - d.setStatus(d.getEndTime().compareTo(now)); + d.setStatus(d.getEndTime().compareTo(DateUtil.date())); }); return new PageResult<>(list, page.getTotal()); } diff --git a/src/main/java/com/gxwebsoft/oa/service/impl/OaTaskRecordServiceImpl.java b/src/main/java/com/gxwebsoft/oa/service/impl/OaTaskRecordServiceImpl.java new file mode 100644 index 0000000..bdaee94 --- /dev/null +++ b/src/main/java/com/gxwebsoft/oa/service/impl/OaTaskRecordServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.oa.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.oa.mapper.OaTaskRecordMapper; +import com.gxwebsoft.oa.service.OaTaskRecordService; +import com.gxwebsoft.oa.entity.OaTaskRecord; +import com.gxwebsoft.oa.param.OaTaskRecordParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 工单回复记录表Service实现 + * + * @author 科技小王子 + * @since 2024-09-10 20:57:42 + */ +@Service +public class OaTaskRecordServiceImpl extends ServiceImpl implements OaTaskRecordService { + + @Override + public PageResult pageRel(OaTaskRecordParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(OaTaskRecordParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("create_time desc"); + return page.sortRecords(list); + } + + @Override + public OaTaskRecord getByIdRel(Integer taskRecordId) { + OaTaskRecordParam param = new OaTaskRecordParam(); + param.setTaskRecordId(taskRecordId); + return param.getOne(baseMapper.selectListRel(param)); + } + +}