后台bug修改

main
王宇航 2024-05-28 13:50:34 +08:00
parent c4df190033
commit 061afaa89a
25 changed files with 650 additions and 213 deletions

View File

@ -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 = "<html><body><p style='font-weight: normal;'>"
+ content
+ "</p></body></html>";
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);
}
}

View File

@ -148,6 +148,19 @@
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<!-- JavaMail API -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.6.2</version>
</dependency>
<!-- JavaMail implementation (e.g., for SMTP) -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
</dependencies>

View File

@ -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;

View File

@ -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<String, Object> cacheMap = redisService.getCacheMap(token);
if (email.equals(cacheMap.get("email"))) {
AppRegister appRegister = (AppRegister) cacheMap.get("email");

View File

@ -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<AppRegisterVo> 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();
}
}
}

View File

@ -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<AppSchool> list = appSchoolService.selectAppSchoolList(appSchool);
// ExcelUtil<AppSchool> util = new ExcelUtil<AppSchool>(AppSchool.class);
// util.exportExcel(response, list, "学校配置数据");
// }
@Log(title = "学校配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AppSchool appSchool)
{
List<AppSchool> list = appSchoolService.selectAppSchoolList(appSchool);
ExcelUtil<AppSchool> util = new ExcelUtil<AppSchool>(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<AppSchool> util = new ExcelUtil<AppSchool>(AppSchool.class);
util.importTemplateExcel(response, "学校数据");
}
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<AppSchool> util = new ExcelUtil<AppSchool>(AppSchool.class);
List<AppSchool> userList = util.importExcel(file.getInputStream());
String message = appSchoolService.importSchool(userList, updateSupport);
return success(message);
}
}

View File

@ -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));
}
}

View File

@ -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);
//修改用户信息

View File

@ -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;

View File

@ -64,4 +64,7 @@ public interface AppRegisterMapper
String phoneNumber);
int updateAppRegisterByPhone(AppRegister appRegister);
long selectAppRegisterCount(AppRegister appRegister);
}

View File

@ -61,4 +61,8 @@ public interface AppSchoolMapper
public int deleteAppSchoolByIds(Long[] ids);
List<AppSchool> selectAppSchoolAllList(@Param("name") String name);
public AppSchool selectAppSchoolByName(String name);
public int updateAppSchoolByName(AppSchool appSchool);
}

View File

@ -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);
}

View File

@ -68,4 +68,6 @@ public interface IAppRegisterService
AppRegister selectAppRegisterByphone(String phoneNumber);
long selectAppRegisterCount(AppRegister appRegister);
}

View File

@ -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<AppSchool> selectAppSchoolAllList(String name);
public String importSchool(List<AppSchool> userList, boolean updateSupport);
}

View File

@ -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);
}

View File

@ -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<AppRegisterVo> selectAppRegisterList(AppRegister appRegister)
{
public List<AppRegisterVo> selectAppRegisterList(AppRegister appRegister) {
List<AppRegister> appRegisters = appRegisterMapper.selectAppRegisterList(appRegister);
List<AppRegisterVo> 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 = "<html><body><h2>欢迎来到我们的服务!!</h2>"
+ "<p>请点击下面的网址确认您的注册:</p>"
+ "<p>http://101.133.172.2:9204/app/activation/"+ token + "/" + email + "</p>"
+ "<p>http://127.0.0.1:9204/app/activation/" + token + "/" + email + "</p>"
+ "</body></html>";
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);
}
}

View File

@ -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<AppSchool> selectAppSchoolList(AppSchool appSchool)
{
public List<AppSchool> 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<AppSchool> selectAppSchoolAllList(String name) {
return appSchoolMapper.selectAppSchoolAllList(name);
return appSchoolMapper.selectAppSchoolAllList(name);
}
@Override
public String importSchool(List<AppSchool> 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("<br/>" + successNum + "、学校 " + appSchool.getName() + " 导入成功");
} else if (updateSupport) {
BeanValidators.validateWithException(validator, appSchool);
appSchool.setUpdateTime(DateUtils.getNowDate());
appSchoolMapper.updateAppSchoolByName(appSchool);
successNum++;
successMsg.append("<br/>" + successNum + "、学校 " + appSchool.getName() + " 更新成功");
} else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、学校 " + appSchool.getName() + " 已存在");
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + 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();
}
}

View File

@ -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;
}
}

View File

@ -45,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="schoolId != null "> and school_id = #{schoolId}</if>
<if test="email != null and email != ''"> and email = #{email}</if>
</where>
order by create_time desc
</select>
<select id="selectAppRegisterById" parameterType="Long" resultMap="AppRegisterResult">
@ -75,6 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="major != null">major,</if>
<if test="companyName != null">company_name,</if>
<if test="nickname != null">nickname,</if>
<if test="provinceId != null">province_id,</if>
<if test="cityId != null">city_id,</if>
<if test="townId != null">town_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="phone != null">#{phone},</if>
@ -97,6 +101,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="major != null">#{major},</if>
<if test="companyName != null">#{companyName},</if>
<if test="nickname != null">#{nickname},</if>
<if test="provinceId != null">#{provinceId},</if>
<if test="cityId != null">#{cityId},</if>
<if test="townId != null">#{townId},</if>
</trim>
</insert>
@ -158,7 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="schoolId != null">school_id = #{schoolId},</if>
<if test="email != null">email = #{email},</if>
<if test="invitationCode != null">invitation_code = #{invitationCode},</if>
<if test="education != null">education = #{education},</if>
<if test="education != null">education = #{education},</if>
<if test="major != null">major = #{major},</if>
<if test="companyName != null">company_name = #{companyName},</if>
<if test="pushId != null">push_id = #{pushId},</if>
@ -167,4 +174,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where phone = #{phone}
</update>
<select id="selectAppRegisterCount" resultType="long">
select count(1) from app_register
</select>
</mapper>

View File

@ -102,4 +102,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
</where>
</select>
<select id="selectAppSchoolByName" resultMap="AppSchoolResult">
<include refid="selectAppSchoolVo"/>
where name = #{name}
</select>
<update id="updateAppSchoolByName">
update app_school
<trim prefix="SET" suffixOverrides=",">
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="email != null">email = #{email},</if>
<if test="schoolImg != null">school_img = #{schoolImg},</if>
</trim>
where name = #{name}
</update>
</mapper>

View File

@ -91,9 +91,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteAppTopicByIds" parameterType="String">
delete from app_topic where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
delete from app_topic where id = #{id}
</delete>
<select id="hasChildById" resultType="Integer">
select count(1) from app_topic where parent_id = #{id}
</select>
</mapper>

View File

@ -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;
});
},

View File

@ -36,25 +36,12 @@
</el-col>
<el-col :span="1.5">
<el-button
type="success"
type="info"
plain
icon="el-icon-edit"
icon="el-icon-upload2"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['app:school:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['app:school:remove']"
>删除</el-button>
@click="handleImport"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -70,9 +57,24 @@
</el-row>
<el-table v-loading="loading" :data="schoolList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="学校id" align="center" prop="id" />
<el-table-column label="学校名称" align="center" prop="name" />
<el-table-column label="邮箱后缀" align="center" prop="email" />
<el-table-column
prop="schoolImg"
header-align="center"
align="center"
label="头像"
>
<template slot-scope="scope" class="demo-image__preview">
<img
:src="scope.row.schoolImg"
width="40"
height="40"
class="head_pic"
/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -110,28 +112,58 @@
<el-form-item label="邮箱域名" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱域名" />
</el-form-item>
<el-form-item label="学校头像">
<el-upload
class="avatar-uploader"
action="http://localhost:1024/dev-api//api/oss/upload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload">
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
</el-form-item>
<!-- <el-form-item label="学校头像">-->
<!-- <el-upload-->
<!-- class="avatar-uploader"-->
<!-- action="http://localhost:1024/dev-api//api/oss/upload"-->
<!-- :show-file-list="false"-->
<!-- :on-success="handleAvatarSuccess"-->
<!-- :before-upload="beforeAvatarUpload">-->
<!-- <img v-if="imageUrl" :src="imageUrl" class="avatar">-->
<!-- <i v-else class="el-icon-plus avatar-uploader-icon"></i>-->
<!-- </el-upload>-->
<!-- </el-form-item>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
</div>
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate"></el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listSchool, getSchool, delSchool, addSchool, updateSchool , uploadAvatar } from "@/api/app/school";
import {getToken} from "@/utils/auth";
export default {
name: "School",
@ -165,7 +197,21 @@ export default {
form: {},
//
rules: {
}
},
upload: {
//
open: false,
//
title: "",
//
isUploading: false,
//
updateSupport: 0,
//
headers: { Authorization: "Bearer " + getToken() },
//
url: process.env.VUE_APP_BASE_API + "app/school/importData",
},
};
},
created() {
@ -265,7 +311,27 @@ export default {
this.download('app/school/export', {
...this.queryParams
}, `school_${new Date().getTime()}.xlsx`)
}
},
/** 导入按钮操作 */
handleImport() {
this.upload.title = "学校导入";
this.upload.open = true;
},
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
//
submitFileForm() {
this.$refs.upload.submit();
},
importTemplate() {
this.download('app/school/importTemplate', {
}, `school_template_${new Date().getTime()}.xlsx`)
},
}
};
</script>

View File

@ -1,3 +1,5 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
@ -28,43 +30,23 @@
</el-col>
<el-col :span="1.5">
<el-button
type="success"
type="info"
plain
icon="el-icon-edit"
icon="el-icon-sort"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['app:topic:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['app:topic:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['app:topic:export']"
>导出</el-button>
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="topicList"
@selection-change="handleSelectionChange"
:default-expand-all="isExpandAll"
row-key="id"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
@ -143,14 +125,55 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog :title="title" :visible.sync="openUpdate" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="24" v-if="form.type === '0'">
<el-form-item label="话题分类" prop="name">
<el-input v-model="form.name" placeholder="请输入话题分类" />
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.type === '1'">
<el-form-item label="话题名称" prop="parentId">
<el-select
v-model="form.parentId"
placeholder="请选择话题分类"
>
<el-option
v-for="item in options"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.type === '1'">
<el-form-item label="话题名称" prop="name">
<el-input v-model="form.name" placeholder="请输入话题名称" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listTopic, getTopic, delTopic, addTopic, updateTopic ,listAppTopic } from "@/api/app/topic";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
export default {
name: "Topic",
components: { Treeselect, IconSelect },
data() {
return {
//
@ -163,6 +186,8 @@ export default {
multiple: true,
//
showSearch: true,
refreshTable: true,
isExpandAll: false,
//
total: 0,
//
@ -171,6 +196,7 @@ export default {
title: "",
//
open: false,
openUpdate: false,
//
queryParams: {
pageNum: 1,
@ -195,7 +221,7 @@ export default {
/** 查询话题信息列表 */
getAppTopic() {
this.loading = true;
// this.loading = true;
this.queryParams.parentId = 0;
this.queryParams.pageNum = 1;
this.queryParams.pageSize = 10000;
@ -222,14 +248,14 @@ export default {
//
reset() {
this.form = {
id: null,
name: null,
createTime: null,
updateTime: null,
createBy: null,
updateBy: null,
remark: null,
type: '0'
id: undefined,
name: undefined,
createTime: undefined,
updateTime: undefined,
createBy: undefined,
updateBy: undefined,
remark: undefined,
type: '1'
};
this.resetForm("form");
},
@ -259,11 +285,11 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.getList();
this.getAppTopic();
const id = row.id || this.ids
getTopic(id).then(response => {
this.form = response.data;
this.open = true;
this.openUpdate = true;
this.title = "修改话题信息";
});
},
@ -274,7 +300,9 @@ export default {
if (this.form.id != null) {
updateTopic(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.openUpdate = false;
this.queryParams.parentId = null ;
this.getList();
this.reset();
});
@ -282,7 +310,9 @@ export default {
addTopic(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.queryParams.parentId = null ;
this.getList();
this.reset();
});
}
}
@ -303,7 +333,15 @@ export default {
this.download('app/topic/export', {
...this.queryParams
}, `topic_${new Date().getTime()}.xlsx`)
}
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
},
}
};
</script>

View File

@ -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;
}
);