@@ -237,4 +237,10 @@ public class User implements Serializable { | |||
*/ | |||
private Integer authorize; | |||
/** | |||
* 订阅次数 1:订阅一次 2非一次订阅 | |||
*/ | |||
private Integer subscribeTimes; | |||
} |
@@ -28,9 +28,10 @@ import org.springframework.transaction.annotation.Transactional; | |||
import org.springframework.util.CollectionUtils; | |||
import org.springframework.web.client.RestTemplate; | |||
import java.time.format.DateTimeFormatter; | |||
import java.time.temporal.TemporalAccessor; | |||
import java.util.*; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** |
@@ -0,0 +1,38 @@ | |||
package com.tuoheng.admin.service.third.wx; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.InspectionFile; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/27 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class WxService { | |||
@Autowired | |||
private UserMapper userMapper; | |||
public JsonResult sendMessage(List<InspectionFile> inspectionFileList, Inspection inspection){ | |||
log.info("进入调用微信小程序接口,推送第一条问题数据"); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
//获取当前授权信息 | |||
Integer authorize = user.getAuthorize(); | |||
return null; | |||
} | |||
} |
@@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<result property="intro" column="intro" /> | |||
<result property="status" column="status" /> | |||
<result property="authorize" column="authorize" /> | |||
<result property="subscribeTimes" column="subscribe_times" /> | |||
<result property="note" column="note" /> | |||
<result property="sort" column="sort" /> | |||
<result property="loginNum" column="login_num" /> | |||
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<sql id="selectUserVo"> | |||
id, tenant_id, code, realname, nickname, gender, avatar, mobile, email, birthday, dept_id, province_code, city_code, district_code, street_code, address, city_name, | |||
username, password, driver_type, driver_code, salt, intro, status, authorize, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time, | |||
username, password, driver_type, driver_code, salt, intro, status, authorize, subscribe_times, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time, | |||
role_id, data_permission, client_id, mark | |||
</sql> | |||
@@ -2,6 +2,7 @@ package com.tuoheng.miniprogram.controller; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.miniprogram.entity.dto.ResetPwdDto; | |||
import com.tuoheng.miniprogram.entity.dto.SubscribeTimesDto; | |||
import com.tuoheng.miniprogram.service.IUserService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
@@ -29,6 +30,15 @@ public class UserController { | |||
return iUserService.getUserInfo(); | |||
} | |||
/** | |||
* 更新用户的订阅次数 | |||
*/ | |||
@PostMapping("/updateSubscribeTimes") | |||
public JsonResult updateSubscribe(){ | |||
return iUserService.updateSubscribe(); | |||
} | |||
/** | |||
* 修改密码 | |||
* @param dto |
@@ -241,4 +241,9 @@ public class User implements Serializable { | |||
*/ | |||
private Integer authorize; | |||
/** | |||
* 订阅次数 1:订阅一次 2非一次订阅 | |||
*/ | |||
private Integer subscribeTimes; | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.miniprogram.entity.dto; | |||
import lombok.Data; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/27 | |||
*/ | |||
@Data | |||
public class SubscribeTimesDto { | |||
/** | |||
* 订阅次数 | |||
*/ | |||
private Integer subscribeTimes; | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
import lombok.Getter; | |||
/** | |||
* 任务状态枚举 | |||
*/ | |||
public enum SubscribeTimesEnum { | |||
//1未授权 2授权 | |||
SUBSCRIBE_TIMES_ONE(1,"订阅一次"), | |||
SUBSCRIBE_TIMES_NO_ONE(2,"非一次订阅"); | |||
SubscribeTimesEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -16,4 +16,5 @@ public interface IUserService extends IService<User> { | |||
JsonResult getList(String deptId); | |||
JsonResult updateSubscribe(); | |||
} |
@@ -17,8 +17,10 @@ import com.tuoheng.miniprogram.dao.UserMapper; | |||
import com.tuoheng.miniprogram.entity.Dept; | |||
import com.tuoheng.miniprogram.entity.dto.ResetPwdDto; | |||
import com.tuoheng.miniprogram.entity.User; | |||
import com.tuoheng.miniprogram.entity.dto.SubscribeTimesDto; | |||
import com.tuoheng.miniprogram.entity.query.OidcUpdatePassRequest; | |||
import com.tuoheng.miniprogram.enums.MarkEnum; | |||
import com.tuoheng.miniprogram.enums.SubscribeTimesEnum; | |||
import com.tuoheng.miniprogram.enums.UserCodeEnum; | |||
import com.tuoheng.miniprogram.service.IUserService; | |||
import com.tuoheng.miniprogram.utils.CurrentUserUtil; | |||
@@ -142,4 +144,16 @@ public class IUserServiceImpl extends ServiceImpl<UserMapper, User> implements I | |||
.eq(User::getStatus, 1)); | |||
return JsonResult.success(userList); | |||
} | |||
@Override | |||
public JsonResult updateSubscribe() { | |||
User user = CurrentUserUtil.getUserInfo(); | |||
user.setSubscribeTimes(SubscribeTimesEnum.SUBSCRIBE_TIMES_NO_ONE.getCode()); | |||
//更新用户信息 | |||
int count = userMapper.updateById(user); | |||
if(count <= 0){ | |||
return JsonResult.error("用户授权订阅次数更新失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -14,10 +14,7 @@ import com.tuoheng.miniprogram.entity.User; | |||
import com.tuoheng.miniprogram.entity.UserAuthorize; | |||
import com.tuoheng.miniprogram.entity.dto.TemplateMinDto; | |||
import com.tuoheng.miniprogram.entity.wx.WxMessageRequest; | |||
import com.tuoheng.miniprogram.enums.AuthorizeStatusEnum; | |||
import com.tuoheng.miniprogram.enums.MarkEnum; | |||
import com.tuoheng.miniprogram.enums.UserAuthorizeEnum; | |||
import com.tuoheng.miniprogram.enums.UserCodeEnum; | |||
import com.tuoheng.miniprogram.enums.*; | |||
import com.tuoheng.miniprogram.param.WxSendMessageParam; | |||
import com.tuoheng.miniprogram.service.IWxService; | |||
import com.tuoheng.miniprogram.utils.CurrentUserUtil; | |||
@@ -148,6 +145,11 @@ public class WxServiceImpl implements IWxService { | |||
public JsonResult sendMessage(WxMessageRequest wxMessageRequest) { | |||
//获取当前登录用户id | |||
String userId = CurrentUserUtil.getUserId(); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if(user.getAuthorize() == AuthorizeStatusEnum.AUTHORIZE_ON.getCode() | |||
&& user.getSubscribeTimes() == SubscribeTimesEnum.SUBSCRIBE_TIMES_NO_ONE.getCode()){ | |||
return JsonResult.success(); | |||
} | |||
boolean isSend =false; | |||
//获取当前登录openId | |||
UserAuthorize userAuthorize = userAuthorizeMapper.selectOne(Wrappers.<UserAuthorize>lambdaQuery() |