1.密码修改

2.gettoken
This commit is contained in:
邱贞招 2024-10-22 20:50:36 +08:00
parent 2b01d14ea5
commit 1cf0151633
13 changed files with 147 additions and 36 deletions

View File

@ -34,6 +34,7 @@ import com.ruoyi.system.service.*;
import com.wechat.pay.java.service.refund.model.Refund;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -257,7 +258,7 @@ public class AppController extends BaseController
if(modelId != null){
list = etFeeRuleService.selectRuleInfoListByModelId(etFeeRule.getModelId());
}else{
list = etFeeRuleService.selectEtFeeRuleListByAreaId(etFeeRule.getAreaId());
list = etFeeRuleService.selectEtFeeRuleList(etFeeRule);
}
return success(list);
}

View File

@ -1615,4 +1615,19 @@ public class AppVerifyController extends BaseController
int result = deptMapper.updateDept(sysDept);
return toAjax(result);
}
/**
* 修改运营区
*/
@Log(title = "运营区", businessType = BusinessType.UPDATE)
@PutMapping("/areaEdit")
public AjaxResult edit(@RequestBody EtOperatingArea etOperatingArea)
{
if (!etOperatingAreaService.checkAreaNameUnique(etOperatingArea))
{
return error("修改运营区'" + etOperatingArea.getAreaName() + "'失败,该运营区已存在");
}
return toAjax(etOperatingAreaService.updateEtOperatingArea(etOperatingArea));
}
}

View File

@ -74,7 +74,7 @@ public class EtFeeRuleController extends BaseController
/**
* 新增收费方式
*/
@PreAuthorize("@ss.hasPermi('system:fee:add')")
// @PreAuthorize("@ss.hasPermi('system:fee:add')")
@Log(title = "收费方式", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EtFeeRule etFeeRule)
@ -85,7 +85,7 @@ public class EtFeeRuleController extends BaseController
/**
* 修改收费方式
*/
@PreAuthorize("@ss.hasPermi('system:fee:edit')")
// @PreAuthorize("@ss.hasPermi('system:fee:edit')")
@Log(title = "收费方式", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EtFeeRule etFeeRule)
@ -96,7 +96,7 @@ public class EtFeeRuleController extends BaseController
/**
* 删除收费方式
*/
@PreAuthorize("@ss.hasPermi('system:fee:remove')")
// @PreAuthorize("@ss.hasPermi('system:fee:remove')")
@Log(title = "收费方式", businessType = BusinessType.DELETE)
@DeleteMapping("/{ruleIds}")
public AjaxResult remove(@PathVariable Long[] ruleIds)

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.system.service.IAsDeviceService;
import com.ruoyi.system.service.IEtFeeRuleService;
import org.springframework.security.access.prepost.PreAuthorize;
@ -56,6 +57,16 @@ public class EtModelController extends BaseController
return getDataTable(list);
}
/**
* 查询所有车辆型号列表
*/
@GetMapping("/allList")
public AjaxResult allList()
{
List<EtModel> list = etModelService.selectAllEtModelList();
return success(list);
}
/**
* 导出车辆型号列表
*/
@ -72,7 +83,7 @@ public class EtModelController extends BaseController
/**
* 获取车辆型号详细信息
*/
@PreAuthorize("@ss.hasPermi('system:model:query')")
// @PreAuthorize("@ss.hasPermi('system:model:query')")
@GetMapping(value = "/{modelId}")
public AjaxResult getInfo(@PathVariable("modelId") Long modelId)
{
@ -86,7 +97,7 @@ public class EtModelController extends BaseController
/**
* 新增车辆型号
*/
@PreAuthorize("@ss.hasPermi('system:model:add')")
// @PreAuthorize("@ss.hasPermi('system:model:add')")
@Log(title = "车辆型号", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EtModel etModel)
@ -97,18 +108,19 @@ public class EtModelController extends BaseController
/**
* 修改车辆型号
*/
@PreAuthorize("@ss.hasPermi('system:model:edit')")
// @PreAuthorize("@ss.hasPermi('system:model:edit')")
@Log(title = "车辆型号", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EtModel etModel)
{
logger.info("修改车辆型号:{}", JSON.toJSON(etModel));
return toAjax(etModelService.updateEtModel(etModel));
}
/**
* 删除车辆型号
*/
@PreAuthorize("@ss.hasPermi('system:model:remove')")
// @PreAuthorize("@ss.hasPermi('system:model:remove')")
@Log(title = "车辆型号", businessType = BusinessType.DELETE)
@DeleteMapping("/{modelIds}")
public AjaxResult remove(@PathVariable Long[] modelIds)

View File

@ -100,6 +100,21 @@ public class SysLoginController
return ajax;
}
/**
* getToken
*
* @return 用户信息
*/
@GetMapping("getToken")
public AjaxResult getToken(Long userId)
{
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.getToken(userId);
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
* 获取app用户信息
*

View File

@ -162,6 +162,7 @@ public class SysUserController extends BaseController
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setCreateBy(getUsername());
user.setInitPassword(user.getPassword());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}

View File

@ -155,6 +155,17 @@ public class SysUser extends BaseEntity
/** 可提现金额 */
public BigDecimal withdrawableAmount;
/** 初始密码 */
private String initPassword;
public String getInitPassword() {
return initPassword;
}
public void setInitPassword(String initPassword) {
this.initPassword = initPassword;
}
public String getCollectionCode() {
return collectionCode;
}

View File

@ -454,4 +454,34 @@ public class SysLoginService
asUserService.updateUserPwd(user.getUserId(), newPassword);
return 1;
}
public String getToken(Long userId) {
AsUser user = asUserService.selectUserById(userId);
if(ObjectUtils.isEmpty(user)) {
throw new ServiceException("未查询到用户信息");
}
Authentication authentication = null; // 用户验证
try {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user.getWxopenid(), Constants.CUSTOM_LOGIN_WX);
// 用户名和密码等信息保存在一个上下文中只要是同一线程等会就能拿到用户名和密码也就是能在loadUserByUsername(String username)方法中进行密码验证等
AuthenticationContextHolder.setContext(authenticationToken);
// 把用户类型放在上下文中的details属性中在UserDetailsServiceImpl.loadUserByUsername中获取
authenticationToken.setDetails(Constants.USER_TYPE_APP);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken);
}
catch (Exception e) {
if (e instanceof BadCredentialsException) {
throw new UserPasswordNotMatchException(); //抛出账号或者密码错误的异常
} else {
throw new ServiceException(e.getMessage()); //抛出其他异常
}
} finally {
AuthenticationContextHolder.clearContext();
}
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordAppLoginInfo(loginUser.getUserId());
return tokenService.createToken(loginUser);
}
}

View File

@ -27,6 +27,13 @@ public interface IEtModelService
*/
public List<EtModel> selectEtModelList(EtModel etModel);
/**
* 查询所有车辆型号列表
*
* @return 车辆型号集合
*/
public List<EtModel> selectAllEtModelList();
/**
* 新增车辆型号
*

View File

@ -20,6 +20,7 @@ import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.service.IAsDeviceService;
import com.ruoyi.system.service.IEtModelService;
import com.ruoyi.system.service.IEtOperatingAreaService;
import com.ruoyi.system.service.IWxPayService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -65,6 +66,10 @@ public class EtModelServiceImpl implements IEtModelService
@Autowired
private ScheduledExecutorService scheduledExecutorService;
@Autowired
private IWxPayService wxPayService;
/**
* 查询车辆型号
@ -113,6 +118,17 @@ public class EtModelServiceImpl implements IEtModelService
return etModels;
}
/**
* 查询所有车辆型号列表
*
* @return 车辆型号
*/
@Override
public List<EtModel> selectAllEtModelList() {
return etModelMapper.selectEtModelList(new EtModel());
}
/**
* 新增车辆型号
*
@ -124,10 +140,10 @@ public class EtModelServiceImpl implements IEtModelService
@Transactional
public int insertEtModel(EtModel etModel)
{
if(etModel.getOperator() == null){
SysUser currentUser = SecurityUtils.getLoginUser().getUser();//获取当前系统用户
if(!currentUser.isAdmin()){
etModel.setOperator(currentUser.getDeptId());
if(ObjectUtil.isNotNull(etModel.getAreaId())){
SysDept deptObjByAreaId = wxPayService.getDeptObjByAreaId(etModel.getAreaId());
if(ObjectUtil.isNotNull(deptObjByAreaId)){
etModel.setOperator(deptObjByAreaId.getDeptId());
}
}
etModel.setCreateTime(DateUtils.getNowDate());
@ -171,10 +187,10 @@ public class EtModelServiceImpl implements IEtModelService
@Transactional
public int updateEtModel(EtModel etModel)
{
if(etModel.getOperator() != null){
SysUser currentUser = SecurityUtils.getLoginUser().getUser();//获取当前系统用户
if(!currentUser.isAdmin()){
etModel.setOperator(currentUser.getDeptId());
if(ObjectUtil.isNotNull(etModel.getAreaId())){
SysDept deptObjByAreaId = wxPayService.getDeptObjByAreaId(etModel.getAreaId());
if(ObjectUtil.isNotNull(deptObjByAreaId)){
etModel.setOperator(deptObjByAreaId.getDeptId());
}
}
etModel.setUpdateTime(DateUtils.getNowDate());

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
@ -21,10 +22,7 @@ import com.ruoyi.system.mapper.AsDeviceMapper;
import com.ruoyi.system.mapper.EtAreaDeptMapper;
import com.ruoyi.system.mapper.EtAreaRuleMapper;
import com.ruoyi.system.mapper.EtOperatingAreaMapper;
import com.ruoyi.system.service.IAsDeviceService;
import com.ruoyi.system.service.IEtFeeRuleService;
import com.ruoyi.system.service.IEtOperatingAreaService;
import com.ruoyi.system.service.IEtParkingAreaService;
import com.ruoyi.system.service.*;
import lombok.extern.slf4j.Slf4j;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
@ -71,6 +69,10 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
@Resource
private IEtParkingAreaService etParkingAreaService;
@Autowired
private IWxPayService wxPayService;
/**
* 查询运营区
@ -193,22 +195,16 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
String wkt = GeoUtils.wkt(geometry);
etOperatingArea.setBoundary(wkt);
int i = dao.updateById(etOperatingArea);
// Long[] ruleIds = etOperatingArea.getRuleIds();
// if(ObjectUtil.isNotNull(ruleIds)){
// etAreaRuleMapper.deleteAreaRuleByAreaId(etOperatingArea.getAreaId());
// if(ObjectUtil.isNotNull(ruleIds)){
// for (Long ruleId:ruleIds){
// etAreaRuleMapper.insert(EtAreaRule.builder().areaId(etOperatingArea.getAreaId()).ruleId(ruleId).build());
// }
// }
// }
Long deptId = SecurityUtils.getDeptId();
if(deptId == 100){
deptId = etOperatingArea.getDeptId();
if(etOperatingArea.getAreaId() == null){
throw new ServiceException("运营区id没有传");
}
if(!ObjectUtil.isNotNull(etOperatingArea.getDeptId()) && deptId == 100){
throw new ServiceException("请选择运营商");
Long areaId = etOperatingArea.getAreaId();
SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId);
if(ObjectUtil.isNull(sysDept)){
throw new ServiceException("根据运营区查询运营商为空areaId = "+areaId);
}
Long deptId = sysDept.getDeptId();
etOperatingArea.setDeptId(deptId);
int i1 = etAreaDeptMapper.deleteAreaDeptByAreaId(etOperatingArea.getAreaId());
if(i1 > 0){
etAreaDeptMapper.insert(EtAreaDept.builder().areaId(etOperatingArea.getAreaId()).deptId(deptId).build());

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
@ -431,13 +432,14 @@ public class SysDeptServiceImpl implements ISysDeptService
sysUser.setNickName(dept.getPhone());
sysUser.setPhonenumber(dept.getPhone());
sysUser.setUserType("00");
String password = configService.selectConfigByKey("sys.user.initPassword");
String password = IdUtils.randomUUIDByDigit(8);
sysUser.setPassword(SecurityUtils.encryptPassword(password));
sysUser.setEmail(dept.getEmail());
sysUser.setStatus("0");
sysUser.setDelFlag("0");
sysUser.setCreateBy(SecurityUtils.getUsername());
sysUser.setCreateTime(DateUtils.getNowDate());
sysUser.setInitPassword(password);
int rows = userMapper.insertUser(sysUser);
// 添加运营商角色

View File

@ -32,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="balance" column="balance" />
<result property="userType" column="user_type" />
<result property="collectionCode" column="collection_code" />
<result property="initPassword" column="init_password" />
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
@ -68,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip,
u.login_date, u.create_by, u.create_time, u.remark, u.area_id,u.dividend_proportion,u.dividend_item,u.app_user_id, u.cooperation_time,
u.login_date, u.create_by, u.create_time, u.remark, u.area_id,u.dividend_proportion,u.dividend_item,u.app_user_id, u.cooperation_time,u.init_password,
u.dividend_status,u.balance, d.dept_name, d.leader,a.area_name areaName from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join et_operating_area a on u.area_id = a.area_id
@ -188,6 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="appUserId != null and appUserId != ''">app_user_id,</if>
<if test="cooperationTime != null">cooperation_time,</if>
<if test="dividendStatus != null and dividendStatus != ''">dividend_status,</if>
<if test="initPassword != null and initPassword != ''">init_password,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
@ -209,6 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="appUserId != null and appUserId != ''">#{appUserId},</if>
<if test="cooperationTime != null">#{cooperationTime},</if>
<if test="dividendStatus != null and dividendStatus != ''">#{dividendStatus},</if>
<if test="initPassword != null and initPassword != ''">#{initPassword},</if>
sysdate()
)
</insert>
@ -237,6 +240,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="cooperationTime != null">cooperation_time = #{cooperationTime},</if>
<if test="dividendStatus != null">dividend_status = #{dividendStatus},</if>
<if test="collectionCode != null">collection_code = #{collectionCode},</if>
<if test="initPassword != null">init_password = #{initPassword},</if>
update_time = sysdate()
</set>
where user_id = #{userId}
@ -265,6 +269,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="appUserId != null">app_user_id = #{appUserId},</if>
<if test="cooperationTime != null">cooperation_time = #{cooperationTime},</if>
<if test="dividendStatus != null">dividend_status = #{dividendStatus},</if>
<if test="initPassword != null">init_password = #{initPassword},</if>
update_time = sysdate()
</set>
where user_id = #{userId}