员工删除

个人中心 修改密码
商品设置热门
This commit is contained in:
2024-08-02 16:43:46 +08:00
parent 16c6ff1ccf
commit 48488daad8
11 changed files with 56 additions and 79 deletions

View File

@@ -22,6 +22,8 @@ package cn.ysk.cashier.utils;
*/ */
public interface CacheKey { public interface CacheKey {
String ONLINE_ADMIN = "ONLINE_ADMIN:";
/** /**
* 激活码 * 激活码
*/ */

View File

@@ -39,8 +39,8 @@ public class TbProductController {
} }
@GetMapping("/isHot") @GetMapping("/isHot")
public ResponseEntity<Object> updateIsHot(@RequestParam String shopId, @RequestParam Integer id){ public ResponseEntity<Object> updateIsHot(@RequestParam Integer isHot, @RequestParam Integer id){
tbProductService.updateIsHot(id,shopId); tbProductService.updateIsHot(id,isHot);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }

View File

@@ -1,25 +1,9 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.controller.shop; package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
import cn.ysk.cashier.service.shop.TbPlussShopStaffService; import cn.ysk.cashier.service.shop.TbPlussShopStaffService;
import cn.ysk.cashier.dto.shop.TbPlussShopStaffQueryCriteria; import cn.ysk.cashier.dto.shop.TbPlussShopStaffQueryCriteria;
import io.swagger.models.auth.In;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -91,4 +75,15 @@ public class TbPlussShopStaffController {
tbPlussShopStaffService.deleteAll(ids); tbPlussShopStaffService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
// @ApiOperation("修改个人密码")
// @PostMapping(value = "/upPass")
// @AnonymousPostMapping
// public ResponseEntity<Object> upshopStaffPass(HttpServletRequest request, @RequestBody Map<String, String> map){
// tbShopInfoService.upShopPass(map.get("username"),map.get("password"));
// //根据token踢出用户
// onlineUserService.logout(tokenProvider.getToken(request));
// log.info("修改商户密码成功。");
// return new ResponseEntity<>(HttpStatus.OK);
// }
} }

View File

@@ -72,7 +72,7 @@ public class TbShopInfoController {
public ResponseEntity<Object> upShopPass(HttpServletRequest request, @RequestBody Map<String, String> map) throws Exception { public ResponseEntity<Object> upShopPass(HttpServletRequest request, @RequestBody Map<String, String> map) throws Exception {
tbShopInfoService.upShopPass(map.get("username"),map.get("password")); tbShopInfoService.upShopPass(map.get("username"),map.get("password"));
//根据token踢出用户 //根据token踢出用户
// onlineUserService.logout(tokenProvider.getToken(request)); onlineUserService.logout(tokenProvider.getToken(request));
log.info("修改商户密码成功。"); log.info("修改商户密码成功。");
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }

View File

@@ -25,9 +25,9 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
@Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true) @Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true)
@Modifying @Modifying
void updateByStatus(List<Integer> productIds); void updateByStatus(List<Integer> productIds);
@Query(value = "update tb_product set is_hot=1 where id = :id",nativeQuery = true) @Query(value = "update tb_product set is_hot=:isHot where id = :id",nativeQuery = true)
@Modifying @Modifying
void updateIsHot(@Param("id") Integer id); void updateIsHot(@Param("id") Integer id,@Param("isHot")Integer isHot);
@Query(value = "update tb_product set is_stock=:isStock where id = :proId and shop_id=:shopId",nativeQuery = true) @Query(value = "update tb_product set is_stock=:isStock where id = :proId and shop_id=:shopId",nativeQuery = true)
@Modifying @Modifying

View File

@@ -1,18 +1,3 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.repository.shop; package cn.ysk.cashier.repository.shop;
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
@@ -21,8 +6,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import java.util.List;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
* @author lyf * @author lyf
@@ -42,6 +25,10 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
@Query("update TbPlussShopStaff set password = :password , updatedAt = :lastPasswordResetTime where account = :account") @Query("update TbPlussShopStaff set password = :password , updatedAt = :lastPasswordResetTime where account = :account")
void updatePass(String account, String password, Long lastPasswordResetTime); void updatePass(String account, String password, Long lastPasswordResetTime);
@Modifying
@Query("update TbPlussShopStaff set password = :password , updatedAt = :lastPasswordResetTime where account = :account and shopId=:shopId")
void updatePassAndShopId(String account, String shopId, String password, Long lastPasswordResetTime);
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account") @Query("select staff from TbPlussShopStaff as staff where staff.account = :account")
TbPlussShopStaff queryByAccount(String account); TbPlussShopStaff queryByAccount(String account);

View File

@@ -523,9 +523,8 @@ public class TbProductServiceImpl implements TbProductService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public void updateIsHot(Integer id, String shopId) { public void updateIsHot(Integer id,Integer isHot) {
tbProductRepository.updateNullHot(shopId); tbProductRepository.updateIsHot(id,isHot);
tbProductRepository.updateIsHot(id);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)

View File

@@ -203,7 +203,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
Set<Long> sysUserIds=new HashSet<>(); Set<Long> sysUserIds=new HashSet<>();
for (Integer id : ids) { for (Integer id : ids) {
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(id).get(); TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(id).get();
User sysUser = userRepository.findByUsername(tbPlussShopStaff.getAccount()); User sysUser = userRepository.findByUsername(tbPlussShopStaff.getShopId()+"@"+tbPlussShopStaff.getAccount());
tbPlussShopStaffRepository.deleteById(id); tbPlussShopStaffRepository.deleteById(id);
sysUserIds.add(sysUser.getId()); sysUserIds.add(sysUser.getId());
} }

View File

@@ -85,7 +85,7 @@ public interface TbProductService {
*/ */
void download(List<TbProductDto> all, HttpServletResponse response) throws IOException; void download(List<TbProductDto> all, HttpServletResponse response) throws IOException;
void updateIsHot(Integer id, String shopId); void updateIsHot(Integer id,Integer isStock);
void updateIsStock(Integer proId, String shopId, Integer isStock); void updateIsStock(Integer proId, String shopId, Integer isStock);

View File

@@ -1,18 +1,3 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.system.domain.vo; package cn.ysk.cashier.system.domain.vo;
import lombok.Data; import lombok.Data;
@@ -25,6 +10,9 @@ import lombok.Data;
@Data @Data
public class UserPassVo { public class UserPassVo {
//staff
private String loginType;
private String oldPass; private String oldPass;
private String newPass; private String newPass;

View File

@@ -1,26 +1,15 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.system.rest; package cn.ysk.cashier.system.rest;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.config.security.service.OnlineUserService;
import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository;
import cn.ysk.cashier.system.domain.Dept; import cn.ysk.cashier.system.domain.Dept;
import cn.ysk.cashier.system.domain.User; import cn.ysk.cashier.system.domain.User;
import cn.ysk.cashier.system.domain.vo.UserPassVo; import cn.ysk.cashier.system.domain.vo.UserPassVo;
import cn.ysk.cashier.system.service.dto.UserDto; import cn.ysk.cashier.system.service.dto.UserDto;
import cn.ysk.cashier.system.service.dto.UserQueryCriteria; import cn.ysk.cashier.system.service.dto.UserQueryCriteria;
import cn.ysk.cashier.utils.MD5Utils;
import cn.ysk.cashier.utils.PageUtil; import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.RsaUtils; import cn.ysk.cashier.utils.RsaUtils;
import cn.ysk.cashier.utils.SecurityUtils; import cn.ysk.cashier.utils.SecurityUtils;
@@ -37,16 +26,20 @@ import cn.ysk.cashier.system.service.dto.RoleSmallDto;
import cn.ysk.cashier.system.service.VerifyService; import cn.ysk.cashier.system.service.VerifyService;
import cn.ysk.cashier.system.service.UserService; import cn.ysk.cashier.system.service.UserService;
import cn.ysk.cashier.utils.enums.CodeEnum; import cn.ysk.cashier.utils.enums.CodeEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@@ -68,6 +61,9 @@ public class UserController {
private final DeptService deptService; private final DeptService deptService;
private final RoleService roleService; private final RoleService roleService;
private final VerifyService verificationCodeService; private final VerifyService verificationCodeService;
private final OnlineUserService onlineUserService;
private final TbPlussShopStaffRepository shopStaffRepository;
private final TokenProvider tokenProvider;
@ApiOperation("导出用户数据") @ApiOperation("导出用户数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
@@ -155,17 +151,27 @@ public class UserController {
@ApiOperation("修改密码") @ApiOperation("修改密码")
@PostMapping(value = "/updatePass") @PostMapping(value = "/updatePass")
public ResponseEntity<Object> updateUserPass(@RequestBody UserPassVo passVo) throws Exception { @Transactional
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass()); public ResponseEntity<Object> updateUserPass(HttpServletRequest request, @RequestBody UserPassVo passVo) throws Exception {
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass()); String currentUsername = SecurityUtils.getCurrentUsername();
UserDto user = userService.findByName(SecurityUtils.getCurrentUsername()); UserDto user = userService.findByName(currentUsername);
if(!passwordEncoder.matches(oldPass, user.getPassword())){ String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getOldPass());
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getNewPass());
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
throw new BadRequestException("修改失败,旧密码错误"); throw new BadRequestException("修改失败,旧密码错误");
} }
if(passwordEncoder.matches(newPass, user.getPassword())){ if (passwordEncoder.matches(newPass, user.getPassword())) {
throw new BadRequestException("新密码不能与旧密码相同"); throw new BadRequestException("新密码不能与旧密码相同");
} }
String encPass = MD5Utils.encrypt( passVo.getNewPass());
if (StringUtils.isNotBlank(passVo.getLoginType()) && passVo.getLoginType().equals("staff")) {
String[] split = currentUsername.split("@");
shopStaffRepository.updatePassAndShopId(split[1],split[0],encPass,System.currentTimeMillis());
}else {
shopStaffRepository.updatePass(currentUsername,encPass,System.currentTimeMillis());
}
userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass)); userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass));
onlineUserService.logout(tokenProvider.getToken(request));
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }