微信网页登录

This commit is contained in:
starrySky
2024-04-09 10:17:49 +08:00
parent b2f6921ef1
commit e8b6c8e0aa
128 changed files with 2861 additions and 4243 deletions

View File

@@ -0,0 +1,17 @@
package com.starry.admin.common.aspect;
import java.lang.annotation.*;
/**
* 陪玩登录注解
*
* @author ruoyi
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ClerkUserLogin {
boolean manage() default false;
}

View File

@@ -0,0 +1,63 @@
package com.starry.admin.common.aspect;
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
import com.starry.admin.common.exception.ServiceException;
import com.starry.admin.modules.clear.mapper.PlayClerkUserInfoMapper;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.weichat.service.WxTokenService;
import com.starry.common.constant.Constants;
import com.starry.common.constant.HttpStatus;
import com.starry.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* 限流处理
*
* @author ruoyi
*/
@Slf4j
@Aspect
@Component
public class ClerkUserLoginAspect {
@Resource
private PlayClerkUserInfoMapper userMapper;
@Resource
private WxTokenService tokenService;
@Resource
private HttpServletRequest request;
@Before("@annotation(clerkUserLogin)")
public void doBefore(JoinPoint point, ClerkUserLogin clerkUserLogin) {
String userToken = request.getHeader(Constants.CLERK_USER_LOGIN_TOKEN);
if (StringUtils.isEmpty(userToken)) {
throw new ServiceException("token为空", HttpStatus.UNAUTHORIZED);
}
userToken = userToken.replace(Constants.TOKEN_PREFIX, "");
// 解析token
String userId;
try {
userId = tokenService.getMiniUserIdByToken(userToken);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
}
PlayClerkUserInfoEntity entity = userMapper.selectById(userId);
if (Objects.isNull(entity)) {
throw new ServiceException("未查询到有效用户", HttpStatus.UNAUTHORIZED);
}
if (!userToken.equals(entity.getToken())) {
throw new ServiceException("token异常", HttpStatus.UNAUTHORIZED);
}
ThreadLocalRequestDetail.setRequestDetail(entity);
}
}

View File

@@ -0,0 +1,17 @@
package com.starry.admin.common.aspect;
import java.lang.annotation.*;
/**
* 客户登录注解
*
* @author ruoyi
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface CustomUserLogin {
boolean manage() default false;
}

View File

@@ -0,0 +1,63 @@
package com.starry.admin.common.aspect;
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
import com.starry.admin.common.exception.ServiceException;
import com.starry.admin.modules.custom.mapper.PlayCustomUserInfoMapper;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.weichat.service.WxTokenService;
import com.starry.common.constant.Constants;
import com.starry.common.constant.HttpStatus;
import com.starry.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* 限流处理
*
* @author ruoyi
*/
@Slf4j
@Aspect
@Component
public class CustomUserLoginAspect {
@Resource
private PlayCustomUserInfoMapper userMapper;
@Resource
private WxTokenService tokenService;
@Resource
private HttpServletRequest request;
@Before("@annotation(customUserLogin)")
public void doBefore(JoinPoint point, CustomUserLogin customUserLogin) {
String userToken = request.getHeader(Constants.CUSTOM_USER_LOGIN_TOKEN);
if (StringUtils.isEmpty(userToken)) {
throw new ServiceException("token为空", HttpStatus.UNAUTHORIZED);
}
userToken = userToken.replace(Constants.TOKEN_PREFIX, "");
// 解析token
String userId;
try {
userId = tokenService.getMiniUserIdByToken(userToken);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
}
PlayCustomUserInfoEntity entity = userMapper.selectById(userId);
if (Objects.isNull(entity)) {
throw new ServiceException("未查询到有效用户", HttpStatus.UNAUTHORIZED);
}
if (!userToken.equals(entity.getToken())) {
throw new ServiceException("token异常", HttpStatus.UNAUTHORIZED);
}
ThreadLocalRequestDetail.setRequestDetail(entity);
}
}

View File

@@ -98,7 +98,7 @@ public class JwtToken {
String token = IdUtil.fastSimpleUUID(); String token = IdUtil.fastSimpleUUID();
jwtUser.setToken(token); jwtUser.setToken(token);
setUserAgent(jwtUser); setUserAgent(jwtUser);
refresToken(jwtUser); refersToken(jwtUser);
Map<String, Object> claims = new HashMap<>(); Map<String, Object> claims = new HashMap<>();
claims.put(Constants.LOGIN_USER_KEY, token); claims.put(Constants.LOGIN_USER_KEY, token);
@@ -167,7 +167,7 @@ public class JwtToken {
jwtUser.setOs(userAgent.getOs().getName()); jwtUser.setOs(userAgent.getOs().getName());
} }
public void refresToken(JwtUser jwtUser) { public void refersToken(JwtUser jwtUser) {
jwtUser.setLoginTime(System.currentTimeMillis()); jwtUser.setLoginTime(System.currentTimeMillis());
jwtUser.setExpireTime(jwtUser.getLoginTime() + expire * 1000); jwtUser.setExpireTime(jwtUser.getLoginTime() + expire * 1000);
String userKey = getTokenKey(jwtUser.getToken()); String userKey = getTokenKey(jwtUser.getToken());
@@ -224,7 +224,7 @@ public class JwtToken {
long expireTime = jwtUser.getExpireTime(); long expireTime = jwtUser.getExpireTime();
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
if (expireTime - currentTime <= MILLIS_MINUTE_TEN) { if (expireTime - currentTime <= MILLIS_MINUTE_TEN) {
refresToken(jwtUser); refersToken(jwtUser);
} }
} }

View File

@@ -0,0 +1,43 @@
package com.starry.admin.common.conf;
import com.alibaba.ttl.TransmittableThreadLocal;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
/**
* @author : huchuansai
* @since : 2024/4/2 12:10 AM
*/
public class ThreadLocalRequestDetail {
private static final TransmittableThreadLocal<Object> threadLocal = new TransmittableThreadLocal<>();
/**
* 设置请求信息到当前线程中
*/
public static void setRequestDetail(Object data) {
threadLocal.set(data);
}
/**
* 从当前线程中获取请求信息
*/
public static Object getRequestDetail() {
return threadLocal.get();
}
public static PlayClerkUserInfoEntity getClerkUserInfo() {
return (PlayClerkUserInfoEntity) threadLocal.get();
}
public static PlayCustomUserInfoEntity getCustomUserInfo() {
return (PlayCustomUserInfoEntity) threadLocal.get();
}
/**
* 销毁
*/
public static void remove() {
threadLocal.remove();
}
}

View File

@@ -1,7 +1,6 @@
package com.starry.admin.common.mybatis.handler; package com.starry.admin.common.mybatis.handler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.starry.admin.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject; import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -23,23 +22,23 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
this.setFieldValByName("createdTime", new Date(), metaObject); this.setFieldValByName("createdTime", new Date(), metaObject);
this.setFieldValByName("deleted", false, metaObject); this.setFieldValByName("deleted", false, metaObject);
this.setFieldValByName("version", 1L, metaObject); this.setFieldValByName("version", 1L, metaObject);
Object createUser = this.getFieldValByName("createdBy", metaObject); // Object createUser = this.getFieldValByName("createdBy", metaObject);
if (createUser == null) { // if (createUser == null) {
if (SecurityUtils.isLogin()) { // if (SecurityUtils.isLogin()) {
this.setFieldValByName("createdBy", SecurityUtils.getUserId(), metaObject); // this.setFieldValByName("createdBy", SecurityUtils.getUserId(), metaObject);
} // }
} // }
} }
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
log.info("start update fill ...."); log.info("start update fill ....");
this.setFieldValByName("updatedTime", new Date(), metaObject); this.setFieldValByName("updatedTime", new Date(), metaObject);
Object createUser = this.getFieldValByName("updatedBy", metaObject); // Object createUser = this.getFieldValByName("updatedBy", metaObject);
if (createUser == null) { // if (createUser == null) {
if (SecurityUtils.isLogin()) { // if (SecurityUtils.isLogin()) {
this.setFieldValByName("updatedBy", SecurityUtils.getUserId(), metaObject); // this.setFieldValByName("updatedBy", SecurityUtils.getUserId(), metaObject);
} // }
} // }
} }
} }

View File

@@ -23,7 +23,7 @@ public class MyTenantLineHandler implements TenantLineHandler {
/** /**
* 排除过滤的表 * 排除过滤的表
*/ */
private static final String[] TABLE_FILTER = {"sys_user", "sys_menu", "sys_tenant_package", "sys_tenant", "sys_dict", "sys_dict_data"}; private static final String[] TABLE_FILTER = {"sys_user", "sys_menu", "sys_tenant_package", "sys_tenant", "sys_dict", "sys_dict_data", "sys_administrative_area_dict_info"};
/** /**
* 排除过滤的表前缀 * 排除过滤的表前缀

View File

@@ -0,0 +1,32 @@
package com.starry.admin.common.security;
import javax.servlet.*;
import java.io.IOException;
/**
* @author admin
* @since 2024/4/7 17:17
**/
public class CustomFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) {
// 初始化代码
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// 在请求处理之前可以进行一些操作
// 例如,可以记录请求开始时间
System.out.println("--------------------");
// 继续调用下一个Filter或servlet
chain.doFilter(request, response);
// 在请求处理之后可以进行一些操作
// 例如,可以记录请求结束时间并计算耗时
}
@Override
public void destroy() {
// 销毁代码
}
}

View File

@@ -65,7 +65,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
"/v2/api-docs/**" "/v2/api-docs/**"
).permitAll() ).permitAll()
// 对登录注册要允许匿名访问 // 对登录注册要允许匿名访问
.antMatchers("/login", "/captcha/get-captcha", "/wx/test/**","/wp/clear/**").permitAll() .antMatchers("/login", "/captcha/get-captcha", "/wx/**").permitAll()
// 跨域请求会先进行一次options请求 // 跨域请求会先进行一次options请求
.antMatchers(HttpMethod.OPTIONS).permitAll() .antMatchers(HttpMethod.OPTIONS).permitAll()
.anyRequest()// 除上面外的所有请求全部需要鉴权认证 .anyRequest()// 除上面外的所有请求全部需要鉴权认证

View File

@@ -34,21 +34,6 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
@Resource @Resource
private JwtToken jwtToken; private JwtToken jwtToken;
@Override
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
String url = request.getRequestURL().toString();
log.debug("url ={}", url);
// 指定URL不拦截
if (url.contains("/wp/clear/")) {
return true;
}
// 指定URL不拦截
if (url.contains("/wp/custom/")) {
return true;
}
return false;
}
@Override @Override
protected void doFilterInternal(@NotNull HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException { protected void doFilterInternal(@NotNull HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {

View File

@@ -0,0 +1,95 @@
package com.starry.admin.modules.clear.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.modules.clear.module.entity.PlayClerkClassificationInfoEntity;
import com.starry.admin.modules.clear.service.IPlayClerkClassificationInfoService;
import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 店员分类Controller
*
* @author admin
* @since 2024-04-06
*/
@RestController
@RequestMapping("/clerk/class")
public class PlayClerkClassificationInfoController {
@Resource
private IPlayClerkClassificationInfoService playClerkClassificationInfoService;
/**
* 查询店员分类列表
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/listAll")
public R listAll() {
List<PlayClerkClassificationInfoEntity> list = playClerkClassificationInfoService.selectPlayClerkClassificationInfo();
return R.ok(list);
}
/**
* 查询店员分类列表
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/list")
public R list(PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
IPage<PlayClerkClassificationInfoEntity> list = playClerkClassificationInfoService.selectPlayClerkClassificationInfoByPage(playClerkClassificationInfo);
return R.ok(list);
}
/**
* 获取店员分类详细信息
*/
@PreAuthorize("@customSs.hasPermission('play:info:query')")
@GetMapping(value = "/{id}")
public R getInfo(@PathVariable("id") String id) {
return R.ok(playClerkClassificationInfoService.selectPlayClerkClassificationInfoById(id));
}
/**
* 新增店员分类
*/
@PreAuthorize("@customSs.hasPermission('play:info:create')")
@Log(title = "店员分类", businessType = BusinessType.INSERT)
@PostMapping("/create")
public R create(@RequestBody PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
boolean success = playClerkClassificationInfoService.create(playClerkClassificationInfo);
if (success) {
return R.ok();
}
return R.error("添加失败");
}
/**
* 修改店员分类
*/
@PreAuthorize("@customSs.hasPermission('play:info:edit')")
@Log(title = "店员分类", businessType = BusinessType.UPDATE)
@PostMapping(value = "/update/{id}")
public R update(@PathVariable String id, @RequestBody PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
playClerkClassificationInfo.setId(id);
boolean success = playClerkClassificationInfoService.update(playClerkClassificationInfo);
if (success) {
return R.ok();
}
return R.error("修改失败");
}
/**
* 删除店员分类
*/
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
@Log(title = "店员分类", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R remove(@PathVariable String[] ids) {
return R.ok(playClerkClassificationInfoService.deletePlayClerkClassificationInfoByIds(ids));
}
}

View File

@@ -23,7 +23,7 @@ import java.util.List;
* @since 2024-03-31 * @since 2024-03-31
*/ */
@RestController @RestController
@RequestMapping("/clark/commodity") @RequestMapping("/clerk/commodity")
public class PlayClerkCommodityController { public class PlayClerkCommodityController {
@Resource @Resource
private IPlayClerkCommodityService playClerkCommodityService; private IPlayClerkCommodityService playClerkCommodityService;

View File

@@ -30,8 +30,8 @@ public class PlayClerkLevelInfoController {
* 查询店员等级列表 * 查询店员等级列表
*/ */
@PreAuthorize("@customSs.hasPermission('play:info:list')") @PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/list") @GetMapping("/listAll")
public R list() { public R listAll() {
return R.ok(playClerkLevelInfoService.selectAll()); return R.ok(playClerkLevelInfoService.selectAll());
} }

View File

@@ -1,11 +1,19 @@
package com.starry.admin.modules.clear.controller; package com.starry.admin.modules.clear.controller;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.modules.clear.module.entity.PlayClerkLevelInfoEntity;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity; import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoQueryVo;
import com.starry.admin.modules.clear.module.vo.PlayClerkLevelQueryReturnVo;
import com.starry.admin.modules.clear.module.vo.PlayClerkUserAddToWxVo;
import com.starry.admin.modules.clear.module.vo.PlayClerkUserAddVo; import com.starry.admin.modules.clear.module.vo.PlayClerkUserAddVo;
import com.starry.admin.modules.clear.module.vo.PlayClerkUserEditVo; import com.starry.admin.modules.clear.module.vo.PlayClerkUserEditVo;
import com.starry.admin.modules.clear.service.IPlayClerkCommodityService; import com.starry.admin.modules.clear.service.IPlayClerkCommodityService;
import com.starry.admin.modules.clear.service.IPlayClerkLevelInfoService;
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService; import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.play.module.entity.PlayUserInfoEntity;
import com.starry.admin.modules.play.service.IPlayUserInfoService;
import com.starry.common.annotation.Log; import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType; import com.starry.common.enums.BusinessType;
import com.starry.common.result.R; import com.starry.common.result.R;
@@ -25,19 +33,44 @@ import javax.annotation.Resource;
@RestController @RestController
@RequestMapping("/clerk/user") @RequestMapping("/clerk/user")
public class PlayClerkUserInfoController { public class PlayClerkUserInfoController {
@Resource
private IPlayUserInfoService playUserInfoService;
@Resource @Resource
private IPlayClerkUserInfoService playClerkUserInfoService; private IPlayClerkUserInfoService playClerkUserInfoService;
@Resource @Resource
private IPlayClerkCommodityService clerkCommodityService; private IPlayClerkCommodityService clerkCommodityService;
@Resource
private IPlayClerkLevelInfoService clerkLevelInfoService;
@GetMapping("/queryLevel")
public R queryLevel() {
PlayClerkLevelInfoEntity entity = clerkLevelInfoService.selectPlayClerkLevelInfoById(playClerkUserInfoService.queryByUserId().getId());
return R.ok(ConvertUtil.entityToVo(entity, PlayClerkLevelQueryReturnVo.class));
}
/**
* 查询店员列表
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/wx/listByPage")
public R listByPage(PlayClerkUserInfoQueryVo vo) {
IPage<PlayClerkUserInfoEntity> list = playClerkUserInfoService.selectPlayClerkUserInfoByPage(vo);
return R.ok(list);
}
/** /**
* 查询店员列表 * 查询店员列表
*/ */
@PreAuthorize("@customSs.hasPermission('play:info:list')") @PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/list") @GetMapping("/list")
public R list(PlayClerkUserInfoEntity playClerkUserInfo) { public R list(PlayClerkUserInfoQueryVo vo) {
IPage<PlayClerkUserInfoEntity> list = playClerkUserInfoService.selectPlayClerkUserInfoByPage(playClerkUserInfo); IPage<PlayClerkUserInfoEntity> list = playClerkUserInfoService.selectPlayClerkUserInfoByPage(vo);
return R.ok(list); return R.ok(list);
} }
@@ -50,6 +83,30 @@ public class PlayClerkUserInfoController {
return R.ok(playClerkUserInfoService.selectPlayClerkUserInfoById(id)); return R.ok(playClerkUserInfoService.selectPlayClerkUserInfoById(id));
} }
/**
* 微信端口新增店员
*/
@PreAuthorize("@customSs.hasPermission('play:info:create')")
@Log(title = "店员", businessType = BusinessType.INSERT)
@PostMapping("/wx/add")
public R add(@Validated @RequestBody PlayClerkUserAddToWxVo vo) {
//微信申请成为店员,需要先创建账户。
PlayUserInfoEntity userInfoEntity = ConvertUtil.entityToVo(vo, PlayUserInfoEntity.class);
userInfoEntity.setId(IdUtil.fastSimpleUUID());
playUserInfoService.create(userInfoEntity);
//账号创建完成后,创建店员
PlayClerkUserInfoEntity clerkUserInfoEntity = ConvertUtil.entityToVo(vo, PlayClerkUserInfoEntity.class);
clerkUserInfoEntity.setPlayUserId(userInfoEntity.getId());
boolean success = playClerkUserInfoService.create(clerkUserInfoEntity);
if (success) {
clerkCommodityService.initClerkCommodity(userInfoEntity.getId());
return R.ok();
}
return R.error("添加失败");
}
/** /**
* 新增店员 * 新增店员
*/ */

View File

@@ -0,0 +1,16 @@
package com.starry.admin.modules.clear.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starry.admin.modules.clear.module.entity.PlayClerkClassificationInfoEntity;
/**
* 店员分类Mapper接口
*
* @author admin
* @since 2024-04-06
*/
public interface PlayClerkClassificationInfoMapper extends BaseMapper<PlayClerkClassificationInfoEntity> {
}

View File

@@ -0,0 +1,41 @@
package com.starry.admin.modules.clear.module.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 店员分类对象 play_clerk_classification_info
*
* @author admin
* @since 2024-04-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("play_clerk_classification_info")
public class PlayClerkClassificationInfoEntity extends BaseEntity<PlayClerkClassificationInfoEntity> {
/**
* UUID
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 类型名称
*/
private String name;
/**
* (排序字段)
*/
private Integer sort;
}

View File

@@ -1,12 +1,13 @@
package com.starry.admin.modules.clear.module.entity; package com.starry.admin.modules.clear.module.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.starry.common.domain.BaseEntity; import com.starry.common.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
/** /**
* 【请填写功能名称】对象 play_clerk_user_info * 店员对象 play_clerk_user_info
* *
* @author admin * @author admin
* @since 2024-03-30 * @since 2024-03-30
@@ -47,6 +48,11 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
*/ */
private String levelId; private String levelId;
/**
* 店员类型
*/
private String typeId;
/** /**
* 店员性别10 * 店员性别10
*/ */
@@ -112,8 +118,9 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
*/ */
private String remark; private String remark;
/** /**
* 在职状态1在职1:离职) * 在职状态1在职0:离职)
*/ */
private String onboardingState; private String onboardingState;
@@ -157,5 +164,11 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
*/ */
private String randomOrder; private String randomOrder;
/**
* 最近一次登录token
*/
@JsonIgnore
private String token;
} }

View File

@@ -0,0 +1,45 @@
package com.starry.admin.modules.clear.module.entity;
import com.starry.common.domain.BasePageEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 店员对象 play_clerk_user_info
*
* @author admin
* @since 2024-03-30
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class PlayClerkUserInfoQueryVo extends BasePageEntity {
/**
* 店员等级
*/
private String levelId;
/**
* 店员类型
*/
private String typeId;
/**
* 店员性别10
*/
private String sex;
/**
* 所在省份
*/
private String province;
/**
* 上架状态【1上架0下架】
*/
private String listingState;
}

View File

@@ -0,0 +1,17 @@
package com.starry.admin.modules.clear.module.vo;
import lombok.Data;
/**
* 店员等级查询接口
*/
@Data
public class PlayClerkLevelQueryReturnVo {
/**
* 登记名称
*/
private String name;
}

View File

@@ -0,0 +1,85 @@
package com.starry.admin.modules.clear.module.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
public class PlayClerkUserAddToWxVo {
/**
* 店员昵称
*/
@NotBlank(message = "昵称不能为空")
private String nickname;
/**
* 店员性别10
*/
@NotNull(message = "性别不能为空")
private Integer sex;
/**
* 年龄
*/
@NotNull(message = "年龄不能为空")
private int age;
/**
* 微信号
*/
@NotBlank(message = "微信号不能为空")
private String weChat;
/**
* 手机号码区号
*/
@NotBlank(message = "微信号不能为空")
private String areaCode;
/**
* 手机号码
*/
@NotBlank(message = "微信号不能为空")
private String phone;
/**
* 音频
*/
@NotBlank(message = "音频不能为空")
private String audioFrequency;
/**
* 所在国家
*/
private String country = "中国";
/**
* 所在省份
*/
@NotBlank(message = "省份不能为空")
private String province;
/**
* 所在城市
*/
@NotBlank(message = "城市不能为空")
private String city;
/**
* 备注
*/
private String remark;
/**
* 账户状态1审批通过0注册未审批
*/
private String accountState = "0";
}

View File

@@ -0,0 +1,71 @@
package com.starry.admin.modules.clear.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.clear.module.entity.PlayClerkClassificationInfoEntity;
import java.util.List;
/**
* 店员分类Service接口
*
* @author admin
* @since 2024-04-06
*/
public interface IPlayClerkClassificationInfoService extends IService<PlayClerkClassificationInfoEntity> {
/**
* 查询店员分类
*
* @param id 店员分类主键
* @return 店员分类
*/
PlayClerkClassificationInfoEntity selectPlayClerkClassificationInfoById(String id);
/**
* 查询店员分类列表
*
* @return 店员分类集合
*/
List<PlayClerkClassificationInfoEntity> selectPlayClerkClassificationInfo();
/**
* 查询店员分类列表
*
* @param playClerkClassificationInfo 店员分类
* @return 店员分类集合
*/
IPage<PlayClerkClassificationInfoEntity> selectPlayClerkClassificationInfoByPage(PlayClerkClassificationInfoEntity playClerkClassificationInfo);
/**
* 新增店员分类
*
* @param playClerkClassificationInfo 店员分类
* @return 结果
*/
boolean create(PlayClerkClassificationInfoEntity playClerkClassificationInfo);
/**
* 修改店员分类
*
* @param playClerkClassificationInfo 店员分类
* @return 结果
*/
boolean update(PlayClerkClassificationInfoEntity playClerkClassificationInfo);
/**
* 批量删除店员分类
*
* @param ids 需要删除的店员分类主键集合
* @return 结果
*/
int deletePlayClerkClassificationInfoByIds(String[] ids);
/**
* 删除店员分类信息
*
* @param id 店员分类主键
* @return 结果
*/
int deletePlayClerkClassificationInfoById(String id);
}

View File

@@ -3,6 +3,7 @@ package com.starry.admin.modules.clear.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity; import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoQueryVo;
/** /**
@@ -12,8 +13,26 @@ import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
* @since 2024-03-30 * @since 2024-03-30
*/ */
public interface IPlayClerkUserInfoService extends IService<PlayClerkUserInfoEntity> { public interface IPlayClerkUserInfoService extends IService<PlayClerkUserInfoEntity> {
/**
* 根据账户ID查询店员
*
* @return 店员
*/
PlayClerkUserInfoEntity queryByUserId();
/** /**
* 查询店员 * 查询店员
*
* @param openId 微信ID
* @return 店员
*/
PlayClerkUserInfoEntity selectByOpenid(String openId);
/**
* 查询店员
*
* @param id 店员主键 * @param id 店员主键
* @return 店员 * @return 店员
*/ */
@@ -21,13 +40,15 @@ public interface IPlayClerkUserInfoService extends IService<PlayClerkUserInfoEnt
/** /**
* 查询店员列表 * 查询店员列表
* @param playClerkUserInfo 店员 *
* @param vo 店员查询对象
* @return 店员集合 * @return 店员集合
*/ */
IPage<PlayClerkUserInfoEntity> selectPlayClerkUserInfoByPage(PlayClerkUserInfoEntity playClerkUserInfo); IPage<PlayClerkUserInfoEntity> selectPlayClerkUserInfoByPage(PlayClerkUserInfoQueryVo vo);
/** /**
* 新增店员 * 新增店员
*
* @param playClerkUserInfo 店员 * @param playClerkUserInfo 店员
* @return 结果 * @return 结果
*/ */
@@ -35,6 +56,7 @@ public interface IPlayClerkUserInfoService extends IService<PlayClerkUserInfoEnt
/** /**
* 修改店员 * 修改店员
*
* @param playClerkUserInfo 店员 * @param playClerkUserInfo 店员
* @return 结果 * @return 结果
*/ */

View File

@@ -0,0 +1,110 @@
package com.starry.admin.modules.clear.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.clear.mapper.PlayClerkClassificationInfoMapper;
import com.starry.admin.modules.clear.module.entity.PlayClerkClassificationInfoEntity;
import com.starry.admin.modules.clear.service.IPlayClerkClassificationInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 店员分类Service业务层处理
*
* @author admin
* @since 2024-04-06
*/
@Service
public class PlayClerkClassificationInfoServiceImpl extends ServiceImpl<PlayClerkClassificationInfoMapper, PlayClerkClassificationInfoEntity> implements IPlayClerkClassificationInfoService {
@Resource
private PlayClerkClassificationInfoMapper playClerkClassificationInfoMapper;
/**
* 查询店员分类
*
* @param id 店员分类主键
* @return 店员分类
*/
@Override
public PlayClerkClassificationInfoEntity selectPlayClerkClassificationInfoById(String id) {
return this.baseMapper.selectById(id);
}
/**
* 查询店员分类列表
*
* @return 店员分类
*/
@Override
public List<PlayClerkClassificationInfoEntity> selectPlayClerkClassificationInfo() {
return this.baseMapper.selectList(new LambdaQueryWrapper<>());
}
/**
* 查询店员分类列表
*
* @param playClerkClassificationInfo 店员分类
* @return 店员分类
*/
@Override
public IPage<PlayClerkClassificationInfoEntity> selectPlayClerkClassificationInfoByPage(PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
Page<PlayClerkClassificationInfoEntity> page = new Page<>(1, 10);
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<PlayClerkClassificationInfoEntity>());
}
/**
* 新增店员分类
*
* @param playClerkClassificationInfo 店员分类
* @return 结果
*/
@Override
public boolean create(PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
if (StrUtil.isBlankIfStr(playClerkClassificationInfo.getId())) {
playClerkClassificationInfo.setId(IdUtil.fastSimpleUUID());
}
return save(playClerkClassificationInfo);
}
/**
* 修改店员分类
*
* @param playClerkClassificationInfo 店员分类
* @return 结果
*/
@Override
public boolean update(PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
return updateById(playClerkClassificationInfo);
}
/**
* 批量删除店员分类
*
* @param ids 需要删除的店员分类主键
* @return 结果
*/
@Override
public int deletePlayClerkClassificationInfoByIds(String[] ids) {
return playClerkClassificationInfoMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除店员分类信息
*
* @param id 店员分类主键
* @return 结果
*/
@Override
public int deletePlayClerkClassificationInfoById(String id) {
return playClerkClassificationInfoMapper.deleteById(id);
}
}

View File

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.clear.mapper.PlayClerkUserInfoMapper; import com.starry.admin.modules.clear.mapper.PlayClerkUserInfoMapper;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity; import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoQueryVo;
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService; import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -26,6 +27,21 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
@Resource @Resource
private PlayClerkUserInfoMapper playClerkUserInfoMapper; private PlayClerkUserInfoMapper playClerkUserInfoMapper;
@Override
public PlayClerkUserInfoEntity queryByUserId() {
LambdaQueryWrapper<PlayClerkUserInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getPlayUserId, "123456");
return this.baseMapper.selectOne(lambdaQueryWrapper);
}
@Override
public PlayClerkUserInfoEntity selectByOpenid(String openId) {
LambdaQueryWrapper<PlayClerkUserInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getPlayUserId, openId);
return this.baseMapper.selectOne(lambdaQueryWrapper);
}
/** /**
* 查询店员 * 查询店员
* *
@@ -40,12 +56,12 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
/** /**
* 查询店员列表 * 查询店员列表
* *
* @param playClerkUserInfo 店员 * @param vo 店员查询对象
* @return 店员 * @return 店员
*/ */
@Override @Override
public IPage<PlayClerkUserInfoEntity> selectPlayClerkUserInfoByPage(PlayClerkUserInfoEntity playClerkUserInfo) { public IPage<PlayClerkUserInfoEntity> selectPlayClerkUserInfoByPage(PlayClerkUserInfoQueryVo vo) {
Page<PlayClerkUserInfoEntity> page = new Page<>(1, 10); Page<PlayClerkUserInfoEntity> page = new Page<>(vo.getPageNum(), vo.getPageSize());
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>()); return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
} }

View File

@@ -17,7 +17,7 @@ public interface IPlayClearServiceService extends IService<PlayClearServiceEntit
* 初始化陪玩的服务项目 * 初始化陪玩的服务项目
* *
* @param playUserId 陪玩用户ID * @param playUserId 陪玩用户ID
* @author 杭州世平信息科技有限公司-xuhq * @author admin
* @since 2024/3/28 11:13 * @since 2024/3/28 11:13
**/ **/
void initPlayService(String playUserId); void initPlayService(String playUserId);
@@ -53,7 +53,7 @@ public interface IPlayClearServiceService extends IService<PlayClearServiceEntit
* @param playUserId 陪玩用户ID * @param playUserId 陪玩用户ID
* @param serviceId 服务ID * @param serviceId 服务ID
* @param enablingState * 项目启用状态【0:停用1启用】 * @param enablingState * 项目启用状态【0:停用1启用】
* @author 杭州世平信息科技有限公司-xuhq * @author admin
* @since 2024/3/28 11:35 * @since 2024/3/28 11:35
**/ **/
void updateServiceEnablingState(String playUserId, String serviceId, String enablingState); void updateServiceEnablingState(String playUserId, String serviceId, String enablingState);

View File

@@ -27,7 +27,7 @@ public interface IPlayServiceInfoService extends IService<PlayServiceInfoEntity>
* 查询所有的服务项目 * 查询所有的服务项目
* *
* @return List<PlayServiceInfoEntity> * @return List<PlayServiceInfoEntity>
* @author 杭州世平信息科技有限公司-xuhq * @author admin
* @since 2024/3/28 11:18 * @since 2024/3/28 11:18
**/ **/
List<PlayServiceInfoEntity> selectPlayServiceInfoAll(); List<PlayServiceInfoEntity> selectPlayServiceInfoAll();

View File

@@ -66,7 +66,7 @@ public class PlayClearServiceServiceImpl extends ServiceImpl<PlayClearServiceMap
@Override @Override
public IPage<PlayClearServiceEntity> selectPlayClearServiceByPage(PlayClearServiceEntity playClearService) { public IPage<PlayClearServiceEntity> selectPlayClearServiceByPage(PlayClearServiceEntity playClearService) {
Page<PlayClearServiceEntity> page = new Page<>(1, 10); Page<PlayClearServiceEntity> page = new Page<>(1, 10);
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<PlayClearServiceEntity>()); return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
} }
/** /**

View File

@@ -53,7 +53,7 @@ public class PlayServiceInfoServiceImpl extends ServiceImpl<PlayServiceInfoMappe
@Override @Override
public IPage<PlayServiceInfoEntity> selectPlayServiceInfoByPage(PlayServiceInfoEntity playServiceInfo) { public IPage<PlayServiceInfoEntity> selectPlayServiceInfoByPage(PlayServiceInfoEntity playServiceInfo) {
Page<PlayServiceInfoEntity> page = new Page<>(1, 10); Page<PlayServiceInfoEntity> page = new Page<>(1, 10);
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<PlayServiceInfoEntity>()); return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
} }
/** /**

View File

@@ -0,0 +1,92 @@
package com.starry.admin.modules.custom.controller;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import com.starry.common.annotation.Log;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 顾客Controller
*
* @author admin
* @since 2024-04-08
*/
@RestController
@RequestMapping("/play/info")
public class PlayCustomUserInfoController {
@Resource
private IPlayCustomUserInfoService playCustomUserInfoService;
/**
* 查询顾客列表
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/list")
public R list(PlayCustomUserInfoEntity playCustomUserInfo) {
IPage<PlayCustomUserInfoEntity> list = playCustomUserInfoService.selectPlayCustomUserInfoByPage(playCustomUserInfo);
return R.ok(list);
}
/**
* 获取顾客详细信息
*/
@PreAuthorize("@customSs.hasPermission('play:info:query')")
@GetMapping(value = "/{id}")
public R getInfo(@PathVariable("id") String id) {
return R.ok(playCustomUserInfoService.selectPlayCustomUserInfoById(id));
}
/**
* 新增顾客
*/
@PreAuthorize("@customSs.hasPermission('play:info:create')")
@Log(title = "顾客", businessType = BusinessType.INSERT)
@PostMapping("/create")
public R create(@RequestBody PlayCustomUserInfoEntity playCustomUserInfo) {
boolean success = playCustomUserInfoService.create(playCustomUserInfo);
if (success) {
return R.ok();
}
return R.error("添加失败");
}
/**
* 修改顾客
*/
@PreAuthorize("@customSs.hasPermission('play:info:edit')")
@Log(title = "顾客", businessType = BusinessType.UPDATE)
@PostMapping(value = "/update/{id}")
public R update(@PathVariable String id, @RequestBody PlayCustomUserInfoEntity playCustomUserInfo) {
playCustomUserInfo.setId(id);
boolean success = playCustomUserInfoService.update(playCustomUserInfo);
if (success) {
return R.ok();
}
return R.error("修改失败");
}
/**
* 删除顾客
*/
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
@Log(title = "顾客", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R remove(@PathVariable String[] ids) {
return R.ok(playCustomUserInfoService.deletePlayCustomUserInfoByIds(ids));
}
}

View File

@@ -0,0 +1,16 @@
package com.starry.admin.modules.custom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
/**
* 顾客Mapper接口
*
* @author admin
* @since 2024-04-08
*/
public interface PlayCustomUserInfoMapper extends BaseMapper<PlayCustomUserInfoEntity> {
}

View File

@@ -0,0 +1,150 @@
package com.starry.admin.modules.custom.module.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 顾客对象 play_custom_user_info
*
* @author admin
* @since 2024-04-08
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("play_custom_user_info")
public class PlayCustomUserInfoEntity extends BaseEntity<PlayCustomUserInfoEntity> {
/**
* UUID
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 用户的标识,对当前公众号唯一
*/
private String openid;
/**
* 用户的标识,对当前公众号唯一
*/
private String unionid;
/**
* 店员昵称
*/
private String nickname;
/**
* 店员性别0:位置;1:男,2:女)
*/
private Integer sex;
/**
* 头像
*/
private String avatar;
/**
* 电话号码
*/
private String phone;
/**
* 等级
*/
private String levelId;
/**
* 所在国家
*/
private String country;
/**
* 所在省份
*/
private String province;
/**
* 所在城市
*/
private String city;
/**
* 账户余额(单位分)
*/
private String accountBalance;
/**
* 余额状态[0:不存在余额1:存在余额]
*/
private String accountState;
/**
* 关注状态[0:未关注1:已关注]
*/
private String subscribeState;
/**
* 黑名单状态[0:黑名单1:非黑名单]
*/
private String blacklistState;
/**
* 违规状态[0:违规,1:未违规]
*/
private String violationState;
/**
* 是否下单状态[0:未未下单1:下单过]
*/
private String purchaseState;
/**
* 绑定手机状态[0:未绑定,1:绑定]
*/
private String mobilePhoneState;
/**
* 注册时间
*/
private Date registrationTime;
/**
* 上次登录时间
*/
private Date lastLoginTime;
/**
* 首次下单时间
*/
private Date firstPurchaseTime;
/**
* 最后一次下单时间
*/
private Date lastPurchaseTime;
/**
* 备注
*/
private String remark;
/**
* 最近一次登录token
*/
@JsonIgnore
private String token;
}

View File

@@ -0,0 +1,72 @@
package com.starry.admin.modules.custom.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
/**
* 顾客Service接口
*
* @author admin
* @since 2024-04-08
*/
public interface IPlayCustomUserInfoService extends IService<PlayCustomUserInfoEntity> {
/**
* 查询顾客
*
* @param openId 顾客主键
* @return 顾客
*/
PlayCustomUserInfoEntity selectByOpenid(String openId);
/**
* 查询顾客
*
* @param id 顾客主键
* @return 顾客
*/
PlayCustomUserInfoEntity selectPlayCustomUserInfoById(String id);
/**
* 查询顾客列表
*
* @param playCustomUserInfo 顾客
* @return 顾客集合
*/
IPage<PlayCustomUserInfoEntity> selectPlayCustomUserInfoByPage(PlayCustomUserInfoEntity playCustomUserInfo);
/**
* 新增顾客
*
* @param playCustomUserInfo 顾客
* @return 结果
*/
boolean create(PlayCustomUserInfoEntity playCustomUserInfo);
/**
* 修改顾客
*
* @param playCustomUserInfo 顾客
* @return 结果
*/
boolean update(PlayCustomUserInfoEntity playCustomUserInfo);
/**
* 批量删除顾客
*
* @param ids 需要删除的顾客主键集合
* @return 结果
*/
int deletePlayCustomUserInfoByIds(String[] ids);
/**
* 删除顾客信息
*
* @param id 顾客主键
* @return 结果
*/
int deletePlayCustomUserInfoById(String id);
}

View File

@@ -0,0 +1,105 @@
package com.starry.admin.modules.custom.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.custom.mapper.PlayCustomUserInfoMapper;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
/**
* 顾客Service业务层处理
*
* @author admin
* @since 2024-04-08
*/
@Service
public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInfoMapper, PlayCustomUserInfoEntity> implements IPlayCustomUserInfoService {
@Resource
private PlayCustomUserInfoMapper playCustomUserInfoMapper;
@Override
public PlayCustomUserInfoEntity selectByOpenid(String openId) {
LambdaQueryWrapper<PlayCustomUserInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PlayCustomUserInfoEntity::getOpenid, openId);
return this.baseMapper.selectOne(lambdaQueryWrapper);
}
/**
* 查询顾客
*
* @param id 顾客主键
* @return 顾客
*/
@Override
public PlayCustomUserInfoEntity selectPlayCustomUserInfoById(String id) {
return this.baseMapper.selectById(id);
}
/**
* 查询顾客列表
*
* @param playCustomUserInfo 顾客
* @return 顾客
*/
@Override
public IPage<PlayCustomUserInfoEntity> selectPlayCustomUserInfoByPage(PlayCustomUserInfoEntity playCustomUserInfo) {
Page<PlayCustomUserInfoEntity> page = new Page<>(1, 10);
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
}
/**
* 新增顾客
*
* @param playCustomUserInfo 顾客
* @return 结果
*/
@Override
public boolean create(PlayCustomUserInfoEntity playCustomUserInfo) {
if (StrUtil.isBlankIfStr(playCustomUserInfo.getId())) {
playCustomUserInfo.setId(IdUtil.fastSimpleUUID());
}
return save(playCustomUserInfo);
}
/**
* 修改顾客
*
* @param playCustomUserInfo 顾客
* @return 结果
*/
@Override
public boolean update(PlayCustomUserInfoEntity playCustomUserInfo) {
return updateById(playCustomUserInfo);
}
/**
* 批量删除顾客
*
* @param ids 需要删除的顾客主键
* @return 结果
*/
@Override
public int deletePlayCustomUserInfoByIds(String[] ids) {
return playCustomUserInfoMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除顾客信息
*
* @param id 顾客主键
* @return 结果
*/
@Override
public int deletePlayCustomUserInfoById(String id) {
return playCustomUserInfoMapper.deleteById(id);
}
}

View File

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starry.admin.modules.order.module.entity.OrderLogInfoEntity; import com.starry.admin.modules.order.module.entity.OrderLogInfoEntity;
/** /**
* 【请填写功能名称】Mapper接口 * 订单日志Mapper接口
* *
* @author admin * @author admin
* @since 2024-03-22 * @since 2024-03-22

View File

@@ -6,7 +6,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
/** /**
* 【请填写功能名称】对象 order_details_info * 订单详细对象 order_details_info
* *
* @author admin * @author admin
* @since 2024-03-20 * @since 2024-03-20

View File

@@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
/** /**
* 【请填写功能名称】对象 order_info * 订单对象 order_info
* *
* @author admin * @author admin
* @since 2024-03-20 * @since 2024-03-20

View File

@@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
/** /**
* 【请填写功能名称】对象 order_info * 订单对象 order_info
* *
* @author admin * @author admin
* @since 2024-03-20 * @since 2024-03-20

View File

@@ -6,7 +6,7 @@ import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
/** /**
* 【请填写功能名称】对象 order_info * 订单信息对象 order_info
* *
* @author admin * @author admin
* @since 2024-03-20 * @since 2024-03-20

View File

@@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
/** /**
* 【请填写功能名称】对象 order_info * 订单信息对象 order_info
* *
* @author admin * @author admin
* @since 2024-03-20 * @since 2024-03-20

View File

@@ -5,56 +5,56 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.order.module.entity.OrderLogInfoEntity; import com.starry.admin.modules.order.module.entity.OrderLogInfoEntity;
/** /**
* 【请填写功能名称】Service接口 * 订单日志Service接口
* *
* @author admin * @author admin
* @since 2024-03-22 * @since 2024-03-22
*/ */
public interface IOrderLogInfoService extends IService<OrderLogInfoEntity> { public interface IOrderLogInfoService extends IService<OrderLogInfoEntity> {
/** /**
* 查询【请填写功能名称】 * 查询订单日志
* *
* @param id 【请填写功能名称】主键 * @param id 订单日志主键
* @return 【请填写功能名称】 * @return 订单日志
*/ */
OrderLogInfoEntity selectOrderLogInfoById(String id); OrderLogInfoEntity selectOrderLogInfoById(String id);
/** /**
* 查询【请填写功能名称】列表 * 查询订单日志列表
* *
* @param orderLogInfo 【请填写功能名称】 * @param orderLogInfo 订单日志
* @return 【请填写功能名称】集合 * @return 订单日志集合
*/ */
IPage<OrderLogInfoEntity> selectOrderLogInfoByPage(OrderLogInfoEntity orderLogInfo); IPage<OrderLogInfoEntity> selectOrderLogInfoByPage(OrderLogInfoEntity orderLogInfo);
/** /**
* 新增【请填写功能名称】 * 新增订单日志
* *
* @param orderLogInfo 【请填写功能名称】 * @param orderLogInfo 订单日志
* @return 结果 * @return 结果
*/ */
boolean create(OrderLogInfoEntity orderLogInfo); boolean create(OrderLogInfoEntity orderLogInfo);
/** /**
* 修改【请填写功能名称】 * 修改订单日志
* *
* @param orderLogInfo 【请填写功能名称】 * @param orderLogInfo 订单日志
* @return 结果 * @return 结果
*/ */
boolean update(OrderLogInfoEntity orderLogInfo); boolean update(OrderLogInfoEntity orderLogInfo);
/** /**
* 批量删除【请填写功能名称】 * 批量删除订单日志
* *
* @param ids 需要删除的【请填写功能名称】主键集合 * @param ids 需要删除的订单日志主键集合
* @return 结果 * @return 结果
*/ */
int deleteOrderLogInfoByIds(String[] ids); int deleteOrderLogInfoByIds(String[] ids);
/** /**
* 删除【请填写功能名称】信息 * 删除订单日志信息
* *
* @param id 【请填写功能名称】主键 * @param id 订单日志主键
* @return 结果 * @return 结果
*/ */
int deleteOrderLogInfoById(String id); int deleteOrderLogInfoById(String id);

View File

@@ -16,7 +16,7 @@ import java.util.Arrays;
/** /**
* 【请填写功能名称】Service业务层处理 * 订单日志Service业务层处理
* *
* @author admin * @author admin
* @since 2024-03-22 * @since 2024-03-22
@@ -27,10 +27,10 @@ public class OrderLogInfoServiceImpl extends ServiceImpl<OrderLogInfoMapper, Ord
private OrderLogInfoMapper orderLogInfoMapper; private OrderLogInfoMapper orderLogInfoMapper;
/** /**
* 查询【请填写功能名称】 * 查询订单日志
* *
* @param id 【请填写功能名称】主键 * @param id 订单日志主键
* @return 【请填写功能名称】 * @return 订单日志
*/ */
@Override @Override
public OrderLogInfoEntity selectOrderLogInfoById(String id) { public OrderLogInfoEntity selectOrderLogInfoById(String id) {
@@ -38,10 +38,10 @@ public class OrderLogInfoServiceImpl extends ServiceImpl<OrderLogInfoMapper, Ord
} }
/** /**
* 查询【请填写功能名称】列表 * 查询订单日志列表
* *
* @param orderLogInfo 【请填写功能名称】 * @param orderLogInfo 订单日志
* @return 【请填写功能名称】 * @return 订单日志
*/ */
@Override @Override
public IPage<OrderLogInfoEntity> selectOrderLogInfoByPage(OrderLogInfoEntity orderLogInfo) { public IPage<OrderLogInfoEntity> selectOrderLogInfoByPage(OrderLogInfoEntity orderLogInfo) {
@@ -50,9 +50,9 @@ public class OrderLogInfoServiceImpl extends ServiceImpl<OrderLogInfoMapper, Ord
} }
/** /**
* 新增【请填写功能名称】 * 新增订单日志
* *
* @param orderLogInfo 【请填写功能名称】 * @param orderLogInfo 订单日志
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -64,9 +64,9 @@ public class OrderLogInfoServiceImpl extends ServiceImpl<OrderLogInfoMapper, Ord
} }
/** /**
* 修改【请填写功能名称】 * 修改订单日志
* *
* @param orderLogInfo 【请填写功能名称】 * @param orderLogInfo 订单日志
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -75,9 +75,9 @@ public class OrderLogInfoServiceImpl extends ServiceImpl<OrderLogInfoMapper, Ord
} }
/** /**
* 批量删除【请填写功能名称】 * 批量删除订单日志
* *
* @param ids 需要删除的【请填写功能名称】主键 * @param ids 需要删除的订单日志主键
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -86,9 +86,9 @@ public class OrderLogInfoServiceImpl extends ServiceImpl<OrderLogInfoMapper, Ord
} }
/** /**
* 删除【请填写功能名称】信息 * 删除订单日志信息
* *
* @param id 【请填写功能名称】主键 * @param id 订单日志主键
* @return 结果 * @return 结果
*/ */
@Override @Override

View File

@@ -0,0 +1,84 @@
package com.starry.admin.modules.play.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.modules.play.module.entity.PlayNoticeInfoEntity;
import com.starry.admin.modules.play.module.vo.PlayNoticeInfoAddVo;
import com.starry.admin.modules.play.service.IPlayNoticeInfoService;
import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import com.starry.common.utils.ConvertUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* 公告Controller
*
* @author admin
* @since 2024-04-06
*/
@RestController
@RequestMapping("/play/notice")
public class PlayNoticeInfoController {
@Resource
private IPlayNoticeInfoService playNoticeInfoService;
/**
* 查询公告列表
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/listAll")
public R listAll(PlayNoticeInfoEntity playNoticeInfo) {
IPage<PlayNoticeInfoEntity> list = playNoticeInfoService.selectPlayNoticeInfoByPage(playNoticeInfo);
return R.ok(list);
}
/**
* 查询公告列表
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/list")
public R list(PlayNoticeInfoEntity playNoticeInfo) {
IPage<PlayNoticeInfoEntity> list = playNoticeInfoService.selectPlayNoticeInfoByPage(playNoticeInfo);
return R.ok(list);
}
/**
* 获取公告详细信息
*/
@PreAuthorize("@customSs.hasPermission('play:info:query')")
@GetMapping(value = "/{id}")
public R getInfo(@PathVariable("id") String id) {
return R.ok(playNoticeInfoService.selectPlayNoticeInfoById(id));
}
/**
* 新增公告
*/
@PreAuthorize("@customSs.hasPermission('play:info:create')")
@Log(title = "公告", businessType = BusinessType.INSERT)
@PostMapping("/create")
public R create(@Valid @RequestBody PlayNoticeInfoAddVo vo) {
PlayNoticeInfoEntity entity = ConvertUtil.entityToVo(vo, PlayNoticeInfoEntity.class);
boolean success = playNoticeInfoService.create(entity);
if (success) {
return R.ok();
}
return R.error("添加失败");
}
/**
* 删除公告
*/
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
@Log(title = "公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R remove(@PathVariable String[] ids) {
return R.ok(playNoticeInfoService.deletePlayNoticeInfoByIds(ids));
}
}

View File

@@ -0,0 +1,16 @@
package com.starry.admin.modules.play.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starry.admin.modules.play.module.entity.PlayNoticeInfoEntity;
/**
* 公告Mapper接口
*
* @author admin
* @since 2024-04-06
*/
public interface PlayNoticeInfoMapper extends BaseMapper<PlayNoticeInfoEntity> {
}

View File

@@ -0,0 +1,46 @@
package com.starry.admin.modules.play.module.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 公告对象 play_notice_info
*
* @author admin
* @since 2024-04-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("play_notice_info")
public class PlayNoticeInfoEntity extends BaseEntity<PlayNoticeInfoEntity> {
/**
*
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 公告类型【0:公告,1:消息】
*/
private String noticeType;
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
}

View File

@@ -37,4 +37,9 @@ public class PlayUserInfoEntity extends BaseEntity<PlayUserInfoEntity> {
*/ */
private String areaCode; private String areaCode;
/**
* 账户状态1审批通过0注册未审批
*/
private String accountState;
} }

View File

@@ -0,0 +1,31 @@
package com.starry.admin.modules.play.module.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
/**
* 公告对象 play_notice_info
*
* @author admin
* @since 2024-04-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class PlayNoticeInfoAddVo {
/**
* 标题
*/
@NotBlank(message = "标题不能为空")
private String title;
/**
* 内容
*/
@NotBlank(message = "内容不能为空")
private String content;
}

View File

@@ -4,6 +4,9 @@ import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
/**
* @author admin
*/
@Data @Data
public class PlayUserInfoUpdateVo { public class PlayUserInfoUpdateVo {

View File

@@ -0,0 +1,70 @@
package com.starry.admin.modules.play.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.play.module.entity.PlayNoticeInfoEntity;
import java.util.List;
/**
* 公告Service接口
*
* @author admin
* @since 2024-04-06
*/
public interface IPlayNoticeInfoService extends IService<PlayNoticeInfoEntity> {
/**
* 查询公告
*
* @param id 公告主键
* @return 公告
*/
PlayNoticeInfoEntity selectPlayNoticeInfoById(String id);
/**
* 查询公告列表
*
* @return 公告集合
*/
List<PlayNoticeInfoEntity> selectPlayNoticeInfo();
/**
* 查询公告列表
*
* @param playNoticeInfo 公告
* @return 公告集合
*/
IPage<PlayNoticeInfoEntity> selectPlayNoticeInfoByPage(PlayNoticeInfoEntity playNoticeInfo);
/**
* 新增公告
*
* @param playNoticeInfo 公告
* @return 结果
*/
boolean create(PlayNoticeInfoEntity playNoticeInfo);
/**
* 修改公告
*
* @param playNoticeInfo 公告
* @return 结果
*/
boolean update(PlayNoticeInfoEntity playNoticeInfo);
/**
* 批量删除公告
*
* @param ids 需要删除的公告主键集合
* @return 结果
*/
int deletePlayNoticeInfoByIds(String[] ids);
/**
* 删除公告信息
*
* @param id 公告主键
* @return 结果
*/
int deletePlayNoticeInfoById(String id);
}

View File

@@ -0,0 +1,104 @@
package com.starry.admin.modules.play.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.play.mapper.PlayNoticeInfoMapper;
import com.starry.admin.modules.play.module.entity.PlayNoticeInfoEntity;
import com.starry.admin.modules.play.service.IPlayNoticeInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 公告Service业务层处理
*
* @author admin
* @since 2024-04-06
*/
@Service
public class PlayNoticeInfoServiceImpl extends ServiceImpl<PlayNoticeInfoMapper, PlayNoticeInfoEntity> implements IPlayNoticeInfoService {
@Resource
private PlayNoticeInfoMapper playNoticeInfoMapper;
/**
* 查询公告
*
* @param id 公告主键
* @return 公告
*/
@Override
public PlayNoticeInfoEntity selectPlayNoticeInfoById(String id) {
return this.baseMapper.selectById(id);
}
@Override
public List<PlayNoticeInfoEntity> selectPlayNoticeInfo() {
return this.baseMapper.selectList(new LambdaQueryWrapper<>());
}
/**
* 查询公告列表
*
* @param playNoticeInfo 公告
* @return 公告
*/
@Override
public IPage<PlayNoticeInfoEntity> selectPlayNoticeInfoByPage(PlayNoticeInfoEntity playNoticeInfo) {
Page<PlayNoticeInfoEntity> page = new Page<>(1, 10);
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
}
/**
* 新增公告
*
* @param playNoticeInfo 公告
* @return 结果
*/
@Override
public boolean create(PlayNoticeInfoEntity playNoticeInfo) {
if (StrUtil.isBlankIfStr(playNoticeInfo.getId())) {
playNoticeInfo.setId(IdUtil.fastSimpleUUID());
}
return save(playNoticeInfo);
}
/**
* 修改公告
*
* @param playNoticeInfo 公告
* @return 结果
*/
@Override
public boolean update(PlayNoticeInfoEntity playNoticeInfo) {
return updateById(playNoticeInfo);
}
/**
* 批量删除公告
*
* @param ids 需要删除的公告主键
* @return 结果
*/
@Override
public int deletePlayNoticeInfoByIds(String[] ids) {
return playNoticeInfoMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除公告信息
*
* @param id 公告主键
* @return 结果
*/
@Override
public int deletePlayNoticeInfoById(String id) {
return playNoticeInfoMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,76 @@
package com.starry.admin.modules.system.controller;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.starry.admin.modules.system.entity.SysAdministrativeAreaDictInfoEntity;
import com.starry.admin.modules.system.service.ISysAdministrativeAreaDictInfoService;
import com.starry.admin.modules.system.vo.AdministrativeAreaQueryReturnVo;
import com.starry.common.result.R;
import com.starry.common.utils.ConvertUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 行政区域字典信息Controller
*
* @author admin
* @since 2024-04-03
*/
@RestController
@RequestMapping("/sys/area")
public class AdministrativeAreaDictInfoController {
@Resource
private ISysAdministrativeAreaDictInfoService playAdministrativeAreaDictInfoService;
/**
* 查询省/市行政区域代码
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/tree")
public R list() {
List<AdministrativeAreaQueryReturnVo> result = new ArrayList<>();
List<SysAdministrativeAreaDictInfoEntity> list = playAdministrativeAreaDictInfoService.selectAll();
Map<String, List<SysAdministrativeAreaDictInfoEntity>> collect = list.stream().filter(a -> a != null && a.getPCode() != null).collect(Collectors.groupingBy(SysAdministrativeAreaDictInfoEntity::getPCode));
if (collect.containsKey("00")) {
result = ConvertUtil.entityToVoList(collect.get("00"), AdministrativeAreaQueryReturnVo.class);
}
for (AdministrativeAreaQueryReturnVo vo : result) {
vo.setChild(ConvertUtil.entityToVoList(collect.get(vo.getCode()), AdministrativeAreaQueryReturnVo.class));
}
return R.ok(result);
}
@GetMapping("/add")
public R add(@RequestParam("index") String index) {
String fileName = "D:\\" + index + ".txt";
JSONArray array = JSONArray.parse(FileUtil.readString(new File(fileName), "UTF-8"));
List<SysAdministrativeAreaDictInfoEntity> list = new ArrayList<>();
for (int i = 0; i < array.size(); i++) {
JSONObject jsonObject = array.getJSONObject(i);
SysAdministrativeAreaDictInfoEntity entity = new SysAdministrativeAreaDictInfoEntity();
entity.setCode(jsonObject.getString("code"));
entity.setName(jsonObject.getString("name"));
if (index.equals("1")) {
entity.setPCode("00");
} else {
entity.setPCode(jsonObject.getString("provinceCode"));
}
entity.setLevel(index);
list.add(entity);
}
playAdministrativeAreaDictInfoService.saveBatch(list);
return R.ok("");
}
}

View File

@@ -0,0 +1,46 @@
package com.starry.admin.modules.system.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 行政区域字典信息对象 play_administrative_area_dict_info
*
* @author admin
* @since 2024-04-03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_administrative_area_dict_info")
public class SysAdministrativeAreaDictInfoEntity extends BaseEntity<SysAdministrativeAreaDictInfoEntity> {
/**
* UUID
*/
private String id;
/**
* 行政单位编码
*/
private String code;
/**
* 新增单位名称
*/
private String name;
/**
* 上级单位编码
*/
private String pCode;
/**
* 行政单位等级
**/
private String level;
}

View File

@@ -0,0 +1,20 @@
package com.starry.admin.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starry.admin.modules.system.entity.SysAdministrativeAreaDictInfoEntity;
import org.apache.ibatis.annotations.Mapper;
;
/**
* 行政区域字典信息Mapper接口
*
* @author admin
* @since 2024-04-03
*/
@Mapper
public interface SysAdministrativeAreaDictInfoMapper extends BaseMapper<SysAdministrativeAreaDictInfoEntity> {
}

View File

@@ -0,0 +1,73 @@
package com.starry.admin.modules.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.system.entity.SysAdministrativeAreaDictInfoEntity;
import java.util.List;
/**
* 行政区域字典信息Service接口
*
* @author admin
* @since 2024-04-03
*/
public interface ISysAdministrativeAreaDictInfoService extends IService<SysAdministrativeAreaDictInfoEntity> {
/**
* 查询行政区域字典信息
*
* @param id 行政区域字典信息主键
* @return 行政区域字典信息
*/
SysAdministrativeAreaDictInfoEntity selectPlayAdministrativeAreaDictInfoById(String id);
/**
* 查询所有行政区域字典信息列表
*
* @return 行政区域字典信息集合
*/
List<SysAdministrativeAreaDictInfoEntity> selectAll();
/**
* 查询行政区域字典信息列表
*
* @param playAdministrativeAreaDictInfo 行政区域字典信息
* @return 行政区域字典信息集合
*/
IPage<SysAdministrativeAreaDictInfoEntity> selectPlayAdministrativeAreaDictInfoByPage(SysAdministrativeAreaDictInfoEntity playAdministrativeAreaDictInfo);
/**
* 新增行政区域字典信息
*
* @param playAdministrativeAreaDictInfo 行政区域字典信息
* @return 结果
*/
boolean create(SysAdministrativeAreaDictInfoEntity playAdministrativeAreaDictInfo);
boolean create(List<SysAdministrativeAreaDictInfoEntity> list);
/**
* 修改行政区域字典信息
*
* @param playAdministrativeAreaDictInfo 行政区域字典信息
* @return 结果
*/
boolean update(SysAdministrativeAreaDictInfoEntity playAdministrativeAreaDictInfo);
/**
* 批量删除行政区域字典信息
*
* @param ids 需要删除的行政区域字典信息主键集合
* @return 结果
*/
int deletePlayAdministrativeAreaDictInfoByIds(String[] ids);
/**
* 删除行政区域字典信息信息
*
* @param id 行政区域字典信息主键
* @return 结果
*/
int deletePlayAdministrativeAreaDictInfoById(String id);
}

View File

@@ -0,0 +1,111 @@
package com.starry.admin.modules.system.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.system.mapper.SysAdministrativeAreaDictInfoMapper;
import com.starry.admin.modules.system.entity.SysAdministrativeAreaDictInfoEntity;
import com.starry.admin.modules.system.service.ISysAdministrativeAreaDictInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 行政区域字典信息Service业务层处理
*
* @author admin
* @since 2024-04-03
*/
@Service
public class SysAdministrativeAreaDictInfoServiceImpl extends ServiceImpl<SysAdministrativeAreaDictInfoMapper, SysAdministrativeAreaDictInfoEntity> implements ISysAdministrativeAreaDictInfoService {
@Resource
private SysAdministrativeAreaDictInfoMapper sysAdministrativeAreaDictInfoMapper;
/**
* 查询行政区域字典信息
*
* @param id 行政区域字典信息主键
* @return 行政区域字典信息
*/
@Override
public SysAdministrativeAreaDictInfoEntity selectPlayAdministrativeAreaDictInfoById(String id) {
return this.baseMapper.selectById(id);
}
@Override
public List<SysAdministrativeAreaDictInfoEntity> selectAll() {
LambdaQueryWrapper<SysAdministrativeAreaDictInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<SysAdministrativeAreaDictInfoEntity>();
lambdaQueryWrapper.eq(SysAdministrativeAreaDictInfoEntity::getLevel, "1").or().eq(SysAdministrativeAreaDictInfoEntity::getLevel, "2");
return this.baseMapper.selectList(lambdaQueryWrapper);
}
/**
* 查询行政区域字典信息列表
*
* @param playAdministrativeAreaDictInfo 行政区域字典信息
* @return 行政区域字典信息
*/
@Override
public IPage<SysAdministrativeAreaDictInfoEntity> selectPlayAdministrativeAreaDictInfoByPage(SysAdministrativeAreaDictInfoEntity playAdministrativeAreaDictInfo) {
Page<SysAdministrativeAreaDictInfoEntity> page = new Page<>(1, 10);
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<SysAdministrativeAreaDictInfoEntity>());
}
/**
* 新增行政区域字典信息
*
* @param playAdministrativeAreaDictInfo 行政区域字典信息
* @return 结果
*/
@Override
public boolean create(SysAdministrativeAreaDictInfoEntity playAdministrativeAreaDictInfo) {
if (StrUtil.isBlankIfStr(playAdministrativeAreaDictInfo.getId())) {
playAdministrativeAreaDictInfo.setId(IdUtil.fastSimpleUUID());
}
return save(playAdministrativeAreaDictInfo);
}
@Override
public boolean create(List<SysAdministrativeAreaDictInfoEntity> list) {
return this.saveBatch(list);
}
/**
* 修改行政区域字典信息
*
* @param playAdministrativeAreaDictInfo 行政区域字典信息
* @return 结果
*/
@Override
public boolean update(SysAdministrativeAreaDictInfoEntity playAdministrativeAreaDictInfo) {
return updateById(playAdministrativeAreaDictInfo);
}
/**
* 批量删除行政区域字典信息
*
* @param ids 需要删除的行政区域字典信息主键
* @return 结果
*/
@Override
public int deletePlayAdministrativeAreaDictInfoByIds(String[] ids) {
return sysAdministrativeAreaDictInfoMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除行政区域字典信息信息
*
* @param id 行政区域字典信息主键
* @return 结果
*/
@Override
public int deletePlayAdministrativeAreaDictInfoById(String id) {
return sysAdministrativeAreaDictInfoMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,34 @@
package com.starry.admin.modules.system.vo;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 行政区域信息集合 play_administrative_area_dict_info
*
* @author admin
* @since 2024-04-03
*/
@Data
public class AdministrativeAreaQueryReturnVo {
/**
* 编码
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 区域集合
**/
private List<AdministrativeAreaQueryReturnVo> child = new ArrayList<>();
}

View File

@@ -1,13 +0,0 @@
package com.starry.admin.modules.weichat.builder;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
/**
* @author admin
*/
public abstract class AbstractBuilder {
public abstract WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, WxMpService service);
}

View File

@@ -1,21 +0,0 @@
package com.starry.admin.modules.weichat.builder;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
/**
* @author admin
*/
public class ImageBuilder extends AbstractBuilder {
@Override
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage,
WxMpService service) {
return WxMpXmlOutMessage.IMAGE().mediaId(content)
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
}
}

View File

@@ -1,22 +0,0 @@
package com.starry.admin.modules.weichat.builder;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage;
/**
* @author admin
*/
public class TextBuilder extends AbstractBuilder {
@Override
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage,
WxMpService service) {
WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content)
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
return m;
}
}

View File

@@ -1,24 +0,0 @@
package com.starry.admin.modules.weichat.config;
/**
* @author admin
*/
public interface CommonConstants {
/**
* 是
*/
String YES = "1";
/**
* 否
*/
String NO = "0";
/**
* 树形父类ID
*/
String PARENT_ID = "0";
/**
* 编码
*/
String UTF8 = "UTF-8";
}

View File

@@ -1,36 +0,0 @@
package com.starry.admin.modules.weichat.config;
import com.starry.admin.modules.weichat.interceptor.ThirdSessionInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* web配置
*
* @author admin
*/
@Configuration
@AllArgsConstructor
public class WebConfig implements WebMvcConfigurer {
/**
* 拦截器
*
* @param registry InterceptorRegistry
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
/*
进入ThirdSession拦截器
*/
registry.addInterceptor(new ThirdSessionInterceptor())
// 拦截/api/**接口
.addPathPatterns("/weixin/api/**")
// 放行接口
.excludePathPatterns("/weixin/api/ma/wxuser/login",
"/weixin/api/ma/orderinfo/notify-order", "/weixin/api/ma/orderinfo/notify-logisticsr",
"/weixin/api/ma/orderinfo/notify-refunds");
}
}

View File

@@ -1,111 +0,0 @@
// package com.starry.admin.modules.weichat.config;
//
//
// import cn.hutool.core.util.StrUtil;
// import com.starry.admin.modules.weichat.entity.CustomWxMpProperties;
// import com.starry.admin.modules.weichat.handler.*;
// import com.starry.admin.modules.weichat.utils.WxMpPropertiesUtils;
// import lombok.AllArgsConstructor;
// import me.chanjar.weixin.common.api.WxConsts;
// import me.chanjar.weixin.mp.api.WxMpMessageRouter;
// import me.chanjar.weixin.mp.api.WxMpService;
// import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
// import me.chanjar.weixin.mp.config.WxMpConfigStorage;
// import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
// import org.springframework.context.annotation.Bean;
// import org.springframework.context.annotation.Configuration;
//
// import java.util.HashMap;
// import java.util.Map;
//
// import static me.chanjar.weixin.common.api.WxConsts.EventType.SUBSCRIBE;
// import static me.chanjar.weixin.common.api.WxConsts.EventType.UNSUBSCRIBE;
// import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType.EVENT;
// import static me.chanjar.weixin.mp.constant.WxMpEventConstants.CustomerService.*;
// import static me.chanjar.weixin.mp.constant.WxMpEventConstants.POI_CHECK_NOTIFY;
//
///**
// * wechat mp configuration
// *
// * @author admin
// */
//@AllArgsConstructor
//@Configuration
// public class WxMpConfiguration {
// private final LogHandler logHandler;
// private final NullHandler nullHandler;
// private final KfSessionHandler kfSessionHandler;
// private final StoreCheckNotifyHandler storeCheckNotifyHandler;
// private final LocationHandler locationHandler;
// private final MenuHandler menuHandler;
// private final MsgHandler msgHandler;
// private final UnsubscribeHandler unsubscribeHandler;
// private final SubscribeHandler subscribeHandler;
// private final ScanHandler scanHandler;
//
// @Bean
// public WxMpService wxMpService() {
// CustomWxMpProperties customWxMpProperties = WxMpPropertiesUtils.getWeiChatProperties();
// if (StrUtil.isBlankIfStr(customWxMpProperties.getAppid()) || StrUtil.isBlankIfStr(customWxMpProperties.getAppid()) || StrUtil.isBlankIfStr(customWxMpProperties.getAppid()) || StrUtil.isBlankIfStr(customWxMpProperties.getAppid())) {
// throw new RuntimeException("微信配置文件出错");
// }
// return getWxMpService(customWxMpProperties);
// }
//
// private static WxMpService getWxMpService(CustomWxMpProperties customWxMpProperties) {
// Map<String, WxMpConfigStorage> multiConfigStorages = new HashMap<>();
// WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
// configStorage.setAppId(customWxMpProperties.getAppid());
// configStorage.setSecret(customWxMpProperties.getSecret());
// configStorage.setToken(customWxMpProperties.getToken());
// configStorage.setAesKey(customWxMpProperties.getAesKey());
//
//
// WxMpService mpService = new WxMpServiceImpl();
// mpService.setMultiConfigStorages(multiConfigStorages);
// return mpService;
// }
//
// @Bean
// public WxMpMessageRouter messageRouter(WxMpService wxMpService) {
// final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService);
//
// // 记录所有事件的日志 (异步执行)
// newRouter.rule().handler(this.logHandler).next();
//
// // 接收客服会话管理事件
// newRouter.rule().async(false).msgType(EVENT).event(KF_CREATE_SESSION).handler(this.kfSessionHandler).end();
// newRouter.rule().async(false).msgType(EVENT).event(KF_CLOSE_SESSION).handler(this.kfSessionHandler).end();
// newRouter.rule().async(false).msgType(EVENT).event(KF_SWITCH_SESSION).handler(this.kfSessionHandler).end();
//
// // 门店审核事件
// newRouter.rule().async(false).msgType(EVENT).event(POI_CHECK_NOTIFY).handler(this.storeCheckNotifyHandler).end();
//
// // 自定义菜单事件
// newRouter.rule().async(false).msgType(EVENT).event(WxConsts.EventType.CLICK).handler(this.menuHandler).end();
//
// // 点击菜单连接事件
// newRouter.rule().async(false).msgType(EVENT).event(WxConsts.EventType.VIEW).handler(this.nullHandler).end();
//
// // 关注事件
// newRouter.rule().async(false).msgType(EVENT).event(SUBSCRIBE).handler(this.subscribeHandler).end();
//
// // 取消关注事件
// newRouter.rule().async(false).msgType(EVENT).event(UNSUBSCRIBE).handler(this.unsubscribeHandler).end();
//
// // 上报地理位置事件
// newRouter.rule().async(false).msgType(EVENT).event(WxConsts.EventType.LOCATION).handler(this.locationHandler).end();
//
// // 接收地理位置消息
// newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION).handler(this.locationHandler).end();
//
// // 扫码事件
// newRouter.rule().async(false).msgType(EVENT).event(WxConsts.EventType.SCAN).handler(this.scanHandler).end();
//
// // 默认
// newRouter.rule().async(false).handler(this.msgHandler).end();
//
// return newRouter;
// }
//
//}

View File

@@ -23,7 +23,7 @@ public interface ConfigConstant {
String SUBSCRIBE_TYPE_WEBLIEN = "2"; String SUBSCRIBE_TYPE_WEBLIEN = "2";
/** /**
* 应用类型 1:小程序 * 应用类型 1:微信
*/ */
String WX_APP_TYPE_1 = "1"; String WX_APP_TYPE_1 = "1";
/** /**

View File

@@ -2,7 +2,7 @@ package com.starry.admin.modules.weichat.constant;
/** /**
* 全局返回码 * 全局返回码
* 小程序用6开头例60001 * 微信用6开头例60001
* *
* @author admin * @author admin
* 2019年7月25日 * 2019年7月25日

File diff suppressed because one or more lines are too long

View File

@@ -1,132 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starry.admin.modules.weichat.constant.ConfigConstant;
import com.starry.admin.modules.weichat.entity.WxAutoReply;
import com.starry.admin.modules.weichat.service.WxAutoReplyService;
import com.starry.common.result.R;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 消息自动回复
*
* @author admin
* @since 2019-04-18 15:40:39
*/
@RestController
@AllArgsConstructor
@RequestMapping("/wxautoreply")
public class WxAutoReplyController {
@Resource
WxAutoReplyService wxAutoReplyService;
/**
* 分页查询
*
* @param page 分页对象
* @param wxAutoReply 消息自动回复
* @return
*/
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:index')")
public R getWxAutoReplyPage(Page page, WxAutoReply wxAutoReply) {
return R.ok(wxAutoReplyService.page(page, Wrappers.query(wxAutoReply)));
}
/**
* 通过id查询消息自动回复
*
* @param id id
* @return R
*/
@GetMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:get')")
public R getById(@PathVariable("id") String id) {
return R.ok(wxAutoReplyService.getById(id));
}
/**
* 新增消息自动回复
*
* @param wxAutoReply 消息自动回复
* @return R
*/
@PostMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:add')")
public R save(@RequestBody WxAutoReply wxAutoReply) {
this.jude(wxAutoReply);
return R.ok(wxAutoReplyService.save(wxAutoReply));
}
/**
* 修改消息自动回复
*
* @param wxAutoReply 消息自动回复
* @return R
*/
@PutMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:edit')")
public R updateById(@RequestBody WxAutoReply wxAutoReply) {
this.jude(wxAutoReply);
return R.ok(wxAutoReplyService.updateById(wxAutoReply));
}
/**
* 通过id删除消息自动回复
*
* @param id id
* @return R
*/
@DeleteMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxautoreply:del')")
public R removeById(@PathVariable String id) {
return R.ok(wxAutoReplyService.removeById(id));
}
/**
* //校验参数
*
* @param wxAutoReply
*/
public void jude(WxAutoReply wxAutoReply) {
if (ConfigConstant.WX_AUTO_REPLY_TYPE_2.equals(wxAutoReply.getType())) {
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
.eq(WxAutoReply::getReqType, wxAutoReply.getReqType());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if (StringUtils.isNotBlank(wxAutoReply.getId())) {
if (list != null && list.size() == 1) {
if (!list.get(0).getId().equals(wxAutoReply.getId())) {
throw new RuntimeException("请求消息类型重复");
}
}
if (list != null && list.size() > 1) {
throw new RuntimeException("请求消息类型重复");
}
}
}
if (ConfigConstant.WX_AUTO_REPLY_TYPE_3.equals(wxAutoReply.getType())) {
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
.eq(WxAutoReply::getReqKey, wxAutoReply.getReqKey())
.eq(WxAutoReply::getRepType, wxAutoReply.getRepMate());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if (list != null && list.size() == 1) {
if (!list.get(0).getId().equals(wxAutoReply.getId())) {
throw new RuntimeException("关键词重复");
}
}
if (list != null && list.size() > 1) {
throw new RuntimeException("关键词重复");
}
}
}
}

View File

@@ -1,129 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.api.WxMpDraftService;
import me.chanjar.weixin.mp.api.WxMpFreePublishService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.draft.WxMpAddDraft;
import me.chanjar.weixin.mp.bean.draft.WxMpDraftArticles;
import me.chanjar.weixin.mp.bean.draft.WxMpUpdateDraft;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 微信草稿箱
*
* @author admin
* @since 2022-03-10 21:26:35
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wxdraft")
@Api(value = "wxdraft", tags = "微信草稿箱")
public class WxDraftController {
@Resource
WxMpService wxService;
/**
* 新增图文消息
*
* @param data
* @return
*/
@ApiOperation(value = "新增草稿箱")
@PostMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:add')")
public R add(@RequestBody JSONObject data) throws Exception {
JSONArray jSONArray = data.getJSONArray("articles");
List<WxMpDraftArticles> articles = jSONArray.toList(WxMpDraftArticles.class);
WxMpAddDraft wxMpAddDraft = new WxMpAddDraft();
wxMpAddDraft.setArticles(articles);
WxMpDraftService wxMpDraftService = wxService.getDraftService();
String rs = wxMpDraftService.addDraft(wxMpAddDraft);
return R.ok(rs);
}
/**
* 修改微信草稿箱
*
* @param data
* @return
*/
@ApiOperation(value = "修改微信草稿箱")
@PutMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:edit')")
public R edit(@RequestBody JSONObject data) throws Exception {
String mediaId = data.getStr("mediaId");
JSONArray jSONArray = data.getJSONArray("articles");
List<WxMpDraftArticles> articles = jSONArray.toList(WxMpDraftArticles.class);
WxMpDraftService wxMpDraftService = wxService.getDraftService();
WxMpUpdateDraft wxMpUpdateDraft = new WxMpUpdateDraft();
wxMpUpdateDraft.setMediaId(mediaId);
int index = 0;
for (WxMpDraftArticles article : articles) {
wxMpUpdateDraft.setIndex(index);
wxMpUpdateDraft.setArticles(article);
wxMpDraftService.updateDraft(wxMpUpdateDraft);
index++;
}
return R.ok();
}
/**
* 通过id删除微信草稿箱
*
* @param
* @return R
*/
@ApiOperation(value = "通过id删除微信草稿箱")
@DeleteMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:del')")
public R del(String id) throws Exception {
WxMpDraftService wxMpDraftService = wxService.getDraftService();
return R.ok(wxMpDraftService.delDraft(id));
}
/**
* 分页查询
*
* @param page 分页对象
* @param
* @return
*/
@ApiOperation(value = "分页查询")
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:index')")
public R getPage(Page page) throws Exception {
WxMpDraftService wxMpDraftService = wxService.getDraftService();
int count = (int) page.getSize();
int offset = (int) page.getCurrent() * count - count;
return R.ok(wxMpDraftService.listDraft(offset, count));
}
/**
* 发布草稿箱
*
* @param id
* @return
*/
@ApiOperation(value = "发布草稿箱")
@PostMapping("/publish/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxdraft:publish')")
public R publish(@PathVariable String id) throws Exception {
WxMpFreePublishService wxMpFreePublishService = wxService.getFreePublishService();
wxMpFreePublishService.submit(id);
return R.ok();
}
}

View File

@@ -1,66 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.api.WxMpFreePublishService;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 微信发布
*
* @author admin
* @since 2022-03-10 21:26:35
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/freepublish")
@Api(value = "freepublish", tags = "微信发布")
public class WxFreePublishController {
@Resource
WxMpService wxService;
/**
* 删除发布
*
* @param
* @return R
*/
@ApiOperation(value = "删除发布")
@DeleteMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxfreepublish:del')")
public R del(String id) throws Exception {
WxMpFreePublishService wxMpFreePublishService = wxService.getFreePublishService();
return R.ok(wxMpFreePublishService.deletePushAllArticle(id));
}
/**
* 获取成功发布列表
*
* @param page 获取成功发布列表
* @param
* @return
*/
@ApiOperation(value = "获取成功发布列表")
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxfreepublish:index')")
public R getPage(Page page) throws Exception {
WxMpFreePublishService wxMpFreePublishService = wxService.getFreePublishService();
int count = (int) page.getSize();
int offset = (int) page.getCurrent() * count - count;
return R.ok(wxMpFreePublishService.getPublicationRecords(offset, count));
}
}

View File

@@ -1,246 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starry.admin.modules.weichat.entity.ImageManager;
import com.starry.admin.modules.weichat.utils.FileUtils;
import com.starry.common.result.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpMaterialService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult;
import me.chanjar.weixin.mp.bean.material.WxMpMaterial;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 微信素材
*
* @author admin
* @since 2019-03-23 21:26:35
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wxmaterial")
public class WxMaterialController {
@Resource
WxMpService wxService;
/**
* 上传非图文微信素材
*
* @param mulFile
* @param mediaType
* @return
*/
@PostMapping("/materialFileUpload")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:add')")
public R materialFileUpload(@RequestParam("file") MultipartFile mulFile,
@RequestParam("title") String title,
@RequestParam("introduction") String introduction,
@RequestParam("mediaType") String mediaType) {
try {
WxMpMaterial material = new WxMpMaterial();
material.setName(mulFile.getOriginalFilename());
if (WxConsts.MediaFileType.VIDEO.equals(mediaType)) {
material.setVideoTitle(title);
material.setVideoIntroduction(introduction);
}
File file = FileUtils.multipartFileToFile(mulFile);
material.setFile(file);
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
WxMpMaterialUploadResult wxMpMaterialUploadResult = wxMpMaterialService.materialFileUpload(mediaType, material);
WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem wxMpMaterialFileBatchGetResult = new WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem();
wxMpMaterialFileBatchGetResult.setName(file.getName());
wxMpMaterialFileBatchGetResult.setMediaId(wxMpMaterialUploadResult.getMediaId());
wxMpMaterialFileBatchGetResult.setUrl(wxMpMaterialUploadResult.getUrl());
return R.ok(wxMpMaterialFileBatchGetResult);
} catch (WxErrorException e) {
log.error("上传非图文微信素材失败" + e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("上传失败", e);
return R.error(e.getLocalizedMessage());
}
}
/**
* 上传图文消息内的图片获取URL
*
* @param mulFile
* @return
*/
@PostMapping("/newsImgUpload")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:add')")
public String newsImgUpload(@RequestParam("file") MultipartFile mulFile) throws Exception {
File file = FileUtils.multipartFileToFile(mulFile);
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
WxMediaImgUploadResult wxMediaImgUploadResult = wxMpMaterialService.mediaImgUpload(file);
Map<Object, Object> responseData = new HashMap<>();
responseData.put("link", wxMediaImgUploadResult.getUrl());
return JSONUtil.toJsonStr(responseData);
}
/**
* 通过id删除微信素材
*
* @param
* @return R
*/
@DeleteMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:del')")
public R materialDel(String id) {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try {
return R.ok(wxMpMaterialService.materialDelete(id));
} catch (WxErrorException e) {
log.error("删除微信素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 分页查询
*
* @param page 分页对象
* @param type
* @return
*/
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:index')")
public R getWxMaterialPage(Page page, String type) {
try {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
int count = (int) page.getSize();
int offset = (int) page.getCurrent() * count - count;
if (WxConsts.MaterialType.NEWS.equals(type)) {
return R.ok(wxMpMaterialService.materialNewsBatchGet(offset, count));
} else {
return R.ok(wxMpMaterialService.materialFileBatchGet(type, offset, count));
}
} catch (WxErrorException e) {
log.error("查询素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 分页查询2
*
* @param type
* @return
*/
@GetMapping("/page-manager")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:index')")
public String getWxMaterialPageManager(Integer count, Integer offset, String type) throws WxErrorException {
List<ImageManager> listImageManager = new ArrayList<>();
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
List<WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem> list = wxMpMaterialService.materialFileBatchGet(type, offset, count).getItems();
list.forEach(wxMaterialFileBatchGetNewsItem -> {
ImageManager imageManager = new ImageManager();
imageManager.setName(wxMaterialFileBatchGetNewsItem.getMediaId());
imageManager.setUrl(wxMaterialFileBatchGetNewsItem.getUrl());
imageManager.setThumb(wxMaterialFileBatchGetNewsItem.getUrl());
listImageManager.add(imageManager);
});
return JSONUtil.toJsonStr(listImageManager);
}
/**
* 获取微信视频素材
*
* @param
* @return R
*/
@GetMapping("/materialVideo")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:get')")
public R getMaterialVideo(String mediaId) {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try {
return R.ok(wxMpMaterialService.materialVideoInfo(mediaId));
} catch (WxErrorException e) {
log.error("获取微信视频素材失败", e);
return R.error(e.getMessage());
}
}
/**
* 获取微信素材直接文件
*
* @param
* @return R
*/
@GetMapping("/materialOther")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmaterial:get')")
public ResponseEntity<byte[]> getMaterialOther(String mediaId, String fileName) throws Exception {
try {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
// 获取文件
InputStream is = wxMpMaterialService.materialImageOrVoiceDownload(mediaId);
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
// 设置文件类型
headers.add("Content-Disposition", "attchement;filename=" + URLEncoder.encode(fileName, "UTF-8"));
headers.add("Content-Type", "application/octet-stream");
HttpStatus statusCode = HttpStatus.OK;
// 返回数据
return new ResponseEntity<>(body, headers, statusCode);
} catch (WxErrorException e) {
log.error("获取微信素材直接文件失败", e);
return null;
}
}
/**
* 获取微信临时素材直接文件
*
* @param
* @return R
*/
@GetMapping("/tempMaterialOther")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:index')")
public ResponseEntity<byte[]> getTempMaterialOther(String mediaId, String fileName) throws Exception {
WxMpMaterialService wxMpMaterialService = wxService.getMaterialService();
try (InputStream is = Files.newInputStream(wxMpMaterialService.mediaDownload(mediaId).toPath())) {
byte[] body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
// 设置文件类型
headers.add("Content-Disposition", "attchement;filename=" + URLEncoder.encode(fileName, "UTF-8"));
headers.add("Content-Type", "application/octet-stream");
HttpStatus statusCode = HttpStatus.OK;
// 返回数据
return new ResponseEntity<>(body, headers, statusCode);
} catch (WxErrorException e) {
log.error("获取微信素材直接文件失败", e);
return null;
}
}
}

View File

@@ -1,63 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.starry.admin.modules.weichat.service.WxMenuService;
import com.starry.common.result.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 自定义菜单
*
* @author admin
* @since 2019-03-27 16:52:10
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wxmenu")
public class WxMenuController {
@Resource
WxMenuService wxMenuService;
/**
* 通过appId查询自定义菜单
*
* @return R
*/
@GetMapping("/list")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmenu:get')")
public R getWxMenuButton() {
return R.ok(wxMenuService.getWxMenuButton());
}
/**
* 保存并发布菜单
*
* @param
* @return R
*/
@PostMapping("/release")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmenu:add')")
public R saveAndRelease(@RequestBody String data) {
JSONObject jSONObject = JSONUtil.parseObj(data);
String strWxMenu = jSONObject.getStr("strWxMenu");
String appId = jSONObject.getStr("appId");
try {
wxMenuService.saveAndRelease(strWxMenu);
return R.ok();
} catch (WxErrorException e) {
log.error("发布自定义菜单失败appID:" + appId + ":" + e.getMessage());
return R.error(e.getMessage());
}
}
}

View File

@@ -1,29 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import com.starry.admin.modules.weichat.service.WxMpApi;
import com.starry.common.result.R;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: huchuansai
* @Date: 2024/3/27 10:39 PM
* @Description:
*/
@RestController
@RequestMapping("/wx/test")
@RequiredArgsConstructor
public class WxMpTestController {
private final WxMpApi wxMpApi;
@GetMapping("/getToken")
public R getToken(String appId, String secret) {
return R.ok(wxMpApi.getAccessToken(appId, secret, true));
}
}

View File

@@ -1,209 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starry.admin.modules.weichat.config.CommonConstants;
import com.starry.admin.modules.weichat.constant.ConfigConstant;
import com.starry.admin.modules.weichat.entity.WxMsg;
import com.starry.admin.modules.weichat.entity.WxMsgVO;
import com.starry.admin.modules.weichat.entity.WxUser;
import com.starry.admin.modules.weichat.service.WxMsgService;
import com.starry.admin.modules.weichat.service.WxUserService;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpKefuService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 微信消息
*
* @author admin
* @since 2019-05-28 16:12:10
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wxmsg")
@Api(value = "wxmsg", tags = "wxmsg管理")
public class WxMsgController {
@Resource
WxMsgService wxMsgService;
@Resource
WxUserService wxUserService;
@Resource
WxMpService wxService;
/**
* 分页查询
*
* @param page 分页对象
* @param wxMsgVO 微信消息
* @return
*/
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:index')")
public R getWxMsgPage(Page<WxMsg> page, WxMsgVO wxMsgVO) {
if (StringUtils.isNotBlank(wxMsgVO.getNotInRepType())) {
return R.ok(wxMsgService.listWxMsgMapGroup(page, wxMsgVO));
}
// 标记为已读
if (StringUtils.isNotBlank(wxMsgVO.getWxUserId())) {
WxMsg wxMsg = new WxMsg();
wxMsg.setReadFlag(CommonConstants.YES);
Wrapper<WxMsg> queryWrapper = Wrappers.<WxMsg>lambdaQuery().eq(WxMsg::getWxUserId, wxMsgVO.getWxUserId()).eq(WxMsg::getReadFlag, CommonConstants.NO);
wxMsgService.update(wxMsg, queryWrapper);
}
return R.ok(wxMsgService.page(page, Wrappers.query(wxMsgVO)));
}
/**
* 通过id查询微信消息
*
* @param id id
* @return R
*/
@GetMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:get')")
public R getById(@PathVariable("id") String id) {
return R.ok(wxMsgService.getById(id));
}
/**
* 新增微信消息
*
* @param wxMsg 微信消息
* @return R
*/
@PostMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:add')")
public R save(@RequestBody WxMsg wxMsg) {
try {
WxUser wxUser = wxUserService.getById(wxMsg.getWxUserId());
// 入库
wxMsg.setNickName(wxUser.getNickName());
wxMsg.setHeadimgUrl(wxUser.getHeadimgUrl());
wxMsg.setCreateTime(LocalDateTime.now());
wxMsg.setType(ConfigConstant.WX_MSG_TYPE_2);
WxMpKefuMessage wxMpKefuMessage = null;
if (WxConsts.KefuMsgType.TEXT.equals(wxMsg.getRepType())) {
wxMsg.setRepContent(wxMsg.getRepContent());
wxMpKefuMessage = WxMpKefuMessage.TEXT().build();
wxMpKefuMessage.setContent(wxMsg.getRepContent());
}
if (WxConsts.KefuMsgType.IMAGE.equals(wxMsg.getRepType())) {// 图片
wxMsg.setRepName(wxMsg.getRepName());
wxMsg.setRepUrl(wxMsg.getRepUrl());
wxMsg.setRepMediaId(wxMsg.getRepMediaId());
wxMpKefuMessage = WxMpKefuMessage.IMAGE().build();
wxMpKefuMessage.setMediaId(wxMsg.getRepMediaId());
}
if (WxConsts.KefuMsgType.VOICE.equals(wxMsg.getRepType())) {
wxMsg.setRepName(wxMsg.getRepName());
wxMsg.setRepUrl(wxMsg.getRepUrl());
wxMsg.setRepMediaId(wxMsg.getRepMediaId());
wxMpKefuMessage = WxMpKefuMessage.VOICE().build();
wxMpKefuMessage.setMediaId(wxMsg.getRepMediaId());
}
if (WxConsts.KefuMsgType.VIDEO.equals(wxMsg.getRepType())) {
wxMsg.setRepName(wxMsg.getRepName());
wxMsg.setRepDesc(wxMsg.getRepDesc());
wxMsg.setRepUrl(wxMsg.getRepUrl());
wxMsg.setRepMediaId(wxMsg.getRepMediaId());
wxMpKefuMessage = WxMpKefuMessage.VIDEO().build();
wxMpKefuMessage.setMediaId(wxMsg.getRepMediaId());
wxMpKefuMessage.setTitle(wxMsg.getRepName());
wxMpKefuMessage.setDescription(wxMsg.getRepDesc());
}
if (WxConsts.KefuMsgType.MUSIC.equals(wxMsg.getRepType())) {
wxMsg.setRepName(wxMsg.getRepName());
wxMsg.setRepDesc(wxMsg.getRepDesc());
wxMsg.setRepUrl(wxMsg.getRepUrl());
wxMsg.setRepHqUrl(wxMsg.getRepHqUrl());
wxMpKefuMessage = WxMpKefuMessage.MUSIC().build();
wxMpKefuMessage.setTitle(wxMsg.getRepName());
wxMpKefuMessage.setDescription(wxMsg.getRepDesc());
wxMpKefuMessage.setMusicUrl(wxMsg.getRepUrl());
wxMpKefuMessage.setHqMusicUrl(wxMsg.getRepHqUrl());
wxMpKefuMessage.setThumbMediaId(wxMsg.getRepThumbMediaId());
}
if (WxConsts.KefuMsgType.NEWS.equals(wxMsg.getRepType())) {
List<WxMpKefuMessage.WxArticle> list = new ArrayList<>();
JSONArray jSONArray = wxMsg.getContent().getJSONArray("articles");
WxMpKefuMessage.WxArticle t;
for (Object object : jSONArray) {
JSONObject jSONObject = JSONUtil.parseObj(JSONUtil.toJsonStr(object));
t = new WxMpKefuMessage.WxArticle();
t.setTitle(jSONObject.getStr("title"));
t.setDescription(jSONObject.getStr("digest"));
t.setPicUrl(jSONObject.getStr("thumbUrl"));
t.setUrl(jSONObject.getStr("url"));
list.add(t);
}
wxMsg.setRepName(wxMsg.getRepName());
wxMsg.setRepDesc(wxMsg.getRepDesc());
wxMsg.setRepUrl(wxMsg.getRepUrl());
wxMsg.setRepMediaId(wxMsg.getRepMediaId());
wxMsg.setContent(wxMsg.getContent());
wxMpKefuMessage = WxMpKefuMessage.NEWS().build();
wxMpKefuMessage.setArticles(list);
}
if (wxMpKefuMessage != null) {
WxMpKefuService wxMpKefuService = wxService.getKefuService();
wxMpKefuMessage.setToUser(wxUser.getOpenId());
wxMpKefuService.sendKefuMessage(wxMpKefuMessage);
wxMsgService.save(wxMsg);
return R.ok(wxMsg);
} else {
return R.error("非法消息类型");
}
} catch (WxErrorException e) {
log.error("新增微信消息失败" + e.getMessage());
return R.error(e.getMessage());
}
}
/**
* 修改微信消息
*
* @param wxMsg 微信消息
* @return R
*/
@PutMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:edit')")
public R updateById(@RequestBody WxMsg wxMsg) {
return R.ok(wxMsgService.updateById(wxMsg));
}
/**
* 通过id删除微信消息
*
* @param id id
* @return R
*/
@DeleteMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxmsg:del')")
public R removeById(@PathVariable String id) {
return R.ok(wxMsgService.removeById(id));
}
}

View File

@@ -0,0 +1,132 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.starry.admin.common.aspect.ClerkUserLogin;
import com.starry.admin.common.aspect.CustomUserLogin;
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.admin.modules.weichat.entity.WxUserLoginVo;
import com.starry.admin.modules.weichat.entity.WxUserQueryAddressVo;
import com.starry.admin.modules.weichat.service.WxOauthService;
import com.starry.admin.modules.weichat.service.WxTokenService;
import com.starry.common.result.R;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Date;
import static com.starry.common.constant.Constants.*;
/**
* 微信用户
*
* @author admin
* @since 2019-03-25 15:39:39
*/
@Slf4j
@RestController
@RequestMapping("/wx/oauth2")
public class WxOauthController {
@Resource
private WxMpService wxMpService;
@Resource
private IPlayCustomUserInfoService customUserInfoService;
@Resource
private IPlayClerkUserInfoService clerkUserInfoService;
@Resource
private WxTokenService tokenService;
@Resource
private WxOauthService wxOauthService;
@GetMapping("/getClerkLoginAddress")
public R getClerkLoginAddress(@RequestBody WxUserQueryAddressVo vo) {
// 默认回调地址
String defaultAddress = "http://july.hucs.top/api/wx/oauth2/clerkLoginCallback";
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
defaultAddress = vo.getUrl();
}
String url = wxMpService.getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
return R.ok(url);
}
@GetMapping("/clerkLoginCallback")
public void clerkLoginCallback(@RequestParam("code") String code) {
}
@GetMapping("/clark/login")
public R clerkLogin(@Valid @RequestBody WxUserLoginVo vo) {
String userId = wxOauthService.clarkUserLogin(vo.getCode());
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectPlayClerkUserInfoById(userId);
JSONObject jsonObject = JSONObject.from(entity);
String tokenForMiniUser = tokenService.createMiniUserToken(entity.getId());
jsonObject.put("tokenValue", TOKEN_PREFIX + tokenForMiniUser);
jsonObject.put("tokenName", CLERK_USER_LOGIN_TOKEN);
jsonObject.put("accountRole", "user");
jsonObject.put("loginDate", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
return R.ok(jsonObject);
}
@ClerkUserLogin
@GetMapping("/clark/logout")
public R clerkLogout() {
wxOauthService.clarkUserLogout(ThreadLocalRequestDetail.getClerkUserInfo());
return R.ok("登出成功");
}
@GetMapping("/getCustomLoginAddress")
public R getCustomLoginAddress(@RequestBody WxUserQueryAddressVo vo) {
// 默认回调地址
String defaultAddress = "http://july.hucs.top/api/wx/oauth2/customLoginCallback";
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
defaultAddress = vo.getUrl();
}
String url = wxMpService.getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
return R.ok(url);
}
@GetMapping("/customLoginCallback")
public void customLoginCallback(@RequestParam("code") String code) {
}
@GetMapping("/custom/login")
public R customLogin(@Valid @RequestBody WxUserLoginVo vo) {
String userId = wxOauthService.customUserLogin(vo.getCode());
PlayCustomUserInfoEntity entity = customUserInfoService.selectPlayCustomUserInfoById(userId);
JSONObject jsonObject = JSONObject.from(entity);
String tokenForMiniUser = tokenService.createMiniUserToken(entity.getId());
jsonObject.put("tokenValue", TOKEN_PREFIX + tokenForMiniUser);
jsonObject.put("tokenName", CUSTOM_USER_LOGIN_TOKEN);
jsonObject.put("accountRole", "user");
jsonObject.put("loginDate", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
return R.ok(jsonObject);
}
@GetMapping("/custom/logout")
@CustomUserLogin
public R customLogout(@Valid @RequestBody WxUserLoginVo vo) {
wxOauthService.customUserLogout(ThreadLocalRequestDetail.getCustomUserInfo());
return R.ok("登出成功");
}
}

View File

@@ -1,110 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author admin
*/
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/weixin/portal/{appid}")
public class WxPortalController {
@Resource
private final WxMpService wxService;
//@Resource
// private final WxMpMessageRouter messageRouter;
@GetMapping(produces = "text/plain;charset=utf-8")
public String authGet(@PathVariable String appid,
@RequestParam(name = "signature", required = false) String signature,
@RequestParam(name = "timestamp", required = false) String timestamp,
@RequestParam(name = "nonce", required = false) String nonce,
@RequestParam(name = "echostr", required = false) String echostr) {
log.info("\n接收到来自微信服务器的认证消息[{}, {}, {}, {}]", signature,
timestamp, nonce, echostr);
if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
throw new IllegalArgumentException("请求参数非法,请核实!");
}
if (!this.wxService.switchover(appid)) {
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
}
if (wxService.checkSignature(timestamp, nonce, signature)) {
return echostr;
}
return "非法请求";
}
@PostMapping(produces = "application/xml; charset=UTF-8")
public String post(@PathVariable String appid,
@RequestBody String requestBody,
@RequestParam("signature") String signature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("openid") String openid,
@RequestParam(name = "encrypt_type", required = false) String encType,
@RequestParam(name = "msg_signature", required = false) String msgSignature) {
log.info("\n接收微信请求[openid=[{}], [signature=[{}], encType=[{}], msgSignature=[{}],"
+ " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
if (!this.wxService.switchover(appid)) {
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
}
if (!wxService.checkSignature(timestamp, nonce, signature)) {
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
}
String out = null;
if (encType == null) {
// 明文传输的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
WxMpXmlOutMessage outMessage = this.route(inMessage);
if (outMessage == null) {
return "";
}
out = outMessage.toXml();
} else if ("aes".equalsIgnoreCase(encType)) {
// aes加密的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpConfigStorage(),
timestamp, nonce, msgSignature);
log.debug("\n消息解密后内容为\n{} ", inMessage.toString());
WxMpXmlOutMessage outMessage = this.route(inMessage);
if (outMessage == null) {
return "";
}
out = outMessage.toEncryptedXml(wxService.getWxMpConfigStorage());
}
log.debug("\n组装回复信息{}", out);
return out;
}
private WxMpXmlOutMessage route(WxMpXmlMessage message) {
// try {
// return this.messageRouter.route(message);
//} catch (Exception e) {
// log.error("路由消息时出现异常!", e);
//}
return null;
}
}

View File

@@ -1,108 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import com.starry.common.result.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpDataCubeService;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
/**
* 微信账号配置
*
* @author admin
* @since 2019-03-23 21:26:35
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wxsummary")
public class WxSummaryController {
@Resource
WxMpService wxService;
/**
* 获取用户增减数据
*
* @param appId
* @param startDate
* @param endDate
* @return
*/
@GetMapping("/usersummary")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxsummary:index')")
public R getUsersummary(String appId, String startDate, String endDate) {
try {
WxMpDataCubeService wxMpDataCubeService = wxService.getDataCubeService();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return R.ok(wxMpDataCubeService.getUserSummary(sdf.parse(startDate), sdf.parse(endDate)));
} catch (WxErrorException e) {
log.error("获取用户增减数据失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("获取用户增减数据失败", e);
return R.error("获取用户增减数据失败");
}
}
/**
* 获取累计用户数据
*
* @param appId
* @param startDate
* @param endDate
* @return
*/
@GetMapping("/usercumulate")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxsummary:index')")
public R getUserCumulate(String appId, String startDate, String endDate) {
try {
WxMpDataCubeService wxMpDataCubeService = wxService.getDataCubeService();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return R.ok(wxMpDataCubeService.getUserCumulate(sdf.parse(startDate), sdf.parse(endDate)));
} catch (WxErrorException e) {
log.error("获取累计用户数据失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("获取用户增减数据失败", e);
return R.error("获取用户增减数据失败");
}
}
/**
* 获取接口分析数据
*
* @param appId
* @param startDate
* @param endDate
* @return
*/
@GetMapping("/interfacesummary")
// @PreAuthorize("@customSs.hasPermission('wxmp:wxsummary:index')")
public R getInterfaceSummary(String appId, String startDate, String endDate) {
try {
WxMpDataCubeService wxMpDataCubeService = wxService.getDataCubeService();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return R.ok(wxMpDataCubeService.getInterfaceSummary(sdf.parse(startDate), sdf.parse(endDate)));
} catch (WxErrorException e) {
log.error("获取接口分析数据失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("获取接口分析数据失败", e);
return R.error("获取接口分析数据失败");
}
}
}

View File

@@ -1,174 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starry.admin.modules.weichat.entity.WxUser;
import com.starry.admin.modules.weichat.service.WxUserService;
import com.starry.common.result.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 微信用户
*
* @author admin
* @since 2019-03-25 15:39:39
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wxuser")
public class WxUserController {
@Resource
WxUserService wxUserService;
/**
* 分页查询
*
* @param page 分页对象
* @param wxUser 微信用户
* @return
*/
@GetMapping("/page")
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:index')")
public R getWxUserPage(Page page, WxUser wxUser, String tagId) {
Wrapper<WxUser> queryWrapper;
if (StringUtils.isNotBlank(tagId)) {
queryWrapper = Wrappers.lambdaQuery(wxUser)
.and(wrapper -> wrapper
.eq(WxUser::getTagidList, "[" + tagId + "]")
.or()
.like(WxUser::getTagidList, "," + tagId + ",")
.or()
.likeRight(WxUser::getTagidList, "[" + tagId + ",")
.or()
.likeLeft(WxUser::getTagidList, "," + tagId + "]"));
} else if (StrUtil.isNotBlank(wxUser.getNickName())) {
String nickName = wxUser.getNickName();
wxUser.setNickName(null);
queryWrapper = Wrappers.lambdaQuery(wxUser)
.like(WxUser::getNickName, nickName);
} else {
queryWrapper = Wrappers.lambdaQuery(wxUser);
}
return R.ok(wxUserService.page(page, queryWrapper));
}
/**
* 通过id查询微信用户
*
* @param id id
* @return R
*/
@GetMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:get')")
public R getById(@PathVariable("id") String id) {
return R.ok(wxUserService.getById(id));
}
/**
* 新增微信用户
*
* @param wxUser 微信用户
* @return R
*/
@PostMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:add')")
public R save(@RequestBody WxUser wxUser) {
return R.ok(wxUserService.save(wxUser));
}
/**
* 修改微信用户
*
* @param wxUser 微信用户
* @return R
*/
@PutMapping
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:edit')")
public R updateById(@RequestBody WxUser wxUser) {
return R.ok(wxUserService.updateById(wxUser));
}
/**
* 通过id删除微信用户
*
* @param id id
* @return R
*/
@DeleteMapping("/{id}")
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:del')")
public R removeById(@PathVariable String id) {
return R.ok(wxUserService.removeById(id));
}
@PostMapping("/synchron")
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:synchro')")
public R synchron() {
try {
wxUserService.synchroWxUser();
return R.ok();
} catch (WxErrorException e) {
log.error("同步微信用户失败", e);
return R.error(e.getMessage());
}
}
/**
* 修改微信用户备注
*
* @param wxUser
* @return
*/
@PutMapping("/remark")
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:edit:remark')")
public R remark(@RequestBody WxUser wxUser) {
try {
return R.ok(wxUserService.updateRemark(wxUser));
} catch (WxErrorException e) {
log.error("修改微信用户备注失败", e);
return R.error(e.getMessage());
}
}
/**
* 打标签
*
* @param data
* @return
*/
@PutMapping("/tagid-list")
@PreAuthorize("@customSs.hasPermission('wxmp:wxuser:tagging')")
public R tagidList(@RequestBody JSONObject data) {
try {
String appId = data.getStr("appId");
String taggingType = data.getStr("taggingType");
JSONArray tagIdsArray = data.getJSONArray("tagIds");
JSONArray openIdsArray = data.getJSONArray("openIds");
String[] openIds = openIdsArray.toArray(new String[0]);
for (Object tagId : tagIdsArray) {
wxUserService.tagging(taggingType, Long.valueOf(String.valueOf(tagId)), openIds);
}
return R.ok();
} catch (WxErrorException e) {
log.error("修改微信用户备注失败", e);
return R.error(e.getMessage());
}
}
}

View File

@@ -1,159 +0,0 @@
package com.starry.admin.modules.weichat.controller;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.starry.admin.modules.weichat.entity.WxUser;
import com.starry.admin.modules.weichat.entity.WxUserTagsDict;
import com.starry.admin.modules.weichat.service.WxUserService;
import com.starry.common.result.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.WxMpUserTagService;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 微信用户标签
*
* @author admin
* @since 2019-03-25 15:39:39
*/
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wxusertags")
public class WxUserTagsController {
@Resource
WxMpService wxService;
@Resource
WxUserService wxUserService;
/**
* 获取微信用户标签
*
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:list')")
@GetMapping("/list")
public R getWxUserList(String appId) {
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
List<WxUserTag> listWxUserTag = wxMpUserTagService.tagGet();
return R.ok(listWxUserTag);
} catch (WxErrorException e) {
log.error("获取微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 获取微信用户标签字典
*
* @param appId
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:list')")
@GetMapping("/dict")
public R getWxUserTagsDict(String appId) {
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
List<WxUserTag> listWxUserTag = wxMpUserTagService.tagGet();
List<WxUserTagsDict> listWxUserTagsDict = new ArrayList<>();
WxUserTagsDict wxUserTagsDict;
for (WxUserTag wxUserTag : listWxUserTag) {
wxUserTagsDict = new WxUserTagsDict();
wxUserTagsDict.setName(wxUserTag.getName());
wxUserTagsDict.setValue(wxUserTag.getId());
listWxUserTagsDict.add(wxUserTagsDict);
}
return R.ok(listWxUserTagsDict);
} catch (WxErrorException e) {
log.error("获取微信用户标签字典失败", e);
return R.error(e.getMessage());
}
}
/**
* 新增微信用户标签
*
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:add')")
@PostMapping
public R save(@RequestBody JSONObject data) {
String appId = data.getStr("appId");
String name = data.getStr("name");
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagCreate(name));
} catch (WxErrorException e) {
log.error("新增微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 修改微信用户标签
*
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:edit')")
@PutMapping
public R updateById(@RequestBody JSONObject data) {
String appId = data.getStr("appId");
Long id = data.getLong("id");
String name = data.getStr("name");
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagUpdate(id, name));
} catch (WxErrorException e) {
log.error("修改微信用户标签失败", e);
return R.error(e.getMessage());
}
}
/**
* 删除微信用户标签
*
* @param id
* @param appId
* @return
*/
@PreAuthorize("@customSs.hasPermission('wxmp:wxusertags:del')")
@DeleteMapping
public R removeById(Long id, String appId) {
int count = (int) wxUserService.count(Wrappers.<WxUser>lambdaQuery()
.and(wrapper -> wrapper
.eq(WxUser::getTagidList, "[" + id + "]")
.or()
.like(WxUser::getTagidList, "," + id + ",")
.or()
.likeRight(WxUser::getTagidList, "[" + id + ",")
.or()
.likeLeft(WxUser::getTagidList, "," + id + "]")));
if (count > 0) {
return R.error("该标签下有用户存在,无法删除");
}
WxMpUserTagService wxMpUserTagService = wxService.getUserTagService();
try {
return R.ok(wxMpUserTagService.tagDelete(id));
} catch (WxErrorException e) {
log.error("删除微信用户标签失败", e);
return R.error(e.getMessage());
}
}
}

View File

@@ -1,32 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
/**
* @author admin
*/
@Data
public class CustomWxMpProperties {
/**
* 微信APPID
*/
public String appid = "wx917f3f747c7dc5dd";
/**
* 微信公众号的app secret
*/
public String secret = "85012dec2ba8bdc9d0174dd800ef1dec";
/**
* 微信公众号的token
*/
public String token = "AkzAW8yqUhOWAFN550";
/**
* 微信公众号的EncodingAESKey
*/
public String aesKey = "tsoM88UUQ5uEHJ29xgNiaHHaoswZapS5ijWpaN6hUZF";
}

View File

@@ -1,22 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
import java.io.Serializable;
/**
* imageManager
*
* @author admin
* @since 2019-03-23 21:26:35
*/
@Data
public class ImageManager implements Serializable {
private static final long serialVersionUID = 1L;
private String url;
private String thumb;
private String tag;
private String name;
private Integer id;
}

View File

@@ -1,40 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONUtil;
import lombok.Data;
import me.chanjar.weixin.common.bean.menu.WxMenuRule;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 自定义菜单模型
*
* @author admin
*/
@Data
public class Menu implements Serializable {
private static final long serialVersionUID = -7083914585539687746L;
private List<MenuButton> button = new ArrayList<>();
private WxMenuRule matchrule;
/**
* 反序列化
*/
public static Menu fromJson(String json) {
return JSONUtil.parseObj(json).toBean(Menu.class);
}
public String toJson() {
return JSONUtil.toJsonStr(this);
}
@Override
public String toString() {
return this.toJson();
}
}

View File

@@ -1,68 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 自定义菜单模型
*
* @author admin
*/
@Data
public class MenuButton implements Serializable {
private String type;
private String name;
private String key;
private String url;
private String media_id;
private String appid;
private String pagepath;
private List<MenuButton> sub_button = new ArrayList<>();
/**
* content内容
*/
private JSONObject content;
private String repContent;
/**
* 消息类型
*/
private String repType;
/**
* 消息名
*/
private String repName;
/**
* 视频和音乐的描述
*/
private String repDesc;
/**
* 视频和音乐的描述
*/
private String repUrl;
/**
* 高质量链接
*/
private String repHqUrl;
/**
* 缩略图的媒体id
*/
private String repThumbMediaId;
/**
* 缩略图url
*/
private String repThumbUrl;
private String article_id;
}

View File

@@ -0,0 +1,69 @@
package com.starry.admin.modules.weichat.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 微信用户对象 play_wx_user_info
*
* @author admin
* @since 2024-04-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("play_wx_user_info")
public class PlayWxUserInfoEntity extends BaseEntity<PlayWxUserInfoEntity> {
/**
* UUID
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 用户的标识,对当前公众号唯一
*/
private String openid;
/**
* 用户的标识,对当前公众号唯一
*/
private String unionid;
/**
* 昵称
*/
private String nickname;
/**
* 性别值为1时是男性值为2时是女性值为0时是未知
*/
private Integer sex;
/**
* 所在城市
*/
private String city;
/**
* 所在国家
*/
private String country;
/**
* 所在省份
*/
private String province;
/**
* 所在省份
*/
private String avatar;
}

View File

@@ -1,28 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
import java.io.Serializable;
/**
* @author admin
*/
@Data
public class ThirdSession implements Serializable {
/**
* 微信用户ID
*/
private String wxUserId;
/**
* 配置项ID
*/
private String appId;
/**
* 微信sessionKey
*/
private String sessionKey;
/**
* 用户标识
*/
private String openId;
}

View File

@@ -1,119 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.starry.common.config.typehandler.JsonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.type.JdbcType;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
* 消息自动回复
*
* @author admin
* @since 2019-04-18 15:40:39
*/
@Data
@TableName("wx_auto_reply")
@EqualsAndHashCode(callSuper = true)
public class WxAutoReply extends Model<WxAutoReply> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 创建者
*/
private String createId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者
*/
private String updateId;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 备注
*/
private String remark;
/**
* 逻辑删除标记0显示1隐藏
*/
private String delFlag;
/**
* 类型1、关注时回复2、消息回复3、关键词回复
*/
@NotNull(message = "类型不能为空")
private String type;
/**
* 关键词
*/
private String reqKey;
/**
* 请求消息类型text文本image图片voice语音video视频shortvideo小视频location地理位置
*/
private String reqType;
/**
* 回复消息类型text文本image图片voice语音video视频music音乐news图文
*/
@NotNull(message = "回复消息类型不能为空")
private String repType;
/**
* 回复类型文本匹配类型1、全匹配2、半匹配
*/
private String repMate;
/**
* 回复类型文本保存文字
*/
private String repContent;
/**
* 回复的素材名、视频和音乐的标题
*/
private String repName;
/**
* 回复类型imge、voice、news、video的mediaID或音乐缩略图的媒体id
*/
private String repMediaId;
/**
* 视频和音乐的描述
*/
private String repDesc;
/**
* 链接
*/
private String repUrl;
/**
* 高质量链接
*/
private String repHqUrl;
/**
* 缩略图的媒体id
*/
private String repThumbMediaId;
/**
* 缩略图url
*/
private String repThumbUrl;
/**
* 图文消息的内容
*/
@TableField(typeHandler = JsonTypeHandler.class, jdbcType = JdbcType.VARCHAR)
private JSONObject content;
}

View File

@@ -1,117 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.starry.common.config.typehandler.JsonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.type.JdbcType;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
* 自定义菜单
*
* @author admin
* @since 2019-03-27 16:52:10
*/
@Data
@TableName("wx_menu")
@EqualsAndHashCode(callSuper = true)
public class WxMenu extends Model<WxMenu> {
private static final long serialVersionUID = 1L;
/**
* 菜单IDclick、scancode_push、scancode_waitmsg、pic_sysphoto、pic_photo_or_album、pic_weixin、location_select保存key
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 父菜单ID
*/
private String parentId;
/**
* 排序值
*/
private Integer sort;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 逻辑删除标记0显示1隐藏
*/
private String delFlag;
/**
* 菜单类型click、view、miniprogram、scancode_push、scancode_waitmsg、pic_sysphoto、pic_photo_or_album、pic_weixin、location_select、media_id、view_limited等
*/
@NotNull(message = "菜单类型不能为空")
private String type;
/**
* 菜单名
*/
@NotNull(message = "菜单名不能为空")
private String name;
/**
* View保存链接到url
*/
private String url;
/**
* Img、voice、News保存mediaID
*/
private String repMediaId;
/**
* 回复消息类型text文本image图片voice语音video视频music音乐news图文
*/
private String repType;
/**
* 素材名、视频和音乐的标题
*/
private String repName;
/**
* Text:保存文字
*/
private String repContent;
/**
* 小程序的appid
*/
private String maAppId;
/**
* 小程序的页面路径
*/
private String maPagePath;
/**
* 视频和音乐的描述
*/
private String repDesc;
/**
* 视频和音乐的描述
*/
private String repUrl;
/**
* 高质量链接
*/
private String repHqUrl;
/**
* 缩略图的媒体id
*/
private String repThumbMediaId;
/**
* 缩略图url
*/
private String repThumbUrl;
/**
* 图文消息的内容
*/
@TableField(typeHandler = JsonTypeHandler.class, jdbcType = JdbcType.VARCHAR)
private JSONObject content;
}

View File

@@ -1,145 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.starry.common.config.typehandler.JsonTypeHandler;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.type.JdbcType;
import java.time.LocalDateTime;
/**
* 微信消息
*
* @author admin
* @since 2019-05-28 16:12:10
*/
@Data
@TableName("wx_msg")
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "微信消息")
public class WxMsg extends Model<WxMsg> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 创建者
*/
private String createId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者
*/
private String updateId;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 备注
*/
private String remark;
/**
* 逻辑删除标记0显示1隐藏
*/
private String delFlag;
/**
* 公众号名称
*/
private String appName;
/**
* 公众号logo
*/
private String appLogo;
/**
* 微信用户ID
*/
private String wxUserId;
/**
* 昵称
*/
private String nickName;
/**
* 头像
*/
private String headimgUrl;
/**
* 消息分类1、用户发给公众号2、公众号发给用户
*/
private String type;
/**
* 消息类型text文本image图片voice语音video视频shortvideo小视频location地理位置music音乐news图文event推送事件
*/
private String repType;
/**
* 事件类型subscribe关注unsubscribe取关CLICK、VIEW菜单事件
*/
private String repEvent;
/**
* 回复类型文本保存文字
*/
private String repContent;
/**
* 回复类型imge、voice、news、video的mediaID或音乐缩略图的媒体id
*/
private String repMediaId;
/**
* 回复的素材名、视频和音乐的标题
*/
private String repName;
/**
* 视频和音乐的描述
*/
private String repDesc;
/**
* 链接
*/
private String repUrl;
/**
* 高质量链接
*/
private String repHqUrl;
/**
* 图文消息的内容
*/
@TableField(typeHandler = JsonTypeHandler.class, jdbcType = JdbcType.VARCHAR)
private JSONObject content;
/**
* 缩略图的媒体id
*/
private String repThumbMediaId;
/**
* 缩略图url
*/
private String repThumbUrl;
/**
* 地理位置维度
*/
private Double repLocationX;
/**
* 地理位置经度
*/
private Double repLocationY;
/**
* 地图缩放大小
*/
private Double repScale;
/**
* 已读标记01
*/
private String readFlag;
}

View File

@@ -1,27 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 微信消息
*
* @author admin
* @since 2019-05-28 16:12:10
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class WxMsgVO extends WxMsg {
private static final long serialVersionUID = 1L;
/**
* 数量
*/
private Integer countMsg;
/**
* repType not in筛选
*/
private String notInRepType;
}

View File

@@ -1,20 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
/**
* 微信开发数据
*
* @author admin
*/
@Data
public class WxOpenDataDTO {
private String appId;
private String userId;
private String encryptedData;
private String errMsg;
private String iv;
private String rawData;
private String signature;
private String sessionKey;
}

View File

@@ -1,153 +0,0 @@
package com.starry.admin.modules.weichat.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.starry.common.config.typehandler.ArrayLongTypeHandler;
import com.starry.common.sensitive.Sensitive;
import com.starry.common.sensitive.SensitiveTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.type.JdbcType;
import java.time.LocalDateTime;
/**
* 微信用户
*
* @author admin
* @since 2019-03-25 15:39:39
*/
@Data
@TableName("wx_user")
@EqualsAndHashCode(callSuper = true)
public class WxUser extends Model<WxUser> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 创建者
*/
private String createId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者
*/
private String updateId;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 备注信息
*/
private String remark;
/**
* 逻辑删除标记0显示1隐藏
*/
private String delFlag;
/**
* 应用类型(1:小程序2:公众号)
*/
private String appType;
/**
* 是否订阅012网页授权用户
*/
private String subscribe;
/**
* 返回用户关注的渠道来源ADD_SCENE_SEARCH 公众号搜索ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移ADD_SCENE_PROFILE_CARD 名片分享ADD_SCENE_QR_CODE 扫描二维码ADD_SCENEPROFILE LINK 图文页内名称点击ADD_SCENE_PROFILE_ITEM 图文页右上角菜单ADD_SCENE_PAID 支付后关注ADD_SCENE_OTHERS 其他
*/
private String subscribeScene;
/**
* 关注时间
*/
private LocalDateTime subscribeTime;
/**
* 关注次数
*/
private Integer subscribeNum;
/**
* 取消关注时间
*/
private LocalDateTime cancelSubscribeTime;
/**
* 用户标识
*/
private String openId;
/**
* 昵称
*/
private String nickName;
/**
* 性别120未知
*/
private String sex;
/**
* 所在城市
*/
private String city;
/**
* 所在国家
*/
private String country;
/**
* 所在省份
*/
private String province;
/**
* 手机号码
*/
@Sensitive(type = SensitiveTypeEnum.MOBILE_PHONE)
private String phone;
/**
* 用户语言
*/
private String language;
/**
* 头像
*/
private String headimgUrl;
/**
* union_id
*/
private String unionId;
/**
* 用户组
*/
private String groupId;
/**
* 标签列表
*/
@TableField(typeHandler = ArrayLongTypeHandler.class, jdbcType = JdbcType.VARCHAR)
private Long[] tagidList;
/**
* 二维码扫码场景
*/
private String qrSceneStr;
/**
* 地理位置纬度
*/
private Double latitude;
/**
* 地理位置经度
*/
private Double longitude;
/**
* 地理位置精度
*/
@TableField(value = "`precision`")
private Double precision;
/**
* 会话密钥
*/
private String sessionKey;
}

View File

@@ -0,0 +1,13 @@
package com.starry.admin.modules.weichat.entity;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class WxUserLoginVo {
@NotBlank(message = "code不能为空")
private String code;
}

View File

@@ -6,7 +6,8 @@ import lombok.Data;
* @author admin * @author admin
*/ */
@Data @Data
public class WxUserTagsDict { public class WxUserQueryAddressVo {
private String name;
private Long value;
private String url;
} }

View File

@@ -1,12 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author admin
*/
public abstract class AbstractHandler implements WxMpMessageHandler {
protected Logger logger = LoggerFactory.getLogger(getClass());
}

View File

@@ -1,25 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author admin
*/
@Component
public class KfSessionHandler extends AbstractHandler {
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
// TODO 对会话做处理
return null;
}
}

View File

@@ -1,44 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import com.starry.admin.modules.weichat.builder.TextBuilder;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;
import java.util.Map;
import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
/**
* @author admin
*/
@Component
public class LocationHandler extends AbstractHandler {
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
if (wxMessage.getMsgType().equals(XmlMsgType.LOCATION)) {
// TODO 接收处理用户发送的地理位置消息
try {
String content = "感谢反馈,您的的地理位置已收到!";
return new TextBuilder().build(content, wxMessage, null);
} catch (Exception e) {
this.logger.error("位置消息接收处理失败", e);
return null;
}
}
// 上报地理位置事件
this.logger.info("上报地理位置,纬度 : {},经度 : {},精度 : {}",
wxMessage.getLatitude(), wxMessage.getLongitude(), wxMessage.getPrecision());
// TODO 可以将用户地理位置信息保存到本地数据库,以便以后使用
return null;
}
}

View File

@@ -1,39 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import cn.hutool.core.util.StrUtil;
import com.starry.admin.modules.weichat.utils.JsonUtils;
import com.starry.common.utils.HttpUtils;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author admin
*/
@Component
public class LogHandler extends AbstractHandler {
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
this.logger.info("\n接收到请求消息内容{}", JsonUtils.toJson(wxMessage));
// 以下为测试代码,自行删除不影响系统功能
if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.EVENT)) {
if (wxMessage.getEvent().equals(WxConsts.EventType.SUBSCRIBE) ||
wxMessage.getEvent().equals(WxConsts.EventType.SCAN)) {
if (wxMessage.getEventKey().contains("jl-wiki")) {
String openId = wxMessage.getFromUser();
String sceneStr = StrUtil.split(wxMessage.getEventKey(), ":").get(1);
String rs = HttpUtils.sendPost("http://127.0.0.1:8083/joolun-open/user", StrUtil.format("openId={}&sceneStr={}", openId, sceneStr));
}
}
}
return null;
}
}

View File

@@ -1,172 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.starry.admin.modules.weichat.config.CommonConstants;
import com.starry.admin.modules.weichat.constant.ConfigConstant;
import com.starry.admin.modules.weichat.entity.WxMenu;
import com.starry.admin.modules.weichat.entity.WxMsg;
import com.starry.admin.modules.weichat.entity.WxUser;
import com.starry.admin.modules.weichat.mapper.WxMenuMapper;
import com.starry.admin.modules.weichat.mapper.WxMsgMapper;
import com.starry.admin.modules.weichat.mapper.WxUserMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.builder.outxml.*;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author admin
*/
@Slf4j
@Component
@AllArgsConstructor
public class MenuHandler extends AbstractHandler {
private final WxMenuMapper wxMenuMapper;
private final WxUserMapper wxUserMapper;
private final WxMsgMapper wxMsgMapper;
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService weixinService,
WxSessionManager sessionManager) throws WxErrorException {
// 消息记录
WxMenu wxMenu;
if (WxConsts.EventType.CLICK.equals(wxMessage.getEvent())
|| WxConsts.EventType.SCANCODE_WAITMSG.equals(wxMessage.getEvent())) {
wxMenu = wxMenuMapper.selectById(wxMessage.getEventKey());
if (wxMenu == null) {// 菜单过期
return new TextBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).content("非常抱歉,该菜单已删除!").build();
}
} else {
wxMenu = new WxMenu();
}
WxUser wxUser = wxUserMapper.selectOne(Wrappers.<WxUser>lambdaQuery()
.eq(WxUser::getOpenId, wxMessage.getFromUser()));
if (wxUser == null) {// 库中无此用户
WxMpUser userWxInfo = weixinService.getUserService()
.userInfo(wxMessage.getFromUser(), null);
wxUser = new WxUser();
wxUser.setSubscribeNum(1);
SubscribeHandler.setWxUserValue(wxUser, userWxInfo);
wxUserMapper.insert(wxUser);
}
// 组装菜单回复消息
return getWxMpXmlOutMessage(wxMessage, wxMenu, wxUser);
}
/**
* 组装菜单回复消息
*
* @param wxMessage
* @param wxMenu
* @return
*/
public WxMpXmlOutMessage getWxMpXmlOutMessage(WxMpXmlMessage wxMessage, WxMenu wxMenu, WxUser wxUser) {
WxMpXmlOutMessage wxMpXmlOutMessage = null;
// 记录接收消息
WxMsg wxMsg = new WxMsg();
// wxMsg.setTenantId(wxApp.getTenantId());
wxMsg.setWxUserId(wxUser.getId());
wxMsg.setNickName(wxUser.getNickName());
wxMsg.setHeadimgUrl(wxUser.getHeadimgUrl());
wxMsg.setType(ConfigConstant.WX_MSG_TYPE_1);
wxMsg.setRepEvent(wxMessage.getEvent());
wxMsg.setRepType(wxMessage.getMsgType());
wxMsg.setRepName(wxMenu.getName());
if (WxConsts.EventType.VIEW.equals(wxMessage.getEvent())) {
wxMsg.setRepUrl(wxMessage.getEventKey());
}
if (WxConsts.EventType.SCANCODE_WAITMSG.equals(wxMessage.getEvent())) {
wxMsg.setRepContent(wxMessage.getScanCodeInfo().getScanResult());
}
wxMsg.setReadFlag(CommonConstants.NO);
LocalDateTime now = LocalDateTime.now();
wxMsg.setCreateTime(now);
wxMsgMapper.insert(wxMsg);
if (WxConsts.MenuButtonType.CLICK.equals(wxMenu.getType())
|| WxConsts.MenuButtonType.SCANCODE_WAITMSG.equals(wxMenu.getType())) {
// 记录回复消息
wxMsg = new WxMsg();
wxMsg.setWxUserId(wxUser.getId());
wxMsg.setNickName(wxUser.getNickName());
wxMsg.setHeadimgUrl(wxUser.getHeadimgUrl());
wxMsg.setCreateTime(now.plusSeconds(1));
wxMsg.setType(ConfigConstant.WX_MSG_TYPE_2);
wxMsg.setRepType(wxMenu.getRepType());
if (WxConsts.KefuMsgType.TEXT.equals(wxMenu.getRepType())) {
wxMsg.setRepContent(wxMenu.getRepContent());
wxMpXmlOutMessage = new TextBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).content(wxMenu.getRepContent()).build();
}
if (WxConsts.KefuMsgType.IMAGE.equals(wxMenu.getRepType())) {
wxMsg.setRepName(wxMenu.getRepName());
wxMsg.setRepUrl(wxMenu.getRepUrl());
wxMsg.setRepMediaId(wxMenu.getRepMediaId());
wxMpXmlOutMessage = new ImageBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).mediaId(wxMenu.getRepMediaId()).build();
}
if (WxConsts.KefuMsgType.VOICE.equals(wxMenu.getRepType())) {
wxMsg.setRepName(wxMenu.getRepName());
wxMsg.setRepUrl(wxMenu.getRepUrl());
wxMsg.setRepMediaId(wxMenu.getRepMediaId());
wxMpXmlOutMessage = new VoiceBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).mediaId(wxMenu.getRepMediaId()).build();
}
if (WxConsts.KefuMsgType.VIDEO.equals(wxMenu.getRepType())) {
wxMsg.setRepName(wxMenu.getRepName());
wxMsg.setRepDesc(wxMenu.getRepDesc());
wxMsg.setRepUrl(wxMenu.getRepUrl());
wxMsg.setRepMediaId(wxMenu.getRepMediaId());
wxMpXmlOutMessage = new VideoBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).mediaId(wxMenu.getRepMediaId())
.title(wxMenu.getRepName()).description(wxMenu.getRepDesc()).build();
}
if (WxConsts.KefuMsgType.MUSIC.equals(wxMenu.getRepType())) {
wxMsg.setRepName(wxMenu.getRepName());
wxMsg.setRepDesc(wxMenu.getRepDesc());
wxMsg.setRepUrl(wxMenu.getRepUrl());
wxMsg.setRepHqUrl(wxMenu.getRepHqUrl());
wxMsg.setRepThumbMediaId(wxMenu.getRepThumbMediaId());
wxMsg.setRepThumbUrl(wxMenu.getRepThumbUrl());
wxMpXmlOutMessage = new MusicBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.thumbMediaId(wxMenu.getRepThumbMediaId())
.title(wxMenu.getRepName()).description(wxMenu.getRepDesc())
.musicUrl(wxMenu.getRepUrl()).hqMusicUrl(wxMenu.getRepHqUrl()).build();
}
if (WxConsts.KefuMsgType.NEWS.equals(wxMenu.getRepType())) {
List<WxMpXmlOutNewsMessage.Item> list = new ArrayList<>();
List<JSONObject> listJSONObject = JSONUtil.toList(wxMenu.getContent().getJSONArray("articles"), JSONObject.class);
WxMpXmlOutNewsMessage.Item t;
for (JSONObject jSONObject : listJSONObject) {
t = new WxMpXmlOutNewsMessage.Item();
t.setTitle(jSONObject.getStr("title"));
t.setDescription(jSONObject.getStr("digest"));
t.setPicUrl(jSONObject.getStr("thumbUrl"));
t.setUrl(jSONObject.getStr("url"));
list.add(t);
}
wxMsg.setRepName(wxMenu.getRepName());
wxMsg.setRepDesc(wxMenu.getRepDesc());
wxMsg.setRepUrl(wxMenu.getRepUrl());
wxMsg.setRepMediaId(wxMenu.getRepMediaId());
wxMsg.setContent(wxMenu.getContent());
wxMpXmlOutMessage = new NewsBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).articles(list).build();
}
wxMsgMapper.insert(wxMsg);
}
return wxMpXmlOutMessage;
}
}

View File

@@ -1,194 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.starry.admin.modules.weichat.config.CommonConstants;
import com.starry.admin.modules.weichat.constant.ConfigConstant;
import com.starry.admin.modules.weichat.constant.WebSocketConstant;
import com.starry.admin.modules.weichat.entity.WxAutoReply;
import com.starry.admin.modules.weichat.entity.WxMsg;
import com.starry.admin.modules.weichat.entity.WxUser;
import com.starry.admin.modules.weichat.mapper.WxUserMapper;
import com.starry.admin.modules.weichat.service.WxAutoReplyService;
import com.starry.admin.modules.weichat.service.WxMsgService;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage;
import me.chanjar.weixin.mp.builder.outxml.*;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
/**
* @author admin
*/
@Component
@AllArgsConstructor
public class MsgHandler extends AbstractHandler {
private final WxAutoReplyService wxAutoReplyService;
private final WxUserMapper wxUserMapper;
private final WxMsgService wxMsgService;
/**
* 组装回复消息,并记录消息
*
* @param wxMessage
* @param listWxAutoReply
* @return
*/
public static WxMpXmlOutMessage getWxMpXmlOutMessage(WxMpXmlMessage wxMessage, List<WxAutoReply> listWxAutoReply, WxUser wxUser, WxMsgService wxMsgService) {
WxMpXmlOutMessage wxMpXmlOutMessage = null;
// 记录接收消息
WxMsg wxMsg = new WxMsg();
wxMsg.setWxUserId(wxUser.getId());
wxMsg.setNickName(wxUser.getNickName());
wxMsg.setHeadimgUrl(wxUser.getHeadimgUrl());
wxMsg.setType(ConfigConstant.WX_MSG_TYPE_1);
wxMsg.setRepEvent(wxMessage.getEvent());
wxMsg.setRepType(wxMessage.getMsgType());
wxMsg.setRepMediaId(wxMessage.getMediaId());
if (XmlMsgType.TEXT.equals(wxMessage.getMsgType())) {
wxMsg.setRepContent(wxMessage.getContent());
}
if (XmlMsgType.VOICE.equals(wxMessage.getMsgType())) {
wxMsg.setRepName(wxMessage.getMediaId() + "." + wxMessage.getFormat());
wxMsg.setRepContent(wxMessage.getRecognition());
}
if (XmlMsgType.IMAGE.equals(wxMessage.getMsgType())) {
wxMsg.setRepUrl(wxMessage.getPicUrl());
}
if (XmlMsgType.LINK.equals(wxMessage.getMsgType())) {
wxMsg.setRepName(wxMessage.getTitle());
wxMsg.setRepDesc(wxMessage.getDescription());
wxMsg.setRepUrl(wxMessage.getUrl());
}
if (WxConsts.MediaFileType.FILE.equals(wxMessage.getMsgType())) {
wxMsg.setRepName(wxMessage.getTitle());
wxMsg.setRepDesc(wxMessage.getDescription());
}
if (XmlMsgType.VIDEO.equals(wxMessage.getMsgType())) {
wxMsg.setRepThumbMediaId(wxMessage.getThumbMediaId());
}
if (XmlMsgType.LOCATION.equals(wxMessage.getMsgType())) {
wxMsg.setRepLocationX(wxMessage.getLocationX());
wxMsg.setRepLocationY(wxMessage.getLocationY());
wxMsg.setRepScale(wxMessage.getScale());
wxMsg.setRepContent(wxMessage.getLabel());
}
wxMsg.setReadFlag(CommonConstants.NO);
LocalDateTime now = LocalDateTime.now();
wxMsg.setCreateTime(now);
wxMsgService.save(wxMsg);
// 推送websocket
String destination = WebSocketConstant.USER_DESTINATION_PREFIX + WebSocketConstant.WX_MSG + wxMsg.getWxUserId();
if (listWxAutoReply != null && !listWxAutoReply.isEmpty()) {
WxAutoReply wxAutoReply = listWxAutoReply.get(0);
// 记录回复消息
wxMsg = new WxMsg();
wxMsg.setWxUserId(wxUser.getId());
wxMsg.setNickName(wxUser.getNickName());
wxMsg.setHeadimgUrl(wxUser.getHeadimgUrl());
wxMsg.setCreateTime(now.plusSeconds(1));
wxMsg.setType(ConfigConstant.WX_MSG_TYPE_2);
wxMsg.setRepType(wxAutoReply.getRepType());
if (WxConsts.KefuMsgType.TEXT.equals(wxAutoReply.getRepType())) {// 文本
wxMsg.setRepContent(wxAutoReply.getRepContent());
wxMpXmlOutMessage = new TextBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).content(wxAutoReply.getRepContent()).build();
}
if (WxConsts.KefuMsgType.IMAGE.equals(wxAutoReply.getRepType())) {// 图片
wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMpXmlOutMessage = new ImageBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).mediaId(wxAutoReply.getRepMediaId()).build();
}
if (WxConsts.KefuMsgType.VOICE.equals(wxAutoReply.getRepType())) {
wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMpXmlOutMessage = new VoiceBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).mediaId(wxAutoReply.getRepMediaId()).build();
}
if (WxConsts.KefuMsgType.VIDEO.equals(wxAutoReply.getRepType())) {
wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepDesc(wxAutoReply.getRepDesc());
wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMpXmlOutMessage = new VideoBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).mediaId(wxAutoReply.getRepMediaId()).title(wxAutoReply.getRepName()).description(wxAutoReply.getRepDesc()).build();
}
if (WxConsts.KefuMsgType.MUSIC.equals(wxAutoReply.getRepType())) {
wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepDesc(wxAutoReply.getRepDesc());
wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepHqUrl(wxAutoReply.getRepHqUrl());
wxMsg.setRepThumbMediaId(wxAutoReply.getRepThumbMediaId());
wxMsg.setRepThumbUrl(wxAutoReply.getRepThumbUrl());
wxMpXmlOutMessage = new MusicBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).thumbMediaId(wxAutoReply.getRepThumbMediaId()).title(wxAutoReply.getRepName()).description(wxAutoReply.getRepDesc()).musicUrl(wxAutoReply.getRepUrl()).hqMusicUrl(wxAutoReply.getRepHqUrl()).build();
}
if (WxConsts.KefuMsgType.NEWS.equals(wxAutoReply.getRepType())) {
List<WxMpXmlOutNewsMessage.Item> list = new ArrayList<>();
List<JSONObject> listJSONObject = wxAutoReply.getContent().getJSONArray("articles").toList(JSONObject.class);
WxMpXmlOutNewsMessage.Item t;
for (JSONObject jSONObject : listJSONObject) {
t = new WxMpXmlOutNewsMessage.Item();
t.setTitle(jSONObject.getStr("title"));
t.setDescription(jSONObject.getStr("digest"));
t.setPicUrl(jSONObject.getStr("thumbUrl"));
t.setUrl(jSONObject.getStr("url"));
list.add(t);
}
wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepDesc(wxAutoReply.getRepDesc());
wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMsg.setContent(wxAutoReply.getContent());
wxMpXmlOutMessage = new NewsBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).articles(list).build();
}
wxMsgService.save(wxMsg);
}
return wxMpXmlOutMessage;
}
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) {
// 组装回复消息
if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
WxMpXmlOutMessage rs;
// TODO 可以选择将消息保存到本地
WxUser wxUser = wxUserMapper.selectOne(Wrappers.<WxUser>lambdaQuery().eq(WxUser::getOpenId, wxMessage.getFromUser()));
if (WxConsts.KefuMsgType.TEXT.equals(wxMessage.getMsgType())) {// 1、先处理是否有文本关键字回复
// 先全匹配
List<WxAutoReply> listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getType, ConfigConstant.WX_AUTO_REPLY_TYPE_3).eq(WxAutoReply::getRepMate, ConfigConstant.WX_REP_MATE_1).eq(WxAutoReply::getReqKey, wxMessage.getContent()));
if (listWxAutoReply != null && !listWxAutoReply.isEmpty()) {
rs = this.getWxMpXmlOutMessage(wxMessage, listWxAutoReply, wxUser, wxMsgService);
if (rs != null) {
return rs;
}
}
// 再半匹配
listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getType, ConfigConstant.WX_AUTO_REPLY_TYPE_3).eq(WxAutoReply::getRepMate, ConfigConstant.WX_REP_MATE_2).like(WxAutoReply::getReqKey, wxMessage.getContent()));
if (listWxAutoReply != null && !listWxAutoReply.isEmpty()) {
rs = this.getWxMpXmlOutMessage(wxMessage, listWxAutoReply, wxUser, wxMsgService);
if (rs != null) {
return rs;
}
}
}
// 2、再处理消息回复
List<WxAutoReply> listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getType, ConfigConstant.WX_AUTO_REPLY_TYPE_2).eq(WxAutoReply::getReqType, wxMessage.getMsgType()));
rs = this.getWxMpXmlOutMessage(wxMessage, listWxAutoReply, wxUser, wxMsgService);
return rs;
}
return null;
}
}

View File

@@ -1,24 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author admin
*/
@Component
public class NullHandler extends AbstractHandler {
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
return null;
}
}

View File

@@ -1,24 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author admin
*/
@Component
public class ScanHandler extends AbstractHandler {
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
// 扫码事件处理
return null;
}
}

View File

@@ -1,27 +0,0 @@
package com.starry.admin.modules.weichat.handler;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* 门店审核事件处理
*
* @author admin
*/
@Component
public class StoreCheckNotifyHandler extends AbstractHandler {
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
// TODO 处理门店审核事件
return null;
}
}

Some files were not shown because too many files have changed in this diff Show More