mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-05 04:03:45 +09:00
ResetPassword 관련 추가
This commit is contained in:
@@ -45,7 +45,7 @@ public class AuthAspect {
|
||||
String[] list = targetController.split("\\.");
|
||||
|
||||
String packageName = list[3];
|
||||
if(packageName.equals("login")) {
|
||||
if(packageName.equals("login") || packageName.equals("resetpassword")) {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.no1.wms.resetpassword;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/resetpassword")
|
||||
public class ResetPasswordController {
|
||||
|
||||
|
||||
@Autowired
|
||||
ResetPasswordService resetPasswordService;
|
||||
|
||||
@PostMapping("/insert")
|
||||
@ResponseBody
|
||||
public String insert(ResetPasswordDto dto, Gson gson){
|
||||
resetPasswordService.insert(dto);
|
||||
|
||||
return gson.toJson("s");
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ResponseBody
|
||||
public String delete(ResetPasswordDto dto, Gson gson){
|
||||
resetPasswordService.delete(dto);
|
||||
|
||||
return gson.toJson("s");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.no1.wms.resetpassword;
|
||||
|
||||
import com.no1.wms.account.AccountDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.ibatis.type.Alias;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Alias("ResetPasswordDto")
|
||||
public class ResetPasswordDto {
|
||||
String id;
|
||||
String accountId;
|
||||
String note;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
Date date;
|
||||
|
||||
AccountDto accountDto;
|
||||
String employeeNumber;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.no1.wms.resetpassword;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ResetPasswordMapper {
|
||||
|
||||
void insert(ResetPasswordDto dto);
|
||||
|
||||
void delete(ResetPasswordDto dto);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.no1.wms.resetpassword;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ResetPasswordService {
|
||||
|
||||
@Autowired
|
||||
ResetPasswordMapper mapper;
|
||||
|
||||
void insert(ResetPasswordDto dto){
|
||||
mapper.insert(dto);
|
||||
}
|
||||
|
||||
void delete(ResetPasswordDto dto){
|
||||
mapper.delete(dto);
|
||||
}
|
||||
}
|
||||
42
src/main/resources/mappers/ResetPasswordMapper.xml
Normal file
42
src/main/resources/mappers/ResetPasswordMapper.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.no1.wms.resetpassword.ResetPasswordMapper">
|
||||
<resultMap id="resetPasswordResultMap" type="resetPasswordDto">
|
||||
<id column="id" property="id"/>
|
||||
<result column="account_id" property="accountId"/>
|
||||
<result column="date" property="date"/>
|
||||
<result column="note" property="note"/>
|
||||
<association property="accountDto" javaType="accountDto">
|
||||
<id column="acc.id" property="id" />
|
||||
<result column="acc.name" property="name" />
|
||||
</association>
|
||||
</resultMap>
|
||||
<insert id="insert" parameterType="resetPasswordDto">
|
||||
insert into reset_password
|
||||
(
|
||||
id, account_id, note, date
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
UUID(), (SELECT id from account where employee_number = #{employeeNumber} ), #{note}, NOW()
|
||||
)
|
||||
</insert>
|
||||
<select id="selectAll" resultMap="resetPasswordResultMap" parameterType="map">
|
||||
SELECT
|
||||
id, account_id, note, date, acc.id, acc.name
|
||||
from reset_password rs join account acc on rs.account_id = acc.id
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 1"> acc.activation = 1 and acc.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 0"> acc.activation = 1 and acc.employee_number like concat('%',#{search},'%') </when>
|
||||
</choose>
|
||||
</where>
|
||||
order by acc.id desc limit #{start}, #{perPage}
|
||||
|
||||
</select>
|
||||
<delete id="delete" parameterType="resetPasswordDto">
|
||||
delete from reset_password WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -36,14 +36,19 @@
|
||||
function onPassReset(){
|
||||
const data={};
|
||||
data.employeeNumber=$("#employ_number").val();
|
||||
data.note=$("#note").val();
|
||||
$.ajax({
|
||||
type: 'post', // 타입 (get, post, put 등등)
|
||||
url: '/login/pass_reset_call', // 요청할 서버url
|
||||
url: '/resetpassword/insert', // 요청할 서버url
|
||||
dataType: 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data: data,
|
||||
success: function (result) { // 결과 성공 콜백함수
|
||||
alert("패스워드 초기화 요청이 완료되었습니다");
|
||||
window.location.href = "/";
|
||||
if (result === 's') {
|
||||
alert("패스워드 초기화 요청이 완료되었습니다");
|
||||
window.location.href = "/login";
|
||||
}else if(result === 'f'){
|
||||
alert("요청에 실패하였습니다")
|
||||
}
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert(error);
|
||||
@@ -56,8 +61,15 @@
|
||||
<h1 class="h3 mb-3 fw-normal">비밀번호 초기화 요청</h1>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
<input type="text" class="form-control" id="employ_number" name="employeeNumber" placeholder="사번">
|
||||
<input type="text" required class="form-control" id="employ_number" name="employeeNumber" placeholder="사번">
|
||||
<label for="employ_number">사번</label>
|
||||
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
|
||||
|
||||
<textarea class="form-control w-100" name="note" id="note" placeholder="사유를 적으세요" required></textarea>
|
||||
<label for="note" class="form-label">사유</label>
|
||||
</div>
|
||||
<button class="w-100 btn btn-lg btn-primary" type="button" onclick="onPassReset()">초기화 요청</button>
|
||||
<p class="mt-5 mb-3 text-muted">© 2023–2024</p>
|
||||
|
||||
Reference in New Issue
Block a user