diff --git a/gan-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/mail/ALiYunMailUtil.java b/gan-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/mail/ALiYunMailUtil.java new file mode 100644 index 0000000..5a62284 --- /dev/null +++ b/gan-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/mail/ALiYunMailUtil.java @@ -0,0 +1,98 @@ +package com.ruoyi.common.core.utils.mail; + +import java.util.Properties; +import javax.activation.DataHandler; +import javax.activation.FileDataSource; +import javax.mail.Authenticator; +import javax.mail.BodyPart; +import javax.mail.Message; +import javax.mail.Multipart; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import javax.mail.internet.MimeUtility; + +import org.apache.commons.lang3.StringUtils; + +public class ALiYunMailUtil { + + private static final String SEND_ADDRESS = "mail@gbgobig.com"; + private static final String SEND_PASSWORD = "ganbeigobig@2024"; + private static final String HOST = "smtp.qiye.aliyun.com"; + private static final String PORT = "25"; // 或80 + private static final String SUBJECT = "Email verification code"; + private static final String FILE_PATH = null; + private static final String CC = null; + + /** + * @param content 邮件内容 + * @param internetAddress 收件人地址 + * @throws Exception + * @throws AddressException + */ + public static void sendMail(String content, String internetAddress) throws AddressException, Exception { + // 设置SSL连接、邮件环境 + // Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + // final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; + Properties props = System.getProperties(); + props.setProperty("mail.smtp.host", HOST); + // props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY); + props.setProperty("mail.smtp.socketFactory.fallback", "false"); + props.setProperty("mail.smtp.port", PORT); // 设置端口 + props.setProperty("mail.debug", "true"); // 启用调试 + props.setProperty("mail.smtp.socketFactory.port", "465"); + props.setProperty("mail.smtp.auth", "true"); + + // 建立邮件会话 + Session session = Session.getDefaultInstance(props, new Authenticator() { // 身份认证 + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(SEND_ADDRESS, SEND_PASSWORD); // 发件人账号、密码 + } + }); + + // 建立邮件对象 + MimeMessage message = new MimeMessage(session); + + // 设置邮件的发件人、收件人、主题 + message.setFrom(new InternetAddress(SEND_ADDRESS)); // 发件人账号 + message.setRecipients(Message.RecipientType.TO, internetAddress); // 收件人账号 + + // 标题 + message.setSubject(SUBJECT); // 邮件标题 + + // 内容 + Multipart multipart = new MimeMultipart(); + BodyPart contentPart = new MimeBodyPart(); + // 将内容包装在HTML样式标签中,调整字体粗细 + String styledContent = "

" + + content + + "

"; + contentPart.setContent(styledContent, "text/html;charset=utf-8"); // 邮件内容 + multipart.addBodyPart(contentPart); + + // 附件部分 + if (StringUtils.isNotBlank(FILE_PATH)) { + BodyPart attachPart = new MimeBodyPart(); + FileDataSource fileDataSource = new FileDataSource(FILE_PATH); // 附件地址 D:/题库上传模板v1.xlsx + attachPart.setDataHandler(new DataHandler(fileDataSource)); + attachPart.setFileName(MimeUtility.encodeText(fileDataSource.getName())); + multipart.addBodyPart(attachPart); + } + + message.setContent(multipart); + + // 抄送地址 + if (StringUtils.isNotBlank(CC)) { + InternetAddress[] internetAddressCC = new InternetAddress().parse(CC); + message.setRecipients(Message.RecipientType.CC, internetAddressCC); + } + + // 发送邮件 + Transport.send(message); + } +} \ No newline at end of file diff --git a/gan-modules/ruoyi-gan/pom.xml b/gan-modules/ruoyi-gan/pom.xml index 465f1ec..3faf0c9 100644 --- a/gan-modules/ruoyi-gan/pom.xml +++ b/gan-modules/ruoyi-gan/pom.xml @@ -148,6 +148,19 @@ org.thymeleaf thymeleaf + + + javax.mail + javax.mail-api + 1.6.2 + + + + + com.sun.mail + javax.mail + 1.6.2 + diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppCountryController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppCountryController.java index 0320086..8e4c95d 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppCountryController.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppCountryController.java @@ -1,5 +1,6 @@ package com.ruoyi.app.controller; +import java.util.ArrayList; import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppLoginController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppLoginController.java index 75cc4b2..3fa5f5c 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppLoginController.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppLoginController.java @@ -58,7 +58,7 @@ public class AppLoginController { private IAppRegisterService appRegisterService; @Autowired - private RedisService redisService; + private RedisService redisService; @Autowired private IAppSchoolService schoolService; @@ -103,24 +103,24 @@ public class AppLoginController { // } // } else { - if (register != null && register.getStatus() != null) { + if (register != null && register.getStatus() != null) { - switch (register.getStatus()) { - case 0: - return R.fail(201, "请等待,您的账号正在审核中!"); - case 1: - return R.fail(201, "您的账号已通过"); - case 2: - appRegisterService.updateAppRegisterByPhone(register); - break; - } - }else{ - AppRegister appRegister = setAppRegister(registerForm); - appRegister.setInvitationCode(registerForm.getInvitationCode()); - int i = appRegisterService.insertAppRegister(appRegister); - Assert.isTrue(i > 0, "注册失败"); + switch (register.getStatus()) { + case 0: + return R.ok(null, "请等待,您的账号正在审核中!"); + case 1: + return R.ok(null, "您的账号已通过"); + case 2: + appRegisterService.updateAppRegisterByPhone(register); + break; } + } else { + AppRegister appRegister = setAppRegister(registerForm); + appRegister.setInvitationCode(registerForm.getInvitationCode()); + int i = appRegisterService.insertAppRegister(appRegister); + Assert.isTrue(i > 0, "注册失败"); + } // } return R.ok(null, "申请成功,请等待审核结果!"); } @@ -129,7 +129,25 @@ public class AppLoginController { @ApiOperation(value = "登录", notes = "登录") public R login(@RequestBody LoginForm loginForm) { AppUser appUser = appUserService.selectAppUserByPhone(loginForm.getPhoneNumber()); - Assert.notNull(appUser, "手机号未注册"); + + + if (appUser == null) { + AppRegister register = appRegisterService.selectAppRegisterByphone(loginForm.getPhoneNumber()); + + if (register != null && register.getStatus() != null) { + + switch (register.getStatus()) { + case 0: + return R.fail(201, "请等待,您的账号正在审核中!"); + case 1: + return R.ok(null, "您的账号已通过"); + case 2: + appRegisterService.updateAppRegisterByPhone(register); + } + } + } else { + Assert.notNull(appUser, "手机号未注册"); + } // Object cacheObject = redisService.getCacheObject(loginForm.getPhoneNumber()); // if (cacheObject != null) { @@ -213,13 +231,10 @@ public class AppLoginController { } - @DeleteMapping("logout") - public R logout(HttpServletRequest request) - { + public R logout(HttpServletRequest request) { String token = SecurityUtils.getToken(request); - if (StringUtils.isNotEmpty(token)) - { + if (StringUtils.isNotEmpty(token)) { // 删除用户缓存记录 AuthUtil.logoutByToken(token); } @@ -227,8 +242,8 @@ public class AppLoginController { } - @RequestMapping(path = "/activation/{token}/{email}",method = RequestMethod.GET) - public String activation(@PathVariable String token , @PathVariable String email) { + @RequestMapping(path = "/activation/{token}/{email}", method = RequestMethod.GET) + public String activation(@PathVariable String token, @PathVariable String email) { Map cacheMap = redisService.getCacheMap(token); if (email.equals(cacheMap.get("email"))) { AppRegister appRegister = (AppRegister) cacheMap.get("email"); diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppRegisterController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppRegisterController.java index 0e4c431..3d2d6c8 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppRegisterController.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppRegisterController.java @@ -1,11 +1,22 @@ package com.ruoyi.app.controller; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; +import cn.hutool.http.HttpUtil; import com.ruoyi.app.domain.vo.AppRegisterVo; import io.swagger.annotations.Api; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.ruoyi.common.log.annotation.Log; @@ -21,15 +32,14 @@ import springfox.documentation.annotations.ApiIgnore; /** * 注册审核Controller - * + * * @author wyh * @date 2024-04-23 */ @RestController @RequestMapping("/register") @ApiIgnore -public class AppRegisterController extends BaseController -{ +public class AppRegisterController extends BaseController { @Autowired private IAppRegisterService appRegisterService; @@ -38,22 +48,21 @@ public class AppRegisterController extends BaseController */ @RequiresPermissions("app:register:list") @GetMapping("/list") - public TableDataInfo list(AppRegister appRegister) - { + public TableDataInfo list(AppRegister appRegister) { startPage(); List list = appRegisterService.selectAppRegisterList(appRegister); - return getDataTable(list); + TableDataInfo dataTable = getDataTable(list); + dataTable.setTotal(appRegisterService.selectAppRegisterCount(appRegister)); + return dataTable; } - /** * 获取注册审核详细信息 */ @RequiresPermissions("app:register:query") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(appRegisterService.selectAppRegisterById(id)); } @@ -63,8 +72,7 @@ public class AppRegisterController extends BaseController @RequiresPermissions("app:register:add") @Log(title = "注册审核", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody AppRegister appRegister) - { + public AjaxResult add(@RequestBody AppRegister appRegister) { return toAjax(appRegisterService.insertAppRegister(appRegister)); } @@ -74,8 +82,7 @@ public class AppRegisterController extends BaseController @RequiresPermissions("app:register:edit") @Log(title = "注册审核", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody AppRegister appRegister) - { + public AjaxResult edit(@RequestBody AppRegister appRegister) { return toAjax(appRegisterService.updateAppRegister(appRegister)); } @@ -84,22 +91,37 @@ public class AppRegisterController extends BaseController */ @RequiresPermissions("app:register:remove") @Log(title = "注册审核", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(appRegisterService.deleteAppRegisterByIds(ids)); } @GetMapping("/pass") - public AjaxResult pass(@RequestParam("id") Long id){ + public AjaxResult pass(@RequestParam("id") Long id) { return toAjax(appRegisterService.passAppRegister(id)); } @PostMapping("/reject") - public AjaxResult reject(@RequestBody AppRegister appRegister) - { + public AjaxResult reject(@RequestBody AppRegister appRegister) { return toAjax(appRegisterService.rejectAppRegister(appRegister)); } + + public static void main(String[] args) { + HttpClient httpClient = HttpClients.createDefault(); + String pushId = "7e63c670480d8f2060f8d21800c3ae17"; + String url = "https://tcb-am7ffkwasxkewhf-3cpy096b83a1.service.tcloudbase.com/urlPush/pushId?pushId=" + pushId + "&title=审核失败&content=审核被驳回"; + + try { + HttpGet request = new HttpGet(url); + HttpResponse response = httpClient.execute(request); + + // Get the response entity as a String + String jsonResponse = EntityUtils.toString(response.getEntity()); + System.out.println(jsonResponse); + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppSchoolController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppSchoolController.java index c634fe0..ebd0878 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppSchoolController.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppSchoolController.java @@ -4,6 +4,8 @@ import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.domain.SysUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,7 @@ import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.utils.poi.ExcelUtil; import com.ruoyi.common.core.web.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; /** * 学校配置Controller @@ -55,15 +58,14 @@ public class AppSchoolController extends BaseController /** * 导出学校配置列表 */ -// @RequiresPermissions("app:school:export") -// @Log(title = "学校配置", businessType = BusinessType.EXPORT) -// @PostMapping("/export") -// public void export(HttpServletResponse response, AppSchool appSchool) -// { -// List list = appSchoolService.selectAppSchoolList(appSchool); -// ExcelUtil util = new ExcelUtil(AppSchool.class); -// util.exportExcel(response, list, "学校配置数据"); -// } + @Log(title = "学校配置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, AppSchool appSchool) + { + List list = appSchoolService.selectAppSchoolList(appSchool); + ExcelUtil util = new ExcelUtil(AppSchool.class); + util.exportExcel(response, list, "学校配置数据"); + } /** * 获取学校配置详细信息 @@ -111,4 +113,21 @@ public class AppSchoolController extends BaseController { return toAjax(appSchoolService.deleteAppSchoolByIds(ids)); } + + + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) throws IOException + { + ExcelUtil util = new ExcelUtil(AppSchool.class); + util.importTemplateExcel(response, "学校数据"); + } + + @PostMapping("/importData") + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception + { + ExcelUtil util = new ExcelUtil(AppSchool.class); + List userList = util.importExcel(file.getInputStream()); + String message = appSchoolService.importSchool(userList, updateSupport); + return success(message); + } } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppTopicController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppTopicController.java index 94c95e8..201a52a 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppTopicController.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppTopicController.java @@ -116,10 +116,15 @@ public class AppTopicController extends BaseController */ @RequiresPermissions("app:topic:remove") @Log(title = "话题信息", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{id}") @ApiOperation(value = "删除话题信息", notes = "删除话题信息", httpMethod = "DELETE") - public AjaxResult remove(@PathVariable Long[] ids) + public AjaxResult remove(@PathVariable Long id) { - return toAjax(appTopicService.deleteAppTopicByIds(ids)); + + if (appTopicService.hasChildById(id)) { + return warn("存在子集数据,不允许删除"); + } + + return toAjax(appTopicService.deleteAppTopicByIds(id)); } } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java index 3f514d2..7849be3 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java @@ -219,6 +219,7 @@ public class PayController extends BaseController order.setPaySoure(3); order.setCreateTime(new Date()); order.setLevel(1); + order.setOutTradeNo( KeyUtil.generateUniqueKey()); appOrderMapper.insertAppOrder(order); //修改用户信息 diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/vo/AppRegisterVo.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/vo/AppRegisterVo.java index d783396..4faf813 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/vo/AppRegisterVo.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/vo/AppRegisterVo.java @@ -1,39 +1,60 @@ package com.ruoyi.app.domain.vo; +import com.ruoyi.app.domain.AppRegister; import com.ruoyi.common.core.annotation.Excel; import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) @Data -public class AppRegisterVo { +public class AppRegisterVo extends AppRegister { private static final long serialVersionUID = 1L; - /** 审核id */ + /** + * 审核id + */ private Long id; - /** 手机号 */ + /** + * 手机号 + */ private String phone; - /** 用户名 */ + /** + * 用户名 + */ private String username; - /** 学校证明 */ + /** + * 学校证明 + */ private String prove; - /** 头像 */ + /** + * 头像 + */ private String avatarUrl; - /** 性别:0-男,1-女 */ + /** + * 性别:0-男,1-女 + */ private Integer sex; - /** 地址 */ + /** + * 地址 + */ private String address; - /** 学校id */ + /** + * 学校id + */ private Long schoolId; private String schoolName; - /** 邮箱 */ + /** + * 邮箱 + */ private String email; diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppRegisterMapper.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppRegisterMapper.java index ac0c38e..b449769 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppRegisterMapper.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppRegisterMapper.java @@ -64,4 +64,7 @@ public interface AppRegisterMapper String phoneNumber); int updateAppRegisterByPhone(AppRegister appRegister); + + long selectAppRegisterCount(AppRegister appRegister); + } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppSchoolMapper.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppSchoolMapper.java index e87327b..988b4f0 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppSchoolMapper.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppSchoolMapper.java @@ -61,4 +61,8 @@ public interface AppSchoolMapper public int deleteAppSchoolByIds(Long[] ids); List selectAppSchoolAllList(@Param("name") String name); + + public AppSchool selectAppSchoolByName(String name); + + public int updateAppSchoolByName(AppSchool appSchool); } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppTopicMapper.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppTopicMapper.java index b16f681..3ed3dd5 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppTopicMapper.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppTopicMapper.java @@ -59,5 +59,7 @@ public interface AppTopicMapper * @param ids 需要删除的数据主键集合 * @return 结果 */ - public int deleteAppTopicByIds(Long[] ids); + public int deleteAppTopicByIds(Long id); + + public int hasChildById(Long id); } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppRegisterService.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppRegisterService.java index e313ca7..6e2cacf 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppRegisterService.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppRegisterService.java @@ -68,4 +68,6 @@ public interface IAppRegisterService AppRegister selectAppRegisterByphone(String phoneNumber); + + long selectAppRegisterCount(AppRegister appRegister); } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppSchoolService.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppSchoolService.java index 314dcbb..20f64ad 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppSchoolService.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppSchoolService.java @@ -2,6 +2,7 @@ package com.ruoyi.app.service; import java.util.List; import com.ruoyi.app.domain.AppSchool; +import com.ruoyi.system.api.domain.SysUser; /** * 学校配置Service接口 @@ -60,4 +61,6 @@ public interface IAppSchoolService public int deleteAppSchoolById(Long id); List selectAppSchoolAllList(String name); + + public String importSchool(List userList, boolean updateSupport); } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppTopicService.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppTopicService.java index ac30327..03bbba0 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppTopicService.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppTopicService.java @@ -51,7 +51,7 @@ public interface IAppTopicService * @param ids 需要删除的话题信息主键集合 * @return 结果 */ - public int deleteAppTopicByIds(Long[] ids); + public int deleteAppTopicByIds(Long id); /** * 删除话题信息信息 @@ -60,4 +60,6 @@ public interface IAppTopicService * @return 结果 */ public int deleteAppTopicById(Long id); + + boolean hasChildById(Long id); } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppRegisterServiceImpl.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppRegisterServiceImpl.java index 9f89f14..7c3e87a 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppRegisterServiceImpl.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppRegisterServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.stream.Collectors; import cn.hutool.core.lang.Assert; +import cn.hutool.http.HttpUtil; import com.ruoyi.app.domain.AppSchool; import com.ruoyi.app.domain.AppUser; import com.ruoyi.app.domain.vo.AppRegisterVo; @@ -12,8 +13,14 @@ import com.ruoyi.app.mapper.AppUserMapper; import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.bean.BeanUtils; +import com.ruoyi.common.core.utils.mail.ALiYunMailUtil; import com.ruoyi.common.core.utils.mail.MailUtil; import com.ruoyi.common.core.utils.uuid.IdUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.app.mapper.AppRegisterMapper; @@ -24,13 +31,12 @@ import javax.mail.MessagingException; /** * 注册审核Service业务层处理 - * + * * @author wyh * @date 2024-04-23 */ @Service -public class AppRegisterServiceImpl implements IAppRegisterService -{ +public class AppRegisterServiceImpl implements IAppRegisterService { @Autowired private AppRegisterMapper appRegisterMapper; @@ -42,27 +48,26 @@ public class AppRegisterServiceImpl implements IAppRegisterService /** * 查询注册审核 - * + * * @param id 注册审核主键 * @return 注册审核 */ @Override - public AppRegister selectAppRegisterById(Long id) - { + public AppRegister selectAppRegisterById(Long id) { return appRegisterMapper.selectAppRegisterById(id); } /** * 查询注册审核列表 - * + * * @param appRegister 注册审核 * @return 注册审核 */ @Override - public List selectAppRegisterList(AppRegister appRegister) - { + public List selectAppRegisterList(AppRegister appRegister) { + List appRegisters = appRegisterMapper.selectAppRegisterList(appRegister); - List collect = appRegisters.stream().map(register -> { + return appRegisters.stream().map(register -> { AppRegisterVo appRegisterVo = new AppRegisterVo(); BeanUtils.copyBeanProp(appRegisterVo, register); AppSchool appSchool = appSchoolMapper.selectAppSchoolById(register.getSchoolId()); @@ -72,31 +77,28 @@ public class AppRegisterServiceImpl implements IAppRegisterService return appRegisterVo; }).collect(Collectors.toList()); - return collect; } /** * 新增注册审核 - * + * * @param appRegister 注册审核 * @return 结果 */ @Override - public int insertAppRegister(AppRegister appRegister) - { + public int insertAppRegister(AppRegister appRegister) { appRegister.setCreateTime(DateUtils.getNowDate()); return appRegisterMapper.insertAppRegister(appRegister); } /** * 修改注册审核 - * + * * @param appRegister 注册审核 * @return 结果 */ @Override - public int updateAppRegister(AppRegister appRegister) - { + public int updateAppRegister(AppRegister appRegister) { appRegister.setUpdateTime(DateUtils.getNowDate()); return appRegisterMapper.updateAppRegister(appRegister); } @@ -109,25 +111,23 @@ public class AppRegisterServiceImpl implements IAppRegisterService /** * 批量删除注册审核 - * + * * @param ids 需要删除的注册审核主键 * @return 结果 */ @Override - public int deleteAppRegisterByIds(Long[] ids) - { + public int deleteAppRegisterByIds(Long[] ids) { return appRegisterMapper.deleteAppRegisterByIds(ids); } /** * 删除注册审核信息 - * + * * @param id 注册审核主键 * @return 结果 */ @Override - public int deleteAppRegisterById(Long id) - { + public int deleteAppRegisterById(Long id) { return appRegisterMapper.deleteAppRegisterById(id); } @@ -135,7 +135,7 @@ public class AppRegisterServiceImpl implements IAppRegisterService public int passAppRegister(Long id) { AppRegister appRegister = appRegisterMapper.selectAppRegisterById(id); Assert.isTrue(appRegister != null, "该申请不存在"); - Assert.isTrue( appRegister.getStatus()!= null && appRegister.getStatus() == 0, "该申请已审核"); + Assert.isTrue(appRegister.getStatus() != null && appRegister.getStatus() == 0, "该申请已审核"); appRegister.setStatus(1); appRegister.setUpdateTime(DateUtils.getNowDate()); int i = appRegisterMapper.updateAppRegister(appRegister); @@ -144,23 +144,38 @@ public class AppRegisterServiceImpl implements IAppRegisterService BeanUtils.copyProperties(appRegister, appUser); appUser.setCreateTime(DateUtils.getNowDate()); appUser.setUpdateTime(DateUtils.getNowDate()); - appUser.setPhone(appRegister.getPhone() != null ? appRegister.getPhone():null); - appUser.setEmail(appRegister.getEmail() != null ? appRegister.getEmail():null); - appUser.setSchool(appRegister.getSchoolId() != null ? appRegister.getSchoolId():null); - appUser.setUsername(appRegister.getUsername() != null ? appRegister.getUsername():null); - appUser.setAddress(appRegister.getAddress() != null ? appRegister.getAddress():null); - appUser.setSex(Long.valueOf(appRegister.getSex() != null ? appRegister.getSex():null)); - appUser.setAvatarUrl(appRegister.getAvatarUrl() != null ? appRegister.getAvatarUrl():null); - appUser.setCompanyName(appRegister.getCompanyName() != null ? appRegister.getCompanyName():null); - appUser.setEducation(appRegister.getEducation() != null ? appRegister.getEducation():null); - appUser.setMajor(appRegister.getMajor() != null ? appRegister.getMajor():null); - appUser.setPushId(appRegister.getPushId() != null ? appRegister.getPushId():null); - appUser.setNickname(appRegister.getNickname() != null ? appRegister.getNickname():null); - appUser.setProvinceId(appRegister.getProvinceId() != null ? appRegister.getProvinceId():null); - appUser.setCityId(appRegister.getCityId() != null ? appRegister.getCityId():null); - appUser.setTownId(appRegister.getTownId() != null ? appRegister.getTownId():null); + appUser.setPhone(appRegister.getPhone() != null ? appRegister.getPhone() : null); + appUser.setEmail(appRegister.getEmail() != null ? appRegister.getEmail() : null); + appUser.setSchool(appRegister.getSchoolId() != null ? appRegister.getSchoolId() : null); + appUser.setUsername(appRegister.getUsername() != null ? appRegister.getUsername() : null); + appUser.setAddress(appRegister.getAddress() != null ? appRegister.getAddress() : null); + appUser.setSex(Long.valueOf(appRegister.getSex() != null ? appRegister.getSex() : null)); + appUser.setAvatarUrl(appRegister.getAvatarUrl() != null ? appRegister.getAvatarUrl() : null); + appUser.setCompanyName(appRegister.getCompanyName() != null ? appRegister.getCompanyName() : null); + appUser.setEducation(appRegister.getEducation() != null ? appRegister.getEducation() : null); + appUser.setMajor(appRegister.getMajor() != null ? appRegister.getMajor() : null); + appUser.setPushId(appRegister.getPushId() != null ? appRegister.getPushId() : null); + appUser.setNickname(appRegister.getNickname() != null ? appRegister.getNickname() : null); + appUser.setProvinceId(appRegister.getProvinceId() != null ? appRegister.getProvinceId() : null); + appUser.setCityId(appRegister.getCityId() != null ? appRegister.getCityId() : null); + appUser.setTownId(appRegister.getTownId() != null ? appRegister.getTownId() : null); appUserMapper.insertAppUser(appUser); + HttpClient httpClient = HttpClients.createDefault(); + String pushId = appRegister.getPushId() != null ? appRegister.getPushId() : null; + String url = "https://tcb-am7ffkwasxkewhf-3cpy096b83a1.service.tcloudbase.com/urlPush/pushId?pushId=" + pushId + "&title=审核完成&content=审核已通过!"; + + try { + HttpGet request = new HttpGet(url); + HttpResponse response = httpClient.execute(request); + + // Get the response entity as a String + String jsonResponse = EntityUtils.toString(response.getEntity()); + System.out.println(jsonResponse); + } catch (Exception e) { + e.printStackTrace(); + } } + return i; } @@ -175,7 +190,24 @@ public class AppRegisterServiceImpl implements IAppRegisterService register.setRemark(appRegister.getRemark()); } appRegister.setUpdateTime(DateUtils.getNowDate()); - return appRegisterMapper.updateAppRegister(appRegister); + int i = appRegisterMapper.updateAppRegister(appRegister); + if (i > 0) { + HttpClient httpClient = HttpClients.createDefault(); + String pushId = appRegister.getPushId() != null ? appRegister.getPushId() : null; + String url = "https://tcb-am7ffkwasxkewhf-3cpy096b83a1.service.tcloudbase.com/urlPush/pushId?pushId=" + pushId + "&title=审核失败&content=审核已被驳回!"; + + try { + HttpGet request = new HttpGet(url); + HttpResponse response = httpClient.execute(request); + + // Get the response entity as a String + String jsonResponse = EntityUtils.toString(response.getEntity()); + System.out.println(jsonResponse); + } catch (Exception e) { + e.printStackTrace(); + } + } + return i; } @Override @@ -184,17 +216,24 @@ public class AppRegisterServiceImpl implements IAppRegisterService return appRegisterMapper.selectAppRegisterByphone(phoneNumber); } + @Override + public long selectAppRegisterCount(AppRegister appRegister) { + return appRegisterMapper.selectAppRegisterCount(appRegister); + } + public static void main(String[] args) { String token = "4e290542-53f3-4a33-96ff-9510dd050100"; String email = "653809315@qq.com"; String EM = "

欢迎来到我们的服务!!

" + "

请点击下面的网址确认您的注册:

" - + "

http://101.133.172.2:9204/app/activation/"+ token + "/" + email + "

" + + "

http://127.0.0.1:9204/app/activation/" + token + "/" + email + "

" + ""; try { - MailUtil.send_mail( "653809315@qq.com",EM); - } catch (MessagingException e) { + ALiYunMailUtil.sendMail(EM, email); + } catch (MessagingException e) { + throw new RuntimeException(e); + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppSchoolServiceImpl.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppSchoolServiceImpl.java index 1a6a23d..839de58 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppSchoolServiceImpl.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppSchoolServiceImpl.java @@ -1,59 +1,66 @@ package com.ruoyi.app.service.impl; import java.util.List; + +import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.utils.bean.BeanValidators; import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.domain.SysUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.app.mapper.AppSchoolMapper; import com.ruoyi.app.domain.AppSchool; import com.ruoyi.app.service.IAppSchoolService; +import javax.validation.Validator; + /** * 学校配置Service业务层处理 - * + * * @author wyh * @date 2024-04-18 */ @Service -public class AppSchoolServiceImpl implements IAppSchoolService -{ +public class AppSchoolServiceImpl implements IAppSchoolService { @Autowired private AppSchoolMapper appSchoolMapper; + + @Autowired + protected Validator validator; + /** * 查询学校配置 - * + * * @param id 学校配置主键 * @return 学校配置 */ @Override - public AppSchool selectAppSchoolById(Long id) - { + public AppSchool selectAppSchoolById(Long id) { return appSchoolMapper.selectAppSchoolById(id); } /** * 查询学校配置列表 - * + * * @param appSchool 学校配置 * @return 学校配置 */ @Override - public List selectAppSchoolList(AppSchool appSchool) - { + public List selectAppSchoolList(AppSchool appSchool) { return appSchoolMapper.selectAppSchoolList(appSchool); } /** * 新增学校配置 - * + * * @param appSchool 学校配置 * @return 结果 */ @Override - public int insertAppSchool(AppSchool appSchool) - { + public int insertAppSchool(AppSchool appSchool) { appSchool.setCreateTime(DateUtils.getNowDate()); appSchool.setUpdateTime(DateUtils.getNowDate()); appSchool.setCreateBy(SecurityUtils.getUsername()); @@ -63,13 +70,12 @@ public class AppSchoolServiceImpl implements IAppSchoolService /** * 修改学校配置 - * + * * @param appSchool 学校配置 * @return 结果 */ @Override - public int updateAppSchool(AppSchool appSchool) - { + public int updateAppSchool(AppSchool appSchool) { appSchool.setUpdateTime(DateUtils.getNowDate()); appSchool.setUpdateBy(SecurityUtils.getUsername()); return appSchoolMapper.updateAppSchool(appSchool); @@ -77,31 +83,73 @@ public class AppSchoolServiceImpl implements IAppSchoolService /** * 批量删除学校配置 - * + * * @param ids 需要删除的学校配置主键 * @return 结果 */ @Override - public int deleteAppSchoolByIds(Long[] ids) - { + public int deleteAppSchoolByIds(Long[] ids) { return appSchoolMapper.deleteAppSchoolByIds(ids); } /** * 删除学校配置信息 - * + * * @param id 学校配置主键 * @return 结果 */ @Override - public int deleteAppSchoolById(Long id) - { + public int deleteAppSchoolById(Long id) { return appSchoolMapper.deleteAppSchoolById(id); } @Override public List selectAppSchoolAllList(String name) { - return appSchoolMapper.selectAppSchoolAllList(name); + return appSchoolMapper.selectAppSchoolAllList(name); } + + @Override + public String importSchool(List schoolList, boolean updateSupport) { + if (StringUtils.isNull(schoolList) || schoolList.size() == 0) { + throw new ServiceException("导入学校数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (AppSchool appSchool : schoolList) { + try { + // 验证是否存在这个用户 + AppSchool s = appSchoolMapper.selectAppSchoolByName(appSchool.getName()); + if (StringUtils.isNull(s)) { + BeanValidators.validateWithException(validator, appSchool); + appSchoolMapper.insertAppSchool(appSchool); + successNum++; + successMsg.append("
" + successNum + "、学校 " + appSchool.getName() + " 导入成功"); + } else if (updateSupport) { + BeanValidators.validateWithException(validator, appSchool); + appSchool.setUpdateTime(DateUtils.getNowDate()); + appSchoolMapper.updateAppSchoolByName(appSchool); + successNum++; + successMsg.append("
" + successNum + "、学校 " + appSchool.getName() + " 更新成功"); + } else { + failureNum++; + failureMsg.append("
" + failureNum + "、学校 " + appSchool.getName() + " 已存在"); + } + } catch (Exception e) { + failureNum++; + String msg = "
" + failureNum + "、学校 " + appSchool.getName() + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + } + } + if (failureNum > 0) { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } else { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } } + diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppTopicServiceImpl.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppTopicServiceImpl.java index 6f382ac..df80214 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppTopicServiceImpl.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppTopicServiceImpl.java @@ -95,13 +95,13 @@ public class AppTopicServiceImpl implements IAppTopicService /** * 批量删除话题信息 * - * @param ids 需要删除的话题信息主键 + * @param id 需要删除的话题信息主键 * @return 结果 */ @Override - public int deleteAppTopicByIds(Long[] ids) + public int deleteAppTopicByIds(Long id) { - return appTopicMapper.deleteAppTopicByIds(ids); + return appTopicMapper.deleteAppTopicByIds(id); } /** @@ -115,4 +115,10 @@ public class AppTopicServiceImpl implements IAppTopicService { return appTopicMapper.deleteAppTopicById(id); } + + @Override + public boolean hasChildById(Long id) { + int i = appTopicMapper.hasChildById(id); + return i > 0; + } } diff --git a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppRegisterMapper.xml b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppRegisterMapper.xml index d48ef42..43b4794 100644 --- a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppRegisterMapper.xml +++ b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppRegisterMapper.xml @@ -45,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and school_id = #{schoolId} and email = #{email} + order by create_time desc + select count(1) from app_register + \ No newline at end of file diff --git a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppSchoolMapper.xml b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppSchoolMapper.xml index f3fb483..52e2631 100644 --- a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppSchoolMapper.xml +++ b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppSchoolMapper.xml @@ -102,4 +102,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and name like concat('%', #{name}, '%') + + + + + update app_school + + create_time = #{createTime}, + update_time = #{updateTime}, + email = #{email}, + school_img = #{schoolImg}, + + where name = #{name} + \ No newline at end of file diff --git a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppTopicMapper.xml b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppTopicMapper.xml index b1f483e..bda2738 100644 --- a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppTopicMapper.xml +++ b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppTopicMapper.xml @@ -91,9 +91,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from app_topic where id in - - #{id} - + delete from app_topic where id = #{id} + + \ No newline at end of file diff --git a/gan-ui/src/views/app/register/index.vue b/gan-ui/src/views/app/register/index.vue index 13b7989..7dcf8dc 100644 --- a/gan-ui/src/views/app/register/index.vue +++ b/gan-ui/src/views/app/register/index.vue @@ -269,7 +269,6 @@ export default { this.schoolList = response.rows; this.total = response.total; this.loading = false; - console.log(response.rows); this.schoolOptions = response.rows; // Correct way to update schoolOptions }); }, @@ -279,6 +278,7 @@ export default { listRegister(this.queryParams).then(response => { this.registerList = response.rows; this.total = response.total; + console.log(response.total); this.loading = false; }); }, diff --git a/gan-ui/src/views/app/school/index.vue b/gan-ui/src/views/app/school/index.vue index 61c96d4..0d78107 100644 --- a/gan-ui/src/views/app/school/index.vue +++ b/gan-ui/src/views/app/school/index.vue @@ -36,25 +36,12 @@ 修改 - - - 删除 + @click="handleImport" + >导入 - + + + + diff --git a/gan-ui/src/views/app/topic/index.vue b/gan-ui/src/views/app/topic/index.vue index c3f23b1..e1942a0 100644 --- a/gan-ui/src/views/app/topic/index.vue +++ b/gan-ui/src/views/app/topic/index.vue @@ -1,3 +1,5 @@ + + diff --git a/gan-ui/src/views/system/operlog/index.vue b/gan-ui/src/views/system/operlog/index.vue index 11032d5..5ab126c 100644 --- a/gan-ui/src/views/system/operlog/index.vue +++ b/gan-ui/src/views/system/operlog/index.vue @@ -256,6 +256,7 @@ export default { list(this.addDateRange(this.queryParams, this.dateRange)).then( response => { this.list = response.rows; this.total = response.total; + console.log(response.total); this.loading = false; } );