| | |
| | | package org.springblade.common.utils; |
| | | |
| | | import org.apache.commons.lang.text.StrSubstitutor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | |
| | | import java.io.OutputStreamWriter; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class SmsUtils { |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public static void send(String phone, Map<String, String> content) { |
| | | |
| | | StrSubstitutor strSubstitutor = new StrSubstitutor(content); |
| | | String url3 = "【上饶基层自治】您正在验证投票操作,验证码:${code}。如非本人操作,则密码可能已泄露,建议立即修改密码或联系客服。"; |
| | | String context3 = strSubstitutor.replace(url3); |
| | | String MAS_ID = "182"; |
| | | String PASSWORD = "bYcLgYwXOZspDzEnaGsNHAGUykKEiexknHY9H98xVTQ8Zbeya8bexQ=="; |
| | | String reqXML = buildRequestXMLString(MAS_ID, PASSWORD, "", phone, context3); |
| | | postXMLSendSMSRequest("http://218.204.110.232:8080/emc/HttpSendSMSService", reqXML); |
| | | } |
| | | |
| | | /** |
| | | * @param args |
| | | */ |
| | |
| | | //下面的MAS_ID、PASSWORD仅供测试使用,正式使用由移动公司分配 |
| | | String MAS_ID = "182"; |
| | | String PASSWORD = "bYcLgYwXOZspDzEnaGsNHAGUykKEiexknHY9H98xVTQ8Zbeya8bexQ=="; |
| | | // Map map = new HashMap<>(); |
| | | // map.put("ip", "127.0.0.1"); |
| | | // map.put("port", "3306"); |
| | | // map.put("tenantCode", "test001"); |
| | | // StrSubstitutor strSubstitutor = new StrSubstitutor(map); |
| | | // String url3 = "jdbc:mysql://${ip}:${port}/${tenantCode}?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai"; |
| | | // String context3 = strSubstitutor.replace(url3); |
| | | // System.out.println(context3); |
| | | |
| | | // String reqXML = buildRequestXMLString(MAS_ID, PASSWORD, "", "18720768376", "测试短信"); |
| | | |
| | | // postXMLSendSMSRequest("http://218.204.110.232:8080/emc/HttpSendSMSService", reqXML); |
| | | String reqXML = buildRequestXMLString(MAS_ID, PASSWORD, "", "18720768376", "测试短信"); |
| | | postXMLSendSMSRequest("http://218.204.110.232:8080/emc/HttpSendSMSService", reqXML); |
| | | } |
| | | } |
| | | |
| | |
| | | * @param article 资讯对象信息 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改资讯信息", notes = "传入article") |
| | | public R submit(@RequestBody ArticleVO article) { |
| | | if (null == article.getId()) { |
| | | if (null == article.getCreateTime()) { |
| | |
| | | * 批量修改评论区状态 |
| | | */ |
| | | @PostMapping("/upcomment") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "批量修改评论区状态", notes = "传入article") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, String type) { |
| | | String[] split = ids.split(","); |
| | | String strArrays = ""; |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectArticleG") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "查询个人资讯", notes = "传入article") |
| | | public R<IPage<Article>> selectArticleG(ArticleVO article, Query query) { |
| | | return R.data(articleService.selectArticleG(Condition.getPage(query), article)); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE; |
| | | |
| | | @NonDS |
| | | @ApiIgnore |
| | | @RestController |
| | | @RequestMapping("/blade-email/email") |
| | | @AllArgsConstructor |
| | | @Api(value = "邮件设置", tags = "邮件表接口") |
| | | public class EmailController extends BladeController { |
| | | |
| | | private final IEmailAccountService emailAccountService; |
| | |
| | | package org.springblade.modules.messageRecord.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | |
| | | @TableName("blade_message_user") |
| | | public class MessageUser implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | |
| | | /** 主键 */ |
| | | @ApiModelProperty(value = "主键ID", example = "") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | /** |
| | | * 消息ID |
| | | */ |
| | | private String messageRecordId; |
| | | private Long id; |
| | | |
| | | //用户id |
| | | private String userId; |
| | | /** 消息记录表主键 */ |
| | | @ApiModelProperty(value = "消息记录表主键", example = "") |
| | | @TableField("message_record_id") |
| | | private Long messageRecordId; |
| | | |
| | | //消息类型 |
| | | private String type; |
| | | |
| | | //邮箱 |
| | | private String email; |
| | | //手机号 |
| | | private String phone; |
| | | |
| | | //是否已读(1、已读;2、未读) |
| | | /** 是否已读(1、已读;2、未读) */ |
| | | @ApiModelProperty(value = "是否已读(1、已读;2、未读)", example = "") |
| | | @TableField("is_read") |
| | | private String isRead; |
| | | |
| | | // 1:待发送,2.:发送成功 3:发送失败 |
| | | private String sendStatus; |
| | | /** 用户id */ |
| | | @ApiModelProperty(value = "用户id", example = "") |
| | | @TableField("user_id") |
| | | private String userId; |
| | | |
| | | // 重试次数 |
| | | private String retryNumber; |
| | | /** 消息类型 */ |
| | | @ApiModelProperty(value = "消息类型", example = "") |
| | | @TableField("type") |
| | | private String type; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("创建时间") |
| | | /** 邮箱 */ |
| | | @ApiModelProperty(value = "邮箱", example = "") |
| | | @TableField("email") |
| | | private String email; |
| | | |
| | | /** 电话号码 */ |
| | | @ApiModelProperty(value = "电话号码", example = "") |
| | | @TableField("phone") |
| | | private String phone; |
| | | |
| | | /** 创建时间 */ |
| | | @ApiModelProperty(value = "创建时间", example = "") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(value = "create_time",fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("更新时间") |
| | | /** 更新时间 */ |
| | | @ApiModelProperty(value = "更新时间", example = "") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(value = "update_time",fill = FieldFill.UPDATE) |
| | | private Date updateTime; |
| | | |
| | | /** 1:待发送,2.:发送成功 3:发送失败 */ |
| | | @ApiModelProperty(value = "1:待发送,2.:发送成功 3:发送失败", example = "") |
| | | @TableField("send_status") |
| | | private String sendStatus; |
| | | |
| | | /** 重试次数 */ |
| | | @ApiModelProperty(value = "重试次数", example = "") |
| | | @TableField("retry_number") |
| | | private Integer retryNumber; |
| | | } |
| | |
| | | <select id="getPage" resultType="org.springblade.modules.messageRecord.vo.MessageUserVO"> |
| | | |
| | | SELECT |
| | | bmu.*, |
| | | bmr.title,bmr.content,bmr.create_time as sendTime,bmr.create_user as sendUserId, |
| | | bu.real_name as sendUserName, |
| | | bu1.real_name as receiveUserName |
| | | bmu.*, |
| | | bmr.title,bmr.content,bmr.create_time as sendTime,bmr.create_user as sendUserId, |
| | | bu.real_name as sendUserName, |
| | | bu1.real_name as receiveUserName |
| | | FROM blade_message_user bmu |
| | | LEFT JOIN blade_message_record bmr ON bmr.id = bmu.message_record_id |
| | | LEFT JOIN blade_user bu ON bu.id = bmr.create_user |
| | | LEFT JOIN blade_user bu1 ON bu1.id = bmu.user_id |
| | | where 1=1 |
| | | <if test="vo.userId != null and vo.userId !=''"> |
| | | and bmu.user_id = #{vo.userId} |
| | | </if> |
| | | <if test="vo.type != null and vo.type !=''"> |
| | | AND bmu.type LIKE CONCAT('%',#{vo.type},'%') |
| | | </if> |
| | | <if test="vo.sendUserId != null and vo.sendUserId !=''"> |
| | | AND bmr.create_user = #{vo.sendUserId} |
| | | </if> |
| | | <if test="vo.userId != null and vo.userId !=''"> |
| | | and bmu.user_id = #{vo.userId} |
| | | </if> |
| | | <if test="vo.type != null and vo.type !=''"> |
| | | AND bmu.type LIKE CONCAT('%',#{vo.type},'%') |
| | | </if> |
| | | |
| | | <if test="vo.title != null and vo.title !=''"> |
| | | AND bmr.title LIKE CONCAT('%',#{vo.title},'%') |
| | | </if> |
| | | |
| | | <if test="vo.sendStatus != null and vo.sendStatus !=''"> |
| | | AND bmu.send_status = #{vo.sendStatus} |
| | | </if> |
| | | |
| | | <if test="vo.content != null and vo.content !=''"> |
| | | AND bmr.content LIKE CONCAT('%',#{vo.content},'%') |
| | | </if> |
| | | <if test="vo.sendUserId != null and vo.sendUserId !=''"> |
| | | AND bmr.create_user = #{vo.sendUserId} |
| | | </if> |
| | | <if test="vo.sendUserName != null and vo.sendUserName !=''"> |
| | | AND bu.real_name LIKE CONCAT('%',#{vo.sendUserName},'%') |
| | | </if> |
| | | <if test="vo.receiveUserName != null and vo.receiveUserName !=''"> |
| | | AND bu1.real_name LIKE CONCAT('%',#{vo.receiveUserName},'%') |
| | | </if> |
| | | ORDER BY bmu.create_time DESC |
| | | </select> |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import liquibase.pro.packaged.S; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.email.service.IEmailAccountService; |
| | | import org.springblade.modules.email.service.IEmailService; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean customizeSave(MessageRecordVO messageRecord) { |
| | | |
| | | if (StringUtils.isBlank(messageRecord.getType())) { |
| | | return false; |
| | | } |
| | | List<User> userList = new ArrayList(); |
| | | |
| | | if (messageRecord.getMessageResource().equals("1")) { |
| | | //系统消息(receiveUser指定的是部门,所以要通过部门去查人) |
| | | userList = userService.getUserListByDeptIds(messageRecord.getReceiver()); |
| | |
| | | |
| | | //保存消息记录 |
| | | boolean saveRecord = save(messageRecord); |
| | | |
| | | List<MessageUser> messageUserList = new ArrayList<>(); |
| | | userList.forEach(user -> { |
| | | MessageUser messageUser = new MessageUser(); |
| | | |
| | | messageUser.setUserId(user.getId().toString()); |
| | | messageUser.setMessageRecordId(messageRecord.getId().toString()); |
| | | messageUser.setType(messageRecord.getType()); |
| | | messageUser.setCreateTime(DateUtil.now()); |
| | | messageUser.setUpdateTime(DateUtil.now()); |
| | | messageUser.setSendStatus("1"); |
| | | if (messageRecord.getType().indexOf("1") > -1) { |
| | | messageUser.setSendStatus("2"); |
| | | } else if (messageRecord.getType().indexOf("2") > -1) { |
| | | messageUser.setEmail(user.getEmail()); |
| | | } else if (messageRecord.getType().indexOf("3") > -1) { |
| | | messageUser.setSendStatus("2"); |
| | | messageUser.setPhone(user.getPhone()); |
| | | List<String> longs = Func.toStrList(messageRecord.getType()); |
| | | for (String type : longs) { |
| | | MessageUser messageUser = new MessageUser(); |
| | | messageUser.setUserId(user.getId().toString()); |
| | | messageUser.setMessageRecordId(messageRecord.getId()); |
| | | messageUser.setType(type); |
| | | messageUser.setCreateTime(DateUtil.now()); |
| | | messageUser.setUpdateTime(DateUtil.now()); |
| | | messageUser.setSendStatus("1"); |
| | | if (messageUser.getType().indexOf("1") > -1) { |
| | | messageUser.setSendStatus("2"); |
| | | } else if (messageUser.getType().indexOf("2") > -1) { |
| | | messageUser.setEmail(user.getEmail()); |
| | | } else if (messageUser.getType().indexOf("3") > -1) { |
| | | messageUser.setSendStatus("2"); |
| | | messageUser.setPhone(user.getPhone()); |
| | | } |
| | | messageUserList.add(messageUser); |
| | | } |
| | | |
| | | messageUserList.add(messageUser); |
| | | }); |
| | | //在message_user表里存数据 |
| | | boolean saveBatch = messageUserService.saveBatch(messageUserList); |
| | |
| | | package org.springblade.modules.messageRecord.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springblade.modules.messageRecord.entity.MessageUser; |
| | | |
| | |
| | | |
| | | private String startTime; |
| | | private String endTime; |
| | | @ApiModelProperty(value = "发送人", example = "") |
| | | private String sendUserName; |
| | | @ApiModelProperty(value = "接收人", example = "") |
| | | private String receiveUserName; |
| | | |
| | | private Long sendUserId; |
| | | |
| | |
| | | * @author BladeX |
| | | */ |
| | | @NonDS |
| | | @ApiIgnore |
| | | //@ApiIgnore |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping(AppConstant.APPLICATION_RESOURCE_NAME + "/sms") |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送短信验证码 |
| | | */ |
| | | @PostMapping("/smsSend") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "发送短信验证码", notes = "") |
| | | public R smsSend( @RequestParam(value = "phone",required = false) String phone,@RequestParam(value = "type",required = false)String type) { |
| | | |
| | | return R.status(smsService.smsSend(phone,type)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | boolean enable(Long id); |
| | | |
| | | /** |
| | | * 发送验证码 |
| | | * @param phone |
| | | * @param type |
| | | * @return |
| | | */ |
| | | boolean smsSend(String phone, String type); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.springblade.common.utils.SmsUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | import org.springblade.modules.resource.entity.Sms; |
| | | import org.springblade.modules.resource.mapper.SmsMapper; |
| | | import org.springblade.modules.resource.service.ISmsService; |
| | | import org.springblade.modules.resource.utils.SmsUtil; |
| | | import org.springblade.modules.resource.vo.SmsVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 短信配置表 服务实现类 |
| | |
| | | return temp1 && temp2; |
| | | } |
| | | |
| | | @Override |
| | | public boolean smsSend(String phone, String type) { |
| | | Map<String, String> params = SmsUtil.getValidateParams(); |
| | | SmsUtils.send(phone, params); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | <if test="user.roleId!=null and user.roleId!=''"> |
| | | and role_id like concat('%',#{user.roleId},'%') |
| | | </if> |
| | | |
| | | <if test="user.deptId!=null and user.deptId!=''"> |
| | | and dept_id like concat('%',#{user.deptId},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="searchUserByDistrictId" resultType="org.springblade.modules.system.entity.User"> |