Commit 7449d082 authored by nie'hong's avatar nie'hong

修改密码

parent f268ddb3
...@@ -52,7 +52,7 @@ public enum BASE_RESP_CODE_ENUM { ...@@ -52,7 +52,7 @@ public enum BASE_RESP_CODE_ENUM {
WORK_ORDER_END("630", "该项目的工单已经全部审批"), WORK_ORDER_END("630", "该项目的工单已经全部审批"),
DEPT_IS_NULL("631","该部门不存在"), DEPT_IS_NULL("631","该部门不存在"),
MANAGER_NOT_PROJECT("632","该管理没有可管理的项目"), MANAGER_NOT_PROJECT("632","该管理没有可管理的项目"),
DEPT_NOT_FOUND("627", "部门信息未找到"); DEPT_NOT_FOUND("633", "部门信息未找到");
/** /**
* 错误编码 * 错误编码
......
...@@ -18,4 +18,8 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> { ...@@ -18,4 +18,8 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> {
WorkUser getUserInfo(Map<String, Object> map); WorkUser getUserInfo(Map<String, Object> map);
WorkUser getUserById(Integer userId); WorkUser getUserById(Integer userId);
Integer updateUserInfo(WorkUser user);
} }
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
<if test="name != null">name = #{name},</if> <if test="name != null">name = #{name},</if>
<if test="oaUserId != null">oa_user_id = #{oaUserId},</if> <if test="oaUserId != null">oa_user_id = #{oaUserId},</if>
<if test="loginName != null">login_name = #{loginName},</if> <if test="loginName != null">login_name = #{loginName},</if>
<if test="password != null">password = #{password},</if>
<if test="phone != null">phone =#{phone},</if> <if test="phone != null">phone =#{phone},</if>
<if test="deptId != null">dept_id = #{deptId},</if> <if test="deptId != null">dept_id = #{deptId},</if>
<if test="email != null">email = #{email},</if> <if test="email != null">email = #{email},</if>
...@@ -78,10 +79,16 @@ ...@@ -78,10 +79,16 @@
</where> </where>
</select> </select>
<select id="getUserById" resultMap="BaseResultMap" parameterType="map" > <select id="getUserById" resultMap="BaseResultMap" parameterType="integer" >
select <include refid="cols_all"/> select <include refid="cols_all"/>
from <include refid="table"/> from <include refid="table"/>
where id = #{userId} where id = #{userId}
</select> </select>
<update id="updateUserInfo" parameterType="cn.wisenergy.model.app.WorkUser">
update <include refid="table"/>
set <include refid="updateCondition"/>
where id = #{id}
</update>
</mapper> </mapper>
...@@ -15,10 +15,11 @@ import java.util.List; ...@@ -15,10 +15,11 @@ import java.util.List;
public interface WorkDeptService { public interface WorkDeptService {
WorkDept getById(Integer id); WorkDept getById(Integer id);
/** /**
* 获取所有部门的信息 * 获取所有部门的信息
* @param userId * @param deptId
* @return * @return
*/ */
List<WorkDept> getDeptInfo(Integer userId, Integer deptId); List<WorkDept> getDeptInfo(Integer deptId);
} }
...@@ -32,4 +32,13 @@ public interface WorkUserService { ...@@ -32,4 +32,13 @@ public interface WorkUserService {
WorkUser getById(Integer id); WorkUser getById(Integer id);
WorkUser getDeptManagerByIds(List<Integer> ids); WorkUser getDeptManagerByIds(List<Integer> ids);
/**
* 将用户旧密码修改为新密码
* @param userId
* @param oldPassword
* @param newPassword
* @return
*/
WorkUser changePassword(Integer userId, String oldPassword, String newPassword);
} }
...@@ -5,8 +5,6 @@ import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM; ...@@ -5,8 +5,6 @@ import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException; import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkDeptMapper; import cn.wisenergy.mapper.WorkDeptMapper;
import cn.wisenergy.model.app.WorkDept; import cn.wisenergy.model.app.WorkDept;
import cn.wisenergy.model.app.WorkUser;
import cn.wisenergy.model.enums.ManagerEnum;
import cn.wisenergy.service.WorkDeptService; import cn.wisenergy.service.WorkDeptService;
import cn.wisenergy.service.WorkUserService; import cn.wisenergy.service.WorkUserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -30,8 +28,6 @@ public class WorkDeptServiceImpl implements WorkDeptService { ...@@ -30,8 +28,6 @@ public class WorkDeptServiceImpl implements WorkDeptService {
@Autowired @Autowired
private WorkDeptMapper workDeptMapper; private WorkDeptMapper workDeptMapper;
@Autowired
private WorkUserService workUserService;
@Override @Override
public WorkDept getById(Integer id) { public WorkDept getById(Integer id) {
log.info("WorkDeptServiceImpl[]getById[]input.param.id" + id); log.info("WorkDeptServiceImpl[]getById[]input.param.id" + id);
...@@ -46,16 +42,11 @@ public class WorkDeptServiceImpl implements WorkDeptService { ...@@ -46,16 +42,11 @@ public class WorkDeptServiceImpl implements WorkDeptService {
} }
@Override @Override
public List<WorkDept> getDeptInfo(Integer userId, Integer deptId) { public List<WorkDept> getDeptInfo(Integer deptId) {
log.info("WorkDeptServiceImpl[]getAllDeptInfo" + userId); log.info("WorkDeptServiceImpl[]getAllDeptInfo" + deptId);
if (userId == null || deptId == null) { if (deptId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
} }
//判断用户权限
WorkUser user = workUserService.getUserById(userId);
if (user.getLevel() == ManagerEnum.NOT_MANAGER.getCode()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
//获取部门信息 //获取部门信息
List<WorkDept> workDepts = workDeptMapper.getDeptById(deptId); List<WorkDept> workDepts = workDeptMapper.getDeptById(deptId);
if (CollectionUtil.isEmpty(workDepts)) { if (CollectionUtil.isEmpty(workDepts)) {
......
...@@ -18,10 +18,12 @@ import org.springframework.util.StringUtils; ...@@ -18,10 +18,12 @@ import org.springframework.util.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
*
* @author chenqi * @author chenqi
* @since 2021-01-19 * @since 2021-01-19
*/ */
...@@ -35,9 +37,10 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -35,9 +37,10 @@ public class WorkUserServiceImpl implements WorkUserService {
private WorkDeptMapper workDeptMapper; private WorkDeptMapper workDeptMapper;
private static final String LOGIN_SOURCE = "PC"; private static final String LOGIN_SOURCE = "PC";
@Override @Override
public WorkUser getById(Integer id) { public WorkUser getById(Integer id) {
log.info("WorkUserServiceImpl[]getById[]input.param.id:{}"+id); log.info("WorkUserServiceImpl[]getById[]input.param.id:{}" + id);
if (null == id) { if (null == id) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
} }
...@@ -62,6 +65,27 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -62,6 +65,27 @@ public class WorkUserServiceImpl implements WorkUserService {
} }
@Override
public WorkUser changePassword(Integer userId, String oldPassword, String newPassword) {
log.info("WorkUserServiceImpl[]changePassword[]input.param{}" + userId + oldPassword + newPassword);
if (userId == null || StringUtils.isEmpty(oldPassword) || StringUtils.isEmpty(newPassword)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
Map<String, Object> map = new HashMap<>();
map.put("id", userId);
map.put("password", Md5Util.digestMD5(oldPassword));
WorkUser user = workUserMapper.getUserInfo(map);
if (user == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.UPDATE_PASSWORD_FAIL_OLD_PASSWORD_ERROR);
}
user.setPassword(Md5Util.digestMD5(newPassword));
Integer count = workUserMapper.updateUserInfo(user);
if (count == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.USER_UPDATE_PASSWORD_FAIL);
}
return user;
}
@Override @Override
public WorkUser login(String loginName, String password, String source) { public WorkUser login(String loginName, String password, String source) {
log.info("WorkUserServiceImpl[]login[].input.param" + loginName + password + source); log.info("WorkUserServiceImpl[]login[].input.param" + loginName + password + source);
......
...@@ -10,7 +10,6 @@ import cn.wisenergy.web.admin.controller.common.BaseController; ...@@ -10,7 +10,6 @@ import cn.wisenergy.web.admin.controller.common.BaseController;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -45,17 +44,14 @@ public class StatisticsController extends BaseController { ...@@ -45,17 +44,14 @@ public class StatisticsController extends BaseController {
} }
@ApiOperation(value = "获取部门信息", notes = "获取部门信息") @ApiOperation(value = "获取部门信息", notes = "获取部门信息")
@ApiImplicitParams({ @ApiImplicitParam(name = "deptId", value = "部门主键", required = true)
@ApiImplicitParam(name = "userId", value = "用户主键", required = true), @GetMapping("/getDeptInfo")
@ApiImplicitParam(name = "deptId", value = "部门主键", required = true) public List<WorkDept> getDeptInfo( Integer deptId) {
}) log.info("StatisticsController[]getDeptInfo[]input.param" + deptId);
@GetMapping("getDeptInfo") if (deptId == null) {
public List<WorkDept> getDeptInfo(Integer userId, Integer deptId) {
log.info("StatisticsController[]getDeptInfo[]input.param" + userId + deptId);
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
} }
List<WorkDept> workDepts = workDeptService.getDeptInfo(userId, deptId); List<WorkDept> workDepts = workDeptService.getDeptInfo(deptId);
return workDepts; return workDepts;
} }
......
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.exception.CustomException; import cn.wisenergy.common.utils.exception.*;
import cn.wisenergy.common.utils.exception.RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.common.utils.exception.Result;
import cn.wisenergy.model.app.WorkUser; import cn.wisenergy.model.app.WorkUser;
import cn.wisenergy.service.WorkTimeOrderService;
import cn.wisenergy.service.WorkUserService; import cn.wisenergy.service.WorkUserService;
import cn.wisenergy.web.admin.controller.common.BaseController; import cn.wisenergy.web.admin.controller.common.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiImplicitParams;
import org.apache.commons.lang.StringUtils; import java.util.ArrayList;
import java.util.List;
/** /**
* @Authotr:陈奇 * @description:
* @QQ1799796883 * @author: nh
*/ * @create: 2021-01-19 17:13
**/
@RestController @RestController
@Api(tags = "用户模块") @Api(tags = "用户模块")
@Slf4j @Slf4j
...@@ -28,6 +31,9 @@ public class WorkUserController extends BaseController { ...@@ -28,6 +31,9 @@ public class WorkUserController extends BaseController {
@Autowired @Autowired
private WorkUserService workUserService; private WorkUserService workUserService;
@Autowired
WorkTimeOrderService workOrderService;
@ApiOperation(value = "根据id获取用户信息", notes = "根据id获取用户信息", httpMethod = "GET") @ApiOperation(value = "根据id获取用户信息", notes = "根据id获取用户信息", httpMethod = "GET")
@ApiImplicitParam(name = "id", value = "用户id", dataType = "int", required = true) @ApiImplicitParam(name = "id", value = "用户id", dataType = "int", required = true)
@GetMapping(value = "/getUserInfo") @GetMapping(value = "/getUserInfo")
...@@ -46,7 +52,7 @@ public class WorkUserController extends BaseController { ...@@ -46,7 +52,7 @@ public class WorkUserController extends BaseController {
@ApiImplicitParam(name = "password", value = "密码", dataType = "string", required = true), @ApiImplicitParam(name = "password", value = "密码", dataType = "string", required = true),
@ApiImplicitParam(name = "source", value = "登录来源:PC/WAP", dataType = "string", required = true) @ApiImplicitParam(name = "source", value = "登录来源:PC/WAP", dataType = "string", required = true)
}) })
@GetMapping(value = "login") @GetMapping(value = "/login")
public Result<WorkUser> login(String loginName, String password, String source) { public Result<WorkUser> login(String loginName, String password, String source) {
log.info("WorkUserController[]login[]input.param" + loginName + password + source); log.info("WorkUserController[]login[]input.param" + loginName + password + source);
if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(loginName)) { if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(loginName)) {
...@@ -55,4 +61,27 @@ public class WorkUserController extends BaseController { ...@@ -55,4 +61,27 @@ public class WorkUserController extends BaseController {
WorkUser workUser = workUserService.login(loginName, password, source); WorkUser workUser = workUserService.login(loginName, password, source);
return getResult(workUser); return getResult(workUser);
} }
@PutMapping(value = "/changePassword")
public Result<WorkUser> changePassword(Integer userId, String oldPassword, String newPassword) {
log.info("WorkUserController[]changePassword[]input.param{}" + userId + oldPassword + newPassword);
if (userId == null || StringUtils.isEmpty(oldPassword) || StringUtils.isEmpty(newPassword)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
WorkUser workUser = workUserService.changePassword(userId, oldPassword, newPassword);
return getResult(workUser);
}
@ApiOperation(value = "获取本月工时统计", notes = "获取本月",httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户主键",dataType = "integer", required = true)
@GetMapping("/getMonthlyWorkingHours")
public Result<ArrayList<Object>> getMonthlyWorkingHours(Integer userId){
log.info("WorkOrderController[]getMonthlyWorkingHours[]input.param" + userId);
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
List<Object> monthlyStatistics = workOrderService.getMonthlyStatistics(userId);
return getResult(monthlyStatistics);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment