二维码分享表单录入

This commit is contained in:
luozhun 2024-09-20 14:51:27 +08:00
parent e5fa6ae335
commit 1e344ac66e
11 changed files with 86 additions and 5 deletions

View File

@ -41,6 +41,8 @@ public class WebConfig implements WebMvcConfigurer {
whiteList.add("/management/getCheckStatus");
//微信小程序注册
whiteList.add("/miniProgramUser/register");
//二维码表单录入保安人员
whiteList.add("/miniProgramUser/qrCodeFormInputSecurityUser");
}
@Override

View File

@ -3,6 +3,7 @@ package com.changhu.module.miniProgram.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.JsonBody;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.module.miniProgram.service.MiniProgramUserService;
@ -34,6 +35,12 @@ public class MiniProgramUserController {
miniProgramUserService.register(params);
}
@Operation(summary = "二维码表单录入保安人员")
@PostMapping("/qrCodeFormInputSecurityUser")
public void qrCodeFormInputSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) {
miniProgramUserService.qrCodeFormInputSecurityUser(params);
}
@Operation(summary = "服务项目保安人员分页")
@PostMapping("/securityUserPager")
public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(@RequestBody PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) {

View File

@ -9,7 +9,11 @@ import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -42,7 +46,15 @@ public class ProjectManageIndexController {
@Operation(summary = "保存或更新保安人员")
@PostMapping("/saveOrUpdateSecurityUser")
public void saveOrUpdateSecurityUser(@RequestBody SaveOrUpdateSecurityUserParams params) {
public void saveOrUpdateSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) {
projectManageIndexService.saveOrUpdateSecurityUser(params);
}
@JsonBody(value = false)
@Operation(summary = "获取表单分享二维码")
@GetMapping(value = "/shareForm_QR_Code")
public ResponseEntity<Resource> shareForm_QR_Code(@Schema(description = "要生成的路径") @RequestParam String path,
@Schema(description = "生成二维码的宽度") @RequestParam(defaultValue = "430") Integer width) {
return projectManageIndexService.shareForm_QR_Code(path, width);
}
}

View File

@ -23,6 +23,10 @@ public class SaveOrUpdateSecurityUserParams {
@Schema(description = "服务项目id")
private Long serviceProjectId;
@NotNull(message = "保安单位不能为空")
@Schema(description = "保安单位id")
private Long securityUnitId;
@NotBlank(message = "名字不能为空")
@Schema(description = "名称")
private String name;

View File

@ -53,6 +53,8 @@ public class IndexServiceProjectListVo {
static class ServiceProjectVo {
@Schema(description = "服务项目id")
private Long snowFlakeId;
@Schema(description = "保安单位id")
private Long securityUnitId;
@Schema(description = "项目经理信息")
private Dict projectManagerMiniProgramUserInfo;
@Schema(description = "服务项目名称")

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
@ -29,4 +30,11 @@ public interface MiniProgramUserService extends IService<MiniProgramUser> {
* @return 保安人员
*/
Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams);
/**
* 二维码表单录入保安人员
*
* @param params 参数
*/
void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params);
}

View File

@ -2,6 +2,9 @@ package com.changhu.module.miniProgram.service;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import java.util.List;
@ -31,4 +34,9 @@ public interface ProjectManageIndexService {
* @param params 保安人员参数
*/
void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params);
/**
* 分享表单录入的二维码
*/
ResponseEntity<Resource> shareForm_QR_Code(String path, Integer width);
}

View File

@ -13,9 +13,11 @@ import com.changhu.module.miniProgram.mapper.SecurityUserMapper;
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.module.miniProgram.service.MiniProgramUserService;
import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
@ -35,6 +37,9 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
@Autowired
private SecurityUserMapper securityUserMapper;
@Autowired
private ProjectManageIndexService projectManageIndexService;
@Override
public void register(MiniProgramUserRegisterParams params) {
MiniProgramUser miniProgramUser = BeanUtil.copyProperties(params, MiniProgramUser.class);
@ -61,4 +66,9 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) {
return securityUserMapper.securityUserPager(queryParams.getPage(), queryParams.getParams());
}
@Override
public void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params) {
projectManageIndexService.saveOrUpdateSecurityUser(params);
}
}

View File

@ -1,5 +1,7 @@
package com.changhu.module.miniProgram.service.impl;
import cn.binarywang.wx.miniapp.api.WxMaQrcodeService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.exception.MessageException;
@ -10,9 +12,18 @@ import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams
import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo;
import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.List;
import java.util.Optional;
@ -21,12 +32,16 @@ import java.util.Optional;
* @createTime 2024/9/10 下午3:50
* @desc ProjectManageIndexServiceImpl...
*/
@Slf4j
@Service
public class ProjectManageIndexServiceImpl implements ProjectManageIndexService {
@Autowired
private ServiceProjectMapper serviceProjectMapper;
@Autowired
private WxMaService wxMaService;
@Override
public List<IndexServiceProjectListVo> getMyServiceProjectList() {
return serviceProjectMapper.getServiceProjectList(null, UserUtil.getUserId());
@ -43,8 +58,6 @@ public class ProjectManageIndexServiceImpl implements ProjectManageIndexService
@Override
public void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params) {
SecurityUser securityUser = BeanUtil.copyProperties(params, SecurityUser.class);
//填充保安单位
securityUser.setSecurityUnitId(UserUtil.getUnitId());
//新增的情况
Long snowFlakeId = securityUser.getSnowFlakeId();
if (snowFlakeId == null) {
@ -74,4 +87,18 @@ public class ProjectManageIndexServiceImpl implements ProjectManageIndexService
throw new MessageException();
}
}
@Override
public ResponseEntity<Resource> shareForm_QR_Code(String path, Integer width) {
WxMaQrcodeService qrcodeService = wxMaService.getQrcodeService();
try {
File qrcodeFile = qrcodeService.createQrcode(path, width);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + qrcodeFile.getName())
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(new FileSystemResource(qrcodeFile));
} catch (WxErrorException e) {
throw new MessageException("生成表单二维码失败:{}", e.getMessage());
}
}
}

View File

@ -144,9 +144,9 @@ sa-token:
wx:
miniapp:
#微信小程序的appid
appid: wx8902ddbfddb820d1
appid: wx0acd1c4fcf94bdd3
#微信小程序的Secret
secret: 8674decea33df3362245937444944596
secret: 4b700dbacb42ef258537ddc61d964a17
msgDataFormat: JSON
project:

View File

@ -48,6 +48,7 @@
ad4.name as 'streetName',
JSON_ARRAYAGG(JSON_OBJECT(
'snowFlakeId', sp.snow_flake_id,
'securityUnitId',sp.security_unit_id,
'name', sp.name,
'type', sp.type,
'isRecruitSecurity', sp.is_recruit_security,