个人信息修改
This commit is contained in:
		
							parent
							
								
									690e8d0576
								
							
						
					
					
						commit
						0abf58f281
					
				| 
						 | 
				
			
			@ -0,0 +1,46 @@
 | 
			
		|||
package com.bonus.material.user.controller;
 | 
			
		||||
 | 
			
		||||
import com.bonus.common.core.web.controller.BaseController;
 | 
			
		||||
import com.bonus.common.core.web.domain.AjaxResult;
 | 
			
		||||
import com.bonus.common.security.utils.SecurityUtils;
 | 
			
		||||
import com.bonus.material.user.entity.UserDto;
 | 
			
		||||
import com.bonus.material.user.service.UserService;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/19 - 14:38
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
@Api(value = "个人管理", tags = {"个人管理"})
 | 
			
		||||
@RequestMapping("/userManage")
 | 
			
		||||
public class UserController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private UserService userService;
 | 
			
		||||
    @ApiOperation(value = "个人信息")
 | 
			
		||||
    @GetMapping("/userInfo")
 | 
			
		||||
    public AjaxResult getUserInfo() {
 | 
			
		||||
        return AjaxResult.success(userService.getUserById(SecurityUtils.getLoginUser().getUserid()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "修改个人信息")
 | 
			
		||||
    @PostMapping("/editUser")
 | 
			
		||||
    public AjaxResult editUser(UserDto userDto) {
 | 
			
		||||
       Integer i = userService.editUser(userDto);
 | 
			
		||||
       if (i > 0){
 | 
			
		||||
           return success("修改成功");
 | 
			
		||||
       }else {
 | 
			
		||||
           return error("修改失败");
 | 
			
		||||
       }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,90 @@
 | 
			
		|||
package com.bonus.material.user.entity;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonFormat;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.format.annotation.DateTimeFormat;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/19 - 14:43
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
public class UserDto {
 | 
			
		||||
    @ApiModelProperty(value = "用户ID")
 | 
			
		||||
    private Long userId;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "部门ID")
 | 
			
		||||
    private Long deptId;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "用户账号")
 | 
			
		||||
    private String userName;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "用户昵称")
 | 
			
		||||
    private String nickName;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "用户类型(00系统用户)")
 | 
			
		||||
    private String userType;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "用户邮箱")
 | 
			
		||||
    private String email;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "手机号码")
 | 
			
		||||
    private String phonenumber;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "用户性别(0男 1女 2未知)")
 | 
			
		||||
    private String sex;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "头像地址")
 | 
			
		||||
    private String avatar;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "密码")
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "帐号状态(0正常 1停用)")
 | 
			
		||||
    private String status;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
 | 
			
		||||
    private String delFlag;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "最后登录IP")
 | 
			
		||||
    private String loginIp;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "最后登录时间")
 | 
			
		||||
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 | 
			
		||||
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
 | 
			
		||||
    private Date loginDate;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "创建者")
 | 
			
		||||
    private String createBy;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "创建时间")
 | 
			
		||||
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 | 
			
		||||
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
 | 
			
		||||
    private Date createTime;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "更新者")
 | 
			
		||||
    private String updateBy;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "更新时间")
 | 
			
		||||
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 | 
			
		||||
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
 | 
			
		||||
    private Date updateTime;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "备注")
 | 
			
		||||
    private String remark;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "登录类型")
 | 
			
		||||
    private String loginType;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "审批状态0:未审批,1:已审批")
 | 
			
		||||
    private String approvalStatus;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "长期和临时用户标识0:临时用户,1:长期用户")
 | 
			
		||||
    private String isPermanent;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "是否内置用户0:内置用户,1:非内置用户")
 | 
			
		||||
    private String isBuiltIn;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
package com.bonus.material.user.mapper;
 | 
			
		||||
 | 
			
		||||
import com.bonus.material.user.entity.UserDto;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/19 - 14:52
 | 
			
		||||
 */
 | 
			
		||||
public interface UserMapper {
 | 
			
		||||
    UserDto getUserById(Long userId);
 | 
			
		||||
 | 
			
		||||
    Integer editUser(UserDto userDto);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
package com.bonus.material.user.service;
 | 
			
		||||
 | 
			
		||||
import com.bonus.material.user.entity.UserDto;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/19 - 14:50
 | 
			
		||||
 */
 | 
			
		||||
public interface UserService {
 | 
			
		||||
 | 
			
		||||
    UserDto getUserById(Long userId);
 | 
			
		||||
 | 
			
		||||
    Integer editUser(UserDto userDto);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
package com.bonus.material.user.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.bonus.material.user.entity.UserDto;
 | 
			
		||||
import com.bonus.material.user.mapper.UserMapper;
 | 
			
		||||
import com.bonus.material.user.service.UserService;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/19 - 14:51
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class UserServiceImpl implements UserService {
 | 
			
		||||
    @Resource
 | 
			
		||||
    private UserMapper userMapper;
 | 
			
		||||
    @Override
 | 
			
		||||
    public UserDto getUserById(Long userId) {
 | 
			
		||||
        return userMapper.getUserById(userId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Integer editUser(UserDto userDto) {
 | 
			
		||||
        return userMapper.editUser(userDto);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8" ?>
 | 
			
		||||
<!DOCTYPE mapper
 | 
			
		||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="com.bonus.material.user.mapper.UserMapper">
 | 
			
		||||
    <update id="editUser">
 | 
			
		||||
        update sys_user
 | 
			
		||||
        <trim prefix="SET" suffixOverrides=",">
 | 
			
		||||
        <if test="phoneNumber != null and phoneNumber != ''">phonenumber = #{phoneNumber},</if>
 | 
			
		||||
        <if test="deptId != null">dept_id = #{deptId},</if>
 | 
			
		||||
        </trim>
 | 
			
		||||
        where user_id = #{userId}
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
    <select id="getUserById" resultType="com.bonus.material.user.entity.UserDto">
 | 
			
		||||
        select * from sys_user where user_id = #{userId}
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
		Loading…
	
		Reference in New Issue