diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 7544240..1dafe0c 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -7,6 +7,8 @@ import com.xkrs.common.tool.TokenUtil; import com.xkrs.dao.SysUserDao; import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.SysUserQo; +import com.xkrs.model.qo.SysUserReceiveSmsQo; +import com.xkrs.model.qo.SysUserVipLevelQo; import com.xkrs.model.validation.SysUserQoInsert; import com.xkrs.model.validation.SysUserQoUpdate; import com.xkrs.model.vo.SysUserVo; @@ -22,10 +24,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; @@ -51,6 +50,64 @@ public class SysUserController { @Resource private RedisService redisService; + /** + * 修改vip等级 + * + * @param sysUserVipLevelQo + * @return + */ + @Transactional(rollbackFor = Exception.class) + @RequestMapping(value = "/updateviplevel", method = RequestMethod.POST) + public String updateVipLevel(@RequestBody SysUserVipLevelQo sysUserVipLevelQo) { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + String ids = sysUserVipLevelQo.getIds(); + List idList = new ArrayList<>(); + if (ids.contains(",")) { + String[] splits = ids.split(","); + if (splits != null && splits.length > 0) { + for (String split : splits) { + idList.add(Integer.parseInt(split)); + } + } + } else { + idList.add(Integer.parseInt(ids)); + } + for (Integer id : idList) { + sysUserDao.updateVipLevel(id, sysUserVipLevelQo.getVipLevel()); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); + } + + /** + * 修改是否接收短信 + * + * @param sysUserReceiveSmsQo + * @return + */ + @Transactional(rollbackFor = Exception.class) + @RequestMapping(value = "/updatereceivesms", method = RequestMethod.POST) + public String updateReceiveSms(@RequestBody SysUserReceiveSmsQo sysUserReceiveSmsQo) { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + String ids = sysUserReceiveSmsQo.getIds(); + List idList = new ArrayList<>(); + if (ids.contains(",")) { + String[] splits = ids.split(","); + if (splits != null && splits.length > 0) { + for (String split : splits) { + idList.add(Integer.parseInt(split)); + } + } + } else { + idList.add(Integer.parseInt(ids)); + } + for (Integer id : idList) { + sysUserDao.updateReceiveSms(id, sysUserReceiveSmsQo.getReceiveSms()); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); + } + /** * 登录用户Token验证 * diff --git a/src/main/java/com/xkrs/dao/SysUserDao.java b/src/main/java/com/xkrs/dao/SysUserDao.java index d4452a8..10d8523 100644 --- a/src/main/java/com/xkrs/dao/SysUserDao.java +++ b/src/main/java/com/xkrs/dao/SysUserDao.java @@ -11,12 +11,22 @@ import java.util.List; /** * SysUserDao + * * @author tajochen */ -public interface SysUserDao extends JpaRepository { +public interface SysUserDao extends JpaRepository { + + @Modifying(clearAutomatically = true) + @Query(value = "UPDATE sys_user SET vip_level = ?2 WHERE id = ?1", nativeQuery = true) + void updateVipLevel(Integer id, Integer vipLevel); + + @Modifying(clearAutomatically = true) + @Query(value = "UPDATE sys_user SET receive_sms = ?2 WHERE id = ?1", nativeQuery = true) + void updateReceiveSms(Integer id, Integer receiveSms); /** * 检查系统用户名是否存在 + * * @param userName * @return */ @@ -25,6 +35,7 @@ public interface SysUserDao extends JpaRepository { /** * 查找用户实体根据用户名 + * * @param userName * @return */ @@ -33,6 +44,7 @@ public interface SysUserDao extends JpaRepository { /** * 根据用户名查询用户信息 + * * @param userName * @return */ @@ -40,37 +52,38 @@ public interface SysUserDao extends JpaRepository { /** * 更新用户登录信息 + * * @param userName * @param ipAddress * @return */ @Modifying - @Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " + - "WHERE user_name = :userName ;", nativeQuery = true) + @Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " + "WHERE user_name = :userName ;", nativeQuery = true) int updateSysUserLogin(@Param("userName") String userName, @Param("ipAddress") String ipAddress); /** * 软删除系统用户根据用户名 + * * @param userName * @return */ @Modifying - @Query(value = "UPDATE sys_user SET delete_flag = 1 " + - "WHERE user_name = :userName ;", nativeQuery = true) + @Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE user_name = :userName ;", nativeQuery = true) int softDeleteSysUserByUserName(@Param("userName") String userName); /** * 软删除系统用户根据id + * * @param id * @return */ @Modifying - @Query(value = "UPDATE sys_user SET delete_flag = 1 " + - "WHERE id = :id ;", nativeQuery = true) + @Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE id = :id ;", nativeQuery = true) int softDeleteGeneralUserById(@Param("id") Integer id); /** * 删除系统用户(危险操作!) + * * @param userName * @return */ @@ -80,86 +93,96 @@ public interface SysUserDao extends JpaRepository { /** * 查询用户信息 + * * @return */ - @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime) " + - "from SysUserEntity") + @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime,vipLevel,receiveSms) " + "from SysUserEntity") List selectAll(); /** * 根据用户名查询实体信息 + * * @param userName * @return */ - @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime) " + - "from SysUserEntity where userName = :userName") + @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime,vipLevel,receiveSms) " + "from SysUserEntity where userName = :userName") SysUserVo selectUserByUserName(String userName); /** * 启用 + * * @param userId */ - @Query(value = "update sys_user set active_flag = 0 where id = ?",nativeQuery = true) - @Modifying(clearAutomatically=true) + @Query(value = "update sys_user set active_flag = 0 where id = ?", nativeQuery = true) + @Modifying(clearAutomatically = true) void updateEnable(Integer userId); /** * 禁用 + * * @param userId */ - @Query(value = "update sys_user set active_flag = 1 where id = ?",nativeQuery = true) - @Modifying(clearAutomatically=true) + @Query(value = "update sys_user set active_flag = 1 where id = ?", nativeQuery = true) + @Modifying(clearAutomatically = true) void updateDisable(Integer userId); /** * 用户修改密码 + * * @param userId * @param newPassword */ - @Query(value = "update sys_user set password = ?2 where id = ?1",nativeQuery = true) - @Modifying(clearAutomatically=true) - void updatePassword(Integer userId,String newPassword); + @Query(value = "update sys_user set password = ?2 where id = ?1", nativeQuery = true) + @Modifying(clearAutomatically = true) + void updatePassword(Integer userId, String newPassword); /** * 根据id查询用户的信息 + * * @param userId * @return */ - @Query(value = "select * from sys_user where id = ?",nativeQuery = true) + @Query(value = "select * from sys_user where id = ?", nativeQuery = true) SysUserEntity selectByUserId(Integer userId); /** * 根据id修改账户的到期时间 + * * @param userId * @param overTime */ - @Query(value = "update sys_user set over_time = ?2 where id = ?1",nativeQuery = true) - @Modifying(clearAutomatically=true) - void updateOverTime(Integer userId,String overTime); + @Query(value = "update sys_user set over_time = ?2 where id = ?1", nativeQuery = true) + @Modifying(clearAutomatically = true) + void updateOverTime(Integer userId, String overTime); /** * 将账户的期限修改为永久有效 + * * @param userId */ - @Query(value = "update sys_user set over_time = '永久' and day_num = 1 where id = ?",nativeQuery = true) - @Modifying(clearAutomatically=true) + @Query(value = "update sys_user set over_time = '永久' and day_num = 1 where id = ?", nativeQuery = true) + @Modifying(clearAutomatically = true) void updateDayNum(Integer userId); /** * 记录用户登录次数 + * * @param userId * @param loginNum */ - @Query(value = "update sys_user set login_num = ?2 where id = ?1",nativeQuery = true) - @Modifying(clearAutomatically=true) - void updateLoginNum(Integer userId,Integer loginNum); + @Query(value = "update sys_user set login_num = ?2 where id = ?1", nativeQuery = true) + @Modifying(clearAutomatically = true) + void updateLoginNum(Integer userId, Integer loginNum); /** * 修改登陆时间 + * * @param userId * @param loginLastTime */ - @Query(value = "update sys_user set login_last_time = ?2 where id = ?1",nativeQuery = true) - @Modifying(clearAutomatically=true) - void updateLoginLastTime(Integer userId,String loginLastTime); + @Query(value = "update sys_user set login_last_time = ?2 where id = ?1", nativeQuery = true) + @Modifying(clearAutomatically = true) + void updateLoginLastTime(Integer userId, String loginLastTime); + + } diff --git a/src/main/java/com/xkrs/model/entity/SysUserEntity.java b/src/main/java/com/xkrs/model/entity/SysUserEntity.java index 8a4e403..7bf94a1 100644 --- a/src/main/java/com/xkrs/model/entity/SysUserEntity.java +++ b/src/main/java/com/xkrs/model/entity/SysUserEntity.java @@ -105,10 +105,14 @@ public class SysUserEntity implements Serializable { private String userAgent; /** - * 是否是VIP用户 + * vip等级 */ - @Column(length = 64, columnDefinition = "varchar(64)") - private String isVip; + private Integer vipLevel; + + /** + * 是否接收短信 + */ + private Integer receiveSms; public SysUserEntity() { } @@ -281,39 +285,24 @@ public class SysUserEntity implements Serializable { this.userAgent = userAgent; } - public String getIsVip() { - return isVip; + public Integer getVipLevel() { + return vipLevel; } - public void setIsVip(String isVip) { - this.isVip = isVip; + public void setVipLevel(Integer vipLevel) { + this.vipLevel = vipLevel; + } + + public Integer getReceiveSms() { + return receiveSms; + } + + public void setReceiveSms(Integer receiveSms) { + this.receiveSms = receiveSms; } @Override public String toString() { - return "SysUserEntity{" + - "id=" + id + - ", userName='" + userName + '\'' + - ", reallyName='" + reallyName + '\'' + - ", password='" + password + '\'' + - ", salt='" + salt + '\'' + - ", telephone='" + telephone + '\'' + - ", countyCode='" + countyCode + '\'' + - ", signature='" + signature + '\'' + - ", activeFlag=" + activeFlag + - ", statusCode=" + statusCode + - ", addTime='" + addTime + '\'' + - ", lastEntryTime=" + lastEntryTime + - ", deleteFlag=" + deleteFlag + - ", lastEntryIp='" + lastEntryIp + '\'' + - ", dayNum=" + dayNum + - ", overTime='" + overTime + '\'' + - ", accountType='" + accountType + '\'' + - ", countyName='" + countyName + '\'' + - ", loginNum=" + loginNum + - ", loginLastTime='" + loginLastTime + '\'' + - ", userAgent='" + userAgent + '\'' + - ", isVip='" + isVip + '\'' + - '}'; + return "SysUserEntity{" + "id=" + id + ", userName='" + userName + '\'' + ", reallyName='" + reallyName + '\'' + ", password='" + password + '\'' + ", salt='" + salt + '\'' + ", telephone='" + telephone + '\'' + ", countyCode='" + countyCode + '\'' + ", signature='" + signature + '\'' + ", activeFlag=" + activeFlag + ", statusCode=" + statusCode + ", addTime='" + addTime + '\'' + ", lastEntryTime=" + lastEntryTime + ", deleteFlag=" + deleteFlag + ", lastEntryIp='" + lastEntryIp + '\'' + ", dayNum=" + dayNum + ", overTime='" + overTime + '\'' + ", accountType='" + accountType + '\'' + ", countyName='" + countyName + '\'' + ", loginNum=" + loginNum + ", loginLastTime='" + loginLastTime + '\'' + ", userAgent='" + userAgent + '\'' + ", vipLevel=" + vipLevel + ", receiveSms=" + receiveSms + '}'; } } diff --git a/src/main/java/com/xkrs/model/qo/SysUserReceiveSmsQo.java b/src/main/java/com/xkrs/model/qo/SysUserReceiveSmsQo.java new file mode 100644 index 0000000..ca93981 --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/SysUserReceiveSmsQo.java @@ -0,0 +1,38 @@ +package com.xkrs.model.qo; + +import com.xkrs.model.validation.SysUserQoUpdate; + +import javax.validation.constraints.NotNull; + +public class SysUserReceiveSmsQo { + + @NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class}) + private String ids; + + @NotNull(message = "{SysUser.receiveSms.blank}", groups = {SysUserQoUpdate.class}) + private Integer receiveSms; + + public SysUserReceiveSmsQo() { + } + + public String getIds() { + return ids; + } + + public void setIds(String ids) { + this.ids = ids; + } + + public Integer getReceiveSms() { + return receiveSms; + } + + public void setReceiveSms(Integer receiveSms) { + this.receiveSms = receiveSms; + } + + @Override + public String toString() { + return "SysUserReceiveSmsQo{" + "ids='" + ids + '\'' + ", receiveSms=" + receiveSms + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/qo/SysUserVipLevelQo.java b/src/main/java/com/xkrs/model/qo/SysUserVipLevelQo.java new file mode 100644 index 0000000..5c3f125 --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/SysUserVipLevelQo.java @@ -0,0 +1,33 @@ +package com.xkrs.model.qo; + +import com.xkrs.model.validation.SysUserQoUpdate; + +import javax.validation.constraints.NotNull; + +public class SysUserVipLevelQo { + + @NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class}) + private String ids; + + @NotNull(message = "{SysUser.vipLevel.blank}", groups = {SysUserQoUpdate.class}) + private Integer vipLevel; + + public SysUserVipLevelQo() { + } + + public String getIds() { + return ids; + } + + public void setIds(String ids) { + this.ids = ids; + } + + public Integer getVipLevel() { + return vipLevel; + } + + public void setVipLevel(Integer vipLevel) { + this.vipLevel = vipLevel; + } +} diff --git a/src/main/java/com/xkrs/model/vo/SysUserVo.java b/src/main/java/com/xkrs/model/vo/SysUserVo.java index 61708b2..a40a90c 100644 --- a/src/main/java/com/xkrs/model/vo/SysUserVo.java +++ b/src/main/java/com/xkrs/model/vo/SysUserVo.java @@ -1,13 +1,14 @@ package com.xkrs.model.vo; import java.io.Serializable; -import java.time.LocalDateTime; /** * SysUserVo + * * @Author tajochen */ public class SysUserVo implements Serializable { + private Integer id; private String reallyName; @@ -34,7 +35,11 @@ public class SysUserVo implements Serializable { private String loginLastTime; - public SysUserVo(Integer id, String reallyName, String telephone, String countyCode, Integer activeFlag, String addTime, String overTime, Integer dayNum, String accountType, String countyName, String lastEntryIp, Integer loginNum, String loginLastTime) { + private Integer vipLevel; + + private Integer receiveSms; + + public SysUserVo(Integer id, String reallyName, String telephone, String countyCode, Integer activeFlag, String addTime, String overTime, Integer dayNum, String accountType, String countyName, String lastEntryIp, Integer loginNum, String loginLastTime, Integer vipLevel, Integer receiveSms) { this.id = id; this.reallyName = reallyName; this.telephone = telephone; @@ -48,6 +53,8 @@ public class SysUserVo implements Serializable { this.lastEntryIp = lastEntryIp; this.loginNum = loginNum; this.loginLastTime = loginLastTime; + this.vipLevel = vipLevel; + this.receiveSms = receiveSms; } public Integer getId() { @@ -153,5 +160,21 @@ public class SysUserVo implements Serializable { public void setLoginLastTime(String loginLastTime) { this.loginLastTime = loginLastTime; } + + public Integer getVipLevel() { + return vipLevel; + } + + public void setVipLevel(Integer vipLevel) { + this.vipLevel = vipLevel; + } + + public Integer getReceiveSms() { + return receiveSms; + } + + public void setReceiveSms(Integer receiveSms) { + this.receiveSms = receiveSms; + } } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 8c86fd7..7b9ef9a 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -367,8 +367,8 @@ public class FirePointServiceImpl implements FirePointService { } } if (telephoneList.size() > 0) { - String[] telephoneArray = telephoneList.toArray(new String[]{}); -// String[] telephoneArray = new String[]{"8615764226530"}; +// String[] telephoneArray = telephoneList.toArray(new String[]{}); + String[] telephoneArray = new String[]{"8615764226530"}; SendSms.sendSmsToUser(telephoneArray, "1425995", new String[]{firePointAddress}); } }