Merge remote-tracking branch 'origin/dev' into zs
This commit is contained in:
commit
f0755c58a1
|
|
@ -22,6 +22,8 @@ package cn.ysk.cashier.utils;
|
|||
*/
|
||||
public interface CacheKey {
|
||||
|
||||
String ONLINE_ADMIN = "ONLINE_ADMIN:";
|
||||
|
||||
/**
|
||||
* 激活码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public class TbProductController {
|
|||
}
|
||||
|
||||
@GetMapping("/isHot")
|
||||
public ResponseEntity<Object> updateIsHot(@RequestParam String shopId, @RequestParam Integer id){
|
||||
tbProductService.updateIsHot(id,shopId);
|
||||
public ResponseEntity<Object> updateIsHot(@RequestParam Integer isHot, @RequestParam Integer id){
|
||||
tbProductService.updateIsHot(id,isHot);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
||||
import cn.ysk.cashier.service.shop.TbPlussShopStaffService;
|
||||
import cn.ysk.cashier.dto.shop.TbPlussShopStaffQueryCriteria;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
|
@ -91,4 +75,15 @@ public class TbPlussShopStaffController {
|
|||
tbPlussShopStaffService.deleteAll(ids);
|
||||
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);
|
||||
// }
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ public class TbShopInfoController {
|
|||
public ResponseEntity<Object> upShopPass(HttpServletRequest request, @RequestBody Map<String, String> map) throws Exception {
|
||||
tbShopInfoService.upShopPass(map.get("username"),map.get("password"));
|
||||
//根据token踢出用户
|
||||
// onlineUserService.logout(tokenProvider.getToken(request));
|
||||
onlineUserService.logout(tokenProvider.getToken(request));
|
||||
log.info("修改商户密码成功。");
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
@Modifying
|
||||
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
|
||||
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)
|
||||
@Modifying
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
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.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
|
|
@ -42,6 +25,10 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
|
|||
@Query("update TbPlussShopStaff set password = :password , updatedAt = :lastPasswordResetTime where account = :account")
|
||||
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")
|
||||
TbPlussShopStaff queryByAccount(String account);
|
||||
|
||||
|
|
|
|||
|
|
@ -523,9 +523,8 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateIsHot(Integer id, String shopId) {
|
||||
tbProductRepository.updateNullHot(shopId);
|
||||
tbProductRepository.updateIsHot(id);
|
||||
public void updateIsHot(Integer id,Integer isHot) {
|
||||
tbProductRepository.updateIsHot(id,isHot);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||
Set<Long> sysUserIds=new HashSet<>();
|
||||
for (Integer id : ids) {
|
||||
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(id).get();
|
||||
User sysUser = userRepository.findByUsername(tbPlussShopStaff.getAccount());
|
||||
User sysUser = userRepository.findByUsername(tbPlussShopStaff.getShopId()+"@"+tbPlussShopStaff.getAccount());
|
||||
tbPlussShopStaffRepository.deleteById(id);
|
||||
sysUserIds.add(sysUser.getId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public interface TbProductService {
|
|||
*/
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -25,6 +10,9 @@ import lombok.Data;
|
|||
@Data
|
||||
public class UserPassVo {
|
||||
|
||||
//staff
|
||||
private String loginType;
|
||||
|
||||
private String oldPass;
|
||||
|
||||
private String newPass;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
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.User;
|
||||
import cn.ysk.cashier.system.domain.vo.UserPassVo;
|
||||
import cn.ysk.cashier.system.service.dto.UserDto;
|
||||
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.RsaUtils;
|
||||
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.UserService;
|
||||
import cn.ysk.cashier.utils.enums.CodeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
|
@ -68,6 +61,9 @@ public class UserController {
|
|||
private final DeptService deptService;
|
||||
private final RoleService roleService;
|
||||
private final VerifyService verificationCodeService;
|
||||
private final OnlineUserService onlineUserService;
|
||||
private final TbPlussShopStaffRepository shopStaffRepository;
|
||||
private final TokenProvider tokenProvider;
|
||||
|
||||
@ApiOperation("导出用户数据")
|
||||
@GetMapping(value = "/download")
|
||||
|
|
@ -155,17 +151,27 @@ public class UserController {
|
|||
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping(value = "/updatePass")
|
||||
public ResponseEntity<Object> updateUserPass(@RequestBody UserPassVo passVo) throws Exception {
|
||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass());
|
||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass());
|
||||
UserDto user = userService.findByName(SecurityUtils.getCurrentUsername());
|
||||
if(!passwordEncoder.matches(oldPass, user.getPassword())){
|
||||
@Transactional
|
||||
public ResponseEntity<Object> updateUserPass(HttpServletRequest request, @RequestBody UserPassVo passVo) throws Exception {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
UserDto user = userService.findByName(currentUsername);
|
||||
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("修改失败,旧密码错误");
|
||||
}
|
||||
if(passwordEncoder.matches(newPass, user.getPassword())){
|
||||
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
||||
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));
|
||||
onlineUserService.logout(tokenProvider.getToken(request));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue